akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<bits/stdc++.h>
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 0; I < (N); ++I)
#define repp(I, A, B) for (int I = (A); I <= (B); ++I)
#define repr(I, N) for (int I = (N)-1; I >= 0; --I)
#define reppr(I, A, B) for (int I = (A); I >= (B); --I)
#define fors(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define mp make_pair
#define pb emplace_back
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(X)
#define in insert
#define cn count
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef set<int> si;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
/*}}}*/
void solve() {
	int n, h;
	R(h, n);
	int s = 0, a;
	rep(i, n) {
		cin >> a;
		s += a;
	}
	if (s >= h)
		W("Yes");
	else
		W("No");
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 3656
N = int(input())
v = list(map(int, input().split()))

v.sort()

result = 0
for i in range(N-1):
    if i == 0:
        result = v[i]
        result = (result + v[i+1]) / 2
    else:
        result = (result + v[i+1]) / 2
    

print(result)

Measured memory_bytes: 9160
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    int n,i,dif,d4=0;
    double d1=0,d2=0,ans2,d3=0,p,ans3,rp;
    scanf("%d",&n);
    int x[n],y[n];
    for(i=1;i<=n;i++) scanf("%d",&x[i]);
    for(i=1;i<=n;i++) scanf("%d",&y[i]);
    for(i=1;i<=n;i++)
    {
        dif=abs(x[i]-y[i]);

        d1=d1+dif;
        d2=d2+dif*dif;
        d3=d3+dif*dif*dif;
        if(d4<dif) d4=dif;
    }


    printf("%.6lf\n",d1);

    ans2=sqrt(d2);  printf("%.6lf\n",ans2);

    ans3=pow(d3,0.333333333333333333333);   printf("%.6lf\n",ans3);

    printf("%.6lf\n",d4*1.0000000);
}





Measured memory_bytes: 2936
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;

int di[4] = {0, 0, -1, 1};
int dj[4] = {1, -1, 0, 0};
#define inRange(x,a,b) (a <= x && x < b)

int main(){
    int w, h;
    while(cin >> w >> h, w+h){
        int mat[h][w];
        vector<pair<int,int>> cake;
        int si, sj, gi, gj;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> mat[i][j];
                if(mat[i][j] == 2)  si = i, sj = j;
                if(mat[i][j] == 3)  gi = i, gj = j;
                if(mat[i][j] == 4)  cake.push_back({i, j});
            }
        }

        int dp[h][w][h][w];
        memset(dp, 1, sizeof(dp));
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(mat[i][j] < 2)   continue;
                dp[i][j][i][j] = 0;
                queue<pair<int,int>> q;
                q.push({i,j});
                while(!q.empty()){
                    auto p = q.front(); q.pop();
                    for(int k = 0; k < 4; k++){
                        int ni = p.first + di[k], nj = p.second + dj[k];
                        if(inRange(ni,0,h)&&inRange(nj,0,w)&&mat[ni][nj]!=0&&dp[i][j][ni][nj]>dp[i][j][p.first][p.second]+1){
                            dp[i][j][ni][nj] = dp[i][j][p.first][p.second]+1;
                            q.push({ni,nj});
                        }
                    }
                }
            }
        }

        sort(cake.begin(), cake.end());
        int ans = 1<<30;
        do{
            int tmp = 0;
            int pi = si, pj = sj;
            for(int i = 0; i < cake.size()+1; i++){
                if(dp[pi][pj][gi][gj] <= 5){
                    tmp += dp[pi][pj][gi][gj];
                    ans = min(tmp, ans);
                    break;
                }
                if(i == cake.size())    break;
                if(dp[pi][pj][cake[i].first][cake[i].second] > 5)   break;
                tmp += dp[pi][pj][cake[i].first][cake[i].second];
                pi = cake[i].first;
                pj = cake[i].second;
            }
        }while(next_permutation(cake.begin(), cake.end()));

        cout << (ans==1<<30 ? -1 : ans) << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
H,W,M = map(int,input().split())

Hmax_temp = [0]*(H+1)
Wmax_temp = [0]*(W+1)
Hmax = 0
Wmax = 0
Bomb = dict()
for i in range(M):
	H_M,W_M = map(int,input().split())
	Hmax_temp[H_M] += 1
	Wmax_temp[W_M] += 1
	Bomb[(H_M,W_M)] = 1

Hmax = max(Hmax_temp)
Wmax = max(Wmax_temp)

