akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<ll> a(n);
	vector<ll> h(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];

		h[a[i]]++;
	}

	bool b = true;
	if (n % 2 == 1)
	{
		for (ll i = 0; i < n; i++)
		{
			if (i == 0)
			{
				if (h[i] != 1)
				{
					b = false;
				}
			}
			else if (i % 2 == 0)
			{
				if (h[i] % 2 == 1 || h[i] > 2)
				{
					b = false;
				}
			}
			else
			{
				if (h[i] > 0)
				{
					b = false;
				}
			}
		}

	}
	else
	{
		for (ll i = 0; i < n; i++)
		{
			if (i % 2 == 1)
			{
				if (h[i] != 2)
				{
					b = false;
				}
			}
			else
			{
				if (h[i] > 0)
				{
					b = false;
				}
			}
		}
	}


	if (b)
	{
		ull res = 1;
		for (ll i = 0; i < n / 2; i++)
		{
			res = (res * 2) % mod;
		}
		println(res);
	}
	else
	{
		println(0);
	}
}


Measured memory_bytes: 1792
#coding:utf-8

def base(num, n):
    if int(num/n):
        return(base(int(num/n), n)+str(num%n))
    return(str(num%n))

if __name__ == "__main__":
    n, k = map(int, input().split())
    base_num = base(n, k)
    print(len(base_num))



