akhauriyash/Code-Regression huggingface dataset:
K = int(input())

N = 50
q = K // N
r = K % N

a = (N - 1 + q) + N - (r - 1)
b = (N - 1 + q) - r

answer = [a] * r + [b] * (N - r)
print(N)
print(' '.join(list(map(str, answer))))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    string s;
    int k;
    cin >> s;
    cin >> k;
    int p = 0;
    while (p < s.size() && k > 0) {
        if (s[p] != 'a' && 'z' - s[p] + 1 <= k) {
            k -= 'z' - s[p] + 1;
            s[p] = 'a';
        }
        p++;
    }
    s.back() = (s.back() - 'a' + k) % 26 + 'a';
    cout << s << endl;
    return 0;
}


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

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

    cout << (n % 1000 == 0 ? 0 : 1000 - n % 1000) << endl;
    return 0;
}


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

public class Main
{

	public static void main(String[] args) throws IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int i = Integer.parseInt(str.substring(0, str.indexOf(" ")));
		int j = Integer.parseInt(str.substring(str.indexOf(" ") + 1));
		System.out.println((i * j) + " " + ((i + j) * 2));
	}

}



Measured memory_bytes: 24444
using System;
using System.Collections.Generic;

class A
{
	public static void Main ()
	{

		while (true) {
			char[] s = Console.ReadLine ().ToCharArray ();
			if (s[0] == '0') {
				break;
			}

			int sum = 0;
			for (int i=0; i<s.Length; i++) {
				sum += s [i] - 48;
			}
			Console.WriteLine (sum);
		}
	}
}