#H方向の走査
y_max = []
for i in range(H+1):
	if Hmax == Hmax_temp[i]:
		y_max.append(i)
		
#W方向の走査
x_max = []
for j in range(W+1):
	if Wmax == Wmax_temp[j]:
		x_max.append(j)

#爆弾設置位置に対象が存在するか？
flag = False
for i in y_max:
	for  j in x_max:
		if (i,j) not in Bomb:
			flag = True
			break
	if flag:
		break

#答えのセット
if flag:
	ans = Wmax + Hmax
else:
	ans = Wmax + Hmax - 1
print(ans)

Measured memory_bytes: 85488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  a_x,a_y,b_x,b_y,i;
  cin >> a_x>>a_y>>b_x>>b_y;
  int x_distance = b_x - a_x;
  int y_distance = b_y - a_y;
  
  for ( i = 0; i<x_distance;i++){
    cout<< "R";
  }
  for ( i = 0; i<y_distance;i++){
    cout<< "U";
  }
  for ( i = 0; i<x_distance;i++){
    cout<< "L";
  }
  for ( i = 0; i<y_distance;i++){
    cout<< "D";
  }
  cout << "D";
  
  for ( i = 0; i<x_distance+1;i++){
    cout<< "R";
  }
  for ( i = 0; i<y_distance+1;i++){
    cout<< "U";
  }
  cout<< "L";
  cout<< "U";
  for ( i = 0; i<x_distance+1;i++){
    cout<< "L";
  }
  for ( i = 0; i<y_distance+1;i++){
    cout<< "D";
  }
  cout<<"R"<<endl;
}


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

using namespace std;

