akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M);
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }

  int start = L[0], end = R[0];
  int flag = true;
  for (int i = 1; i < M; i++) {
    if (L[i] > end || R[i] < start) {
      flag = false;
    }
    else {
      if (start < L[i]) {
        start = L[i];
      }
      if (R[i] < end) {
        end = R[i];
      }
    }
  }
  if (flag) {
    cout << end - start + 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 1024
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << i << "\n"

const ll MOD = 998244353;
//const ll MOD = 1e9+7;

bool prime[100010];

ll count[100010];
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  prime[0]=false;prime[1]=false;

  rep(i,2,100010)prime[i]=true;

  rep(i,2,100010){
    if(prime[i]){
      rep(j,2,100010/i + 1){
        if(i*j<100010)prime[i*j]=false;
      }
    }
  }

  ll q;
  std::cin>>q;

  count[0]=0;

  rep(i,1,100010){
    count[i]=count[i-1];
    if((i%2==1)&&prime[i]&&prime[(i+1)/2])count[i]++;
  }

  rep(i,0,q){
    ll l,r;
    std::cin>>l>>r;

    std::cout<<count[r]-count[l-1]<<"\n";
  }

  return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void){

	long N;
	long K;
	long T;
	
	long A;
	A=0;
	
	long i;
	
	int ret;
	
	ret = scanf("%ld %ld",&N,&K);
	
	for (i=1; i<=N; i++){
		
		scanf("%ld",&T);
		
		if ( T >= K ){A++;}
		
	}
	
	printf("%ld",A);
	


}


Measured memory_bytes: 128
N=int(input())
l=[]
for i in range(N):
  d,t=input().split()
  l.append([d,t])
m=0
for i in l:
  if i[1] == "JPY":
    m=m+int(i[0])
  else:
    m=m+380000.0*float(i[0])
print(m)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
edge=[[] for _ in range(N)]
for i in range(N-1):
    edge[i].append((i+1,1,1))
for i in range(N):
    for j in range(i+1,N):
        if A[i]<A[j]:
            edge[i].append((j,A[i],A[j]))
que=deque([0])
d=[0]*N
d[0]=1000
while que:
    v=que.popleft()
    for nv,be,af in edge[v]:
        tmp=d[v]//be
        if d[nv]<d[v]-tmp*be+tmp*af:
            d[nv]=d[v]-tmp*be+tmp*af
            que.append(nv)
print(d[-1])

Measured memory_bytes: 74380
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        int abc[] = {a, b, c};
        Arrays.sort(abc);
        System.out.println(abc[0] * abc[1] / 2);
        inp.close();
    }
}


Measured memory_bytes: 23764
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;

int main(){
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == ',')s[i] = ' ';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            boolean hh = false;
            boolean ww = false;
            if (h <= a[i]) {
                hh = true;
            }
            if (w <= b[i]) {
                ww = true;
            }
            if (hh && ww) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26324
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 = ii()
A = iil()

for i in A:
    if i%2 == 0:
        if i%3 != 0 and i%5 != 0:
            print('DENIED')
            exit()

print('APPROVED')

Measured memory_bytes: 3060
h = int(input())
key = list(map(int,input().split()))
key.insert(0,0)

for i in range(h):
    k = i + 1
    lk = 2*k
    rk = 2*k + 1
    pk = int(0.5*k)
    if k == 1:
        print("node {0}: key = {1}, left key = {2}, right key = {3}, ".format(k, key[k], key[lk], key[rk]))
    elif lk > h:
        print("node {0}: key = {1}, parent key = {2}, ".format(k, key[k], key[pk]))
    elif rk > h:
        print("node {0}: key = {1}, parent key = {2}, left key = {3}, ".format(k, key[k], key[pk], key[lk]))
    else:
        print("node {0}: key = {1}, parent key = {2}, left key = {3}, right key = {4}, ".format(k, key[k], key[pk], key[lk], key[rk]))

Measured memory_bytes: 7752
import sys
sys.setrecursionlimit(10**6)

N,M = map(int,input().split())
G = [[] for i in range(N)]
for i in range(M):
	a,b = map(lambda x: int(x)-1, input().split())
	G[a].append(b)
	G[b].append(a)

flag = False

