akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define MAX 1000                                      
typedef long long ll;
typedef unsigned long long ull;
extern inline int max( int a, int b ) { return a > b ? a : b ; }
extern inline int min( int a, int b ) { return a > b ? b : a ; }
extern inline ll lmax( ll a, ll b ) { return a > b ? a : b ; }
extern inline ll lmin( ll a, ll b ) { return a > b ? b : a ; }
extern inline ull ulmax( ull a, ull b ) { return a > b ? a : b ; }
extern inline ull ulmin( ull a, ull b ) { return a > b ? b : a ; }

int main()
{
	int T, A;
	int ans = 0;
	int arr[20];
	
	scanf("%d", &T);
	for( int i=0; i<T; ++i ){
		scanf("%d", arr+i);
	}
	for( int i=0; i<T; ++i ){
		scanf("%d", &A);
		ans += arr[i] > A ? arr[i]-A : 0;
	}
	printf("%d", ans);
	
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int>> m(N, vector<int>(N));
	for (auto i = 0; i < M; ++i)
	{
		int L, R;
		cin >> L >> R;
		--L;
		--R;
		++m[0][R];
		if (L + 1 < N)
		{
			--m[L + 1][R];
		}
	}

	for (auto i = 0; i < N; ++i)
	{
		for (auto j = 1; j < N; ++j)
		{
			m[j][i] += m[j - 1][i];
		}
	}
	for (auto i = 1; i < N; ++i)
	{
		for (auto j = 0; j < N; ++j)
		{
			m[j][i] += m[j][i - 1];
		}
	}

	vector<int> ans;
	for (auto i = 0; i < Q; ++i)
	{
		int p, q;
		cin >> p >> q;
		--p;
		--q;
		ans.push_back(m[p][q]);
	}

	for (auto i = 0; i < Q; ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 2424
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL NONE = -1000000000000ll;
const LL N = (1<<16);
LL n;
LL dp[N] = {0};
LL v[N] = {0};
LL a[16][16] = {0};

LL g(LL, LL, LL);
LL f(LL bit){
    if(dp[bit] != NONE)return dp[bit];
    LL score = v[bit];
    //REP(i,16){
    //    LL mask = 1<<i;
    //    if((bit & mask) != 0){
    //        // dp[bit - mask] + dp[mask] == dp[bit - mask] + 0
    //        score = max(score, f(bit - mask));
    //    }
    //}
    //return dp[bit] = score;
    return dp[bit] = max(score, g(bit, 0, 0));
}

LL g(LL bit, LL mask, LL dep){
    if(dep == n){
        if(mask == bit || mask == 0) return NONE;
        return f(bit - mask) + f(mask);
    }
    LL hot = (1 << dep);
    if((bit & hot) != 0){
        return max(g(bit, mask, dep + 1), g(bit, mask | hot, dep + 1));
    }
    else {
        return g(bit, mask, dep + 1);
    }
}

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

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

    FOR(bit,3,1<<n){
        REP(i,n){
            if((bit & (1<<i)) != 0){
                REP(j,n){
                    if((bit & (1<<j)) != 0){
                        v[bit] += a[i][j];
                    }
                }
            }
        }
        v[bit] /= 2;
    }
    REP(i,N)dp[i] = NONE;
    REP(i,n)dp[1<<i] = 0;
    PUTS(f((1<<n) - 1));
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n, m, a;
	int h[1001], p[1001], q[1001];
	int b[101];
	int i, j, k;
	int t;
	
	while (1){
		scanf("%d%d%d", &n, &m, &a);
		if ((n | m | a) == 0){
			break;
		}
		
		memset(p, 0, sizeof(p));
		memset(q, 0, sizeof(q));
		
		for (j = 0; j < m; j++){
			scanf("%d%d%d", &h[j], &p[j], &q[j]);
		}
		
		for (j = 0; j < m; j++){
			for (k = 0; k < m - 1; k++){
				if (h[k] > h[k + 1]){
					t = h[k];
					h[k] = h[k + 1];
					h[k + 1] = t;
					
					t = p[k];
					p[k] = p[k + 1];
					p[k + 1] = t;
					
					t = q[k];
					q[k] = q[k + 1];
					q[k + 1] = t;
				}
			}
		}
		
		for (j = 1; j <= n; j++){
			b[j] = j;
		}
		
		for (j = 0; j < m; j++){
//printf("<%d %d>", p[j], q[j]);
			t = b[p[j]];
			b[p[j]] = b[q[j]];
			b[q[j]] = t;
		}
		
		printf("%d\n", b[a]);
	}
	
	return (0);
}

Measured memory_bytes: 612
import java.awt.geom.*;
import java.util.*;
public class Main {

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int [] array = new int[3];
			for(int i = 0; i < 3; i++){
				array[i] = sc.nextInt();
			}
			if((array[0]|array[1]|array[2]) == 0) break;
			Arrays.sort(array);
			long c = array[0] * array[0] + array[1] * array[1];
			
			int n = sc.nextInt();
			for(int i = 0; i < n; i++){
				long entrance = sc.nextInt();
				if(c < (entrance * 2) * (entrance * 2)){
					System.out.println("OK");
				}
				else{
					System.out.println("NA");
				}
			}
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
U = 2*10**5
MOD = 10**9+7

fact = [1]*(U+1)
fact_inv = [1]*(U+1)

for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)

for i in range(U,0,-1):
	fact_inv[i-1] = (fact_inv[i]*i)%MOD

def comb(n,k):
  if k < 0 or k > n:
    return 0
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x

H,W,A,B = map(int,input().split())

# はじめてB+1列目に入る瞬間で場合分けして足す

ans = 0
for i in range(H-A):
  # (0,0) to (i,B-1)
  x = comb(B-1+i,i)
  # (i,B) to (H-1,W-1)
  a = H-1-i
  b = W-1-B
  x *= comb(a+b,a)
  x %= MOD
  ans += x
ans %= MOD
print(ans)

Measured memory_bytes: 18804
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #pragma once
#define trav(var, container) for(auto& var: container)
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)x.size()
using namespace std;
using namespace __gnu_pbds;
using ld = long double; 
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
struct chash { // large odd number for C
	const uint64_t C = ll(4e18 * acos(0)) | 71;
	ll operator()(ll x) const { return __builtin_bswap64(x*C); }
};

