akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void dk()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
double coin(vector<double> v, int n)
{
    double dp[n + 1][n + 1];
    memset(dp, 0, sizeof dp);
    for (int i = n / 2 + 1; i <= n; i++)
    {
        dp[0][i] = 1;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = n - i; j >= 0; j--)
        {
            dp[i][j] = v[i - 1] * dp[i - 1][j + 1] + (1 - v[i - 1]) * dp[i - 1][j];
        }
    }
    return dp[n][0];
}
int32_t main()
{
    //dk();
    int n;
    cin >> n;
    vector<double> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    double k = coin(v, n);
    cout << ps(k, 10);
    return 0;
}

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

using namespace std;

typedef long long int ll;

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

    int a, b;
    double t;

    cin >> a >> b >> t;
    t += 0.5;

    int sum = 0, ans = 0, i = 1;
    while(true){
        if(i * a <= t){
            ans++;
         //   sum += i * a;

        }
        else break;
        i++;
    }

    cout << ans * b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
int cnt[50][50];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<string>s(n); rep(i, n)cin >> s[i];
	rep(i, n) {
		rep(j, s[i].size()) {
			cnt[i][s[i][j] - 'a']++;
		}
	}
	rep(i, 26) {
		int ans = INF;
		rep(j, n) {
			chmin(ans, cnt[j][i]);
		}
		rep(j, ans) {
			cout << (char)(i + 'a');
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  int z;
  int a=0;
  for(long long i=2;i*i<=n;++i){
    int c=0;
    while(n%i==0){
      n/=i;
      c++;
    }
    for(int j=1;c>0;++j,c-=j){
      a++;
    }
  }
  if(n!=1)a++;
  cout<<a;
}

Measured memory_bytes: 3632
/*
 * created   : 2019-08-05 00:11:26
 * accepted  : 2019-08-05 00:17:42
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n + 1; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  ll ans = 0;
  for (int i = 0; i < n + 1; i++) {
    int pr = 0;
    if (i > 0) {
      pr += b[i - 1];
    }
    int x = min(pr, a[i]);
    ans += x;
    a[i] -= x;
    if (i < n) {
      int y = min(b[i], a[i]);
      ans += y;
      b[i] -= y;
    }
  }
  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc149/tasks/abc149_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

const int SZ = 1e5 + 10;

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int N> struct Prime {
    bool b[N + 1]; // trueなら素数
    constexpr Prime() : b() {
        for (int_fast64_t i = 0; i <= N; ++i)
            b[i] = true;
        b[0] = b[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            for (int_fast64_t j = i * i; j <= N; j += i)
                b[j] = false;
        }
    }
};
Prime<SZ> prime;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    while (true) {
        if (prime.b[X]) {
            cout << X << endl;
            break;
        }
        X++;
    }
    return 0;
}


Measured memory_bytes: 3672
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll M = 1e9+7;
const ll INF = 1e9+7;

ll n, x, d, cnt, ans;
priority_queue<P, vector<P>, greater<P> > pq[220000];
map<ll, ll> mp;

int main() {
  cin >> n >> x >> d;
  
  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
      return 0;
    } else {
      cout << n+1 << endl;
      return 0;
    }
  }
  
  if (d < 0) x = -x, d = -d;
  
  for (ll p = 0; p <= n; p++) {
    ll xp = x * p;
    ll st = xp/d + p * (p-1) / 2;
    ll gl = xp/d + p * (2*n-p-1) / 2;
    if (mp[xp%d] == 0) mp[xp%d] = ++cnt;
    pq[mp[xp%d]].push(P(st, gl));
  }
  
  for (ll i = 0; i < 210000; i++) {
    ll s = -1e18;
    while (pq[i].size()) {
      ll nt = pq[i].top().first;
      ll ns = pq[i].top().second;
      pq[i].pop();
      if (s < ns) {
        ans += ns - max(s, nt-1);
        s = ns;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 25856
import itertools
import math
N, M = map(int, input().split())
a = []
ans = 0
for _ in range(M):
  a.append(set(map(int, input().split())))
for ind in itertools.permutations([i for i in range(N)]):
  if ind[0] != 0:
    break
  flag = True
  for i in range(N):
    if i == N-1:
      break
    if not(set([ind[i]+1, ind[i+1]+1]) in a):
      flag = False
  if flag:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 2002;
ll dp[MAX][MAX] = {};

int main() {
   

    ll n,x;
    cin >> n >> x;
    vector <ll> a;
    for (ll i=0;i<n;i++){
        ll p;
        cin >> p;
        a.push_back(p);
    }
    for (ll j=0;j<n;j++){
        dp[1][j] = a[j];
        if(j) {
            dp[2][j] = min(a[j], a[j - 1]);
        }else{
            dp[2][j] = min(a[j], a[n-1]);
        }
    }
    for (ll i=2;i<=n;i++){
        for (ll j=0;j<n;j++){
            if(j-1 >= 0 and j-i >= 0) {
                dp[i + 1][j] = min(dp[i - 1][j - 1], min(dp[1][j], dp[1][j - i]));
            }else if(j-i >= 0){
                dp[i + 1][j] = min(dp[i - 1][j-1+n], min(dp[1][j], dp[1][j - i]));
            }else if(j-1 >= 0){
                dp[i + 1][j] = min(dp[i - 1][j - 1], min(dp[1][j], dp[1][j - i + n]));
            }else{
                dp[i + 1][j] = min(dp[i - 1][j - 1+n], min(dp[1][j], dp[1][j - i+n]));
            }
        }
    }
    ll ans;
    for (ll num_magic = 0;num_magic<n;num_magic++){
        ll pre = 0;
        for (ll j=0;j<n;j++){
            pre += dp[num_magic+1][j];
//            cout << dp[num_magic+1][j] << " ";
        }
//        cout << endl;
        pre += num_magic*x;
//        cout << pre << endl;
        if(num_magic == 0){
            ans = pre;
        }else{
            if(ans > pre){
                ans = pre;
            }
        }
    }
    cout << ans << endl;



}




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

int main() {
  string S;
  cin >> S;
  
  int N = S.length();
  int N_limit = N/2;
  
  int ans = 0;
  if (N > 1) {
    for (int i = 0; i < N_limit; i++) {
      if (S[i] != S[N-i-1]) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int n ;
    cin >> n ;
    int a[n] , su = 0 , cur = 0 , ans = inf ;
    rep(i , n) cin >> a[i] , su += a[i] ;
    rep(i , n){
        if(i + 1 < n) cur += a[i]; 
        ans = min(ans , abs(su - 2 * cur));
    }
    cout << ans ;
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int mm[26]={0};
    string str;
    fill_n(mm,26,1e5);
    for(int i=0;i<n;i++)
    {
        cin>>str;
        int cnt[26]={0};
        int len=str.length();
        for(int j=0;j<len;j++)
        {
            cnt[str[j]-'a']++;
        }
        for(int j=0;j<26;j++)
        {
            mm[j]=min(mm[j],cnt[j]);
        }
    }
    for(int i=0;i<26;i++)
    {
        for(int j=0;j<mm[i];j++)
            cout<<char(97+i);
    }

} 



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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int a[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> a[i];

    return true;
}

void solve() {
    sort(a, a + n);

    if (a[0] == a[n - 1]) {
        if (a[0] == 0)
            cout << "Yes\n";
        else
            cout << "No\n";

        return ;
    }

    if (n % 3 != 0) {
        cout << "No\n";
        return ;
    }

    for (int i = 0; i < n; ++i)
        if (a[i] != a[i - i % (n / 3)]) {
            cout << "No\n";
            return ;
        }

    if (a[0] ^ a[(n / 3)] ^ a[2 * (n / 3)])
        cout << "No\n";
    else
        cout << "Yes\n";
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	//C問題

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a, b;

		a = scan.nextInt();
		b = scan.nextInt();

		Set<Integer> sets = new HashSet<>();

		sets.add(1);
		sets.add(2);
		sets.add(3);

		sets.remove(a);
		sets.remove(b);

		sets.forEach(System.out::println);

	}

}

Measured memory_bytes: 24916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;

/**
 * RUPC
 */
public class Main {

	static final int MAX = 1_000_001;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		//
		int N = parseInt(br.readLine());
		long[] sum = new long[MAX];

		StringTokenizer st = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++) {
			int a = parseInt(st.nextToken());
			sum[a] += a;
		}

		for (int i = 1; i < MAX; i++) {
			sum[i] += sum[i - 1];
		}

		//
		int M = parseInt(br.readLine());
		int[] b = new int[M];
		long[] c = new long[M];

		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < M; i++) {
			b[i] = parseInt(st.nextToken());
		}

		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < M; i++) {
			c[i] = parseLong(st.nextToken());
		}

		//
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < M; i++) {
			if (sum[b[i]] >= c[i]) {
				sb.append("Yes\n");
			} else {
				sb.append("No\n");
			}
		}

		System.out.print(sb.toString());

	}
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
using namespace std;

