akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

vector<ll> save;
map<ll, ll> rm;

 
void s(ll N){
    ll n = N;
    if(n <= 0) return;
    ll exp;
    if(n % 2 == 0) {
        if (rm[2] == 0) save.push_back(2);
        exp = 0;
        while (n % 2 == 0) {
            n /= 2;
            exp++;
        }
        if (exp > rm[2]) rm[2] = exp;
    }
    if(n == 1) return;
    for(ll i = 3; i <= sqrt(N); i+=2){
        if(n % i == 0){
            if(rm[i] == 0) save.push_back(i);
            exp = 0;
            while(n % i == 0){
                n /= i;
                exp++;
            }
            if(exp > rm[i]) rm[i] = exp;
        }
    }
    if(n != 1){
        if(rm[n] == 0){
            save.push_back(n);
            rm[n] = 1;
        }
    }
}

ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
        s(A[i]);
    }
    
    ll lcm = 1;
    ll mod = 1e9+7;
    rep(i,save.size()){
        rep(j,rm[save[i]]){
            lcm *= save[i] % mod;
            lcm %= mod;
        }
    }
    
    ll ans = 0;
    rep(i,N){
        ans += lcm * modinv(A[i],mod) % mod; //逆元をかける
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll n, a, b; cin >> n >> a >> b;
	cout << max((n-2)*(b-a)+1, 0ll) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i%3!=0 and i%5!=0){
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
n = int(input())
R = []
for i in range(n):
    R.append(int(input()))

maxv = R[1]-R[0]
minv = R[0]

for i in range(1, n):
    maxv = max(maxv, R[i]-minv)
    minv = min(minv, R[i])

print(maxv) 

Measured memory_bytes: 15548
N,K=map(int,input().split())

ans=0

baisuu=1
multiplier=0
count=[0]
for i in range(N,0,-1):
    while baisuu*i<K:
        baisuu*=2
        multiplier+=1
        count.append(0)
    
    count[multiplier]+=1

ans=0
for i in range(len(count)):
    ans+=count[i]*0.5**i

ans/=N
print(ans)

Measured memory_bytes: 63876
#include<stdio.h>
#include<ctype.h>
main(){
    char ch;
 
    while(1){
        scanf("%c",&ch);
        if(islower(ch)){
            ch = toupper(ch);
        }
        else if(isupper(ch)){
            ch = tolower(ch);
        }
        printf("%c",ch);
 
        if(ch == '\n') break;
    }
    return 0;
}


Measured memory_bytes: 2692
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int f[3005][3005],a[3005];
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			f[i][j]=(a[i]>a[j]);
	for(int i=1;i<=q;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		for(int j=1;j<=n;j++)if(j!=x&&j!=y){
			f[x][j]=f[y][j]=1ll*(f[y][j]+f[x][j])*((mod+1)/2)%mod;
			f[j][x]=f[j][y]=1ll*(f[j][x]+f[j][y])*((mod+1)/2)%mod;
		}
		f[x][y]=f[y][x]=1ll*(f[y][x]+f[x][y])*((mod+1)/2)%mod;	}
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			ans=(ans+f[i][j])%mod;
		}
	for(int i=1;i<=q;i++)ans=ans*2%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 35456
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    

    class Program
    {


        static long Solve(int N, int W, int[] w, int[] v)
        {
            long[,] dp = new long[N + 1, W + 1];

            for (int j = 0; j <= W; j++) dp[0, j] = 0;
            for (int i = 0; i <= N; i++) dp[i, 0] = 0;

            for(int i = 1; i <= N; i++)
            {
                for(int j = 0; j <= W; j++)
                {
                    dp[i, j] = dp[i - 1, j];
                    if (j - w[i] >= 0) dp[i, j] = Math.Max(dp[i, j], dp[i - 1, j - w[i]] + v[i]);
                }
            }

            return dp[N, W];
        }


        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int W = int.Parse(input[1]);

            int[] w = new int[N + 1];
            int[] v = new int[N + 1];

            for(int i = 1; i <= N; i++)
            {
                input = Console.ReadLine().Split(' ');
                w[i] = int.Parse(input[0]);
                v[i] = int.Parse(input[1]);
            }

            Console.WriteLine(Solve(N, W, w, v));
            
        }
    }
}