unordered_map<ll, int> mp;
const int N = 1e3;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    mp.reserve(1 << 12);
    mp.max_load_factor(0.25);
    int x;
    cin >> x;
    for(ll i = -N; i <= N; ++i) {
        mp[i*i*i*i*i] = (int)i;
    }
    trav(i, mp) {
        if(mp.find(i.first - x) != mp.end()) {
            cout << i.second << " " << mp[i.first - x];
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>

int main(void) {
    int a,b,c,d,e,k;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    scanf("%d", &k);

    if (e-a <= k) printf("Yay!\n");
    if (e-a > k) printf(":(\n");

    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


ll A, B, C, D;
map<ll, ll> memo;

ll rec(const ll N) {
  if (N == 0) return 0;
  if (N == 1) return D;
  if (memo.count(N) > 0) return memo[N];
  ll res = 1LL << 61;

  if (D < res / N)
    chmin(res, N * D);

  ll multis[] = {2, 3, 5};
  ll coins[] = {A, B, C};
  REP(i, 3) {
    ll multi = multis[i];
    ll coin = coins[i];
    ll U = (N + multi - 1) / multi * multi;
    ll L = (N / multi) * multi;
    chmin(res, abs(U-N) * D + coin + rec(U/multi));
    chmin(res, abs(L-N) * D + coin + rec(L/multi));
  }
  return memo[N] = res;
}

int main2() {
  memo.clear();
  ll N;
  cin >> N >> A >> B >> C >> D;
  ll ans = rec(N);
  cout << ans << endl;
  return 0;
}

int main() {
  int T; cin >> T;
  while (T--)
    main2();
  return 0;
}

Measured memory_bytes: 4504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


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

    set<int> a;
    a.insert(s);
    int i = 1;
    int tmp = s;
    while(true){
        i++;
        if (tmp % 2 == 0) tmp /= 2;
        else tmp = 3 * tmp + 1;
        if (a.find(tmp) != a.end()) {
            cout << i << endl;
            break;
        }
        a.insert(tmp);
    }

    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

int main()
{
	int a, b;
	string s;
	cin >> a >> b >> s;

	for (int i = 0; i < s.size(); i++)
	{
		if (i != a && s[i] == '-')
		{
			cout << "No" << endl;
			return 0;
		}
		else if (i == a && s[i] != '-')
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	ll x;
	cin >> x;
	ll sum = 0;
	ll i = 1;
	while (sum < x) {
		sum += i;
		i++;
	}
	cout << i -1 << endl;
	return 0;
}

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

int main()
{
        string s;
        int i;
        getline(cin, s);
        int l = s.length();
        for(i=0; i< l ; i++) {
                if((s[i]<='z') && (s[i]>='a')){
                        s[i]=s[i] + 'A' - 'a';
                }
                else if((s[i]>= 'A') && (s[i]<='Z')){
                        s[i]=s[i]-('A'-'a');
                }
                cout << s[i];
        }
        cout << endl;
}



Measured memory_bytes: 3208
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String str = f.readLine();
        int n = str.length();
        long sum = 0;
        int ptr = 0;
        long cnt = 0;
        long curr = 0;
        while(ptr < n){
            if(str.charAt(ptr) == '>'){
                while(ptr < n && str.charAt(ptr) == '>'){
                    ptr++;
                    cnt++;
                }
                if(curr > cnt){
                    sum+=(curr+(((cnt)*(cnt-1))/2));
                }else{
                    sum+=(((cnt+1)*(cnt))/2);
                }
                curr = 0;
                cnt = 0;
            }else{
                sum+=curr;
                curr++;
                ptr++;
            }
        }
        if(str.charAt(n-1) == '<') sum+=curr;
        out.println(sum);
        out.close();
    }
}


Measured memory_bytes: 25868
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    vector<double> A(N);
    double cnt = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        cnt += A.at(i);
    }
    sort(A.begin(),A.end());
    double usi = cnt/(4*M);
    if(A.at(N-M) >= usi) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <bitset>

using namespace std;

vector<int> table((123456+1)*2, 1);
// bitset<123456*2> bitTable(1);

void init(){
    // iota(table.begin(), table.end(), 0);
    table[0] = 0;
    table[1] = 0;
    for(int i = 2; i < sqrt(table.size()); ++i){
        if(table[i] == 1){
            for(int j = 2; i*j < table.size(); ++j){
                table[i*j] = 0;
            }
        }
    }
    for(int i = 1; i < table.size(); ++i){
        table[i] = table[i-1] + table[i];
    }
}

int main(){
    init();
    int n = 0;
    while(cin >> n){
        if(n == 0) break;
        cout << table[n*2]-table[n] << endl;
    }

    return 0;
}


Measured memory_bytes: 3664
N, M = map(int, input().split())
l_same = [-1, -1, -1]
if N == 1:
  s_num = '0'
else:
  s_num = '1' + '0' * (N - 1)
ans = int(s_num)
for i in range(M):
  s, c = map(int, input().split())
  if N != 1 and (s == 1 and c == 0):
    ans = -1
    break
  elif l_same[s - 1] != -1 and l_same[s - 1] != c:
    ans = -1
    break
  else:
    l_same[s - 1] = c
    s_num = s_num[0:s - 1] + str(c) +  s_num[s:]
    ans = int(s_num)
print(ans)
  

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

int main()
{
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(n) cin >> v[i];

  for (ll i = 0; i < n; i++)
  {
    if(v[i]%2==0)
    {
      if(v[i]%3!=0 && v[i]%5!=0)
      {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;
  

  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
lis = []

for i in range(n-1):
  lis.append(abs(a[i] - a[i+1]))
  
subsum = sum(lis) + abs(a[0]) + abs(a[-1])  
a = [0] + a + [0]


for i in range(1,n+1):
  if a[i-1] <= a[i] <= a[i+1] or a[i+1] <= a[i] <= a[i-1]:
    print(subsum)
  elif a[i-1] <= a[i+1] <= a[i] or a[i] <= a[i+1] <= a[i-1]:
    print(subsum - (2*abs(a[i+1] - a[i])))
  elif a[i] < a[i-1] <= a[i+1] or a[i+1] <= a[i-1] <= a[i]:
    print(subsum - (2*abs(a[i] - a[i-1])))
  

Measured memory_bytes: 13920
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

    double time = 0;
    int times = 1;
    int made = 0;
    while (true) {
        time += times * a;
        if (time <= t + 0.5) made+=b;
        else break;
    }
    cout << made << endl;
    return 0;
}


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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int N, K;
  cin >> N >> K;

  int p[200000+5] = {};

  rep(i, N){
    cin >> p[i];
  }

  int u[200000+5] = {};
  int sum = 0;
  rep(i, K){
    sum += p[i];
  }

  rep(i, N - K + 1){
    u[i] = sum;
    sum -= p[i];
    sum += p[i+K];
  }

  cout << fixed << setprecision(10) << (*max_element(u, u+N-K+1) + K) / 2.0 << endl;
}

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int N, count = 0;
  string S;
  cin >> N ;
  cin >> S;
  
  //vector<int> p(N); 
  for(int i = 0; i<N -2; i++){
    
    if(S.substr(i, 3) == "ABC"){
    	count++;
    }
  }
  
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
    long long n,a,b;

    cin>>n>>a>>b;

    if(a > b)
	cout<<0<<endl;
    else if(n == 1 && a != b)
	cout<<0<<endl;
    else if(n == 1 && a == b)
	cout<<1<<endl;
    else
    {
	cout<<(n-2)*(b-a)+1<<endl;
    }

    return 0;
}


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

int main()
{
	string deck; 
	
	while(cin >> deck && deck != "-") {
		int n; cin >> n;
		int shuffle;

		while(n-- && cin >> shuffle)
			rotate(deck.begin(), deck.begin()+shuffle, deck.end());
		cout << deck << endl;
	}

	return 0;
}



Measured memory_bytes: 3180
#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input!{
        s:Chars,
        t:Chars,
    }
    
    let mut ans = 0;

    for i in 0..s.len(){
        if s[i] != t[i]{
            ans += 1;
        }
    }

    println!("{}",ans);

}