using ll = long long;
using ii = pair<ll, ll>;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int d[n];
    rep(i, n) { cin >> d[i]; }

    sort(d, d + n);

    int temp = d[n / 2] - d[n / 2 - 1];

    cout << temp << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

using namespace std;


/******************************************************************************
	typedef
******************************************************************************/
typedef unsigned long long int ullint;


/******************************************************************************
	Main
******************************************************************************/
int main() {
	ullint n = 0;
	cin >> n;
	assert(n >= 1 && n <= 100000);
	string s = "";
	cin >> s;
	assert(s.length() > 0);

	char prev;
	for (ullint i = 0; i < s.length(); i++) {
		if (i > 0 && s.at(i) == prev) {
			n--;
			continue;
		}
		prev = s[i];

	}
	cout << n << endl;

	return 0;
}


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

int n;
string s;
map<string,ll> mp[20];

int main() {
    cin >> n >> s;
    string ss;
    ll ans = 0;
    ss = s.substr(0,n);
    for (int i = 0; i < (1 << n); i++) {
        string tmp = "";
        int cnt = 0;
        for (int j = 0; j < n; j++)  {
            if (i & (1 << j)) {
                tmp += ss[j];
                cnt++;
            }
        }
        for (int j = n - 1; j >= 0; j--) {
            if (!(i & (1 << j))) {
                tmp += ss[j];
            }
        }
        mp[cnt][tmp]++;
    }
    ss = s.substr(n,n);
    for (int i = 0; i < (1 << n); i++) {
        string tmp = "";
        int cnt = 0;
        for (int j = n - 1; j >= 0; j--) {
            if (i & (1 << j)) {
                tmp += ss[j];
                cnt++;
            }
        }
        for (int j = 0; j < n; j++)  {
            if (!(i & (1 << j))) {
                tmp += ss[j];
            }
        }
        ans += mp[cnt][tmp];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 73984
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    char a,b; cin>>a>>b;
    if(a==b) cout<<"H"<<endl;
    else cout<<"D"<<endl;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
 
#define nl '\n'
#define pi 3.14159265358979323846264338327950L
#define ll long long 
#define ull unsigned long long
#define debug(x)       { cerr << #x << " = " << x << endl; } 
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
const int Max = (int)2e5+5;
 
//functions
ll lcm(ll a,ll b) {if(a==0 || b==0){return 0;}else{return (a*b)/__gcd(a,b);}}
 
//direction arry
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
//____________________________________________________________________________________________________
void solve()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    long double deg = abs(30*h - 5.5*m);
    long double c = (long double)(a*a+b*b) - (long double)(2*a*b*cos(deg*pi/180));
    cout<<setprecision(20)<<sqrtl(c)<<endl;
}
int main()
{
    fastread;
    int tc=1;
    // cin>>tc;
    while(tc--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4168
while True:
    try:
        H=0; B=0;
        a=list(map(int,input().split()))
        b=list(map(int,input().split()))
    except:
        break
    if a[0]==b[0]:
        H+=1
    if a[1]==b[1]:
        H+=1
    if a[2]==b[2]:
        H+=1
    if a[3]==b[3]:
        H+=1
    if a[0]==b[1] or a[0]==b[2] or a[0]==b[3]:
        B+=1
    if a[1]==b[0] or a[1]==b[2] or a[1]==b[3]:
        B+=1
    if a[2]==b[0] or a[2]==b[1] or a[2]==b[3]:
        B+=1
    if a[3]==b[0] or a[3]==b[1] or a[3]==b[2]:
        B+=1
    print(H, B)
    


Measured memory_bytes: 5604
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var h = cin.ReadIntArray(N);

            Array.Sort(h);
            int ans = 1000000000;
            for(int i = 0; i < N - K + 1; i++)
            {
                int tmp = h[i + K - 1] - h[i];
                if (tmp < ans)
                {
                    ans = tmp;
                }
            }
            Console.WriteLine(ans);
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 15568
n,y=map(int,input().split())
a=b=c=-1

for i in range(n+1):
    total=0
    for j in range(n+1):
        k=n-i-j
        if k<0 :
            continue
        total=10000*i+5000*j+1000*k
        if total==y:
            a=i
            b=j
            c=k
print('{} {} {}'.format(a,b,c))
        


Measured memory_bytes: 3060
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
	int h, w;
	scanf("%d %d", &h, &w);
	char foo[51][51];
	for (int i = 0; i < h; ++i) {
		scanf("%s", foo[i]);
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (foo[i][j] == '#') {
				putchar('#');
				continue;
			}
			int count = 0;
			if (i != 0) {
				count += foo[i - 1][j] == '#' ? 1 : 0;
				if (j != w - 1) {
					count += foo[i - 1][j + 1] == '#' ? 1 : 0;
				}
				if (j != 0) {
					count += foo[i - 1][j - 1] == '#' ? 1 : 0;
				}
			}
			if (j != 0) {
				count += foo[i][j - 1] == '#' ? 1 : 0;
				if (i != h - 1) {
					count += foo[i + 1][j - 1] == '#' ? 1 : 0;
				}
			}
			if (i != h - 1) {
				count += foo[i + 1][j] == '#' ? 1 : 0;
				if (j != w - 1) {
					count += foo[i + 1][j + 1] == '#' ? 1 : 0;
				}
			}
			if (j != w - 1) {
				count += foo[i][j + 1] == '#' ? 1 : 0;
			}
			putchar(count + '0');
		}
		putchar('\n');
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int main(){
    ll n, q;
    cin >> n >> q;
    string s;
    getline(cin, s);
    getline(cin, s);
    vector<ll> cs(s.size(), 0);
    for(int i = 1; i < s.size(); ++i){
        cs.at(i) = cs.at(i - 1);
        if(s.at(i - 1) == 'A' && s.at(i) == 'C'){
            cs.at(i) += 1;
        }
    }
    for(int i = 0; i < q; ++i){
        ll l, r;
        cin >> l >> r;
        l--; r--;
        cout << cs.at(r) - cs.at(l) << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		char[][] s = new char[h][w];
		for (int i = 0; i < h; i++) {
			s[i] = br.readLine().toCharArray();
		}
		br.close();

		int[] dx = {0, 0, -1, 1};
		int[] dy = {-1, 1, 0, 0};
		boolean[][] visit = new boolean[h][w];
		long ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (visit[i][j]) {
					continue;
				}
				long kuro = 0;
				long siro = 0;
				Queue<Integer> que = new ArrayDeque<Integer>();
				que.add(i * 1000 + j);
				visit[i][j] = true;
				while (!que.isEmpty()) {
					int cur = que.poll();
					int x = cur / 1000;
					int y = cur % 1000;
					if (s[x][y] == '#') {
						kuro++;
					} else {
						siro++;
					}
					for (int a = 0; a < 4; a++) {
						int xx = x + dx[a];
						int yy = y + dy[a];
						if (0 <= xx && xx < h && 0 <= yy && yy < w
								&& !visit[xx][yy] && s[x][y] != s[xx][yy]) {
							que.add(xx * 1000 + yy);
							visit[xx][yy] = true;
						}
					}
				}
				ans += kuro * siro;
			}
		}
		System.out.println(ans);
	}
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

char a, b;

void solve()
{
    cin >> a >> b;
    if(a == b) cout << 'H' << endl;
    else cout << 'D' << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n, x;
    cin >> n;
    vector<ll>v(n);
    vector<ll>u(n);
     for (ll i = 0; i < n; i++) {
        cin >> x;
        v[i] = x;
    }
    for (ll i = 0; i < n; i++) {
        cin >> x;
        u[i] = x;
    }

    ll ans = 0;

    for (ll i = 0; i < n; i++) {
        ll s = 0;
        for (ll j = 0; j <= i; j++) {
            s += v[j];
        }
        for (ll j = i; j < n; j++) {
            s += u[j];
        }
        ans = max(ans , s);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
#include"bits/stdc++.h"
using namespace std;
int x,y,z,k,s,num=0;

int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

int main() {
	k=read();
	s=read();
	for(x=0; x<=k; x++)
		for(y=0; y<=k; y++)
			if(s-x-y>=0&&s-x-y<=k)
				num++;
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  //std::vector<int> v(5);
  string s; cin>>s;
  //cout << s[6] - '1' << endl;
  if (s[5] == '1') {
    cout << "TBD" << endl;
    return 0;
  } else {
    if (s[6] <= '4') {
      cout << "Heisei" << endl;
      return 0;
    } else {
      cout << "TBD" << endl;
      return 0;
    }
  }
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli a,b;
    cin2(a,b);
    if (a+b==3)
        cout << 3 << endl;
    else if (a+b==4)
        cout << 2 << endl;
    else
        cout << 1 << endl;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> t;
    t.resize(n);
    rep(i, n) cin >> t[i];
    int sum = 0;
    rep(i, n) sum += t[i];
    int m;
    cin >> m;
    vector<ll> ans(m);
    rep(i, m)
    {
        int h, w;
        cin >> h >> w;
        h--;
        ans[i] = sum + w - t[h];
    }
    rep(i, m) cout << ans[i] << "\n";
}


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


public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int h = scanner.nextInt();
		long[] p = new long[w];
		long[] q = new long[h];
		for(int i = 0; i < w; ++i)
			p[i] = scanner.nextLong();
		for(int i = 0; i < h; ++i)
			q[i] = scanner.nextLong();
		Arrays.sort(p);
		Arrays.sort(q);
		int r = 0, c = 0;
		int wi = 0, hi = 0;
		long cost = 0;
		long size = 1L * (w+1L) * (h+1L) - 1L;
		for(long i = 0; i < size; ){
			if(wi == w){
				long num = w+1-r;
				cost += q[hi] * num;
				i += num;
				c++;
				hi++;
			}
			else if(hi == h){
				long num = h+1-c;
				cost += p[wi] * num;
				i += num;
				r++;
				wi++;
			}
			else if(p[wi] < q[hi]){
				long num = h+1-c;
				cost += p[wi] * num;
				i += num;
				r++;
				wi++;
			}else{
				long num = w+1-r;
				cost += q[hi] * num;
				i += num;
				c++;
				hi++;
			}
		}
		System.out.println(cost);
		scanner.close();
	}

}


Measured memory_bytes: 67588
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a,b;
    cin >> a >> b;
    if(a==1) a+=13;
    if(b==1) b+=13;
    if(a==b) puts("Draw");
    else a>b ? puts("Alice") : puts("Bob");
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())), dtype = 'int64')
a1 = np.min(A)
a2 = np.max(A)