Measured memory_bytes: 2940
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll n;
    cin >> n;

    if (n % 2 == 1) {
        cout << 0 << '\n';
    } else {
        ll ans = 0;
        for (ll i = 10; i <= n; i *= 5) {
            ans += n / i;
            if (i > n / 5) break;
        }

        cout << ans << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def calc(case):
    # /2, /3, /5, +-1
    N, A, B, C, D = case
    memo = defaultdict(int)
    x = N
    def dp(n):
        if n == 0:
            return 0
        elif n == 1:
            return D
        elif n == 2:
            return D + min([A, D])
        for k in [2, 3, 5]:
            for i in [0, 1]:
                if memo[n // k + i] == 0:
                    memo[n // k + i] = dp(n // k + i)
        ret = min([
            n * D, 
            A + (n % 2) * D + memo[n // 2],
            A + (2 - n % 2) * D + memo[n // 2 + 1],
            B + (n % 3) * D + memo[n // 3],
            B + (3 - n % 3) * D + memo[n // 3 + 1],
            C + (n % 5) * D + memo[n // 5],
            C + (5 - n % 5) * D + memo[n // 5 + 1]
        ])
        return ret
    return dp(N)


def main():
    T = int(input())
    cases = [list(map(int, input().split())) for _ in range(T)]
    for case in cases:
        print(calc(case))


if __name__ == '__main__':
    main()


Measured memory_bytes: 23224
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#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 bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a,b;
  cin >> a >>b;
  int ans;
  if(a>b)swap(a,b);
  if(a==1 && b ==2)ans=3;
  if(a==2 && b ==3)ans=1;
  if(a==1 && b==3)ans=2;
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] data = new int[N][2];
        ArrayList<ArrayList> points = new ArrayList<>();
        for (int i = 0 ; i < N ; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            data[i][0] = x;
            data[i][1] = y;
            ArrayList<Integer> set = new ArrayList<>();
            set.add(i + 1);
            points.add(set);
        }
        int ans = 0;
        double sum = 0.0;
        while (!points.isEmpty()){
             ArrayList<Integer> currentSet = points.remove(0);
             if(currentSet.size() == N){
                 sum += getSum(currentSet, data);
                 ans ++;
             } else {
                 for (int i = 1 ; i < N + 1; i++){
                     if (!currentSet.contains(i)){
                         ArrayList<Integer> newSet = new ArrayList<>(currentSet);
                         newSet.add(i);
                         points.add(newSet);
                     }
                 }
             }
        }
        System.out.println(sum / ans);
        sc.close();
    }

    public static double getSum(List<Integer> point, int data[][]){
        double sum = 0;
        for (int i = 1 ; i < point.size(); i++){
            int x1 = data[point.get(i - 1) - 1][0];
            int y1 = data[point.get(i - 1) - 1][1];
            int x2 = data[point.get(i) - 1][0];
            int y2 = data[point.get(i) - 1][1];
            sum += getDistance(x1, y1, x2, y2);
        }
        return sum;
    }

    public static double getDistance(int x1, int y1, int x2, int y2){
        return Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2));
    }
}


Measured memory_bytes: 38556
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int n,m,sum;
    sum = 0;
    vector<int> data;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        int x; cin >> x; sum+=x; data.push_back(x);
    }

    sort(data.begin(),data.end(), std::greater<int>() );

    int i;
    for(i=0;i<m;i++){
        //printf("%d %d\n",data[i],sum/(4*m));
        if(data[i]*4*m<sum){
            break;
        }
    }

    if(i==m)cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for (int i = (int)k; i < (int)n; ++i)

using namespace std;
using ii = pair<int,int>;
using ll = long long;

constexpr int MAXN = 5 + 200000;
constexpr int MOD = 7 + 1e9;
int f[MAXN];

int mul(int a, int b) {
  return (int)((1LL*a*b) % MOD);
}

int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}

int fpow(int b, int e) {
  int ans = 1, p = b;
  for (; e; e >>= 1) {
    if(e & 1) ans = mul(ans, p);
    p = mul(p, p);
  }
  return ans;
}

int inv(int x) {
  return fpow(x, MOD - 2);
}

int c(int n, int k) {
  return mul(f[n], inv(mul(f[k], f[n-k])));
}

vector<int> t[MAXN];
vector<ii> pre[MAXN], pos[MAXN];
int sz[MAXN], dp[MAXN];

int dfs(int u, int p) {
  if (dp[u] != -1) return dp[u];
  if (find(t[u].begin(), t[u].end(), p) != t[u].end()) t[u].erase(find(t[u].begin(), t[u].end(), p));

  sz[u] = 0;
  pre[u].push_back({1,0});
  pos[u].push_back({1,0});

  for (int v : t[u]) {
    int ansv = dfs(v,u);
    sz[u] += sz[v];
    pre[u].push_back({mul(pre[u].back().first, mul(c(sz[u], sz[v]), ansv)), sz[u]});
  }

  int s = 0;
  for (int i = (int) t[u].size() - 1; i >= 0; --i) {
    int v = t[u][i], ansv = dfs(v,u);
    s += sz[v];
    pos[u].push_back({mul(pos[u].back().first, mul(c(s, sz[v]), ansv)), s});
  }
  reverse(pos[u].begin(), pos[u].end());
  sz[u]++;
  return dp[u] = pos[u].front().first;
}

int res[MAXN], n;
void dfs2(int u, int resup, int szup) {
  res[u] = mul(c(n-1, sz[u]-1), mul(resup, pos[u].front().first));
  for (int i = 0; i < (int) t[u].size(); ++i) {
    int ores = resup, s = szup;

    s += pre[u][i].second;
    ores = mul(ores, mul(c(s, pre[u][i].second), pre[u][i].first));

    s += pos[u][1+i].second;
    ores = mul(ores, mul(c(s, pos[u][1+i].second), pos[u][1+i].first));

    dfs2(t[u][i], ores, s+1);
  }
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  f[0] = 1;
  foi (i,1,MAXN) f[i] = mul(i, f[i-1]);
  cin >> n;
  foi (i,1,n) {
    int x,y; cin >> x >> y;
    t[x].push_back(y);
    t[y].push_back(x);
  }
  memset(dp, -1, sizeof dp);
  dfs(1,-1);
  dfs2(1,1,0);
  for (int i = 1; i <= n; ++i) cout << res[i] << '\n';
  return 0;
}


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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;

signed main(){
    int n;
    cin >> n;
    if(n&1){
        cout << 0;
        return 0;
    }
    int c = 0;
    int x = 10;
    int cc = 1;
    while(1){
        if(n/x == 0) break;
        c += cc*n/x;
        x *= 5;
    }
    cout << c;
}


Measured memory_bytes: 3604
import numpy as np
n=int(input())
h=list(map(int,input().split()))
cnt=0
ans=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        cnt+=1
    else:
        ans=np.max((ans,cnt))
        cnt=0
ans=np.max((ans,cnt))
print(ans)

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

using namespace std;

vector<int> dp;

int longestPath(vector<vector<int>>& G, int v){
  if(dp[v] == -1){
    int r = 0;
    for(int i=0;i<G[v].size();i++){
      r = max(r, 1+longestPath(G,G[v][i]));
    }
    dp[v] = r;
  }
  return dp[v];
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    G[x-1].push_back(y-1);
  }
  int r = 0;
  dp = vector<int>(N,-1);
  for(int i=0;i<N;i++)
    r = max(r,longestPath(G,i));
  cout << r;
  return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define y1 wzpakking
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
char s[105];
int main(){
	scanf("%s",s+1);
	if (s[2]=='u') puts("Cloudy");
	if (s[2]=='l') puts("Rainy");
	if (s[2]=='a') puts("Sunny");
}

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

int main() {
    int n;
    priority_queue<int> pq;
    int a;
    cin>>n;
    for (size_t i = 0; i < n; i++)
    {
        cin>>a;
        pq.push(a);
    }
    int sign = 1;
    int ans = 0;
    while(!pq.empty()) {
        ans += pq.top() * sign;
        sign *= -1;
        pq.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

int main(int argc, char *argv[]) {
  std::string s;
  std::cin >> s;
  std::set<char> c;
  for (auto &i : s)
    c.insert(i);
  if (c.find('N') != c.end() && c.find('S') != c.end() && c.size() == 2)
    std::cout << "Yes" << std::endl;
  else if (c.find('E') != c.end() && c.find('W') != c.end() && c.size() == 2)
    std::cout << "Yes" << std::endl;
  else if (c.size() == 4)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18 + 1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

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

	ll cnt = 0;
	while (B <= A) {
		B *= 2;
		cnt++;
	}
	while (C <= B) {
		C *= 2;
		cnt++;
	}
	if (cnt <= K) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main()
{
    char a[101],b[101];
    int i,j,c=0;
    char p2,tm;
 
    scanf("%s",a);
    scanf("%s",b);
 
    for(i=0;i<strlen(a);i++)
    {
 
        if((strcmp(a,b))==0)
            {
                c++;
                break;
            }
 
 
 
        p2=a[0];
 
        for(j=0;a[j+1]!='\0';j++)
        {
            a[j]=a[j+1];
        }
        a[j]=p2;
 
 
    }
    if(c==0) printf("No");
    else printf("Yes");
 
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	int cnt = 0;
	rep(i, N) {
		cin >> h[i];
		if (h[i] >= K) {
			cnt++;
		}
	}
	cout << cnt;

	return 0;
}

Measured memory_bytes: 640
# [箱A, 箱B, 箱C]
list = input().split()

# 箱Aと箱B入れ替え
temp = list[0]
list[0] = list[1]
list[1] = temp

# 箱Aと箱C入れ替え
temp = list[0]
list[0] = list[2]
list[2] = temp              
              
print(' '.join(list))

Measured memory_bytes: 9008
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    for i in (0..7).rev() {
        if 2i32.pow(i) <= n {
            println!("{}", 2i32.pow(i));
            return;
        }
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);

			char[] chrArr = br.readLine().toCharArray();
			int sum = 0;

			for (char chr : chrArr) {
				if (chr == '1') {
					sum++;
				}
			}
			System.out.println(sum);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}

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

int main(){
    int W, H, x, y, r;
    int xr, yr, xr2, yr2;
    cin>>W>>H>>x>>y>>r;
    xr=x+r;
    yr=y+r;
    xr2=x-r;
    yr2=y-r;
    if(xr2>=0){
        if(yr2>=0){
            if(xr<=W){
                if(yr<=H){
                    cout<<"Yes\n";
                }
                else{
                    cout<<"No\n";
                }
            }
            else{
                cout<<"No\n";
            }
        }
        else{
            cout<<"No\n";
        }
    }
    else{
        cout<<"No\n";
      }
      return 0;
}


Measured memory_bytes: 3104
#include <iostream>
int main ()
{
    int N,i;
    std::cin>>N;
    if(N%1000 == 0){
        std::cout<< 0 <<std::endl;
    }
    else{
        i = 1000 - (N%1000);
        std::cout<< i <<std::endl;
    }
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if((a+b)>(c+d)) cout << "Left";
    else if((a+b)<(c+d)) cout << "Right";
    else cout << "Balanced";
    cout << endl;
    return 0;
}

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

int a, b, c;

int main (){
	cin >> a >> b >> c ;
	if (a == b){
		cout << c;
	}
	else if (a == c){
		cout << b;
	}
	else if (b == c){
		cout << a;
	}
	
	return 0;
}

Measured memory_bytes: 256
import math

a, b = map(int, input().split())

if a/(b+1) < 0.8 and 0.8 < (a+1)/b:
    mina = a/0.08
    minb = b/0.1
    bigger = max(mina, minb)
    print(math.ceil(bigger))
else:
    print(-1)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	double xa1,xa2,ya1,ya2,xb1,xb2,yb1,yb2;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)!=EOF){
		if(xa1>xb2||ya1>yb2||xb1>xa2||yb1>ya2){
			printf("NO\n");
		}else{
			printf("YES\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2536
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vs s(n);
	rep(i,n) cin >> s[i];
	map<string,ll> mp;
	rep(i,n){
		mp[s[i]]++;
	}
	ll mx = 0;
	rep(i,n){
		chmax(mx,mp[s[i]]);
	}
	for(auto i : mp){
		if(i.second == mx){
			cout << i.first << endl;
		}
	}
}

Measured memory_bytes: 26752
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;


int main() {
	int n;
	int cn[30] = {};
	string str;
	cin >> n;
	for (int i = 'z' - 'a'; i >= 0; i--) {
		cn[i] = 100;
	}
	for (int i = 0; i < n; i++) {
		cin >> str;
		int temp[30] = {};
		for (auto &&c : str) {
			temp[c - 'a']++;
		}
		for (int i = 'z' - 'a'; i >= 0; i--) {
			cn[i] = min(cn[i], temp[i]);
		}
	}
	for (int i = 0; i <= 'z' - 'a'; i++) {
		char c = (char)('a' + i);
		for (int j = 0; j < cn[i]; j++) {
			cout << c;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
 
using namespace std;
 
int main(void){
 
    int x, y;
 
    while (1) {
        cin >> x >> y;
        if (x == 0 && y == 0)
            break;
 
        if (x > y)
            cout << y << ' ' << x << endl;
        else
            cout << x << ' ' << y << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3076
/*input
2
4
5 7 2
4 6 1
1 5 2
6 8 1
4
1 2 1
1 2 1
1 2 1
1 2 1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#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 <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

  int n;
  cin >> n;
  int v;
  vector <int> vec;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.pb(v);
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += (vec[i] * vec[j]);
    }
  }
  cout << ans << endl;

  return 0;
} 


Measured memory_bytes: 256
#include <stdio.h>
int q, n, c;
int modpow(int a, int b, int m) {
	int ret = 1;
	for(int i = 30; i >= 0; i--) {
		ret = 1LL * ret * ret % m;
		if(b & (1 << i)) ret = 1LL * ret * a % m;
	}
	return ret;
}
bool issprp(int x, int a) {
	int d = x - 1, s = 0;
	while(d % 2 == 0) d /= 2, s++;
	int p = modpow(a, d, x);
	if(p == 1) return true;
	for(int i = 0; i < s; i++) {
		if(p == x - 1) return true;
		p = 1LL * p * p % x;
	}
	return false;
}
bool slowprime(int x) {
	for(int i = 2; i * i <= x; i++) {
		if(x % i == 0) return false;
	}
	return true;
}
bool isprime(int x) {
	if(x < 30000) return slowprime(x);
	return issprp(x, 2) && issprp(x, 7) && issprp(x, 61);
}
int main() {
	scanf("%d", &q);
	for(int i = 0; i < q; i++) {
		scanf("%d", &n);
		if(n > 1 && isprime(n)) c++;
	}
	printf("%d\n", c);
}

Measured memory_bytes: 2668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pb push_back
#define fi first
#define se second
#define Mod 1000000007


int main(){
    ll i,j;
    ll h,w;
    cin>>h>>w;

    ll a[h][w];

    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            char x;
            cin>>x;
            if(x=='.') a[i][j]=0;
            else a[i][j]=1;
        }
    }
    
    ll dp[h][w];
    dp[0][0]= 0;
    if(a[0][0]==0) dp[0][0]=1;
    
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(i==0&&j==0) continue;

            
            if(i-1>=0&&j-1>=0){
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]=dp[i][j]%Mod;
            }
            else if(i-1>=0) dp[i][j]=dp[i-1][j];
            else dp[i][j]=dp[i][j-1];

            if(a[i][j]==1) dp[i][j]=0;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}



Measured memory_bytes: 15872
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, X = MAP()
CA = [LIST() for _ in range(N)]

ans = INF
for x in product([0, 1], repeat=N):
	s = np.zeros((M, ))
	tmp = 0
	for i in range(N):
		if x[i]:
			C, *A = CA[i]
			tmp += C
			s += np.array(A, dtype=np.int64)
	s = s.tolist()
	if all(x >= X for x in s):
		ans = min(ans, tmp)
print(ans if ans != INF else -1)


Measured memory_bytes: 27236
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
pyi = []
for i in range(m):
    p,y= map(int, input().split())
    pyi.append([p,y,i]) #県番号、誕生年、市番号の順

pyi.sort(key=lambda x: x[1]) #誕生年でソート
pyi.sort(key=lambda x: x[0]) #県番号でソート
#県番号の順番で並びつつも、同県の中では誕生年順になっている

ken = 0 #県番号の初期化
for i in range(m):
    if pyi[i][0] != ken: #新しい県に突入した時
        ken = pyi[i][0] #県番号を更新
        x = 1 #xは同県内での順位を表す
    else: #前と同じ県の時
        x += 1 #同県内の順位は1つ手前の市+1
    pyi[i].append(x) #リストpyiの要素の各リストの末尾に同県内の順位を付け加える

pyi.sort(key=lambda x: x[2]) #出力順に直すために市番号でソート
for i in range(m): #県番号と同県内の順位をゼロ埋めして出力
    print(str(pyi[i][0]).zfill(6)+str(pyi[i][3]).zfill(6))

Measured memory_bytes: 77660
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,i,j;
    cin>>a;
    int dish[a],happy[a],plhappy[a];
    b=0;
    for(i=0;i<a;i++)
    cin>>dish[i];
    for(i=0;i<a;i++){
    cin>>c;
    b=b+c;
    }
    for(i=0;i<a-1;i++)
    cin>>plhappy[i];
    for(i=1;i<a;i++){
        if(dish[i-1]+1==dish[i])
        b=b+plhappy[dish[i-1]-1];
    }
    cout<<b<<endl;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
print(41, 100)
for _ in range(10):
    for _ in range(50):
        print('.', end='')
        if b>1:
            print('#', end='')
            b -= 1
        else:
            print('.', end='')
    print()
    print('.'*100)
print('#'*100)
for _ in range(10):
    for _ in range(50):
        print('#', end='')
        if a>1:
            print('.', end='')
            a -= 1
        else:
            print('#', end='')
    print()
    print('#'*100)

Measured memory_bytes: 3316
/* 
AOJ 1153
Equal Total Scores
2015.4.25
 */
#include<stdio.h>

int t_num, h_num, t_cards[100], h_cards[100];

void equalize(){
  int i, j, t_sum = 0, h_sum = 0, t_changed = 0, h_changed = 0;

  
  for(i = 0; i < t_num; i++ ){
    t_sum += t_cards[i]; 
  }
  for(i = 0; i < h_num; i++){
    h_sum += h_cards[i];
  }


  for(i = 0; i < t_num; i++){
    for(j = 0; j < h_num; j++){
      t_changed = t_sum + h_cards[j] - t_cards[i];
      h_changed = h_sum + t_cards[i] - h_cards[j];
      if(t_changed == h_changed){
	printf("%d %d\n", t_cards[i], h_cards[j]);
	return ;
      }
    }
  }
  printf("-1\n");
  return ;
}

int main(void){
  int i;
  while(1){
    scanf("%d %d", &t_num, &h_num);
    if(t_num == 0 && h_num == 0){
      break;
    }

    for(i = 0; i < 100; i++){
      t_cards[i] = 0;
      h_cards[i] = 0;
    }


    for(i = 0; i < t_num; i++){
      scanf("%d", &t_cards[i]);
    }
    for(i = 0; i < h_num; i++){
      scanf("%d", &h_cards[i]);
    }


    equalize();

  }
  return ;
}

Measured memory_bytes: 612
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#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 ll long long int
#define ull unsigned long long int
#define ld long double
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]

typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
typedef vector<ii> vii;
typedef vector<lii> lvii;

#define min_prq(t) priority_queue<t,vector<t>,greater<t>>
#define max_prq(t) priority_queue<t>
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " is " << a << endl;
	err(++it, args...);
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
#define mod 1000000007
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_product() { return 1LL; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------


signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n,ans1=0,ans2=0;
	cin>>n;
	lvi a(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	ll x;x=a[0];
	ans1+=max(0LL,1LL-x);
	x=max(1LL,x);
	for(int i=1;i<n;i++)
	{
		ll y;y=a[i];
		ll k=y+x;
		if(x<0)
		{
			ans1+=max(0LL,1LL-k);
			x=max(1LL,k);
		}
		else if(x>0)
		{
			k=y+x;
			ans1+=max(0LL,k+1LL);
			x=min(-1LL,k);
		}
	}
	x=a[0];
	ans2+=max(0LL,1LL+x);
	x=min(-1LL,x);
	for(int i=1;i<n;i++)
	{
		ll y;y=a[i];
		ll k=y+x;
		if(x<0)
		{
			ans2+=max(0LL,1LL-k);
			x=max(1LL,k);
		}
		else if(x>0)
		{
			k=y+x;
			ans2+=max(0LL,k+1LL);
			x=min(-1LL,k);
		}
	}
	cout<<min(ans1,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<math.h>
#define pr(x) printf("%s %lld\n", #x , x)

int main()
{
    //freopen("in.txt", "w", stdout);
	long long sum , n ;
    scanf("%lld",&n);
    sum = 0 ; 
    for( long long int i = 1 ; i <= n ; i++){
        if(i % 3 != 0 ){
            if(i % 5 != 0) sum+= i;
        }
        
    }
    printf("%lld\n",sum);

}   

Measured memory_bytes: 1720
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
using namespace std;



int main() {
	bool endm = true;
	int sk;
	vector<int> s(10,0),ans(10,0);
	cin >> sk;
	for (int i = 3; i >=0; i--) {
		s[i] = sk % 10;
		//cout << sk<<i << endl;
		sk /= 10;
		//cout<< s[i] <<i<< endl;
	}
	
	if (((s[0] * 10 + s[1]) <= 12 && (s[0] * 10 + s[1]) > 0)&&((s[2] * 10 + s[3]) <= 12 && (s[2] * 10 + s[3]) > 0)) {
		ans[0] = 0;
		cout << "AMBIGUOUS" << endl;
		endm = false;
	}
	if (((s[2] * 10 + s[3]) <= 12 && (s[2] * 10 + s[3]) > 0) && endm) {
		ans[1] = 1;
		cout << "YYMM" << endl;
	}
	if (((s[0] * 10 + s[1]) <= 12 && (s[0] * 10 + s[1]) > 0) && endm) {
		ans[2] = 1;
		cout << "MMYY" << endl;
	}
	if ((ans[1] == 0 && ans[2] == 0)&&endm) {
		cout << "NA" << endl;

	}
	
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, res = 0;
  cin >> N >> M;
  for (int i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      if (M / i >= N)
        res = max(res, i);
      if (i >= N)
        res = max(res, M / i);
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	int num[50] = {};
	bool odd = false;
	for (int i = 0; i < N; i++) {
		cin >> num[i];
		num[i] %= 2;
		if (num[i])odd = true;
	}
	if (odd)cout << (long long int)pow(2, N - 1);
	else if (M)cout << "0\n";
	else cout << (long long int)pow(2, N) << endl;
	return 0;
}

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



int main()
{
	int N, M;
	int k = 0;
	int sum = 0;
	cin >> N >> M ;
	
	vector<int> a(N);


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

		cin >> a[i];
		sum += a[i];
	}



	for (int i = 0; i < N; i++) {
		if ((double)sum /(double)(4 * M) <= a[i])
			k++;
	}

	if (k >= M) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
		

}


Measured memory_bytes: 256
n,k = map(int,input().split())

p = list(map(int,input().split()))

s = [0]*(n+1)

for i in range(n):
    s[i+1] = s[i] + (p[i] + 1)/2

res = 0

for i in range(n-k+1):
    res = max(res, s[i+k] - s[i])
    
print("{:.10f}".format(res))

Measured memory_bytes: 31984
import java.lang.Math.PI

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val r = readInt()
    println(PI * r * 2)
}

Measured memory_bytes: 34728
#import math
import fractions
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:abs(int(y)-x),input().split()))
#print(xmod)
gcd = xmod[0]
for i in xmod:
    gcd = fractions.gcd(gcd,i)

print(gcd)

Measured memory_bytes: 16264
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const ll maxn = 2 * 1e6 + 5;
const ll mod = 1e9 + 7;
ll a[maxn],b[maxn],c[maxn];
ll x,y,aa,bb,cc,ans;
bool cmp(ll a, ll b)
{
    return a > b;
}
int main()
{
    priority_queue<ll,vector<ll>,greater<ll> > qu;
    cin >> x >> y >> aa >> bb >> cc;
    for(int i = 1; i <= aa; i++)
        cin >> a[i];
    for(int i = 1; i <= bb; i++)
        cin >> b[i];
    for(int i = 1; i <= cc; i++)
        cin >> c[i];
    sort(a + 1,a + aa + 1,cmp);
    sort(b + 1,b + bb + 1,cmp);
    sort(c + 1,c + cc + 1,cmp);
    for(int i = 1; i <= x; i++)
    {
        ans += a[i];
        qu.push(a[i]);
    }
    for(int i = 1; i <= y; i++)
    {
        ans += b[i];
        qu.push(b[i]);
    }
    for(int i = 1; i <= cc; i++)
    {
        ll t = qu.top();
        if(c[i] > t)
        {
            ans += abs(c[i] - t);
            qu.pop();
            qu.push(c[i]);
        }
        else
            break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10356
/*  ex4_1
    L40S38  */
#include<stdio.h>
#include<math.h>
int main(void){
    int n,d;
    //n:リンゴの木の本数
    //d:iの木の監視員はx番の木(i-d<=x<=i+d})を監視
    scanf("%d %d",&n,&d);
    int a=n/(2*d+1);//監視員は最大2*d+1本の木を監視
    int r=n%(2*d+1);
    if(r>0){
        a+=1;
        //r>0ならばa人では監視できない木を監視する監視員が必要
    }
    printf("%d",a);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int happy;
    happy = 0;
    int money = 0;
    scanf("%d",&money);
    
    while(money >= 500){
        money = money - 500;
        happy = happy + 1000;
        
    }
    while(money >= 5){
        money -= 5;
        happy += 5;
    }
    printf("%d\n",happy);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e6+17;
const LL MOD = 1e9+7;
char a[2][55];
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    scanf("%s",a[0]);
    scanf("%s",a[1]);
    LL ans = 1,k=0;
    for (int i = 0; i < n; ++i)
    {
    	if(a[0][i]==a[1][i]) 
    	{
    		if(k==0) ans=(ans*3)%MOD;
    		if(k==1) ans=(ans*2)%MOD;
    		k = 1;
    	}
    	else
    	{
    		if(k==0) ans=(ans*6)%MOD;
    		if(k==1) ans=(ans*2)%MOD;
    		if(k==2) ans=(ans*3)%MOD;
    		k = 2;
    		i++;
    	} 
    }
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
char c;
bool vis[27];
int i;
int main()
{
	while (cin>>c) vis[c-'a'+1]=1;
	for (i=1;i<=26;i++) if (!vis[i]) {cout<<((char)(i+'a'-1));return 0;}
	cout<<"None";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main()
{
    int k;
    cin>>k;
    if(k%2==0)
    {
        cout<<(k/2)*(k/2)<<endl;
    }
    else
    {
        cout<<(k/2)*((k/2)+1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    string s;
    cin >> s;
    
    int count =0;
    
    for(int i=0;i < 3;i++){
        if(s.at(i)==s.at(i+1)){
            count ++;
        }
    }
    
    if(count >= 1) cout << "Bad" << endl;
    else cout << "Good" << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include <math.h>

int swap(int *sw1,int *sw2){
	*sw1=*sw1+*sw2;
	*sw2=*sw1-*sw2;
	*sw1=*sw1-*sw2;
	return 0;
}
int main(void){

	int w,n,i,box1,box2,ans[30];

	scanf("%d",&w);
	scanf("%d",&n);

	for(i=1;i<=w;i++){
		ans[i-1]=i;
	}

	for(i=0;i<n;i++){
		scanf("%d,%d",&box1,&box2);
		swap(&ans[box1-1],&ans[box2-1]);
	}

	for(i=0;i<w;i++){
		printf("%d\n",ans[i]);
	}
	scanf("%d",&i);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    string x,y;
    cin >> x>>y;
    if(x<y)cout << "<" << endl;
    else if(x>y)cout << ">" << endl;
    else cout << "=" << endl;
}

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

int main(){
  int n;
  int u = 0;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  for(int j=0; j<n; j++){
    if(a[j]==a[j+1]){
      u++;
    }
  }

  if(u>0){cout << "NO" << endl;}
  else {cout << "YES" << endl;}

}

Measured memory_bytes: 1024
#import <stdio.h>
#import <math.h>

int check_prime(int target) {
    int is_prime = 1;

    for (int i = 2; i <= sqrt(target); i++) {
        if (target % i == 0) {
            is_prime = 0;
            break;
        }
    }

    return is_prime;
}

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

    int A[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    int cnt = 0;
    int target;
    for (int i = 0; i < N; i++) {
        target = A[i];

        if (check_prime(target)) {
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}



Measured memory_bytes: 2040
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

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

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 1e6+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int N;
vector<int> ANS[MAXN];

void work(){
    scanf("%d",&N);
    int i,ok=0;
    for(i=1;i*(i+1)<=N*2;i++){
        if(i*(i+1)==N*2){
            ok=1; break;
        }
    }
    if(!ok) printf("No\n");
    else{
        printf("Yes\n%d\n",i+1);
        int cur=1;
        for(int id=1;id<i+1;id++){
            for(int j=1;j<=i-id+1;j++){
                ANS[id].push_back(cur);
                ANS[id+j].push_back(cur);
                cur++;
            }
        }
        for(int id=1;id<=i+1;id++){
            printf("%d",ANS[id].size());
            for(int j=0;j<ANS[id].size();j++){
                printf(" %d",ANS[id][j]);
            }
            printf("\n");
        }
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}


















Measured memory_bytes: 25728
#include<stdio.h>
#include<string.h>
int main(void)
{
	int len,i;
	char s[101],x;
	scanf("%s",s);
	len=strlen(s);
	x='x';
	for(i=0;i<len;i++){
		printf("%c",x);
	}
	return 0;
}

Measured memory_bytes: 1644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<fstream>
#include<time.h>
#include<iterator>
#include<random>

//#pragma warning( disable:4996 )
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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

int MOD = (ll)1000000000 + 7;

const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int A[200020], B[200020];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int idx = 0, mx = 0,mn = INF;
	int N; cin >> N;
	bool found = false;
	REP(i, N) {
		cin >> A[i] >> B[i];
		if (A[i] > B[i]) {
			found = true;
			if (B[i] < mn) {
				mn = B[i];
				idx = i;
			}
		}
	}
	int ans = 0;
	if (!found) {
		print(0);
		return 0;
	}
	else {
		REP(i, N) {
			if (i == idx) {
				ans += A[i]-B[i];
			}
			else {
				ans += A[i];
			}
		}
	}
	print(ans);
}


Measured memory_bytes: 640