def dfs(p, x, d):
	if d>=2:
		if x==N-1:
			global flag
			flag = True
		return

	for i in G[x]:
		if i==p:
			continue
		else:
			dfs(x,i,d+1)

dfs(-1,0,0)
print('POSSIBLE' if flag else 'IMPOSSIBLE')

Measured memory_bytes: 38296
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	int D, N;
	cin >> D >> N;
	if (D == 0) {
		if (N == 100) {
			OUT(101);
			return 0;
		}
		OUT(N);
		return 0;
	}
	else if (D == 1) {
		if (N == 100) {
			OUT(10100);
			return 0;
		}
		OUT(100 * N);

		return 0;
	}
	else {
		
		if (N == 100) {
			OUT(1010000);
			return 0;
		}
		
		OUT(10000 * N);
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int a[2][1500000];

int main() 
{
	int n,m;
	while(cin >> n >> m && n>0 && m>0)
	{
		int h[1500]={0};
		int w[1500]={0};
		for(int i=0;i<n;i++){ cin >> h[i];}
		for(int i=0;i<m;i++){ cin >> w[i];}
		
		fill(a[0],a[0]+1500000,0);
		fill(a[1],a[1]+1500000,0);
		
		for(int i=0;i<n;i++){
			int sum =0;
			for(int j=i;j<n;j++)
			{
				sum+=h[j];
				a[0][sum-1]++;
			}
		}
		for(int i=0;i<m;i++){
			int sum =0;
			for(int j=i;j<m;j++)
			{
				sum+=w[j];
				a[1][sum-1]++;
			}
		}
		
		int ans=0;
		for(int i=0;i<1500000;i++)
		{
			ans += a[0][i]*a[1][i];
		}
		cout << ans << endl;	
	}
	return 0 ;
}

Measured memory_bytes: 12884
inputs = [s.strip() for s in open(0).readlines()]
import numpy as np
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, row in zip(range(h), grid):
            for j, val in zip(range(w), row):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, row)) for row in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

h, w = map(int, inputs[0].split())
grid = Grid(inputs[1:]).grid

dp = np.zeros((h, w), np.int)
if grid[0][0] == '#':
    dp[0, 0] = 1
for i in range(1, w):
    dp[0, i] = dp[0, i-1] + int(grid[0, i-1] + grid[0, i] == '.#')
for i in range(1, h):
    dp[i, 0] = dp[i-1, 0] + int(grid[i-1, 0] + grid[i, 0] == '.#')
x = y = 1
while not (x == w-1 and y == h-1):
    for i in range(x, w):
        dp[y, i] = min(dp[y, i-1] + int(grid[y, i-1] + grid[y, i] == '.#'),
                       dp[y-1, i] + int(grid[y-1, i] + grid[y, i] == '.#'))
    for i in range(y+1, h):
        dp[i, x] = min(dp[i-1, x] + int(grid[i-1, x] + grid[i, x] == '.#'),
                       dp[i, x-1] + int(grid[i, x-1] + grid[i, x] == '.#'))
    x, y = min(x+1, w-1), min(y+1, h-1)
print(min(dp[y-1, x] + int(grid[y-1, x] + grid[y, x] == '.#'), 
          dp[y, x-1] + int(grid[y, x-1] + grid[y, x] == '.#')))

Measured memory_bytes: 21052
i,a[10],b[10],h,g,c,x;main(n){for(scanf("%d",&n);n--;puts(x?"NO":"YES")){for(a[0]=b[0]=h=g=i=x=0;i++<10;){scanf("%d",&c);if(x)continue;if(a[h]<c||b[g]<c)if(a[h]<c&&(a[h]>b[g]||b[g]>=c))a[++h]=c;else b[++g]=c;else x=1;}}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> dp(N+1, true);
  int tmp;
  for (int i = 0; i < M; i++){
    cin >> tmp;
    dp[tmp] = false;
  }
  for (int i = 2; i <= N; i++){
    if (dp[i] == false)
      continue;
    dp[i] = dp[i-1] + dp[i-2];
    dp[i] %= 1000000007;
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 640
// C++ implementation of the above approach
#include <bits/stdc++.h>
using namespace std;
double p[3000];
double dp[3000][3000]={0.0};
// Driver Code
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i+=1)
        cin>>p[i];
    dp[0][0]=1.0;
    for(int i=1;i<=n;i+=1){
        for(int j=0;j<=i;j+=1){
            if(j==0)
                dp[i][j]=dp[i-1][j]*(1.0-p[i]);
            else
                dp[i][j]=dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i];
        }
    }
    double ans=0.0;
    for(int i=(n+1)/2;i<=n;i+=1)
        ans+=dp[n][i];
    cout<<setprecision(10)<<fixed<<ans<<endl;

    return 0;
}

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