ans = 1000000
for p in range(a1,a2+1):
    B = (A-p)**2
    s = np.sum(B)
    if s < ans:
        ans = s

print(ans)

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

int main(){
  vector<char> roman10 = {'I', 'X', 'C', 'M'};
  vector<char> roman5 = {'V', 'L', 'D'};
  vector<int> num10 = {1, 10, 100, 1000};
  vector<int> num5 = {5, 50, 500};

  string S;
  while(cin >> S){
    int ans = 0;

    for(int i=0; i<S.length(); i++){
      bool flag = false;
      for(int j=0; j<3; j++){
        if(S[i] == roman5[j]){
          ans += num5[j]; flag = true; break;
        }
      }
      if(flag) continue;

      for(int j=0; j<4; j++){
        if(S[i] == roman10[j]){
          if(j != 3 && S[i+1] == roman10[j+1]){
            ans += num10[j+1]-num10[j]; i++; break;
          } else if (j != 3 && S[i+1] == roman5[j]){
            ans += num5[j]-num10[j]; i++; break;
          } else {
            ans += num10[j]; break;
          }
        }
      }
    }

    cout << ans << endl;
  }
}
  
  


Measured memory_bytes: 3140
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(void){
	int a,b;
	cin>>a>>b;
	ll ans = 0;
	rep(i,b-a){
		ans += i;
	}
	cout<<ans-a<<endl;
	return 0;
}


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