Measured memory_bytes: 8896
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, a = Is()
X = LI()
Y = [x-a for x in X]
# dp[i][total]
dp = [[0]*101*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
    for j in range(-50*(n+1), 51*(n+1)):
        dp[i][j] += dp[i-1][j]
        dp[i][j+Y[i-1]] += dp[i-1][j]
print(dp[n][0]-1)


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

int main()
{
    int n;
    cin >> n;
    int s[n + 1];
    for (int i = 0; i <= n; i++)
        s[i] = -1;
    int m;
    int ans = 1;
    cin >> m;
    while (m--)
    {
        int i, d;
        cin >> i >> d;
        if (s[i] == -1||s[i]==d)
            s[i] = d;
        else
            ans = 0;
    }
    if (ans == 0)
        cout << -1;
    else
    {
        if (n == 1 || s[1] != 0)
        {
            if (s[1] == -1&&n!=1)
                s[1] = 1;
            for (int i = 1; i <= n; i++)
            {
                if (s[i] == -1)
                    s[i] = 0;
                cout << s[i];
            }
        }
        else
            cout << -1;
    }
}

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

int main()
{
    int i, j;
    int n, m;
    int A[100][100];
    int b[100];
    int res;
    cin >> n >> m;
    
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            cin >> A[i][j];
    for (i = 0; i < m; i++)
        cin >> b[i];

    for (i = 0; i < n; i++)
    {
        res = 0;
        for (j = 0; j < m; j++)
            res += A[i][j] * b[j];
        cout << res << endl;
    }    
    return 0;
}



Measured memory_bytes: 3156
using System;
class SS
{
  static void Main()
  {
    var lines=Console.ReadLine().Split(' ');
    int M=int.Parse(lines[0]);
    int N=int.Parse(lines[1]);
    lines=Console.ReadLine().Split(' ');
    int[] goods=new int[M];
    float AmountGoods=0;
    for(int i=0;i<M;i++)
    {
      goods[i]=int.Parse(lines[i]);
      AmountGoods+=goods[i];
    }
    AmountGoods=(float)AmountGoods/(4*N);
    //Console.WriteLine(AmountGoods);
    for(int i=0;i<M;i++)
    {
      if(goods[i]>=AmountGoods)
        N--;
      if(N<=0)
        break;
    }
    if(N<=0)
      Console.WriteLine("Yes");
    else
      Console.WriteLine("No");
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long n, m;
long long dp[305][305][305] = {0};

long long solve();

int main() {
  cin >> n >> m;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  if(n > m) return 0;
  smodfact();
  dp[0][1][1] = 1;
  for(int i = 0; i < m; ++i)
    for(int j = 1; j <= n; ++j)
      for(int k = 1; k <= n; ++k) {
        dp[i + 1][j][k] += dp[i][j][k] * (j - k) % N;
        dp[i + 1][j][k] %= N;
        dp[i + 1][j][k] +=
            dp[i][j - 1][k] * (n - j + 1) % N;
        dp[i + 1][j][k] %= N;
        dp[i + 1][j][j] += dp[i][j][k] * k % N;
        dp[i + 1][j][j] %= N;
      }
  return dp[m][n][n];
}

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

using namespace std;

using ll = long long int;
ll A, B, Q;

vector<ll> s, t;


#define INF 100000000000LL


ll bs_lower(const vector<ll> &a, ll target) {
  auto it = upper_bound(a.begin(), a.end(), target);

  if (it != a.begin()) {
    return *(it - 1);
  } else {
    return INF;
  }
}

ll bs_upper(const vector<ll> &a, ll target) {
  auto it = lower_bound(a.begin(), a.end(), target);

  if (it != a.end()) {
    return *it;
  } else {
    return INF;
  }
}

ll lower_upper(const vector<ll> &a, ll target) {
  ll west = bs_upper(a, target);
  ll east = bs_lower(a, target);

  if (abs(west - target) < abs(east - target)) {
    return west;
  } else {
    return east;
  }
}

ll length(ll a, ll b, ll c)
{
  return abs(a - b) + abs(b - c);
}

ll search(const vector<ll> &a, const vector<ll> &b, ll x) {
  ll s0 = bs_lower(a, x);
  ll s1 = bs_upper(a, x);
  ll t0 = lower_upper(b, s0);
  ll t1 = lower_upper(b, s1);

  return min(length(x, s0, t0), length(x, s1, t1));

}

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

  for (int i = 0; i < A; i++) {
    ll tmp;
    cin >> tmp;
    s.push_back(tmp);
  }

  for (int i = 0; i < B; i++) {
    ll tmp;
    cin >> tmp;
    t.push_back(tmp);
  }

  for (int i = 0; i < Q; i++) {
    ll x; cin >> x;
    ll res = min(search(s, t, x), search(t, s, x));

    cout << res << endl;
  }

  return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll X=0;
    cin >> X;
    bool f=0;
    for(ll a=-120;a<=120;a++){
        for(ll b=-120;b<=120;b++){
            if(a*a*a*a*a-b*b*b*b*b==X){
                cout<<a<<" "<<b<<endl;
                f=1;
            }
        }
        if(f==1)break;
    }
}

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

int main(){

    int N;
    cin >> N;
    vector<long long> X(N);
    for(int i = 0; i < N; i++) cin >> X[i];

    vector<long long> Xsort(X);
    sort(Xsort.begin(), Xsort.end());

    long long left = Xsort[(N / 2) - 1], right = Xsort[N / 2];
    for(int i = 0; i < N; i++){
        if(X[i] <= left) cout << right << endl;
        else cout << left << endl;
    }

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
const int maxn = 303;
long double f[maxn][maxn][maxn];
bool v[maxn][maxn][maxn];
int n;
long double solve(int c0, int c1, int c2){
  if(c0 == 0 && c1 == 0 && c2 == 0) return 0;
  if(v[c0][c1][c2]) return f[c0][c1][c2];
  long double ans = 1.0 * n/(c0 + c1 + c2);
  if(c0) ans += c0 * solve(c0 - 1, c1, c2) / (c0 + c1 + c2);
  if(c1) ans += c1 * solve(c0 + 1, c1 - 1, c2) / (c0 + c1 + c2);
  if(c2) ans += c2 * solve(c0, c1 + 1, c2 - 1) / (c0 + c1 + c2);
  v[c0][c1][c2] = 1;
  return f[c0][c1][c2] = ans;
}
int main(){
  cin >> n;
  int c0 = 0, c1 = 0, c2 = 0;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    if(x == 1) c0++;
    if(x == 2) c1++;
    if(x == 3) c2++;
  }
  cout << fixed << setprecision(15) << solve(c0, c1, c2) << endl;
  return 0;
}

Measured memory_bytes: 459008
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 1e6+5;
const int LG = 25;

#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
//---------------------------

ll a[MAX_N];
ll  b[MAX_N];

int main(){
    fastio;
    ll n;
    cin>>n;
    f(i,0,n+1) cin>>a[i];
    f(i,0,n) cin>>b[i];
    ll ans = 0;
    f(i,0,n){
        if(a[i] > b[i]) ans+=b[i];
        else if(a[i+1] + a[i]> b[i]) {ans+=b[i];a[i+1] = a[i+1]+a[i] -b[i];}
        else {ans+=(a[i+1]+a[i]);a[i+1] = 0;}
    }
    cout<<ans<<endl;

}






Measured memory_bytes: 5200
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

int x,y;
int map[15][15];
int dp[15][15];

int solve(int i,int j,bool naname){
  //cout<<"a"<<i<<"\t"<<j<<endl;
  if(j < 0 ||j >= x) return 0;
  if(i >= y) return 1;
  if(naname)
    if(map[i][j] == 2)
      return 0;
  if(dp[i][j] >= 0) return dp[i][j];
 
  int ret;

  //cout<<i<<"\t"<<j<<endl;
  switch(map[i][j]){
  case 0:
    ret = solve(i+1,j-1,true) + solve(i+1,j,false)+solve(i+1,j+1,true);
    break;
  case 2:
    ret = solve(i+2,j,false);
    break;
  }

  return dp[i][j] = ret;
}


int main(){
  while(cin>>x>>y){
    if(x == 0 && y==0)
      return 0;
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<y;i++){
      for(int j = 0;j<x;j++){
	cin>>map[i][j];
	if(map[i][j] == 1)
	  dp[i][j] = 0;
      }
    }
    int ans = 0;
    for(int j = 0;j<x;j++){
      if(map[y-1][j] != 1)
	dp[y-1][j] = 1;
    }
    for(int j = 0;j<x;j++){
      ans += solve(0,j,false);
      // cout<<"ans:"<<ans<<endl;
    }
    cout<<ans<<endl;
    
  }

  return 0;
}

Measured memory_bytes: 1160
import numpy as np
n, x, y = map(int, input().split())

ans = [0] * n
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))] += 1