// the base of 10^18 = 60

typedef long long ll;
const int maxn = 1e5 + 10;
ll k, a[maxn];
int n, m, data[maxn], pos[61][maxn];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a + i), data[i] = i;
  }
  scanf("%d %lld", &m, &k);
  for (int i = 1, x; i <= m; i++) {
    scanf("%d", &x);
    swap(data[x], data[x + 1]);
  }
  for (int i = 1; i <= n; i++) {
    pos[0][i] = data[i];
  }
  for (int i = 1; i < 61; i++) {
    for (int j = 1; j <= n; j++) {
      pos[i][j] = pos[i - 1][pos[i - 1][j]];
    }
  }
  for (int i = 1; i <= n; i++) {
    data[i] = i;
  }
  for (int p = 60; ~p; p--) {
    if (k >> p & 1) {
      for (int i = 1; i <= n; i++) {
        data[i] = pos[p][data[i]];
      }
    }
  }
  static int c[maxn];
  for (int i = 1; i <= n; i++) {
    c[i] = a[i] - a[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1] + c[data[i]];
    printf("%lld\n", a[i]);
  }
  return 0;
}

Measured memory_bytes: 26624
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
enum = enumerate
inf = 1001001002002002002

import random

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().rstrip().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def bye(res):
	sT = "No Yes".split()
	print(sT[res])
	#exit(0)

def sol(N,vA,S):
	sZ = set({0,})
	for a,c in zip(vA[::-1],S[::-1]):
		v = a
		for z in reversed(sorted(list(sZ))):
			v = min(v, v^z)
			#if not N: print(z,v)##
		if c=="0":
			sZ |= {v,}
		elif v not in sZ:
			sZ = set({})
			break
		#else:
		#	pass	# sZ = sZ
		#if not N: print(sZ)##
	
	res = 1
	if sZ:
		res = 0
	
	#print(sZ)###
	print(res)


def main():
	T, = linput()
	for _ in "*"*T:
		N, = linput()
		vA = linput()
		S, = linput(str)
		sol(N, vA, S)

def ran():
	N = 200
	#N=6
	vRan = [random.randint(1,10) for _ in "*"*N]
	S = "".join(str(random.randint(0,1)) for _ in "*"*N)
	#print(max(vRan))#
	#vRan = [5, 7, 7, 3, 1, 7]###
	#S = "111000"###
	print(vRan,S)
	sol(N=0, vA=vRan, S=S)
	exit(0)
	
if __name__ == "__main__":
	#ran()
	main()


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

int main() {
    long int x;
    long int n_time = 0;
    cin >> x;
    n_time = (x / 11) * 2;
    if (x % 11 == 0) n_time += 0;
    else if (x % 11 <= 6)
        n_time += 1;
    else
        n_time += 2;
    cout << n_time << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>

int main(void){
	int a,b;
	int i = 1;
	int outlet;
	scanf("%d %d",&a,&b);
	if(b == 1) {
	    puts("0");
	    return 0;
	}
	outlet = a;
	while(outlet < b){
		outlet += a - 1;
		i++;
	}
	printf("%d",i);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	
	private static final long MOD = 1000000000 + 7;
	
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int s = sc.nextInt();
			
			//数列長がnの時、最低限からの余剰(s - n*3)をnで0以上で分配する通り数を考える必要あり
			//n=2、余剰=50 ==> 51通り
			//n=3, 余剰=50 ==> A+B+C=50 A, B, C>=50
			//n=4, ... --> 50+n C n-1
			
			int maxLen = s / 3;
			long ans = 0;
			
			for(int i = 1 ; i <= maxLen ; i++ ) {
				int rest = s - i * 3;
				
				long comb = combination(rest + (i-1), i-1);
//				System.out.println(comb);
				
				ans = (ans + comb) % MOD;
				
			}
			
			System.out.println(ans);
		}
	}
	public static long combination(int a, int b) {
		
//		System.out.println(a + " C " + b);
		
		long comb = 1;
		for(int i = 0 ; i < b ; i++ ) {
			comb = comb * (long)(a-i) % MOD;
			comb = comb * calcModInv((long)(b-i)) % MOD;
		}
		
		return comb;
		
	}

	public static long calcModInv(long a) {
		long n = MOD - 2;
		long ans = 1;
		
		while(n > 0 ) {
			if ( (n & 1) == 0x1) {
				ans = ans * a % MOD;
			}
			a = a * a % MOD;
			n = n >> 1;
		}
		
		return ans;
	}
}