Measured memory_bytes: 3956
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Clone>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0].clone(), v[1].clone())
}

fn main() {
    let (s, t) = read_touple::<String>();
    println!("{}{}", t, s);
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>

int h,w;

std::map<char,int> map;

int main() {

    std::cin>>h>>w;

    char ch;

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            std::cin>>ch;
            ++map[ch];
        }
    }

    int cnt1=0,cnt2=0,cnt4=0;

    for(auto p : map){
        cnt4+=p.second/4;
        if(p.second%4==1)
            ++cnt1;
        else if(p.second%4==2)
            ++cnt2;
        else if(p.second%4==3){
            ++cnt2;
            ++cnt1;
        }
    }

    if(cnt4<h/2*(w/2)){
        std::cout<<"No"<<std::endl;
        return 0;
    }

    cnt4-=h/2*(w/2);

    if(cnt4*2+cnt2!=(w%2)*(h/2)+(h%2)*(w/2)){
        std::cout<<"No"<<std::endl;
        return 0;
    }

    if(w%2&&h%2){
        if(cnt1==1)
            std::cout<<"Yes"<<std::endl;
        else
            std::cout<<"No"<<std::endl;
    }
    else{
        if(cnt1==0)
            std::cout<<"Yes"<<std::endl;
        else
            std::cout<<"No"<<std::endl;
    }

    return 0;
}

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