for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 14496
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int nd[100010];//同じ数字が何個あるか
int rd[100010];//nmodmが何個あるか
int rc[100010];//nmodmを何個余るか

signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
        nd[a[i]]++;
        rd[a[i] % m]++;
    }
    int ans = 0;
    // rep(i, 0, 10){
    //     cout << i << rd[i] << endl;
    // }

    rep(i, 0, m / 2 + 1){
        int ot = (m - i) % m;
        if(ot == i){
            rc[i] = rd[i] % 2;
            ans += rd[i] / 2;
        }else{
            int tmp = min(rd[i], rd[ot]);
            ans += tmp;
            rc[i] = rd[i] - tmp;
            rc[ot] = rd[ot] - tmp;
        }
        // cout << i << " " << ans << endl;
    }
    rep(i, 0, 100010){
        if(nd[i] >= 2 && rc[i % m] >= 2){
            int tmp = min(nd[i] / 2, rc[i % m] / 2);
            ans += tmp;
            rc[i % m] -= 2 * tmp;
        }
    }
    o(ans);
}

Measured memory_bytes: 3328
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
int search(int x) {

	int k = 0;
	int p = 1;
	while (p * 2 <= max_n)
	{
		p *= 2;
	}
	for (int i = p; i > 0; i /= 2)
	{
		if (i + k < max_n && bit[i + k] < x) {
			x -= bit[i + k];
			k += i;
		}
	}
	return k + 1;
}
void solv() {
	string s,p;
	cin >> s;
	cin >> p;
	s += s;
	for (size_t i = 0; i + p.size() < s.size(); i++)
	{
		bool ok = true;
		for (size_t j = 0; j < p.size(); j++)
		{
			if (s[i + j] != p[j]) {
				ok = false;
				break;;
			}
		}
		if(ok){
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



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

int main(void){
	double r,m,s;
	scanf("%lf",&r);
	m = r*r*M_PI;
	s = r*2.0*M_PI;
	
	printf("%.6f %.6f\n",m,s);
	
	
	return 0;
	
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    if(e-a<=n){
        cout<<"Yay!"<<endl;
        return 0;
    }
    cout<<":("<<endl;
}


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

void chmin(int &a, int b) {if(b < a) a = b;}
int N, A, B, C;
int l[10];
const int INF = 1LL << 29;

int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c) return INF;
        return abs(A-a) + abs(B-b) + abs(C-c);
    }

    int res = rec(i+1, a, b, c);
    chmin(res, rec(i+1, a+l[i], b, c) + (a? 10: 0));
    chmin(res, rec(i+1, a, b+l[i], c) + (b? 10: 0));
    chmin(res, rec(i+1, a, b, c+l[i]) + (c? 10: 0));

    return res;
}
int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; ++i) cin >> l[i];
    int res = INF;
    
    chmin(res, rec(0, 0, 0, 0));

    cout << res << endl; 
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, h: "List[int]"):
    counter = 0
    for hh in h:
        if hh >= K:
            counter += 1
    print(counter)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