int main()
{
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int cost=0;
    if(min(x,y)*(a+b)>2*min(x,y)*c)
        cost+=2*min(x,y)*c;
    else
    {
        cost+=min(x,y)*(a+b);
    }
    int k=0;
    if(x>=y)
    {
        k=x-y;
        cost+=min(a*k,2*k*c);
    }
    else
    {
        k=y-x;
        cost+=min(b*k,2*k*c);
    }
    cout<<cost;
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement

N = int(input())
C = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
DP = [set() for _ in range(N)]
DP[0].add((1, 'a'))

for i in range(1, N):
    for num, s in DP[i-1]:
        for j in range(num):
            DP[i].add((num, s + C[j]))
        DP[i].add((num + 1, s + C[num]))
A = []
for _, ax in DP[N-1]:
    A.append(ax)
A.sort()
for a in A:
    print(a)






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

int main(){
  int n, s = 0; scanf("%d", &n);
  map<int, int> m;
  rep(i, n){
    int a; scanf("%d", &a);
    m[a]++;
  }
  rep(i, 1e5-1) s = max(s, m[i]+m[i+1]+m[i+2]);
  printf("%d\n", s);
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;

  double ans = 0;
  for(int i=1; i<=N; ++i)
  {
    int num = 0;
    for(int score=i; score<K; score=score*2)
    {
      ++num;
    }
    double div = N * pow(2,num);
    ans += 1/div;
  }
  printf("%.20f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

using ll=long long;

void solve(long long N, long long M){
  if(M > N){
    ll m=N; N=M; M=m;
  }

  if(M==1){
    if(N==1){
      cout << 1 << endl;;
    }else{
      cout << N-2 << endl;;
    }
  }else{
    cout << (N-2)*(M-2) << endl;;
  }
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	solve(N, M);
	return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	fmt.Println(a[len(a)-1] - a[0])
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <climits>

using namespace std;
#define forn(x, n)         for (int x = 0; x < n; x++)
#define forr(x, n)         for (int x = n; x >= 0; x--)
#define for1(x, n)         for (int x = 1; x < n; x++)
#define fore(x, a, b, c)   for (int x = a; x <= b; x += c)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define sc                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define eprint(...) 0
#endif
template<class T> bool smin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool smax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int N = 200010;
char line[N];
ll dp[N];
string num;

ll epow(ll a, ll b, ll Mod) {
    ll res = 1;
    while (b) {
        if (b & 1) 
            res = res * a % Mod;
        b >>= 1;
        a = a * a % Mod;
    }    
    return res;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    scanf("%s", line);
    num = string(line);
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 1;
    fore(i, 3, N - 1, 1) {
        int tmp = i % __builtin_popcount(i);
        dp[i] = 1 + dp[tmp];
    }

    ll cnt = 0;
    forn(i, n) if (num[i] == '1') ++cnt;
    reverse(all(num));
    ll rem1 = 0;
    ll rem2 = 0;
    vector<ll> ans;
    if (cnt == 1) {
        int pos = -1;
        forn(i, n) if (num[i] == '1') pos = i;
        eprint(pos);
        forn(i, n) {
            ll val = (epow(2, pos, 2) + epow(2, i, 2)) % 2;
            if (num[i] == '0') {
                ans.pb(1 + dp[val]);
            }
            else ans.pb(0);
        }
        reverse(all(ans));
        forn(i, sz(ans)) printf("%d\n", ans[i]);
        return 0;
    }
    forn(i, n) {
        rem1 = (rem1 + (num[i] - '0') * epow(2, i, cnt-1) % (cnt-1)) % (cnt-1);
        rem2 = (rem2 + (num[i] - '0') * epow(2, i, cnt+1) % (cnt+1)) % (cnt+1);
    }
    forn(i, n) {
        if (num[i] == '0') {
            ll tmp = (rem2 + epow(2, i, cnt+1)) % (cnt+1);
            ans.pb(1 + dp[tmp]);
        } else {
            ll tmp = (cnt-1 + (rem1 - epow(2, i, cnt-1)) % (cnt-1)) % (cnt-1);
            ans.pb(1 + dp[tmp]);
        }
    }
    reverse(all(ans));
    forn(i, sz(ans)) printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 7308
import copy
n=int(input())
a1=[int(i) for i in input().split()]
a2=copy.deepcopy(a1)
for i in range(1,n):
    a1[i]+=a1[i-1]
for i in range(1,n):
    a2[i]+=a2[i-1]

pm1,c1=0,0
pm2,c2=0,0

for i in range(n):
    a1[i]+=pm1
    if i%2==1:
        if a1[i]>=0:
            pm1-=(a1[i]+1)
            c1+=(a1[i]+1)
    else:
        if a1[i]<=0:
            pm1+=(-a1[i]+1)
            c1+=(-a1[i]+1)

for i in range(n):
    a2[i]+=pm2
    if i%2==0:
        if a2[i]>=0:
            pm2-=(a2[i]+1)
            c2+=(a2[i]+1)
    else:
        if a2[i]<=0:
            pm2+=(-a2[i]+1)
            c2+=(-a2[i]+1)

#print(c1)
#print(c2)
print(min(c1,c2))


Measured memory_bytes: 15096
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors
import numpy as np
N = int(input())
B = list(map(int,input().split()))
B.sort()
memory = 0
C = np.array(B)
min_number = B[0]
if len(B) < 3:
    print(B[-1])
    exit()
for i in make_divisors(min_number):
    if min_number % i == 0:
        if len(C[C % i != 0]) < 2:
                memory = i
                break
min_number = B[1]
for i in make_divisors(min_number):
    if min_number % i == 0:
        if len(C[C % i != 0]) < 2:
            if memory < i:    
                memory = i
            break
print(memory)

Measured memory_bytes: 23092
a,b,c=map(int,input().split())
v=set([])
if b-a<c:
    c=b-a
if a==b:
    print(a)
for i in range(c):
    v.add(a+i)
    v.add(b-i)
l=list(v)
l.sort()
for i in range(len(l)):
    print(l[i])

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

int main()
{
    int a[105] = {0};
    string s;
    cin >> s;
    
    for(int i = 0; i < s.size(); ++i)
    {
        a[s[i]-'a']++;
    }
    
    for(int i = 0; i < 105; ++i)
    {
        if(a[i] % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    String S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.S = sc.next();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        StringBuilder S2 = new StringBuilder(String.valueOf(S.charAt(0)));
        
        
        for (int i=1; i<S.length(); i++) {
        	if (S.charAt(i) == S.charAt(i-1)) {
        		continue;
        	} else {
        		S2.append(String.valueOf(S.charAt(i)));
        	}
        }
        
        count = S2.toString().length();
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 44460
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <iomanip>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, K; cin >> N >> K;
    double shouritsus = 0;
    for (int i = 1; i <= N; ++i) {
        int sai = i;
        double shouritsu = 1;
        while(sai < K) {
            sai *= 2;
            shouritsu *= 0.5;
        }
        shouritsus += shouritsu/N;
    }
    cout << setprecision(12) << shouritsus << endl;
}


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

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

    vector<string> s(n);
    map<string,int> mp;
    rep(i,n) {
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
    }
    int ans = 0;
    for(auto it : mp){
        int x = it.second;
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;
}

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

int int_sort( const void * a , const void * b ) {
  if( *(int*)a < *(int*)b ) {
    return -1;
  } else if( *(int*)a == *(int*)b ) {
    return 0;
  }
  return 1;
}

int main(void) {
  int N;
  scanf("%d", &N);

  int A[100000];
  for(int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  if(N == 2) {
    printf("%d\n", abs(A[0] - A[1]));
    return 0;
  }
  qsort((void*)A, N, sizeof(A[0]), int_sort);

  int B[100000];
  int pos = N / 2;
  int beg, end;
  int flag;
  int offset;
  B[pos] = A[0];
  beg = 1;
  end = N - 1;
  flag = 1;
  offset = 1;
  while(1) {
    if(flag == 1) {
      B[pos-offset] = A[end--];
      if(end < beg) break;
      B[pos+offset] = A[end--];
      if(end < beg) break;
      flag = 0;
    } else {
      B[pos-offset] = A[beg++];
      if(end < beg) break;
      B[pos+offset] = A[beg++];
      if(end < beg) break;
      flag = 1;
    }
    offset++;
  }
  
  int C[100000];
  C[pos] = A[N-1];
  beg = 0;
  end = N - 2;
  flag = 0;
  offset = 1;
  while(1) {
    if(flag == 1) {
      C[pos-offset] = A[end--];
      if(end < beg) break;
      C[pos+offset] = A[end--];
      if(end < beg) break;
      flag = 0;
    } else {
      C[pos-offset] = A[beg++];
      if(end < beg) break;
      C[pos+offset] = A[beg++];
      if(end < beg) break;
      flag = 1;
    }
    offset++;
  }
  long long int sumB = 0;
  for(int i = 1; i < N; i++) {
    sumB += abs(B[i-1] - B[i]);
  }
  long long int sumC = 0;
  for(int i = 1; i < N; i++) {
    sumC += abs(C[i-1] - C[i]);
  }
#if 0
  printf("B[]=");
  for(int i = 0; i < N; i++) {
    printf("%d ", B[i]);
  }
  printf(": sum=%lld\n", sumB);
  printf("C[]=");
  for(int i = 0; i < N; i++) {
    printf("%d ", C[i]);
  }
  printf(": sum=%lld\n", sumC);
#endif
  if(sumB < sumC)
    printf("%lld\n", sumC);
  else
    printf("%lld\n", sumB);
    
  return 0;
}


Measured memory_bytes: 1396
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    int H, W, N; cin >> H >> W >> N;
    if(W < H){
        int temp = H;
        H = W; 
        W = temp;
    }
    // H < W;
    int mass = 0;
    for(int i = 0; i < H; i++){
        mass += W;
        if(N <= mass){
            cout << i+1 << endl;
            return 0;
        }
    }
}

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

using namespace std;

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

const int N = 1e5 + 10;

struct Node {
  int id, vl;
} p[N];

bool cmp(Node a, Node b) {
  return a.vl > b.vl;
}

int n, a[N], l1[N], l2[N], r1[N], r2[N];
set<int> s;

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[i].vl = a[i];
    p[i].id = i;
  }
  s.clear();
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= n; i++) l2[i] = 0, r2[i] = n + 1;
  s.insert(p[1].id);
  for (int i = 2; i <= n; i++) {
    auto cur = s.lower_bound(p[i].id);
    if (cur != s.end()) {
      r1[p[i].id] = *cur;
      s.erase(cur);
      auto tmp = s.lower_bound(p[i].id);
      if (tmp != s.end()) r2[p[i].id] = *tmp;
      s.insert(*cur);
    }
    if (cur != s.begin()) {
      l1[p[i].id] = *(--cur);
      s.erase(cur);
      auto tmp = s.lower_bound(p[i].id);
      if (tmp != s.begin()) l2[p[i].id] = *(--tmp);
      s.insert(*cur);
    }
    s.insert(p[i].id);
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    // cout << i << " " << l1[i] << " " << l2[i] << " " << r1[i] << " " << r2[i] << endl;
    if (l1[i]) ans += 1ll * a[i] * (l1[i] - l2[i]) * ((r1[i] ? r1[i] : n + 1) - i);
    if (r1[i]) ans += 1ll * a[i] * (r2[i] - r1[i]) * (i - (l1[i] ? l1[i] : 0));
    // cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

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

const double EPS = 1e-10;
bool EQ(double a, double b){return fabs(a-b) < EPS;}
typedef complex<double> Point;
#define X real()
#define Y imag()
double dot(Point a, Point b){return real(conj(a) * b);}
double cross(Point a, Point b){return imag(conj(a) * b);}

typedef vector<Point> Polygon;
#define curr(P,i) P[i]
#define next(P,i) P[(i+1)%P.size()]
#define prev(P,i) P[(i+P.size()-1) % P.size()]

const int IN = 2;
const int ON = 1;
const int OUT = 0;
int contains(Polygon P, Point p) {
  bool in = false;
  for(int i = 0; i < P.size(); ++i){
    Point a = curr(P,i) - p;
    Point b = next(P,i) - p;
    // 点が多角形の辺上にある場合
    if(EQ(cross(a,b), 0.0) && dot(a,b) < EPS) return ON;
    // 点が多角形の内側にあるか外側にあるかを調べる
    if(a.Y > b.Y) swap(a,b);
    if(a.Y < EPS && EPS < b.Y && cross(a,b) > EPS) in = !in;
  }
  return in ? IN: OUT;
}

int main() {
  int n,x,y;
  Polygon P;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>x>>y;
    P.push_back(Point(x,y));
  }

  int q;
  Point p;
  cin>>q;
  for(int i=0;i<q;++i){
    cin>>x>>y;
    cout<<contains(P,Point(x,y))<<endl;
  }
  return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main(void) {
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if ((a < c && c < b) || (b < c && c < a)) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a < c&&c < b) {
		cout << "Yes" << endl;
	}
	else if (b < c&&c < a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }

    count:=0;
    max  :=0;
    min  :=100;


    Read(a);
    if max<a then
      max:=a;
    if min>a then
      min:=a;
    Read(a);
    if max<a then
      max:=a;
    if min>a then
      min:=a;
    Read(a);
    if max<a then
      max:=a;
    if min>a then
      min:=a;

    Writeln(max-min);

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
import collections

N=int(input())
S=[]
for i in range(N):
  S.append(input())
c = collections.Counter(S)
d = c.most_common()

ans_list=[]
maxi=d[0][-1]
for i,item in enumerate(d):
  if d[i][-1] == maxi:
    ans_list.append(item[0])
    
ans_list.sort()
for item2 in ans_list:
  print(item2)

Measured memory_bytes: 47636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		if (B % A == 0)
			System.out.println(A + B);
		else
			System.out.println(B - A);
		scanner.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)
#define MOD (1e9+7)

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

void Main(){
  ll N; cin >> N;

  int res = INF;
  for(ll A = 1; A <= pow(N, 0.5); A++){
    if(N % A != 0) continue;
    ll B = N / A;
    int tmp = floor(log10(B)+1);
    if(tmp < res) res = tmp;
  }

  cout << res << endl;
}

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

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

  Main();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
using namespace std;
//static const int INF = 1e9;
//static const double PI = acos(-1.0);
//static const double EPS = 1e-10;
//static const int dx[8] = { 1, 1, 0,-1,-1,-1, 0, 1};
//static const int dy[8] = { 0, 1, 1, 1, 0,-1,-1,-1};
typedef long long int LL;
typedef unsigned long long int ULL;
typedef vector<int> VI;
int main() {
  int n;
  cin >> n;
  VI p(n);
  REP(i, n) { cin >> p[i]; }
  int ans = 0;
  REP(i, n) {
    if(i + 1 == p[i]) {
      p[i] ^= p[i + 1];
      p[i + 1] ^= p[i];
      p[i] ^= p[i + 1];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

    if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int min1 = 1000;
  for(int i=0;i<s.size()-2;i++){
    string ans = s.substr(i,3);
    int num = stoi(ans);
    min1 = min(abs(753-num),min1);
  }
  cout << min1 << endl;
}
 

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
using vpll = vector<pll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void mysort(vpll &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vpll cas(n) ;
	ll mn = 1000000000 ;
	ll mx = -1000000000 ;
	for(int i=0;i<n;i++){
		cin >> cas.at(i).first >> cas.at(i).second ;
		if(mn>cas.at(i).first) mn = cas.at(i).first ;
		if(mx<cas.at(i).first) mx = cas.at(i).first ;
	}
	ll q ; cin >> q ;
	vpll town(q) ;
	map<pll,ll> m ;
	for(int i=0;i<q;i++){
		cin >> town.at(i).first >> town.at(i).second ;
		m[town.at(i)] = i ;
	}
	mysort(town) ;
	ll up,down ;
	for(int i=0;i<n;i++){
		if(cas.at((i+1+n)%n).first==mn&&cas.at(i).first!=mn) up = i ;
		if(cas.at((i-1+n)%n).first==mn&&cas.at(i).first!=mn) down = i ;
	}
	vll ans(q,0) ;
	for(int i=0;i<q;i++){
		ld x,y ;
		x = (ld)(town.at(i).first)*(999900.0/1000000.0) ;
		y = (ld)(town.at(i).second)*(999900.0/1000000.0) ;
//		cout << x << " " << y << endl ;
		if(x<mn||x>mx) continue ;
		while(cas.at(up).first<x) up = (up-1+n)%n ;
		while(cas.at(down).first<x) down = (down+1+n)%n ;
		ll preu = (up+1+n)%n,pred = (down-1+n)%n ;
		ld a = (ld)(cas.at(up).second-cas.at(preu).second)/(ld)(cas.at(up).first-cas.at(preu).first) ;
		ld b = (ld)(cas.at(down).second-cas.at(pred).second)/(ld)(cas.at(down).first-cas.at(pred).first) ;
		bool ok_u = (cas.at(preu).second+(x-cas.at(preu).first)*a>y) ;
		bool ok_d = (cas.at(pred).second+(x-cas.at(pred).first)*b<y) ;
		if(ok_u&&ok_d) ans.at(m[town.at(i)]) = 1 ;
//		cout << cas.at(preu).first << " " << cas.at(up).first << " " << cas.at(preu).second+(x-cas.at(preu).first)*a << endl ;
//		cout << cas.at(pred).first << " " << cas.at(down).first << " " << cas.at(pred).second+(x-cas.at(pred).first)*b << endl ;
	}
	for(auto i:ans) cout << i << endl ;
}



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

int main(void) {

	std::string S;
	cin >> S;

	bool answer = true;

	if (S[0] == 'A' && S[1] == 'A' && S[2] == 'A') {
		answer = false;
	}


	if (S[0] == 'B' && S[1] == 'B' && S[2] == 'B') {
		answer = false;
	}

	if (answer == true) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

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

int main() {
    vector<int> a(3);
    REP(i, 3) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = abs(a[0] - a[1]) + abs(a[1] - a[2]);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		boolean ans = true;
		for ( int i = 0 ; i < N ; i++ ) {
			if (A[i] % 2 == 0) {
				if ( A[i] % 3 != 0 && A[i] % 5 != 0 ) {
					ans = false;
					break;
				}
			}
		}

		System.out.println(ans ? "APPROVED" : "DENIED");
	}
}


Measured memory_bytes: 21972
import java.math.BigDecimal;
import java.util.Scanner;

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

        long a = sc.nextLong();
        String b = sc.next();
        BigDecimal c = new BigDecimal(b);
        BigDecimal d = new BigDecimal(a);
        System.out.println(c.multiply(d).toBigInteger());
    }
}

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

int main() {
	int N; cin >> N;
	vector<int>a(N); for (auto&& x : a)cin >> x;
	
	int cnt = 0, tmp = 1;
	while (cnt < a.size()) {
		tmp = a[tmp-1];
		cnt++;
		if (tmp == 2) {
			cout << cnt << endl;
			return 0;
		}
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 640
count = int(input())
list = input().split(" ")
state = False
i = 0
num = int(list[i])
i += 1
limit = 10 ** 18
if "0" in list:
  num = 0
  count = 0

while i < count:
  num = num * int(list[i])

  if num > limit:
    print(-1)
    state = True
    break
    
  i += 1

if not state:
  print(num)

Measured memory_bytes: 19372
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
#define maxi 100000000000000000
using namespace std;

void solve()
{ll t,n,m,k,ans,z=0,x,y,p=0,q=0,l=INT_MIN,mini=0,prev;
  cin>>m>>n;
  for(ll i=22;i<=n;i++)
  {  p=1;
    x=i;
  	while(x)
  	{
  	  if(x%10>=2)
		p*=(x%10);
	  else
	  {
	  p=0;
	  break;}
	  x/=10;	
	}
	if(p<=m&&p>0)
	z++;
  }
  cout<<z;
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}
/*
ll bfs(ll x)
{
	vector<ll> vis(100001,-1),papa(100001,-1);
	vis[x]=0; queue<ll> q;
	q.push(x);
	//cout<<"ok"<<endl;
	ll len=INT_MAX;
	while(!q.empty())
   { ll y=q.front();
     q.pop();
 	for( auto j:adj[y])
	{
		if(vis[j]==-1)
		{   //cout<<"ok"<<endl;
			vis[j]=vis[y]+1;
			papa[j]=y;
			q.push(j);
		}
		else if(j!=papa[y])
		{   //cout<<"chk"<<endl;
			len=min(len,vis[j]+vis[y]+1);
			break;
		}
	}
   }
   //cout<<len<<endl;
   return len;
}*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
class abcd
{
    public:
    ll day;
    ll vas;
};
bool fun1(abcd x,abcd y)
{
    return x.vas<y.vas;
}
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    ll n,w;
    cin>>n>>w;
    ll wt[n];
    ll val[n];
    rep(i,0,n)
    {
        cin>>wt[i]>>val[i];
    }
    // n is number of objects available 
    // w is max possible weight possible in knapsack

    ll dp[n+1][w+1]; // contains all possible values of number of objects and weights upto n and w
    // if number of objects == 0 then max sum of values  == 0 
    // similarly if max possible weight is 0 .. then max sum of values == 0 
    rep(i,0,n+1 )
    {
        dp[i][0]=0;
    }
    rep(i,0,w+1 )
    {
        dp[0][i]=0;
    }
    rep(i,1,n+1)
    {
        rep(j,1,w+1) 
        {
            if( wt[i-1] > j )
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=max( dp[i-1][j] , val[i-1] + dp[i-1][j-wt[i-1] ] );
            }
        }
    }
    cout<<dp[n][w]<<endl;
}


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

int solve(int n, int m, int **dp){
    
}

int main(){
    int n,m;
    cin>>n>>m;
    int arr[n][m];
    int M = 1000000007;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            char x;
            cin>>x;
            if(x == '.'){
                arr[i][j] = 0;
            }else if(x == '#'){
                arr[i][j] = 1;
            }
        }
    }
    if(arr[0][0] == 1){
        cout<<0;
    }
    else{
        int dp[n][m];
        memset(dp,0,sizeof(dp));
        dp[0][0] = 1;
        for(int i = 1; i < n; i++){
            if(arr[i][0] == 0 && dp[i-1][0]==1)dp[i][0] = 1;
            else
                dp[i][0] = 0;
        }
        for(int i = 1; i < m; i++){
            if(arr[0][i] == 0 && dp[0][i-1]==1)dp[0][i] = 1;
            else
                dp[0][i] = 0;
        }
        for(int i = 1; i < n; i++){
            for(int j = 1; j < m; j++){
                if(arr[i][j] == 1)dp[i][j] == 0;
                else
                dp[i][j] = ((dp[i-1][j])%M + (dp[i][j-1])%M)%M;
            }
        }
        // for(int i = 0; i < n; i++){
        //     for(int j = 0; j < m; j++){
        //         cout<<arr[i][j]<<" ";
        //     }
        //     cout<<endl;
        // }
        cout<<(dp[n-1][m-1])%M;
    }
}

Measured memory_bytes: 8064
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

# kanzenni rikai

tmp_A = [0] * N

for i, x in enumerate(A):
    if i % 2 == 0:
        tmp_A[i] = x
    else:
        tmp_A[i] = -x
# print(tmp_A)
x1 = sum(tmp_A)
tmp = x1
ans = []
for i in range(N):
    # print(int(tmp*2), end=" ")
    print(int(tmp), end=" ")
    tmp = 2 * A[i] - tmp


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

using namespace std;

int
main(void){
	string a, b, c;
	cin >> a >> b >> c;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	char cur = 'a';
	while(true){
		if(cur == 'a'){
			if(a.size() == 0){
				cout << "A";
				return 0;
			}
			cur = a[a.size() - 1];
			a.pop_back();
		}
		else if(cur == 'b'){
			if(b.size() == 0){
				cout << "B";
				return 0;
			}
			cur = b[b.size() - 1];
			b.pop_back();
		}
		else{
			if(c.size() == 0){
				cout << "C";
				return 0;
			}
			cur = c[c.size() - 1];
			c.pop_back();
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main(){
	int N;
	int a = -1, b = -1, sum = 0;
	cin >> N;
	rep(i, 0, N) {
		cin >> a;
		if (a == b) {
			++sum;
			++i;
			cin >> b;
		}
		else {
			b = a;
		}
	}
	cout << sum << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> L(2 * N);
  REP(i, 2 * N) cin >> L[i];
  sort(ALL(L));
  int res = 0;
  REP(i, N) res += L[2 * i];
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

static const double pi = 3.14159265358979323846;

long long mod = 1000000007;

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

  if(N==1){
    cout << 3 <<endl;
    return 0;
  }

  string S1, S2;
  cin >> S1; cin >> S2;

  long long combination = 1;
  bool prev_single = false;
  for(int i=0;i<N;i++){
    if(i==0){
      if(S1[0]==S1[1]){
        combination *= 6;
        prev_single = false;
        i++;
      }
      else{
        combination *= 3;
        prev_single = true;
      }
    }
    else if (i==N-1){
      combination *= prev_single * 2 + (!prev_single) * 1;
      combination %= mod;
    }
    else{
      if(S1[i]==S1[i+1]){
        combination *= prev_single * 2 + (!prev_single) * 3;
        combination %= mod;
        prev_single = false;
        i++;
      }
      else{
        combination *= prev_single * 2 + (!prev_single) * 1;
        combination %= mod;
        prev_single = true;
      }
    }
  }

  cout << combination%mod << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
int main() {
	int n, d[100000], ans;
	cin >> n;
	for (int a = 0; a < n; a++) {
		cin >> d[a];
	}
	sort(d, d + n);
	ans = d[n / 2] - d[n / 2 - 1];
	if (ans <= 0)ans = 0;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    char c;
    cin>>c;

    int x = c - 'a';
    x++;

    c = x + 'a';
    cout<<c<<endl;

    


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <set>
#define ll long long
using namespace std;
int main()
{
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		long ans = 0;
		
		for(int i=0; i<N; i++) {
			int m1 = Math.min(A[i], B[i]);
			ans += m1;
			A[i] -= m1;
			B[i] -= m1;
			int m2 = Math.min(A[i+1], B[i]);
			ans += m2;
			A[i+1] -= m2;
			B[i] -= m2;
		}

		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 64824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n,a; cin>>n>>a;
    cout<<n*n-a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) ((x).begin(), (x).end())
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    int cnt[n + 1] = {};
    rep(i, n) rep(j, n) {
        int d = abs(i - j);
        chmin<int>(d, abs(i - x) + abs(j - y) + 1);
        chmin<int>(d, abs(i - y) + 1 + abs(j - x));
        cnt[d]++;
    }
    rep(i, n - 1) cout << cnt[i + 1] / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
N, L = map(int, input().split())
 
result = int((N + 2 * L - 1) / 2 * N)
 
if(L < 0 and 0 < N + L - 1): print(result)
elif(L >= 0): print(result - L)
else: print(result - (N + L - 1))

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

int main(){
  int H, W;
  cin >> H >> W;

  for (int i = 0; i < W+2; i++) {
    cout << '#';
  }
  cout << endl;

  for (int i = 0; i < H; i++) {
    cout << '#';
    for (int j = 0; j < W; j++) {
      char a;
      cin >> a;
      cout << a;
    }
    cout << '#' << endl;
  }

  for (int i = 0; i < W+2; i++) {
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long

using namespace std;
const int MOD=1000000007;
const int INF=9000000009;
const double eps=1e-10;

signed main(){
  string s,t;
  cin>>s>>t;
  int a=stoi(s);
  int b=stoi(t);
  int ans=0;
  for(int i=a;i<b+1;i++){
    string u=to_string(i);
    string v=u;
    reverse(ALL(v));
    if(u==v)ans++;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  int n;
  cin >> n;
  
  bool all_white = true;
  vii a(n, vi(n));
  rep (i, n) {
    rep (j, n) {
      char c;
      cin >> c;
      a[i][j] = (c == '#');
      if (a[i][j]) all_white = false;
    }
  }
  
  if (all_white) {
    cout << -1 << endl;
    return 0;
  }

  int h = n, w = n;
  vector<bool> black(w), white(w);
  int cnt = n;
  rep (j, w) {
    black[j] = true;
    white[j] = true;
    rep (i, n) {
      if (not a[i][j]) black[j] = false;
      if (a[i][j]) white[j] = false;
    }
    if (black[j]) cnt--;
  }
  //DEBUG_VEC(white);
  //DEBUG_VEC(black);
  
  int mi = inf;
  rep (i, h) {
    int ans = 0;
    if (white[i]) {
      ans++;
    }
    rep (j, w) {
      if (not a[i][j]) ans++;
    }
    ans += cnt;
    chmin(mi, ans);
  }
  cout << mi << endl;
  
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long sum = 0;
    int t = 0;
    for (int i = 0; i < n - 1; i++) {
        sum += a[i];
        if (sum * 2 < a[i+1]) t = i + 1;
    }
    cout << n - t << endl;
    return 0;
}

Measured memory_bytes: 640