Measured memory_bytes: 89568
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
/*int main(){
    ll c=0,d=0,k=0,n,m,h,w,p,q;
    const int max = 100000;
    string s,s1,s2;
    ll num[max+1];

    cin >> n >> k;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        num[a] += b;
    }

    for (int ans=1; ans<=max; ans++){
        if(k <= num[ans]){
            cout << ans << endl;
            break;
        }
        k -= num[ans];
    }

    return 0;
}*/
const int AMAX = 100000;
ll cnt[AMAX + 1];

int main(void) {
ll N;
ll K;
cin >> N >> K;

rep(i,N){
 int A, B;
 cin >> A >> B;
 cnt[A] += B;
 }

for (int ans = 1; ans <= AMAX; ans++){
 if (K <= cnt[ans]) {
 cout << ans << endl;
 break;
}
 K -= cnt[ans];
 }

 return 0;
 }

Measured memory_bytes: 1024
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(a);
    cout<<a+(a*a)+(a*a*a)<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int main()
{
    double r;
    cin >> r;
    double L = 2 * r * PI;
    double S = r * r * PI;
    cout << fixed << setprecision(10) << S << " " << L << endl;
 //   system("pause");
    return 0;
}


Measured memory_bytes: 3280
#include<iostream>

using namespace std;

long long Fib_itr(int n){
    long long fib_n1 = 1, fib_n2 = 1;
    for (int i = 1; i < n; i++)
    {
        fib_n1 += fib_n2;
        fib_n2 = fib_n1 - fib_n2;
    }
    return fib_n2;
}

int main(){
    int n; cin >> n;
    cout << Fib_itr(n+1) << endl;
}


Measured memory_bytes: 3096
import java.util.Scanner;

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

    int w = scanner.nextInt();
    for (int i = 0; i < w; ++i) array[i] = i + 1;

    int n = scanner.nextInt();

    for (int i = 0; i < n; ++i) {
      int temp, a , b;
      String str = scanner.next();
      String[] num = str.split(",");
      temp = array[a = (Integer.parseInt(num[0]) - 1)];
      array[a] = array[b = (Integer.parseInt(num[1]) - 1)];
      array[b] = temp;
    }

    for (int i = 0; i < w; ++i) System.out.println(array[i]);
  }
}


Measured memory_bytes: 26308
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define INF 1123456789012
using namespace std;

int main(){
	ll n, m; cin >> n >> m;
	vector<ll> vec(n, 0);
	rep(i, m){
		ll a, b; cin >> a >> b;
		a--; b--;
		vec[a]++; vec[b]++;
	}rep(i, n){
		if (vec[i] & 1){
			cout << "NO" << endl;
			exit(0);
		}
	}cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1024
N, M, K = map(int, input().split())
F = [[] for _ in range(N)]
B = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    F[a].append(b)
    F[b].append(a)

for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    B[c].append(d)
    B[d].append(c)


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)


UF = UnionFind(N)
for iam in range(N):
    for friend in F[iam]:
        UF.union(iam, friend)

ans = [UF.size[UF.find(iam)] - 1 for iam in range(N)]
for iam in range(N):
    ans[iam] -= len(F[iam])

for iam in range(N):
    for block in B[iam]:
        if UF.same(iam, block):
            ans[iam] -= 1

print(*ans, sep=' ')