Measured memory_bytes: 35760
import sys
n = int(input())
lis = []
lis.append(input())
ans = 0
for i in range(n-1):
    word = input()
    if word in lis:
        ans += 1
    if word[0] != lis[-1][-1]:
        ans += 2
    lis.append(word)    
if ans == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if (c-a-b>0 && 4*a*b<(c-a-b)*(c-a-b)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

typedef struct{
  double x;
  double y;
} P;

void kock(int, P , P);

int main() {
  int n;
  P P1 = {0,0}, P2 = {100,0};

  scanf("%d",&n);
  printf("%.8f %.8f\n",P1.x,P1.y);
  kock(n, P1, P2);
  printf("%.8f %.8f\n",P2.x,P2.y);

  return 0;
}

void kock(int n, P p1, P p2)
{
  P s, t, u;

  if(n == 0) return;

  s.x = (double)(2 * p1.x + 1 * p2.x)/(double)3;
  s.y = (double)(2 * p1.y + 1 * p2.y)/(double)3;
  t.x = (double)(1 * p1.x + 2 * p2.x)/(double)3;
  t.y = (double)(1 * p1.y + 2 * p2.y)/(double)3;

  u.x = (t.x - s.x) * cos(M_PI/(double)3) - (t.y - s.y)
        * sin(M_PI/(double)3) + s.x;
  u.y = (t.x - s.x) * sin(M_PI/(double)3) + (t.y - s.y)
        * cos(M_PI/(double)3) + s.y;

  kock(n-1, p1, s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1, t, p2);

}


Measured memory_bytes: 1960
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
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; }
using Graph = vector<vector<int> >;
using P = pair<int, int>; 
// MOD
const int MOD = 1000000007;
using ll = long long;
long long INF = 1<<30;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
//int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int H, W;
int field[100][100];

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}

struct Unionfind{
    vector<int> par;