int main(){
  int Q;
  cin >> Q;
  long long A, B, C;
  for(int i; i < Q; i++){
    cin >> A >> B;
    if(A == B || A + 1 == B) cout << 2 * A - 2 << endl;
    else{
      C = sqrt(A * B);
      if(C * C == A * B) C--;
      if(C * (C + 1) >= A * B) cout << 2 * C - 2 << endl;
      else cout << 2 * C - 1 << endl;
    }
  }
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define rof_(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

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};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//
lint A, B, C, D;

bool judge() {
	if (A < B) return false;
	if (B > D) return false;
	if (B <= C) return true;
	lint g = __gcd(B, D);
	return B - g + (A % g) <= C;
}

int main() {
	int T;
	cin >> T;
	for_(i,0,T) {
		cin >> A >> B >> C >> D;
		if (judge()) puts("Yes");
		else puts("No");
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#define oo 987654321
#define INT long long
using namespace std;

INT n, k, x = 1, t[100010], mx;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>t[i];
        if( i == 0 ) x = t[i];
        x = __gcd(x, t[i]);
        mx = max(mx, t[i]);
    }
    if( mx < k ) return cout<<"IMPOSSIBLE"<<endl, 0;
    else
    {
        for(int i = 0 ; i < n ; i++ )
            if( (mx-k)%x == 0 ) return cout<<"POSSIBLE"<<endl, 0;
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    char C;
    cin >> C;
    cout << ++C << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[1001][1001];
char a[1001][1001];
int main()
{
	ll h,w,i,j;
	cin>>h>>w;
	dp[0][0]=1;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		cin>>a[i][j];
	}
	for(i=1;i<w;i++)
	{
		if(a[0][i]=='#')
		dp[0][i]=0;
		else
		dp[0][i]=dp[0][i-1];
	}
	for(i=1;i<h;i++)
	{
		if(a[i][0]=='#')
		dp[i][0]=0;
		else
		dp[i][0]=dp[i-1][0];
	}
	for(i=1;i<h;i++)
	{
		for(j=1;j<w;j++)
		{
			if(a[i][j]=='.')
		    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
		    else
		    dp[i][j]=0;
		}
	}
	/*for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 9088
open Batteries

let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let s_l = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%s " (fun a -> a)) in
  let c_l_l = List.map (fun s -> String.to_list s |> List.sort compare) s_l in

  let rec test c = function
    | [] -> false, []
    | hd :: tl -> 
      if hd = c then true, tl else
      if hd < c then test c tl else
        false, (hd::tl)
  in

  let rec aux res c_l c_l_l = match c_l with
      [] -> res
    | c :: tl -> 
      let tmp = List.map (test c) c_l_l in
      let tf, tls = List.fold_left (fun (tf1, tls) (tf2, tl) -> (tf1 && tf2), (tl :: tls)) (true,[]) tmp in
      if tf then aux (c::res) tl tls else
        aux res tl tls
  in

  let res = aux [] (List.hd c_l_l) (List.tl c_l_l) in
  Printf.printf "%s\n" @@ 
  String.of_list (List.rev res)



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

void fast_io() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
}

int main() {
  fast_io();

  int n, a, b;
  cin >> n;

  int doublets = 0;
  bool ans = false;

  while (n--) {
    cin >> a >> b;
    if (a == b) doublets++;
    else doublets = 0;

    if (doublets == 3) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "Yes\n" : "No\n");
}


Measured memory_bytes: 3688
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;


	vector<int> cnt(M, 0);

	for (int i = 0; i < N; i++) {
		int K;
		cin >> K;

		for (int j = 0; j < K; j++) {
			int A;
			cin >> A;
			--A;
			++cnt.at(A);
		}
	}

	int ans = 0;
	for (int i = 0; i < M; i++) {
		if (cnt.at(i) == N) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val(n,k,q) = readLine()!!.split(" ").map(String::toInt)
  var p = Array(n, {i -> 0})
  for (i in 0 until q) {
    val a = readLine()!!.toInt()
    p[a-1] += 1
  }
  for (i in 0 until n) {
    if (k + p[i] > q) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

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

int main() {
  
  int a,b,k;
  vector<int> vec = {1};
  cin >> a >> b >> k;
  for (int i =2;i<101;i++){
    if (a%i + b%i == 0){
      vec.push_back(i);
    }
  }
  
  int max = vec.size();
  cout << vec.at(max - k) <<endl;
      


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> T(N);
    int sum = 0;
    for(int i = 0;i < N;i++){
        cin >> T[i];
        sum += T[i];
    }
   int M;
   cin >> M;
   vector<int> P(M);
   vector<int> X(M);
   for(int i= 0;i < M;i++){
       cin >> P[i] >> X[i];
   }
   for(int i = 0;i < M;i++){
       cout << sum - T[P[i]- 1] + X[i] << endl;
   }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int a,b;cin>>a>>b;
    int m = min(a,b);
    a -= m;b -= m;
    int k = 16-m*2;
    if(k/2>=max(a,b))cout<<"Yay!";
    else cout<<":(";

    
}



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

struct Card{char suit, value;};

void selectionSort(struct Card A[], int N) {
        int i, j, mini;
        for(i = 0; i < N; i++) {
                mini = i;
                for(j = i; j < N; j++) {
                        if(A[j].value < A[mini].value) mini = j;
                }
                Card t = A[i]; A[i] = A[mini]; A[mini] = t;
        }
}

void bubbleSort(struct Card A[], int N) {
        for(int i = 0; i < N; i++) {
                for(int j = N - 1; j >= i; j--) {
                        if(A[j].value < A[j - 1].value) {
                                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
                        }
                }
        }
}

void print(struct Card A[], int N) {
        for(int i = 0; i < N; i++) {
                if(i > 0) cout << " ";
                cout << A[i].suit << A[i].value;
        }
        cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
        for(int i = 0; i < N; i++) {
                if(C1[i].suit != C2[i].suit) return false;
        }
        return true;
}

int main() {
        Card C1[100], C2[100];
        int N;
        cin >> N;
        for(int i = 0; i < N; i++) {
                cin >> C1[i].suit >> C1[i].value;
                C2[i] = C1[i];
        }
        bubbleSort(C1, N);
        selectionSort(C2, N);
        print(C1, N);
        cout << "Stable" << endl;
    print(C2, N);
        if(isStable(C1, C2, N)) {
                cout << "Stable" << endl;
        } else {
                cout << "Not stable" << endl;
        }
        return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

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

  int cnt = 0;
  REP(i,3) if(s[i]==t[i]) cnt++;

  cout << cnt << endl;
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
ll mi[1<<12];
ll dp[1<<12];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,1<<N) mi[i]=dp[i]=1LL<<60;
	FOR(i,M) {
		int mask=0;
		cin>>x>>y;
		FOR(j,y) {
			cin>>r;
			mask |= 1<<(r-1);
		}
		mi[mask]=min(mi[mask],(ll)x);
	}
	
	dp[0]=0;
	FOR(x,1<<N) FOR(y,1<<N) dp[x|y]=min(dp[x|y],dp[x]+mi[y]);
	
	if(dp[(1<<N)-1]==1LL<<60) {
		cout<<-1<<endl;
	}
	else {
		cout<<dp[(1<<N)-1]<<endl;
	}
	
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;

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


int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll res = 0;
  for(int i = 60; i >= -1; i--) { //bitが立っている桁を探す。i==-1はXとkが完全一致する場合
    if(i != -1 && !(k & (1LL<<i)))
      continue;
    ll tmp = 0;
    for(int j = 60; j >= 0; j--) { //Xを桁ごとに考える
      ll mask = 1LL<<j;
      int num = 0;
      rep(l,n){
        if(a[l] & mask)
          num++;
      }
      if(j > i) { //iより上位の桁はkに揃える
        if(k & mask) //==1ならXのこの桁は1になる→a[l]のこの桁のbitは反転する
          tmp += mask*(n-num); //(1LL<<jの値)*(この桁のbitが0になっているa[l]の個数)
        else //==0なら
          tmp += mask*num;
      }
      else if (j == i) { //i桁目は0に
        tmp += mask*num;
      }
      else { //iより下位の桁は0でも1でもいいので、a[l]のこの桁のbitを多く立たせられるほうを選ぶ
        tmp += mask*max(num, n-num);
      }
    }
    res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdint>

int main()
{
    int64_t a, b, k;
    std::cin >> a >> b >> k;

    if (a > 0)
    {
        auto m = std::min(a, k);
        a -= m;
        k -= m;
    }

    if (b > 0)
    {
        auto m = std::min(b, k);
        b -= m;
        k -= m;
    }

    std::cout << a << " " << b << std::endl;

    return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
  for(int i=0;i<=n;i++){
      dp[i][0] = 1;
  }
  for(int i=1;i<=n;i++){
      for(int j=1;j<=k;j++){
          if(a[i-1]>=j){
              dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
          }
          else{
              dp[i][j] = (((dp[i][j-1] + dp[i-1][j]))%MOD -  dp[i-1][j-a[i-1]-1]);
              if(dp[i][j]<0){
                  dp[i][j] =MOD+dp[i][j];
              }
              
          }
          
      }
  }
  cout<<dp[n][k]%MOD;
  
}

Measured memory_bytes: 80256
#include<stdio.h>
#include<ctype.h>

#define Num 1000

int main(void)
{
  char str[Num];
  int i=0;
  
  while(scanf("%c",&str[i])!=EOF)
    {
      if(islower(str[i])!=0)str[i]=toupper(str[i]);
   
      printf("%c",str[i]);
      i++;
    }
  //printf("\n");


  return 0;
}

Measured memory_bytes: 0
from collections import defaultdict
# d = defaultdict(int)で0で初期化
# d = defaultdict(lambda: 100)で100で初期化
n, t = map(int, input().split())
a = list(map(int, input().split()))
mn = 1 << 32
i = 0
d = defaultdict(int)
while i < n - 1:
    if a[i] < mn:
        eqmn = 1
        mn = a[i]
        while i < n - 1 and a[i] == a[i + 1]:
            eqmn += 1
            i += 1

    elif a[i] < a[i + 1]:
        eqmx = 1
        while i < n - 1 and a[i] <= a[i + 1]:
            if a[i] == a[i + 1]:
                eqmx += 1
            else:
                eqmx = 1
            i += 1
        mx = a[i]
        d[mx - mn] += min(eqmx, eqmn)

    else:
        i += 1

print(d[max(d.keys())])


Measured memory_bytes: 90736
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

right = [0]
left = [0]

for a in A:
    left.append(max(a, left[-1]))

for a in reversed(A):
    right.append(max(a, right[-1]))

for i in range(N):
    print(max(left[i], right[N-i-1]))


Measured memory_bytes: 15636
S = input()

n = len(S)
ans = "Yes"
if S != S[::-1]:
    ans = "No"
A = S[:(n-1)//2]
if A != A[::-1]:
    ans = "No"

B = S[(n+3)//2-1:]
if B != B[::-1]:
    ans = "No"

print(ans)

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;

#define mp make_pair
typedef pair<int,int> pii;

vector<pii> v;//the lines that we need to care about...
vector<pii> v2;//storing prefix sum sort of stuff...

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int r,c,n,p1,p2,x1,y1,x2,y2;
    bool b1,b2;
    cin>>r>>c>>n;
    while(n--){
      cin>>x1>>y1>>x2>>y2;
      b1=(x1==0 || x1==r || y1==0 || y1==c);
      b2=(x2==0 || x2==r || y2==0 || y2==c);
      if(b1&&b2){//both points on some edge...
        //find "index" of the point...
        if(y1==0)p1=x1;
        else if(y1==c)p1=r+c+(r-x1);
        else if(x1==r)p1=r+y1;
        else p1=r+c+r+(c-y1);

        if(y2==0)p2=x2;
        else if(y2==c)p2=r+c+(r-x2);
        else if(x2==r)p2=r+y2;
        else p2=r+c+r+(c-y2);
        if(p1>p2)swap(p1,p2);
        v.push_back(mp(p1,p2));
        v2.push_back(mp(p1,1));
        v2.push_back(mp(p2,-1));
      }
    }
    v2.push_back(mp(-1,0));//for prefix summing purposes...
    sort(v2.begin(),v2.end());
    for(int x=1;x<v2.size();x++){
      v2[x].second+=v2[x-1].second;
    }
    for(int x=0;x<v.size();x++){
      p1=v[x].first;p2=v[x].second;
      if(lower_bound(v2.begin(),v2.end(),mp(p1,-1))->second - lower_bound(v2.begin(),v2.end(),mp(p2,-1))->second !=1 ){
        //since it should be 1 after prefix summing...
        cout<<"NO\n";
        return 0;
      }
    }
    cout<<"YES\n";
    return 0;
}
/*

*/


Measured memory_bytes: 3052
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void)
{
    double a,b,h,m,ha,ma,sa;
    double pi=3.141592653589793238462643;
    cin >> a >> b >> h >> m;
    ha=30*h+0.5*m; ma=6*m;
    sa=abs(ha-ma);
    printf("%.12lf" ,pow(a*a+b*b-2*a*b*cos(sa*pi/180.0),0.5));
    return 0;
}


Measured memory_bytes: 4356
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   char[] c = sc.next().toCharArray();
   
   int ans=0;
   for(int i=0;i<c.length-1;i++)
   {
     if(c[i]!=c[i+1]) ans++; 
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 26276
n, d = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
count = 0
for i in range(n):
    x = xy[i][0]
    y = xy[i][1]
    dis = (x*x+y*y)**0.5
    if dis <= d:
        count+= 1
print(count)

Measured memory_bytes: 103168
#include <iostream>
#include <stdlib.h>
#define llint long long

using namespace std;

llint n;
llint a, b, c, d;

int main(void)
{
	cin >> n >> a >> b >> c >> d;
	a *= 2, b *= 2, c *= 2, d *= 2;
	n--;
	
	llint x = abs(b - a);
	
	if(c == 0 && d == 0){
		if(x == 0) cout << "YES" << endl;
		else cout << "NO" << endl;
		return 0;
	}
	
	llint l = (c+d)/2;
	llint w = (d-c)/2;
	
	llint cent;
	if(x > n*l) cent = n*l;
	else{
		if(n%2 == 0){
			if(x/l%2 == 0) cent = x/(2*l)*(2*l);
			else cent = (x/(2*l)+1)*(2*l);
		}
		else{
			if(x/l%2 == 1) cent = (x/(2*l))*(2*l) + l;
			else cent = (x/(2*l))*(2*l) + l;
		}
	}
	
	if(abs(cent - x) <= n*w) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
alp = [chr(ord('a') + i) for i in range(26)]

#A
def A():
    x, a, b = LI()
    if abs(x - a) > abs(x - b):
        print("B")
    else:
        print("A")
    return

#B
def B():
    s = S()
    s = set(s)
    for i in s:
        alp.remove(i)
    if len(alp) == 0:
        print("None")
    else:
        print(alp[0])
    return

#C
def C():
    n = II()
    a = LI()
    i = 1
    a.sort(reverse=True)
    ans = []
    while i < n:
        if a[i] == a[i - 1]:
            ans.append(a[i])
            if len(ans) == 2:
                print(ans[0] * ans[1])
                return
            i += 2
        else:
            i += 1
    print(0)

#D
def D():
    n = II()
    s1 = S()
    s2 = S()
    i = 0
    f = 0
    if s1[i] == s2[i]:
        ans = 3
        i += 1
        f = 1
    else:
        ans = 6
        i += 2
    while i < n:
        if s1[i] == s2[i]:
            ans *= 2 if f else 1
            ans %= mod
            i += 1
            f = 1
            continue
        i += 2
        ans *= 2 if f else 3
        f = 0
        ans %= mod
    print(ans%mod)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 40688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t;
    vector<int>a,b;
    cin>>n;
    for(int i=0; i<n; i++){cin>>t; a.push_back(t);}
    b=a;
    sort(b.rbegin(),b.rend());
    for(int i=0; i<n; i++)(a[i]==b[0])?cout<<b[1]<<endl:cout<<b[0]<<endl;
    /*
    fails in some cases
    int n, mx, mx2,temp;
    cin>>n;
    int a[n+1],b[n+1];
    //a[0]=mx=temp;
    mx=mx2=-1;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>mx) mx=a[i];
        if(a[i]>mx2 && a[i] != mx) mx2=a[i];
        //if(a[i]>mx2) (mx2 == -1)?mx2=a[i]:(a[i] != mx)?mx2=a[i]:mx2;
       // cout<<mx<<' '<<mx2<<endl;
    }
    if(mx2== -1)mx2=mx;
    for(int i=0; i<n; i++)
    {
        (a[i] == mx)?cout<<mx2<<endl:cout<<mx<<endl;
    }
*/
    return 0;
}
/*
3
4
2
3
*/


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

int main(){
  int n;
  cin >> n;
  int ans=0;
  int tmp=0;
  int a,b;
  cin >> a;
  for(int i=0; i<n-1; i++){
    cin >> b;
    if(a>=b){tmp++;}
    else{ans = max(ans,tmp);tmp=0;}
    a=b;
    //cout << tmp << endl;
  }
  ans = max(ans,tmp);
  cout << ans << endl;
}

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


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

    int preA = -1, preB = -1, preC = -1;
    int nextA, nextB, nextC;

    int count = 0;
    while (A%2 == 0 && B%2 == 0 && C%2==0) {
        if (A == preA && B == preB && C == preC) {
            count = -1;
            break;
        }
        preA = A;
        preB = B;
        preC = C;

        nextA = B / 2 + C / 2;
        nextB = C / 2 + A / 2;
        nextC = A / 2 + B / 2;
        A = nextA;
        B = nextB;
        C = nextC;
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  string a,b;
  cin>>a;
  cin>>b;
  for(i=0;i<n;i++)
  {
    cout<<a[i]<<b[i];
  } 
}

  

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string n;
    cin >> n;
    int a = n.size();
    for(int i=0;i<a/2;i++){
        if(n[i] != n[a - 1 -i]){
            cout << "No" << '\n';
            return 0;
        }
    }   
    cout << "Yes" << '\n';

    return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Text.Printf

main :: IO ()
main = loop 

loop :: IO ()
loop = do
  { [x,y] <- getInts
  ; if x == 0 && y == 0 then return ()
    else do
      { putInts (if x > y then [y, x] else [x, y])
      ; loop
      }
  }
 

--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn .  unwords . map show



Measured memory_bytes: 4096
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

w,h,n = map(int,input().split())
field = [[True for i in range(w)] for j in range(h)]

def paint(start,end,rotate=False):
    if rotate:
        for i in range(start,end):
            field[i] = [False for i in range(w)]

    else:
        for line in field[:]:
            for i in range(start,end):
                line[i] = False
for _ in range(n):
    x,y,a = map(int,input().split())
    if a == 1:  #1
        paint(0,x)
    elif a == 2:#2
        paint(x,w)
    elif a == 3:#3
        paint(0,y,rotate=True)
    else:       #4
        paint(y,h,rotate=True)

count = 0
for li in field[:]:
    count += li.count(True)
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef		vector<int>				 vi;
typedef 	vector<vi>				vii;
typedef		pair<int,int>			pii;
typedef		unsigned long long		ull;
typedef		long long				ll ;
#define MOD (int)(1e9+7)
#define INF (int)(1<<29) 
#define fori(i,a,b)		for(int i=a ; i <= b ; i++) 			
#define ford(i,a,b)  	for(int i=a ; i >= b ; i-- ) 
#define rep(i,n)   		for(int i=0; i < n ; i++ ) 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;


int main()
{
	ios_base::sync_with_stdio(0);	
	string a ;
	cin >> a; 
	if ( a[0] == a[2] ) 
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	return 0 ;
}



Measured memory_bytes: 256