Measured memory_bytes: 48448
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    int ans = x;
    rep(i, n) {
        int a;
        cin >> a;
        int k = 1;
        while(k <= d) {
            ans++;
            k += a;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s,t;cin>>s>>t;
  bool flag=false;
  int t_long=t.size();
  int s_long=s.size();
  for(int i=s_long-t_long; i>=0;i--){
    if(flag)break;
    if(s[i]==t[0] || s[i]=='?'){
      bool check=true;
      string tmp=s.substr(i, t_long);

      for(int j=0;j<t_long;j++){
        if(tmp[j]!=t[j] && tmp[j] !='?'){
          check=false;
          break;
        }
      }
      if(check){
        for(int k=i;k<i+t_long;k++){
          s[k]=t[k-i];
        }
        flag=true;
      }
    }
  }
  for(int i=0;i<s_long;i++){
    if(s[i]=='?')s[i]='a';
  }
  cout<<((flag)?s:"UNRESTORABLE")<<"\n";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

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

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

int main(){
    int n=in,k=in;
    vector<int> h(n);
    for (int i=0;i<n;i++) h[i]=in;
    sort(h.begin(),h.end());
    ll sum=0;
    for (int i=0;i<n-k;i++){
        sum+=h[i];
    }
    out(sum);
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
   int x, max=-1000000, min=1000000,tmp=0;
   long long int sum=0;
   
   scanf("%d", &x);
   
   for (int i=0; i<x; i++){
       scanf("%d", &tmp);
       sum+=tmp;
       if(tmp < min)min = tmp;
       if(tmp > max)max = tmp;
   }
   
   printf("%d %d %lld\n", min, max, sum);
   
   return 0;
}


Measured memory_bytes: 3204
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

def main():
    a, b = map(int, input().split())
    if a <= 5:
        print(0)
    elif a <= 12:
        print(b // 2)
    else:
        print(b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
def soinsu(n):
    dic = defaultdict(int)
    i = 2
    while i*i <= n:
        if n%i == 0:
            dic[i] += 1
            n //= i
        else:
            i += 1
    if n!= 1:
        dic[n] += 1
    return dic
dic = soinsu(n)
ans = 0
for k,v in dic.items():
    i = 1
    while True:
        if v >= i:
            ans += 1
            v -= i
            i += 1
        else:
            break
print(ans)


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> v(n, false);
  for(int i=0;i<k;i++) {
    int d;
    cin >> d;
    for(int j=0;j<d;j++) {
      int a;
      cin >> a;
      a--;
      if(!v[a]) v[a] = !v[a];
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++) {
    if(!v[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<double>x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<n;i++){
        double y;
        cin>>y;
        x[i]=abs(x[i]-y);
    }
    double s1=0,s2=0,s3=0,sinf=0;
    for(int i=0;i<n;i++){
        s1+=x[i];
        s2+=x[i]*x[i];
        s3+=x[i]*x[i]*x[i];
        sinf=max(sinf,x[i]);
    }
    s2=sqrt(s2);
    s3=cbrt(s3);
    cout<<fixed<<setprecision(10);
    cout<<s1<<endl<<s2<<endl<<s3<<endl<<sinf<<endl;
     
}


Measured memory_bytes: 3444
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }

int L[102];

int main(){
    ll W,H,x,y;
    cin >> W >> H >> x >> y;
    cout << fixed << setprecision(10) << W * H / 2.0 << " ";
    if (x * 2 == W && y * 2 == H){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2*1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++)
        if(i%3 && i%5) sum += i;
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

class UnionFind{
public:
	vector<int> par;
	//0-indexed
	UnionFind(int n){init(n);}
	void init(int n = 1) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		par[x] = y;
	}
	bool same(int x,int y){
		return root(x)==root(y);
	}
};


// なもりグラフ
// https://www.hamayanhamayan.com/entry/2019/08/25/090415

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,H,W;
	ll ans = 0;
	cin >> N >> H >> W;
	UnionFind uf(H+W+6);
	priority_queue< pair<ll,P> > pq;
	FOR(i,0,N){
		int r,c,a;
		cin >> r >> c >> a;
		pq.push({a,{r,c}});
	}
	FOR(i,0,N){
		auto X = pq.top();
		int h = X.second.first;
		int w = X.second.second;
		int a = X.first;
		pq.pop();
		if(not uf.same(h,w+H)){
			ans += a;
			uf.unite(h,w+H);
		}else if(not uf.same(h,H+W+2)){
			ans += a;
			uf.unite(h,H+W+2);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5620
# Problem:
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(inputString):
    full_set = set()
    input_set = set()
    for j in range(ord('a'), ord('z')+1, +1):
        full_set.add(chr(j))
    for j in range(0, len(inputString), +1):
        input_set.add(inputString[j])
    # print("FULLSET:{}".format(full_set))
    # print("INPUT:{}".format(input_set))
    # set -= other
    full_set -= input_set
    # print("NOTFOUND:{}".format(full_set))
    fullset_list = list(full_set)
    fullset_list.sort()
    # print("NOT in STRING:{}".format(fullset_list))
    if 0 == len(fullset_list):
        result = "None"
    else:
        result = fullset_list[0]
    return result


if __name__ == "__main__":
    S = sys.stdin.readline().split()
    print("{}".format(solver(S[0])))


Measured memory_bytes: 3316
inpts = [int(n) for n in input().split()]
for i in range(2):
    for j in range(2-i):
        if inpts[j] > inpts[j+1]:
            temp = inpts[j]
            inpts[j] = inpts[j+1]
            inpts[j+1] = temp
print(' '.join([str(n) for n in inpts]))

Measured memory_bytes: 7664
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int X,N;
  cin >> X >> N;
  vi used(102,0);
  rep(i,N) {
    int x;
    cin >> x;
    used[x]++;
  }
  int ans = 0;
  srep(k,1,102) {
    if(used[k]) continue;
    if(abs(ans-X)>abs(k-X)) {
      ans=k;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) throws IOException {
		try (AtCoderReader ar = new AtCoderReader()) {
			ar.next();
			int[] A = ar.nextIntArray();

			int min = Integer.MAX_VALUE;

			for (int i = 0; i < A.length; i++) {
				min = Math.min(min, getCan2DivCount(A[i]));
			}

			System.out.println(min);
		}
	}

	private static int getCan2DivCount(int num) {
		if (num % 2 == 0) {
			return 1 + getCan2DivCount(num / 2);
		} else {
			return 0;
		}
	}

	public static class AtCoderReader implements AutoCloseable {
		private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public final String[] nextStringArray() throws IOException {
			return this.br.readLine().split(" ");
		}

		public final Stream<String> nextStream() throws IOException {
			return Stream.of(this.nextStringArray());
		}

		public final IntStream nextIntStream() throws NumberFormatException, IOException {
			return this.nextStream().mapToInt(Integer::parseInt);
		}

		public final int[] nextIntArray() throws IOException {
			return this.nextIntStream().toArray();
		}

		public final int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public final String next() throws IOException {
			return this.br.readLine();
		}

		@Override
		public final void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 26324
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val A = map(N)(_ => sc.nextInt())
    rep(N){ i =>
      if (i > 0) out.print(' ')
      val j = if (i <= (N - 1) / 2) {
        i
      } else {
        - i + N - 1
      }
      val k = (N - 1) / 2 - j
      val l = if (N % 2 == 0 && i <= (N - 1) / 2) {
        k * 2 + 1
      } else if (N % 2 == 1 && i > (N - 1) / 2) {
        k * 2 - 1
      } else {
        k * 2
      }
      out.print(A(l))
    }
    out.println()
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    (0 until n) foreach (i => res(i) = f(i))
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)
      map
    }

    def rep(f: A => Unit): Unit = {
      as.indices foreach (i => f(as(i)))
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(a => sum = num.plus(sum, f(a)))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 55932
using System;
using System.Linq;
using System.Collections.Generic;

namespace lineAralgebra
{
	class Program
	{
		public static void Main(String[] args)
		{
			var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
			var h = input[0];
			var n = input[1];

			var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

			for (var i = 0; i < n; i++)
			{
				h -= a[i];
			}

			if (h <= 0)
			{
				System.Console.WriteLine("Yes");
			}
			else
			{
				System.Console.WriteLine("No");
			}
		}
	}
}



Measured memory_bytes: 19296
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();

    if s.starts_with("YAKI"){
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<string,ll> counter;
void fff()
{
	int n;
	cin >> n;
	string s;
	FOR(i,0,n)
	{
		cin >> s;
		counter[s]++;
	}
	cout <<"AC x " << counter["AC"]<<ln;
	cout <<"WA x " << counter["WA"]<<ln;
	cout <<"TLE x " << counter["TLE"]<<ln;
	cout <<"RE x " << counter["RE"]<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 3684
#define _crt_secure_no_warnings

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main()
{
	int a[12];
	char c;
	while (1)
	{
		int sum = 0;
		for (size_t i = 0; i < 12; i++)
		{
			if (cin >> a[i])
			{
				if (i != 11)cin >> c;
				if (i < 10)
				{
					sum += a[i];
				}
			} else
			{
				return 0;
			}
		}
		double x;
		x = (double)a[10] / (double)(a[10] + a[11]);
		x *= sum;
		int i = 0;
		while (x > 0)
		{
			x -= a[i];
			i++;
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define INF 1e9 + 7
#define nd second
using namespace std;
typedef long long int lo;

int main(){
    //freopen("kenar.gir","r",stdin);
    //freopen("kenar.cik","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

    lo h,n;
    cin >> h >> n;
    lo sum;
    for(lo i = 0;i < n;i++){
        lo a;
        cin >> a;
        sum += a;
    }
    if(sum >= h) cout << "Yes";
    else cout << "No"; 
}



Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

import numpy as np


#N = 2 * 10 ** 5
#X = np.random.randint(0, 2, N)
#Y = int('0b' + ''.join(X.astype(str).tolist()), 0)

N = int(input())
X = input()
Y = int('0b' + X, 0)
X = np.array(list(X), int)

p = int(X.sum())
m1 = Y % (p + 1)
m2 = Y % max(1, p - 1)


count = np.zeros((N + 1, ))
for n in range(1, N):
    i = np.array(list(bin(n))[2:], int).sum()
    count[n] = 1 + count[n % i]

ans = [0] * N
for n in range(1, N + 1):
    flag = 0
    if X[n - 1]:
        z = m2 - pow(2, N - n, max(1, p - 1))
        z %= max(1, p - 1)
        if p - 1 == 0:
            flag = 1
    else:
        z = pow(2, N - n, p + 1) + m1
        z %= p + 1
        if p == 0:
            z = 0

    ans[n - 1] = int(count[z] + 1)
    if z == 0 and flag:
        ans [n - 1] = 0

print('\n'.join(map(str, ans)))

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    int q;
    cin >> q;

    int query, f, dir=1;
    char c;
    list<char> L;
    for(int i=0;i<s.size();i++) {
        L.push_back(s.at(i));
    }

    for(int i=0;i<q;i++) {
        cin >> query;
        if(query==1) {
            if(dir==1) dir=2;
            else dir = 1;
        }
        else {
            cin >> f >> c;
            if(dir==1) {
                if(f==1) {
                    L.push_front(c);
                }
                else {
                    L.push_back(c);
                }
            }
            else {
                if(f==1) {
                    L.push_back(c);
                }
                else {
                    L.push_front(c);
                }
            }
        }
    }

    if(dir==2) L.reverse();

    for(auto itr=L.begin();itr!=L.end();itr++) {
        cout << *itr;
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 9984
n,m = gets.split.map(&:to_i)
cape = Array.new(n).map{Array.new}
m.times do
  a,b = gets.split.map(&:to_i)
  cape[a-1] << b
  cape[b-1] << a
end
ans = Array.new(n)
f = Hash.new(-1)
q = [1]
f[1] = 0
while q != []
  s = q[0]
  cape[s-1].each do |i|
    if f[i] == -1
      f[i] = f[s]+1
      ans[i-1] = s
      q << i
    end
  end
  q.shift
end

x = true
for j in 1..(n-1)
  x = false if  ans[j] == nil
end
if x
  ans[0] = "Yes"
  puts ans
else
  puts "No"
end

Measured memory_bytes: 38024
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
const int N=1e6+5;
struct node{
	int x,y;
};
bool operator < (node a,node b)
{
	return a.x<b.x;
}
int n,ans,a[N],b[N];
priority_queue<node>q;
int suan(int x)
{
	if(x==n+1)return 1;
	if(x==0)return n;
	return x;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)b[i]=read();
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i])q.push((node){b[i],i});
	while(!q.empty())
	{
		node u=q.top();q.pop();
		int x=b[suan(u.y+1)]+b[suan(u.y-1)];
		if(b[u.y]-x<a[u.y]){puts("-1");return 0;}
		int y=b[u.y]-a[u.y];
		ans+=y/x;
		y%=x;
		b[u.y]=a[u.y]+y;
		if(b[u.y]!=a[u.y])q.push((node){b[u.y],u.y});
	}
	cout<<ans;
}

Measured memory_bytes: 12144
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func main() {
	x, a := nextInt(), nextInt()
	if x < a {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで

int main(){
  int64_t n, ans=1, flag, i=0, MOD=pow(10,9)+7;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  if(s1[i]==s2[i]) {
    ans*=3;
    ans%=MOD;
    flag=1;
    i++;
  }
  else {
    ans*=6;
    ans%=MOD;
    flag=0;
    i+=2;
  }
  for(i; i<n;){
    if(flag&&s1[i]!=s2[i]){
      ans*=2;
      ans%=MOD;
      flag=0;
      i+=2;
    }
    else if(flag){
      ans*=2;
      ans%=MOD;
      flag=1;
      i++;
    }
    else if(s1[i]!=s2[i]){
      ans*=3;
      ans%=MOD;
      flag=0;
      i+=2;
    }
    else{
      flag=1;
      i+=1;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3620
n = int(input())
alp = [chr(i) for i in range(97, 97+26)]

ans = []
while n != 0:
  c = n % 26
  ans.insert(0, alp[c-1])
  n //= 26
  if c == 0:
    n -= 1
  
print("".join(ans))

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int n;
    cin >> n;
    int f[201010];
    ll MOD = 1000000007;
    vector<pair<int,int>> v;
    rep(i,n+10){
        f[i] = -1;
    }
    rep(i,n){
        int x;
        cin >> x;
        if(f[x]!=(-1)&&(i-1)!=f[x]){
            pair<int,int> tmp;
            tmp.first = i-1;
            tmp.second = f[x];
            v.push_back(tmp);
        }
        f[x] = i;
    }
    sort(v.begin(),v.end());
    rep(i,v.size()){
        swap(v[i].first,v[i].second);
        //cout << v[i].first << ' ' << v[i].second << endl;
    }


    ll dp[n+10] = {};
    dp[0] = 1;
    dp[1] = 1;

    int count = 0;

    srep(i,2,n+10){
        dp[i] = dp[i-1];
        if(count<v.size()){
            while(v[count].second==(i-1)){
                dp[i] = (dp[i] + dp[v[count].first]) % MOD;
                count++;
                if(count==v.size()){
                    break;
                }
            }
        }
    }



    cout << dp[n+5] << endl;
    return 0;
}
 
 
 

Measured memory_bytes: 4336
n = int(input())
y = 1

while y <= n :
    if(y % 3 == 0):
        print(' %d'%y,end='')
    else:
        p = y
        while(p != 0):
            if(p % 10 == 3):
                print(' %d'%y,end='')
                break
            p //= 10
    y+=1
print()



Measured memory_bytes: 5868
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

ll memo[1000010];

ll fib(ll x){
  if(x == 0) return 1;
  else if(x <= 2) return x;
  else if(memo[x] != 0) return memo[x];
  return memo[x] = fib(x-2) + fib(x-1);
}

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

  vector<ll> a(m),b(m);
  rep(i,m) cin >> a[i] >> b[i];

  vector<bool> vec(n,true);

  rep(i,m){
      if(h[a[i]-1] < h[b[i]-1]){
          vec[a[i]-1] = false;
      }
      else if(h[a[i]-1] > h[b[i]-1]){
          vec[b[i]-1] = false;
      }
      else{
          vec[a[i]-1] = false;
          vec[b[i]-1] = false;
      }
  }

  ll ans = 0;

  rep(i,n){
      if(vec[i]) ans++;
  }

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

Measured memory_bytes: 5636
S = gets.chomp!
count = Array.new(10,0)
max = 0

S.size.times do |i|
    if S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'
        count[i] = count[i - 1] + 1
        if max < count[i]
            max = count[i]
        end
    end
end

puts max


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF  = 1<<30;


// verified by: https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_d


struct item {
  int v, w;
  bool operator<(const item &r) const { return w < r.w; }
  void operator+=(const item &r) { w += r.w, v += r.v; }
};


vector<item> enum_powerset(const vector<item> &is) {
  vector<item> a = {{0, 0}};
  vector<item> c;
  c.reserve(1<<sz(is));
  for (auto &i : is) {
    auto b = a;
    for (auto &e : b) e += i;
    merge(all(a), all(b), back_inserter(c));
    swap(a, c);
    c.clear();
  }
  return a;
}


int solve(const vector<item> &is, int W) {
  int n = sz(is);
  auto a = enum_powerset({is.begin(), is.begin() + n/2});
  auto b = enum_powerset({is.begin() + n/2, is.end()});
  reverse(all(a));
 
  int ans = 0;
  int vbmax = -INF;
  auto itr = b.begin();
  for (auto &[va, wa] : a) {
    while (itr != b.end() && wa + itr->w <= W) {
      chmax(vbmax, itr->v);
      ++itr;
    }
    chmax(ans, va + vbmax);
  }
  return ans;
}


int main() {
  int n; cin >> n;
  vector<item> is(n);
  for (auto &[v, w] : is) cin >> v >> w;
  is.insert(is.begin(), {0, 0});

  int q; cin >> q;
  rep(_, q) {
    int v, l; cin >> v >> l;
    vector<item> qi;
    while (v) {
      qi.push_back(is[v]);
      v /= 2;
    }
    cout << solve(qi, l) << '\n';
  }
}


Measured memory_bytes: 7412