int main(){
	int N, i, j, ans;
	scanf("%d", &N);
	int *p = (int *)malloc(sizeof(int) * (N + 1));
	int *have_pair = (int *)malloc(sizeof(int) * (N + 1));
	p[0] = -1;
	for(i = 1; i <= N; i++){
		scanf("%d", &p[i]);
	}
	for(i = 1; i <= N; i++){
		for(j = 0; j <= N; j++){
			have_pair[j] = 0;
		}
		ans = 0;
		for(j = i; j > 0; j--){
			if(have_pair[j] == 0 && have_pair[p[j]] == 0){
				ans++;
				have_pair[p[j]] = 1;
			}
		}
/*		printf("i = %d\n", i);
		for(j = 0; j <= N; j++){
			printf("%d  ", have_pair[j]);
		}
		printf("\n");
*/		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1868
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << a * b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e5 + 17;

int n;
string s[2];
llong dp[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	scanf("%s", buff);
	s[0] = buff;
	scanf("%s", buff);
	s[1] = buff;

	return true;
}

void solve()
{
	vector<int> v;

	for (int i = 0; i < n; )
		if (s[0][i] == s[1][i])
			v.push_back(1), ++i;
		else
			v.push_back(2), ++++i;

	for (int i = 0; i < size(v); ++i)
	{
		if (i == 0)
		{
			if (v[i] == 1)
				dp[i] = 3;
			else
				dp[i] = 6;
		}
		else
		{
			if (v[i] == 1)
			{
				if (v[i - 1] == 1)
					dp[i] = dp[i - 1] * 2ll % inf;
				else
					dp[i] = dp[i - 1];
			}
			else
			{
				if (v[i - 1] == 1)
					dp[i] = dp[i - 1] * 2ll % inf;
				else
					dp[i] = dp[i - 1] * 3ll % inf;
			}
		}
	}

	printf("%lld\n", dp[size(v) - 1]);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<vector>
using namespace std;
long long blackNum=0;
long long whiteNum=0;
vector<string> v;
vector<vector<bool> > flags;
long long H,W;
void f(int i,int j,bool last){
    if(i<0||i>=H||j<0||j>=W||!flags[i][j]) return;
    flags[i][j]=false;
    //last true means last is .
    if(last){
	if(v[i][j]=='.'){
	    flags[i][j]=true;
	    return;
	}
	blackNum++;
	last=false;
    }
    else{
	if(v[i][j]=='#'){
	    flags[i][j]=true;
	    return;
	}
	whiteNum++;
	last=true;
    }
    f(i-1,j,last);
    f(i+1,j,last);
    f(i,j-1,last);
    f(i,j+1,last);
}
	   
	
int main(){
    cin>>H>>W;
    v=vector<string>(H);
    flags=vector<vector<bool> >(H,vector<bool>(W,true));
    for(int i=0;i<H;i++){
	cin>>v[i];
    }
    long long ans=0;
    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    if(v[i][j]=='#'){
		blackNum=0;
		whiteNum=0;
		f(i,j,true);
		ans+=blackNum*whiteNum;
	        //cout<<i<<" "<<j<<":"<<blackNum<<" "<<whiteNum<<endl;
	    }
	}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12928
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n);
    Cins(ll, n, a);
    Cins(ll, n, b);
    Cins(ll, n, c);
    Sort(a);
    Sort(b);
    Sort(c);
    vector<ll> nb(n);
    
    For(i, n) nb[i] = distance(a.begin(), lower_bound(Range(a), b[i]));
    Cusum(ll, n, nb, snb);
    ll ans = 0;
    For(i, n) ans += snb[distance(b.begin(), lower_bound(Range(b), c[i]))];
    Cout(ans);
}


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

vector<vector<int>> ans(1000000, vector<int>(4));
vector<vector<int>> a(501, vector<int>(501));
int n = 0;

void pushToAns(int x, int b, int c, int d) {
  a[x][b]--;
  a[c][d]++;
  ans[n][0] = x + 1;
  ans[n][1] = b + 1;
  ans[n][2] = c + 1;
  ans[n][3] = d + 1;
  n++;
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a[i][j] % 2 == 1 && a[i][j] > 0) {
        if (i < H - 1 && (a[i + 1][j] % 2 == 1 || j == W-1)) {
          pushToAns(i, j, i + 1, j);
        } else if(j < W - 1){
          pushToAns(i, j, i, j + 1);
        } 
      }
    }
  }
  cout << n << endl;
  for (int i = 0; i < n; i++) {
    cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " "
         << ans[i][3] << endl;
  }
}


Measured memory_bytes: 58772