    Unionfind(int n) : par(n, -1){}

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    } 

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x]>par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    k = min(n, k);
    ll ans = 0;
    for(int i=0; i<n-k; i++){
        ans += h[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 1396
"use strict"

function main(input) {
  input = input.split(/\n/)
  let S = input[0].split("")
  const T = input[1].split("")
  const us = "UNRESTORABLE"
  if (S.length < T.length) {
    console.log(us)
    return
  } else {
    for (let i = S.length - T.length; i >= 0; i--) {
      //
      let x = 0
      for (let j = 0; j < T.length; j++) {
        //Tの区間の中で合致するかどうか
        if (S[i + j] == T[j] || S[i + j] == "?") {
          //この文字は合致、または?だからパス
        } else {
          //合致しない＞この区間は合致しない
          x++
          continue
        }
        //
      }
      if (x > 0) continue
      //continue されなかったので合致、Tで埋める
      // point = i
      //Tで埋める
      for (let k = 0; k < T.length; k++) {
        S[i + k] = T[k]
      }
      //残りの?をaに変換 todo : 正規表現などで
      // S = S.replace(/(.+)/, "a")
      for (let i = 0; i < S.length; i++) {
        S[i] = S[i] == "?" ? "a" : S[i]
      }

      console.log((S = S.join("")))
      return
    }
  }
  //
  console.log(us)
  //
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 21064
from itertools import combinations_with_replacement

N,M,Q = map(int, input().split())

l = [ 1 + i for i in range(M) ] 

C = [
  list(map(int, input().split())) for _ in range(Q)
]

ans = 0
for p in list(combinations_with_replacement(l, N)):
  temp = 0
  for c in C:
    #print(c, p)
    if p[c[1] - 1] - p[c[0] - 1] == c[2]:
      temp += c[3]
      
  ans = max(ans, temp)
  
print(ans)

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

int main(void) {
	int n,x;
	string marks;
	cin >> n;

	int s[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		 h[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		 c[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
		 d[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};

	for (int i = 0; i < n; i++)
	{
		cin >> marks >> x;

		if (marks == "S")
		{
			s[x] = x;
		}
		else if (marks == "H")
		{
			h[x] = x;
		}
		else if (marks == "C")
		{
			c[x] = x;
		}
		else if (marks == "D")
		{
			d[x] = x;
		}
	}

	for (int i = 1; i <= 13; i++)
	{
		if (s[i] == 0)
		{
			cout << "S " << i << endl;
		}
	}

	for (int i = 1; i <= 13; i++)
	{
		if (h[i] == 0)
		{
			cout << "H " << i << endl;
		}
	}

	for (int i = 1; i <= 13; i++)
	{
		if (c[i] == 0)
		{
			cout << "C " << i << endl;
		}
	}

	for (int i = 1; i <= 13; i++)
	{
		if (d[i] == 0)
		{
			cout << "D " << i << endl;
		}
	}



	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    rep(i,1,10) 
        rep(j,1,10) 
            cout << i << 'x' << j << '=' << i*j << '\n';
    return 0;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int a,b,w,x,y;
	cin >> w >> a >> b;
	x = a+w;
	y = b+w;
	if(x<b){
		cout << (b-x) << endl;
	}else if(y<a){
		cout << (a-y) << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main(int argc, char **argv)
{
    int N, M, X;
    std::cin >> N >> M >> X;

    std::vector<int> C(N);
    std::vector<std::vector<int>> A(N, std::vector<int>(M));
    std::vector<int> total(M, 0);

    for(int i = 0; i < N; i++){
        std::cin >> C.at(i);
        for(int j = 0; j < M; j++){
            int a;
            std::cin >> a;
            A.at(i).at(j) = a;
            total.at(j) += a;
        }
    }

    for(int i = 0; i < M; i++){
        if(total.at(i) < X){
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    int NN = std::pow(2, N);
    //std::cout << NN << std::endl;

    int min = 10000009;
    for(int i = 0; i < NN; i++){
        int pattern = i;
        int cost = 0;
        std::vector<int> B(M, 0);
        //printf("pattern: %03x\n", pattern);
        bool flag = false;
        for(int j = 0; j < N; j++){
            int id = 1<<j;
            if((pattern & id) != 0){ // buy Cj
                //printf(" [%d] ", j);
                cost += C.at(j);
                flag = true;
                for(int k = 0; k < M; k++){
                    B.at(k) += A.at(j).at(k);
                    if(B.at(k) < X){ // lack
                        flag = false;
                    }
                }
                if(flag) break;
            }else{
                //printf(" -%d- ", j);
            }
        }
        //printf("\n");
        if(flag)
            min = std::min(min, cost);
    }
    std::cout << min << std::endl;
    
    
}


Measured memory_bytes: 4044
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<vector>
#include<string>
using namespace std;
const int inf=0x3f3f3f3f;
typedef long long ll;
int a[105];
int main()
{
    for(int i=1; i<=105; i++)
        a[i]=a[i-1]+i;
    ll n;
    int ans=0;
    cin>>n;
    for(ll i=2; i*i<=n; i++)
    {
        if(n%i==0)
        {
            int cnt=0;
            while(n%i==0)
            {
                n/=i;
                cnt++;
            }
            int idx=1;
            for(int j=1; j<=105; j++)
                if(cnt>=a[j])
                    idx=j;
                else
                    break;
            ans+=idx;
        }
    }
    if(n!=1)
        ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int n;
int dp[1000000][3];
int a[100000],b[1000000],c[1000000];

signed main(){
  cin>>n;
  rep(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }

  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];

  FOR(i,1,n){
    dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b[i]+max(dp[i-1][2],dp[i-1][0]);
    dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
  }

  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 11264
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <random>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1ll<<50 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

ll DFS(vvll &g,vll &dp,int p){
	if(dp[p]!=-1) return dp[p] ;
	ll mx = 0 ;
	for(int i=0;i<g[p].size();i++){
		chmax(mx,DFS(g,dp,g[p][i])+1) ;
	}
	dp[p] = mx ;
	return dp[p] ;
}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vvll g(n) ;
	vll cnt(n,0) ;
	for(int i=0;i<m;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		g[a].push_back(b) ;
		cnt[b]++ ;
	}
	vll dp(n,-1) ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		if(cnt[i]==0){
			chmax(ans,DFS(g,dp,i)) ;
		}
	}
	cout << ans << endl ;
}


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

int main() {
	int Q;
	cin >> Q;
	vector<int> L(Q), R(Q);
	int MAX = 0;
	for (int i = 0; i < Q; i++) {
		cin >> L[i] >> R[i];
		MAX = max(MAX, R[i]);
	}
	vector<int> NotPrime(MAX + 1), Answers;
	if (MAX >= 3) Answers.push_back(3);
	for (int i = 3; i <= MAX; i += 2) {
		if (NotPrime[i] > 0) continue;
		else {
			if (NotPrime[i] == -1) Answers.push_back(i);
			if (i * 2 - 1 < MAX + 1 && NotPrime[i * 2 - 1] == 0) NotPrime[i * 2 - 1] = -1;
			int j = i * 3;
			while (j < MAX + 1) {
				NotPrime[j] = 1;
				j += 2 * i;
			}
		}
	}
	for (int i = 0; i < Q; i++)
		cout << distance(lower_bound(Answers.begin(), Answers.end(), L[i]),
			upper_bound(Answers.begin(), Answers.end(), R[i])) << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	cin >> n >> h;
	vector<ll> a(n);
	vector<ll> b(n);
	ll maxa = 0;
	ll res = 0;
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	rep(i, n) {
		chmax(maxa, a[i]);
	}
	rep(i, n) {
		if (maxa > b[i]) {
			b[i] = -1;
		}
	}
	sort(b.begin(), b.end(), greater<ll>());
	rep(i, n) {
		if (b[i] != -1) {
			h -= b[i];
			++res;
		}
		else {
			break;
		}
		if (h <= 0) {
			cout << res << endl;
			return 0;
		}
	}
	res += h / maxa;
	if (h % maxa != 0) {
		++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
#define EPS 10e-10
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > EPS)   return +1;
  if (cross(b, c) < -EPS)   return -1;
  if (dot(b, c) < -EPS)     return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}

double D(P a, P b) {
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

int main() {
  int m;
  while(cin >> m && m) {
    int n;
    cin >> n;
    double x,y;
    vector<P> a(n);
    rep(i,n) {
      cin >> x >> y;
      a[i]=P(x,y);
    }
    REP(t,1,m+1) {
      vector<P> b[2];
      int k;
      cin >> k;
      rep(j,k) {
	cin >> x >> y;
	b[0].pb(P(x,y));
      }
      rrep(j,k) b[1].pb(b[0][j]);
      if(n!=k) continue;
      bool ck1=true,ck2=true;
      rep(i,n-2) {
	if(ccw(a[i],a[i+1],a[i+2])!=ccw(b[0][i],b[0][i+1],b[0][i+2])) ck1=false;
	if(ccw(a[i],a[i+1],a[i+2])!=ccw(b[1][i],b[1][i+1],b[1][i+2])) ck2=false;
      }
      rep(i,n-1) {
	if(D(a[i],a[i+1])!=D(b[0][i],b[0][i+1])) ck1=false;
	if(D(a[i],a[i+1])!=D(b[1][i],b[1][i+1])) ck2=false;
      }
      if(ck1||ck2) pr(t);
    }
    pr("+++++");
  }
  return 0;
}


Measured memory_bytes: 1240
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        for (int i = 1; i <= 9; i++) {
            if (n % i == 0) {
                int x = n / i;
                if (x >= 1 && x <= 9) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int N;
    map<int,ll> m,mm;
    cin>>N;
    int *a = new int[N];
    rep(i,N){
        cin>>a[i];
        m[a[i]]++;
        mm[a[i]]++;
    } 
    ll ans = 0;
    rep(i,N){
        ans += (mm[a[i]]*(mm[a[i]]-1))/2;
        mm[a[i]] = 0;
    }
    rep(i,N){
        cout<< ans - (m[a[i]]-1) <<endl;
    }
    delete[] a;
    return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
  int input_num;
  int datas[200000];
  int now_data = 0;
  int diff_ans = 0;
  cin >> input_num;
  for (int i = 0; i < input_num; i++) {
    cin >> datas[i];
  }

  diff_ans = datas[1] - datas[0];
  now_data = datas[0];
  
  for (int i = 1; i < input_num; i++) {
    // cout << now_data<< " "<< datas[i] << "\n";
    if (now_data > datas[i]) {
      now_data = datas[i];
    }
    // cout <<"now_data" now_data<< << "\n";
    else if ((datas[i] - now_data) > diff_ans) {
      diff_ans = datas[i] - now_data;
    }
  }
  // cout << now_data << "\n";
  cout << diff_ans << "\n";
  
  return 0;
}




Measured memory_bytes: 3856
#include <iostream>
using namespace std;
typedef long long int ll;
int main(){
ll a,b,c;
ll x,cnt=0;
cin >> a>> b>> c;
x=1;ll sum;
while(1){
  sum=a*x;
  if(cnt==b) break;
  if(sum%b==c) {
    cout << "YES"<<endl;
    return 0;
  }
  x++;
  cnt++;
}
cout <<"NO"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	static int[][] board;
	static int w, h;
	static int sx, sy;
	static int inf = 1000000000;
	private static int dfs(int x, int y, int bx, int by, int count){// (x, y)?????????G?????§???????°??????¢?????????(???????????°inf)
		int[] res  = new int[4];
		if(count > 10) return inf;
		for(int i = 0; i < 4; i++) res[i] = inf;
		board[bx][by] = 0; // ??????????????????
		if(x > 0 && board[x-1][y] != 1){// x?????????
			for(int i = 1; x-i >= 0; i++){
				if(board[x-i][y] == 1){
					res[0] = dfs(x-i+1, y, x-i, y, count+1);
					break;
				}else if (board[x-i][y] == 3) {
					board[bx][by] = 1; // ????????????
					return 1;
				}
			}
			if(res[0] != inf) res[0]++;
		}
		if(y > 0 && board[x][y-1] != 1){// y?????????
			for(int i = 1; y-i >= 0; i++){
				if(board[x][y-i] == 1){
					res[1] = dfs(x, y-i+1, x, y-i, count+1);
					break;
				}else if (board[x][y-i] == 3) {
					board[bx][by] = 1; // ????????????
					return 1;
				}
			}
			if(res[1] != inf) res[1]++;
		}
		if(x+1 < w && board[x+1][y] != 1){// x??£??????
			for(int i = 1; x+i < w; i++){
				if(board[x+i][y] == 1){
					res[2] = dfs(x+i-1, y, x+i, y, count+1);
					break;
				}else if (board[x+i][y] == 3) {
					board[bx][by] = 1; // ????????????
					return 1;
				}
			}
			if(res[2] != inf) res[2]++;
		}
		if(y+1 < h && board[x][y+1] != 1){// y??£??????
			for(int i = 1; y+i < h; i++){
				if(board[x][y+i] == 1){
					res[3] = dfs(x, y+i-1, x, y+i, count+1);
					break;
				}else if (board[x][y+i] == 3) {
					board[bx][by] = 1; // ????????????
					return 1;
				}
			}
			if(res[3] != inf) res[3]++;
		}
		board[bx][by] = 1; // ????????????
		Arrays.sort(res);
		return res[0];
	}
	private static void solve(){
		int res = dfs(sx, sy, sx, sy, 0);
		if(res != inf && res <= 10) System.out.println(res);
		else System.out.println(-1);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0) break;
			board = new int[w][h];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					board[j][i] = sc.nextInt();
					if(board[j][i] == 2){
						sx = j;
						sy = i;
					}
				}
			}
			solve();
		}
	}
}

Measured memory_bytes: 67392
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

string Zaki;
string O;
ll M,L;
ll N;

ll mod_pow(ll x,ll n){
    ll res=1;
    x%=MOD;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n/=2;
    }
    return res;
}

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

  M=Zaki.size();
  L=O.size();

  string RevO=O;
  reverse(RevO.begin(),RevO.end());

  string S="",T="";
  if(L>N){
      string Hoge="";
      for(int i=0;i<N;i++) Hoge+=RevO[i];
      S+=Hoge;
      S+=Zaki;
      S+=Hoge;
      S+=O;

      T=S;
      reverse(T.begin(),T.end());
      for(int i=0;i<S.size();i++){
          if(S[i]==T[i]);
          else{
              cout<<0<<endl;
              return 0;
          }
      }
      cout<<1<<endl;
      return 0;
  }else{
      S+=RevO;
      S+=Zaki;
      S+=RevO;
      S+=O;

      T=S;
      reverse(T.begin(),T.end());
      for(int i=0;i<S.size();i++){
          if(S[i]==T[i]);
          else{
              cout<<0<<endl;
              return 0;
          }
      }

      ll ans=mod_pow(26,(N-L)/2);
      if((N-L)%2) ans=ans*26%MOD;
      cout<<ans<<endl;
  }

  return 0;
}



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

int main(void)
{
	int n, i, r;
	char t[256];
	char h[256];
	int tp = 0, hp = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", t, h);
		r = strcmp(t, h);
		if (r == 0)
		{
			tp++;
			hp++;
	    } else if (r > 0) {
			tp += 3;
	    } else {
			hp += 3;
	    }
	}
	printf("%d %d\n", tp, hp);

	return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    while (b <= a){
        if (k == 0){
            ctn("No");
            return 0;
        }
        b*=2;
        k--;
    }
    while (c <= b){
        if (k == 0){
            ctn("No");
            return 0;
        }
        c*=2;
        k--;
    }
    if (b > a && c > a && c > b){
        ctn("Yes");
        return 0;
    }
    ctn("No");

    
    return 0;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int r;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> r;
    cout << 3.1415926 * (r + r) << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

const int mod = 1000000007;
typedef long long ll;
struct mint
{
    ll x; //
    mint(ll 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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
combination comb(3000);

mint H(int n, int r)
{
    return comb(n + r - 1, r);
}

int main()
{
    int N, K;
    cin >> N >> K;
    rep(i, K)
    {
        int m = i + 1;
        mint a = H(m, K - m), b = H(m + 1, N - K - i);
        mint ans = a * b;
        // cout << a << ", " << b << endl;
        cout << ans << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))

constexpr ll MOD = 1e9+7;
// constexpr int INF = 1<<25;
constexpr ll  INF = 1LL<<50;

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T checkmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T checkmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

// Forward declaration
template <typename T>
void dumpContents(const T& v, const string& msg="");

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
constexpr int CITIIES=5;
vll C(CITIIES);
ll N;


// C-indexに全員着いたのが時刻t
ll calc(int index, ll t0, ll& min_capacity) {
  // city index -> index+1
  if (min_capacity <= C[index]) {
    return t0+1;
  }

  min_capacity = C[index];
  // 時刻tが終ったときまでにindexから輸送した人数
  ll x = (t0-index)*min_capacity;
  ll y = N - x; // y人残っている

  ll t = y/min_capacity + (y%min_capacity ? 1 : 0);
  return t0 + t;
}

int main(int argc, char** argv) {
  cin >> N;

  for (int i=0; i<CITIIES; i++) {
    cin >> C[i];
  }

  ll t = 0;
  ll capa = INF;
  // C0 -> C1
  t = calc(0, t, capa);
  //cerr << "1: " << t << endl;
  t = calc(1, t, capa);
  //cerr << "2: " << t << endl;
  t = calc(2, t, capa);
  //cerr << "3: " << t << endl;
  t = calc(3, t, capa);
  //cerr << "4: " << t << endl;
  t = calc(4, t, capa);

  cout << t << endl;

  return 0;
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

int N;
int	x[200000];
int	y[200000];

signed main(){
	cin >> N;
	REP(i, 0, N) {
	    scanf("%d", &x[i]);
	    y[i] = x[i];
	}
	
	sort(x, x + N);
	
	int p1 = N / 2 - 1;
	int p2;
	REP(i, 0, N) {
	   // p2 = lower_bound(x.begin(), x.end(), y[i]) - x.begin();
	    p2 = lower_bound(x, x + N, y[i]) - x;

		if(p2 <= p1)	cout << x[p1 + 1] << endl;
		else	    	cout << x[p1] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3712