if __name__ == '__main__':
    main()


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

int main() {
    string N;
    int A, B; 
    cin >> N >> A >> B;
    int S = stoi(N);
    int res = 0;
    for (int i=1; i<=S; i++) {
        int tmp = 0;
        string I = to_string(i);
        for (int j=0; j<I.size(); j++) {
            tmp += I.at(j)-'0';
        }
        if (tmp>=A && tmp<=B) res+=i;
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int ac=0,wa=0;
  map<int,int> ma,al;
  rep(i,m){
    int p;
    string s;
    cin>>p>>s;
    if(s=="AC"){if(!al.count(p)){al[p]=1;
                                 ma[p]=1;
                                 ac++;}
                if(al.count(p)&&!ma.count(p)){ma[p]=1;
                                              ac++;
                                              wa+=al[p];}}
    if(s=="WA"){if(al.count(p)){al[p]++;}
                if(!al.count(p)){al[p]=1;}}}
    cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 9600
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));

bool isprime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) if (num % i == 0) return false;
    return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int count = 0;
    for(ll a : A) if(isprime(a)) count++;
    cout << count << endl;
}



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

int main(void) {
 int nn;
 cin >> nn;
 string str;
 map<string, int> mp;
 for (int i=0;i<nn;i++){
   cin >> str;
   if (mp.count(str)!=0) {
     mp[str] += 1;
   } else {
     mp[str] = 1;
   }
 }
 int mn;
 cin >> mn;
 for (int i=0;i<mn;i++){
   cin >> str;
   if (int(mp.count(str))!=0) {
     mp[str] -= 1;
   } else {
     mp[str] = -1;
   }
 }
 map<string, int>::iterator mpitr = mp.begin();
 int _max = 0;
 while(mpitr != mp.end()){
   if (mpitr->second>=_max) {
     _max = mpitr->second;
   }
   mpitr++;
 }
 cout << _max << endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    string S;
    cin >> S;
    cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

string temp = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

int main()
{
  int W, H, P;
  bool bit[1005][1005];
  bool cur[8][105][105];

  __int128 mask, slow[1005], obj[8][105];
  
  while(cin >> W >> H >> P, W) {
    for(int i = 0; i < H; i++) {
      string S;
      cin >> S;
      for(int j = 0; j < S.size(); j++) {
        auto bb = temp.find(S[j]);
        for(int k = 0; k < 6; k++) {
          if(j * 6 + k >= W) break;
          bit[i][j * 6 + k] = (bb >> (5 - k)) & 1;
        }
      }
    }


    for(int i = 0; i < P; i++) {
      string S;
      cin >> S;
      for(int j = 0; j < S.size(); j++) {
        auto bb = temp.find(S[j]);
        for(int k = 0; k < 6; k++) {
          if(j * 6 + k >= P) break;
          cur[0][i][j * 6 + k] = (bb >> (5 - k)) & 1;
        }
      }
    }

    for(int i = 0; i < P; i++) {
      for(int j = 0; j < P; j++) {
        cur[4][i][j] = cur[0][j][i];
      }
    }

    for(int i = 0; i < 8; i++) {
      if(i % 4 == 0) continue;
      for(int j = 0; j < P; j++) {
        for(int k = 0; k < P; k++) {
          cur[i][j][k] = cur[i - 1][k][P - j - 1];
        }
      }
    }


    mask = ((__int128) 1 << P) - 1;
    for(int i = 0; i < 8; i++) {
      for(int j = 0; j < P; j++) {
        obj[i][j] = 0;
        for(int k = 0; k < P; k++) {
          obj[i][j] <<= 1;
          obj[i][j] |= cur[i][j][k];
        }
      }
    }

    for(int i = 0; i < H; i++) {
      slow[i] = 0;
      for(int j = 0; j < P; j++) {
        slow[i] <<= 1;
        slow[i] |= bit[i][j];
      }
    }


    int ret = 0;

    for(int j = 0; j <= W - P; j++) {
      for(int i = 0; i <= H - P; i++) {
        for(int k = 0; k < 8; k++) {
          bool rematch = true;
          for(int l = 0; l < P; l++) {
            rematch &= slow[i + l] == obj[k][l];
          }
          if(rematch) {
            ++ret;
            break;
          }
        }
      }
      for(int i = 0; i < H; i++) {
        slow[i] = (slow[i] << 1 | bit[i][j + P]) & mask;
      }
    }
    cout << ret << endl;
  }

}

Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
//1になるまで攻撃した回数
long long two(long long n){
    long long count = 0;
    long i=0;
    while(n>1){
        n = n/2;
        // cout <<"i"<<pow(2,i)<<endl;
        // cout <<"pow "<<pow(2,i)<<endl;
        count += pow(2,i);
        i++;
    }
    // cout << "count = "<< count << endl;
    return count;
}
//割った回数
long long two2(long long n){
    long long count2 = 0;
    long i=0;
    while(n>1){
        n = n/2;
        // cout <<"i"<<pow(2,i)<<endl;
        // cout <<"pow "<<pow(2,i)<<endl;
        count2++;
        i++;
    }
    // cout << "count = "<< count << endl;
    return count2;
}
int main(){
    long long H;
    cin >> H;
    long long count = 0;

    long long ans;
    long long a = two(H);
    long long b = two2(H);
    ans = pow(2,b)+a;
    // cout << "a = "<<a << endl;
    // cout << "b = "<<b << endl;
    cout << ans << endl;
    // }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

int main()
{
	int a, b, result = 0;
	char op;
	
	while(std::cin >> a >> op >> b)
	{
		if (op == '+') result = a + b;
		else if (op == '-') result = a - b;
		else if (op == '*') result = a * b;
		else if (op == '/') result = a / b;
		else break;
		std::cout << result << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
n,q = map(int,input().split())
s = input().replace("AC","aC")
L = [0]*n
cnt = 0
for i in range(1,n):
    if s[i-1] == "a":
        cnt += 1
    L[i]=cnt
        
for i in range(q):
    l,r = map(int,input().split())
    print(L[r-1] - L[l-1])


Measured memory_bytes: 6084
/**

     .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW / BESITE SOV
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o

*/


//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


bool DEBUG = 0;
#define debug(x) if (DEBUG) {cerr << #x << " = " << x << "\n";}
#define debug_vec(x) if (DEBUG) {cerr << #x << " = {"; for(auto a : x) cerr << a << ","; cerr << "}" << endl;}

#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll n;
main() {
    file("sort");
    ios;
    cin >> n;
    int ans = 0;
    if (n & 1) return !(cout << 0);
    int cur = 5;
    while (n) {
        n /= cur;
        ans += n / 2;
    }
    cout << ans;
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int A,B;
	char op;
	cin>>A>>op>>B;
	if(op=='+')cout<<A+B;
	else cout<<A-B;
}

Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Mod-Int
constexpr int MOD = 1000000007;
struct ModInt {
    ll val;
    ModInt() = default;
    ModInt(ll x) : val(x % MOD + (x < 0 ? MOD : 0)) {}
    ModInt &operator+= (const ModInt &x) {if ((val += x.val) >= MOD) val -= MOD; return *this;}
    ModInt &operator-= (const ModInt &x) {if ((val -= x.val) < 0) val += MOD; return *this;}
    ModInt &operator*= (const ModInt &x) {(val *= x.val) %= MOD; return *this;}
    ModInt operator+ (const ModInt &x) const {return ModInt(*this) += x;}
    ModInt operator- (const ModInt &x) const {return ModInt(*this) -= x;}
    ModInt operator* (const ModInt &x) const {return ModInt(*this) *= x;}
    ModInt pow(ll t) const {
        if (!t) return ModInt(1);
        ModInt m = pow(t / 2);
        m *= m;
        if (t & 1) m *= *this;
        return m;
    }
    ModInt inv() const {return pow(MOD - 2);}
    ModInt &operator/= (const ModInt &x) {return *this *= x.inv();}
    ModInt operator/ (const ModInt &x) const {return ModInt(*this) /= x;}
    friend istream &operator>> (istream &is, ModInt &x) {is >> x.val; return is;}
    friend ostream &operator<< (ostream &os, const ModInt &x) {os << x.val; return os;}
};

int main() {
    int n;
    cin >> n;
    vector<ModInt> a(n);
    rep(i, n) cin >> a[i];
    
    ModInt sum(0), ans(0);
    rep(i, n) {
        ans += a[i] * sum;
        sum += a[i];
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4776
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const int INF = (1e9);
vector<Pair> v;
int n;
int cntUp(int x) {
  int ans = 0;
  fore(i, 0, n) {
    if (v[i].second >= x) ans++;
  }
  return ans;
}
int cntDown(int x) {
  int ans = 0;
  fore(i, 0, n) {
    if (x >= v[i].first) ans++;
  }
  return ans;
}
int bbUp(int x) {
  int lo = 0, hi = INF + 1;
  while (hi - lo > 1) {
    int mi = (hi + lo) / 2;
    if (cntUp(mi) > x) {
      lo = mi;
    } else {
      hi = mi;
    }
  }
  return lo;
}
int bbDown(int x) {
  int lo = 0, hi = INF + 1;
  while (hi - lo > 1) {
    int mi = (hi + lo) / 2;
    if (cntDown(mi) > x) {
      hi = mi;
    } else {
      lo = mi;
    }
  }
  return hi;
}
void solve() {
  cin >> n;
  v.resize(n);
  fore(i, 0, n) {
    cin >> v[i].first >> v[i].second;
  }
  int ans;
  if (n % 2 == 1) {
    int r = bbUp(n / 2);
    int l = bbDown(n / 2);
    ans = r - l + 1;
  } else {
    int r1 = bbUp(n / 2);
    int l1 = bbDown(n / 2 - 1);
    int r2 = bbUp(n / 2 - 1);
    int l2 = bbDown(n / 2);
    int l = l1 + l2;
    int r = r1 + r2;
    //cout << l1 << "-" << r1 << endl;
    //cout << l2 << "-" << r2 << endl;
    ans = (r - l + 1);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  //cin >> t;
  while (t--) solve();

  return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  string ans = "Yes";
  for (int i=0; i<s.size(); i++) {
    if (i%2 && s[i]=='R') ans = "No";
    if (!(i%2) && s[i]=='L') ans = "No";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
Uruchamiamy samolot zwiadowczy ( + 500% do wzlamaniej )

/▄/  /█/  /◐/  /▐/   /▌/ /▀/ /░/ /  / choose your own style!

***IT'S OUR LONG WAY TO THE OIILLLL***


░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀  ░░░░░░░░███░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░█▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▀██████████████████████████████████████████████████
░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▄████▄████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████
░░░░░░░░░░░░░░░░░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█████████▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀  ░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████░░░░░░░░░░░░░░░
*/


//#pragma GCC target("avx2")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <bits/stdc++.h>
using namespace std ;
#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;template <typename T> using ordered_set = tree <T, null_type, less< T >, rb_tree_tag,tree_order_statistics_node_update>;
namespace fastio {template <class T> ostream &operator<<(ostream &os, const vector<T> &container) {for (auto &u : container)os << u << " ";return os;} template<class T1, class T2> ostream& operator << (ostream& os, const pair<T1, T2>& p) {return os << p.first << " " << p.second;}template <class T> ostream &operator<<(ostream &os, set<T> const& con) {    for (auto &u : con)        os << u << " ";return os;} void pr() {} template <typename T, typename... args> void pr(T x, args... tail) {cout << x << " ";pr(tail...);}} using namespace fastio;

#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define F first
#define S second
#define pii pair < int , int >
#define TIME 1.0 * clock() / CLOCKS_PER_SEC
mt19937_64 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = 2e5 + 3;


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

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

    ld pi = 3.141592653;
    ld r;
    cin >> r;
    cout << fixed<<2 * pi * r;
}




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

int main()
{
	int n, k;

	cin >> n >> k;

	int count = k;

	for (int i = 1; i < n; ++i)
	{
		count *= k - 1;
	}

	cout << count << endl;
	return 0;
}

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

#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define FILL(v,p) memset(v,p,sizeof v)
#define FIO ios::sync_with_stdio(NULL); cin.tie(NULL)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define PI acos(-1.0)

const ll MOD = 1000000007;
const ll INF = 2000000000000000001LL;
const ld EPS = 1e-9;

int main()
{
    FIO;
    
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    
    map<ll,ll> mp;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    
    ll ans = 0;
    for(pair<ll,ll> p:mp)
    {
        ans+= (p.second*(p.second-1))/2;
    }
    
    for(int i=0;i<n;i++)
    {
        ll tans = ans;
        
        tans-= (mp[a[i]]*(mp[a[i]]-1))/2;
        ll cal = mp[a[i]]-1;
        
        tans += (cal*(cal-1))/2;
       
        cout << tans << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  ll n;
  cin >> n;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  cout << n*2*3.14159265358979 << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing
/*
123356788aa
124456799bb

V H -> 2
H V -> 1
V V -> 2
H H -> 3
*/
ll mul(ll x, ll y) {
	return (x % MOD * y % MOD) % MOD;
}
int main() {
	int n;
	cin >> n;
	string s[2];
	cin >> s[0] >> s[1];
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		if (s[0][i] == s[1][i]) {
			if (i == 0) {
				ans = mul(ans, 3LL);
			}
			else {
				if (s[0][i - 1] == s[1][i - 1]) {
					ans = mul(ans, 2LL);
				}
			}
		}
		else {
			if (i == 0) {
				ans = mul(ans, 6LL);
			}
			else {
				if (s[0][i - 1] == s[1][i - 1]) {
					ans = mul(ans, 2LL);
				}
				else {
					ans = mul(ans, 3LL);
				}
			}
			i++;
		}
	}
	cout << ans;
}


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

unordered_map<string, int> dist;

struct A {
  string s;
  int d;
  int zero;
};

int main() {
  queue<A> que;
  que.push({string("01234567"), 0, 0});
  dist[string("01234567")] = 0;
  while(!que.empty()) {
    string arr = que.front().s;
    int d = que.front().d;
    int zero = que.front().zero;
    que.pop();
    do {
      int b;
      if(zero % 4 == 3) break;
      else b = zero + 1;
      string next = arr;
      swap(next[zero], next[b]);
      if(!dist.count(next)) {
        dist[next] = d + 1;
        que.push({next, d + 1, b});
      }
    } while(false);
    do {
      int b;
      if(zero % 4 == 0) break;
      else b = zero - 1;
      string next = arr;
      swap(next[zero], next[b]);
      if(!dist.count(next)) {
        dist[next] = d + 1;
        que.push({next, d + 1, b});
      }
    } while(false);

    do {
      int b;
      b = zero ^ 4;
      string next = arr;
      swap(next[zero], next[b]);
      if(!dist.count(next)) {
        dist[next] = d + 1;
        que.push({next, d + 1, b});
      }
    } while(false);
  }
  array<int, 8> arr;
  while(cin >> arr[0]) {
    for(int i = 1;i < 8;i++) cin >> arr[i];
    string s;
    for(auto x: arr) s.push_back((char)(x + (int)'0'));
    cout << dist[s] << endl;
  }
}



Measured memory_bytes: 4888
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
d = []

h.sort()
# print(h)
tmp = 10 ** 10

for i in range(n):
    if i + k - 1 >= len(h):
        break
    tmp = min(tmp, h[i + k - 1] - h[i])

print(tmp)


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

struct edge {
  ll t;
  ll c;
};

ll beki(ll n) {  // nを超えずに何回3を掛けれるか
  ll res = 0, now = 1;
  while (now * 3 <= n) { now *= 3, res++; }
  return res;
}

ll po(int n) {  // 3のn乗を返す
  ll res = 1;
  for (int i = 0; i < n; i++) {
    res *= 3;
  }
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  int l;
  cin >> l;
  vector<edge> g[25];
  int countedge = 0;

  vector<ll> kumi(25);  // i番目より下に何通りあるか
  kumi[0] = 1;
  for (int i = 0; i < 24; i++)
    kumi[i + 1] = kumi[i] * 3;

  ll cho = 0, count = 0;  // 使う頂点数
  bool owa = false;
  for (int i = 1; i <= 20; i++) {  // 今見ている頂点
    for (int j = 0; j < 3; j++) {  // 3本ずつ足していく
      g[i].push_back((edge){i - 1, kumi[i - 1] * j});
      countedge++;
      count = kumi[i - 1] * (j + 1);

      if (count + kumi[i - 1] > l) {  // これ以上追加するのはよくなさそう…
        while (count < l) {
          g[i].push_back(edge{beki(l - count), count});
          countedge++;
          count += kumi[beki(l - count)];
        }
        // 最後に
        cout << i + 1 << " " << countedge << endl;
        for (int x = 0; x <= i; x++) {
          for (auto a : g[x]) {
            cout << (i + 1) - x << " " << (i + 1) - a.t << " " << a.c << endl;
          }
        }
        owa = true;
        break;
      }
    }
    if (owa) break;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

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

    vector<ll> dp(N+1,INF);
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    reverse(all(A));
    rep(i,N){
        ll inx;
        inx = upper_bound(all(dp),A[i]) -dp.begin();
        dp[inx] = A[i];
    }
    ll ans;
    rep(i,N+1){
        if(dp[i] == INF){
            ans = i;
            break;
        }
    }

    cout << ans << endl;
    return 0;
    

}


Measured memory_bytes: 4808
#include <stdio.h>

int main() {

    int a, b;
    int maxx = -99999999;

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

    maxx = a + b;

    if(maxx < (a - b)) {
        maxx = a - b;
    }

    if(maxx < (a * b)) {
        maxx = a * b;
    }

    printf("%d", maxx);

    return 0;
}

Measured memory_bytes: 128
import java.util.*

object MainKt {
	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val s = scanner.next()

		val zeroCount = count(s, '0')
		val oneCount = s.length - zeroCount

		println(Math.min(zeroCount, oneCount)*2)
	}

	fun count(str: String, target: Char): Int {
		var count = 0
		str.toCharArray().forEach { c -> if (c==target) count++ }
		return count
	}
}

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

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

int n, k;
char s[200001];

int main() {
    cin >> n >> k;
    scanf("%s",s);
    char p = 'L';
    int c = 0, v = 0;
    if (s[0] == 'L') v++;
    if (s[n - 1] == 'R') v++;
    for (int i = 0; i < n; i++) {
        if (p == 'R' && s[i] == 'L') c++;
        p = s[i];
    }
    if (c - k > 0) {
        cout << n - ((c - k) * 2 + v) << endl;
    } else if (c - k == 0 && v == 2) {
        cout << n - 2 << endl;
    } else {
        cout << n - 1 << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000
using namespace std;
typedef long long ll;

ll n;
ll data[100001];

ll solve(){
  ll res = 0;
  ll part = 0;
  rep(i, 0, n){
    if(i%2==0){
      if(part + data[i] <= 0){
        res += llabs(part + data[i]-1);
        part = 1;;
      }
      else{
        part += data[i];
      }
    }
    else{
      if(part + data[i] >= 0){
        res += llabs(part + data[i] +1);
        part = -1;
      }
      else{
        part += data[i];
      }
    }
  }
  return res;
}

int main(){
  cin >> n;
  ll ans = 0;
  rep(i, 0, n)  cin >> data[i];
  ans = solve();
  rep(i, 0, n)  data[i]*=-1;
  cout << min(ans, solve()) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979


int main()
{
	int n, d, count = 0;
	cin >> n >> d;
	vector<vector<int>> a(n, vector<int>(d));

	rep(i, n)rep(j, d)  cin >> a[i][j];

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			double x = 0.0;
			rep(k, d) x += pow((a[i][k] - a[j][k]), 2);

			if (sqrt(x) - (int)sqrt(x) == 0) count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3716
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if(a*b>=c*d)
	printf("%d\n", a*b);
	else
	printf("%d\n", c*d);
	
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES  

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>


int main(){
    int n, m, l;
    std::cin >> n >> m >> l;

    std::vector<std::vector<long long>> a(n, std::vector<long long>(m));
    std::vector<std::vector<long long>> b(m, std::vector<long long>(l));
    std::vector<std::vector<long long>> c(n, std::vector<long long>(l, 0));

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            std::cin >> a.at(i).at(j);
        }
    }

    for(int i = 0; i < m; ++i){
        for(int j = 0; j < l; ++j){
            std::cin >> b.at(i).at(j);
        }
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < l; ++j){
            for(int k = 0; k < m; ++k){
                c.at(i).at(j) += a.at(i).at(k) * b.at(k).at(j);
            }
        }
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < l; ++j){
            std::cout << c.at(i).at(j);
            if(l - 1 == j){
                std::cout << std::endl;
            }else{
                std::cout << " ";
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3292