akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        h: usize, w: usize,
        ch: Usize1, cw: Usize1,
        dh: Usize1, dw: Usize1,
        s: [Chars; h]
    }

    let mut visited = vec![vec![false; w]; h];
    let mut que = VecDeque::new();
    que.push_back((cw, ch, 0));
    while let Some((x, y, count)) = que.pop_back() {
        if x == dw && y == dh {
            println!("{}", count);
            return;
        }
        if visited[y][x] {
            continue;
        }
        visited[y][x] = true;
        let d = [(1, 0), (-1, 0), (0, 1), (0, -1)];
        for &(dx, dy) in &d {
            let x2 = clamp(x as isize + dx, 0, w as isize - 1) as usize;
            let y2 = clamp(y as isize + dy, 0, h as isize - 1) as usize;
            if s[y2][x2] == '.' && !visited[y2][x2] {
                que.push_back((x2, y2, count));
            }
        }
        for dy in -2..=2 {
            for dx in -2..=2 {
                let x2 = clamp(x as isize + dx, 0, w as isize - 1) as usize;
                let y2 = clamp(y as isize + dy, 0, h as isize - 1) as usize;
                if s[y2][x2] == '.' && !visited[y2][x2] {
                    que.push_front((x2, y2, count + 1));
                }
            }
        }

    }
    println!("-1");
}


Measured memory_bytes: 11008
<?php
  
$n = trim(fgets(STDIN));
$k = trim(fgets(STDIN));

$ans = '1'; 
for($i=0; $i<min((strlen($n)), $k); $i++){
  if ($n[$i] !== '1'){
    $ans = $n[$i];
    break;
  }
}

echo $ans;

  
?>

Measured memory_bytes: 4604
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納　par[x] == x の時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0)
        self.rank = [0] * (n+1)
        # 各々の集合の要素数（根が代表して値を持っておく）
        self.count = [1] * (n+1)

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        root = x
        queue = [x]
        data = []
        while queue:
            now = queue.pop()
            if self.par[now] == now:
                root = now
            else:
                # 根でないなら親の要素で再検索
                data.append(now)
                queue.append(self.par[now])
        # 検索する過程で親を更新
        for y in data:
            self.par[y] = root
        return root

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        t = (x == y)
        if UnionFind.same_check(self,x,y):
            return t
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return t


    # 同じ集合に属しているか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def size(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]

n,m,k = map(int,input().split())
u = UnionFind(n)
ans = [-1 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ans[a] -= 1
    ans[b] -= 1
    u.union(a,b)
#print(*ans)
for i in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    if u.same_check(c,d):
        ans[c] -= 1
        ans[d] -= 1

print(*[u.size(i)+x for i,x in enumerate(ans)])

Measured memory_bytes: 77344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = -100; i <= 100; i++) {
			int temp = 0;
			for (int j = 0; j < N; j++) {
				temp += (a[j] - i) * (a[j] - i);
			}
			if (min > temp) {
				min = temp;
			}
		}
		System.out.println(min);
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

const int MAX=5000000;

int fac[MAX],finv[MAX],inv[MAX];
 
void t(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  repi(i,2,MAX){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
 
int calc(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;
}


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

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int k;
  string s;
  cin>>k>>s;
  int num=s.size();
  int ans=0;
  int now=1;
  rep(i,k){
    now*=25;
    now%=MOD;
  }
  t();
  rep(i,k+1){
   
    if(i!=0){
      now = now * modinv(25,MOD) % MOD;
      now*=26;
      now%=MOD;
    }
    // cout<<now<<" "<<ans<<endl;
    int kosuu=num-1+(k-i);
    int pl=now*calc(kosuu,k-i)%MOD;
    ans+=pl;
    ans%=MOD;
  }
  
  cout<<ans<<endl;
  
  


  return 0;
}


Measured memory_bytes: 121404
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    x = [0] * (n + 2)
    for i in range(m):
        l, r = list(map(int, input().rstrip('\n').split()))
        x[l] += 1
        x[r+1] -= 1
    t = 0
    cnt = 0
    for i in range(n + 2):
        t += x[i]
        if t == m:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 4080
n = int(input())
a = list(map(int, input().split()))


if n%2 == 0:
    for i in range(n-1,-1,-2):
        print(a[i], end=' ')
    for i in range(0, n, 2):
        print(a[i], end=' ')
    
elif n%2 == 1:
    for i in range(n-1,-1,-2):
        print(a[i], end=' ')
    for i in range(1, n, 2):
        print(a[i], end=' ')
    


Measured memory_bytes: 94036
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   if (s == "BBB" || s == "AAA")
      cout << "No" << endl;
   else
      cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 3e5 + 10;
#endif
using namespace std;
int fac[maxn], inv[maxn], N, M;
inline int exgcd(int a, int b, int& x, int& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    int d = exgcd(b, a % b, x, y), tmp = x;
    x = y;
    y = tmp - a / b * y;
    return d;
}
inline int Inv(int a, int b)
{
    int d, x, y;
    d = exgcd(a, b, x, y);
    return (x + b) % b;
}
void init()
{
    fac[0] = 1;
    for (ri i = 1; i < maxn; ++i) {
        fac[i] = fac[i - 1] * i % MOD;
    }
    for (ri i = 0; i < maxn; ++i) {
        inv[i] = Inv(fac[i], MOD);
    }
}
inline int cnm(int n, int m)
{
    if (n < m)
        return 0;
    return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin >> N >> M;
    init();
    vector<int> p;
    for (ri i = 2; i * i <= M; ++i) {
        if (M % i == 0) {
            int cnt = 0;
            while (M % i == 0) {
                ++cnt;
                M /= i;
            }
            p.push_back(cnt);
        }
    }
    if (M != 1)
        p.push_back(1);
    int ans = 1;
    for (auto e : p) {
        ans *= cnm(N + e - 1, N - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
from collections import Counter
n = int(input())
count=0
res = 0
for _ in range(n):
  a = int(input())
  if res < a:
    tmp = (a-res)%2
    count += res+(a-tmp-res)//2
    res = tmp
  else:
    count += a
    res = 0
    
print(count)

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

#define MAX 100

int main() {
	int n;
	int A[MAX];
	cin >> n;
	bool flag = 1;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) {
			if ((A[i] % 3 != 0) && (A[i] % 5 != 0)) {
				flag = 0;
				break;	
			}
		}
	}
	if (flag) {
		cout << "APPROVED" << endl;
	} else {
		cout << "DENIED" << endl;
	}
	return 0;
	
}

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

Measured memory_bytes: 3060
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

int main(){
  int n;
  while (cin >> n, n){
    map<int, int> s;
    int res = -1;
    rep(i, n){
      int x;
      cin >> x;
      if (++s[x] > n / 2) res = x;
    }
    cout << (res == -1 ? "NO COLOR" : to_string(res)) << endl;
  }
}

Measured memory_bytes: 4820
# -*- coding: utf-8 -*-
from collections import  deque
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
 
adj = [[] for _ in range(N+1)]  
 
for _ in range(M):
    l, r, d = inpl()
    adj[l].append([r, d])
    adj[r].append([l, -d])
 
X = [-1 for _ in range(N+1)]
searched = [False for _ in range(N+1)]
S = 0 # == sum(searched)
res = True
g = 1
Q = deque([])
for g in range(1, N+1):
    if searched[g]:
        continue
    X[g] = 0
    Q.append(g)
    searched[g] = True
    while Q:
        p = Q.popleft()
        for np, d in adj[p]:
            if searched[np]:
                if X[np] != X[p] + d:
                    Q = []
                    res = False
                    break
            else:
                X[np] = X[p] + d
                Q.append(np)
                searched[np] = True
    if not res:
        break
 
if res:
    print("Yes")
else:
    print("No")

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

using namespace std;

const int mod = 1e9 + 7;

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;


    if(abs(c - a) <= d || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=32;
vector<int>v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main(){;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	cout<<v[n-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, d, x, dp[MAX], p[15][15];

int solve(int i){
    fill(dp+1, dp+x+1, -1);
    dp[0] = 0;
    rep(t, x+1)if(dp[t] >= 0){
        rep(j, n)if(p[i+1][j] > p[i][j]){
            if(t+p[i][j] <= x) chmax(dp[t+p[i][j]], dp[t] + p[i+1][j]-p[i][j]);
        }
    }
    return *max_element(dp, dp+x+1);
}

int main(){
    scanf("%d%d%d", &n, &d, &x);
    rep(i, d)rep(j, n) scanf("%d", &p[i][j]);
    rep(i, d-1){
        x += solve(i);
    }
    printf("%d\n", x);
}


Measured memory_bytes: 3312
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> pl;
const ll INF=1000000000+7;
const double PI=3.141592653589;

vector<vector<ll>> comb(int n, int r) {
    vector<vector<ll>> v(n+1,vector<ll>(n+1,0));
    for(int i=0; i<v.size();i++) {
      v[i][0]=1;
      v[i][i]=1;
    }
    for (int j=1;j<v.size();j++) {
      for (int k=1;k<j;k++) {
        v[j][k]=(v[j-1][k-1]+v[j-1][k])%INF;
      }
    }
    return v;
}

int main(){
  int n,k; cin>>n>>k;

  auto comb1=comb(n,n-k+1);
  auto comb2=comb(n,k-1);
  rep(i,k){
    ll c11=comb1[n-k+1][i+1]%INF;
    ll c22=comb2[k-1][i]%INF;
    // cout<<"cc "<<cc<<endl;
    ll ans=(c11*c22)%INF;
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 62976
#include <stdio.h>

#define N 101
  
int main(){
  int n, m;
  int i, j, k, l;
  int G[N][N];

  scanf("%d", &n);
  for(i = 0; i <= n; i++){
    for(j = 0; j <= n; j++){
      G[i][j] = 0;
    }
  } 

  for(i = 0; i < n; i++){
    scanf("%d%d", &m, &k);    
    for(j = 0; j < k; j++){
      scanf("%d", &l);
      G[m][l] = 1;      
    }
  }

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      if(j==n){
        if(G[i][j] != 0){
          printf("1");
        } else printf("0");
        break;    
      }

      if(G[i][j] != 0){
        printf("1 ");
      } else printf("0 ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 624
N = int(input())
n = [int(i) for i in input().split()]
min = max = total = n[0]
for i in range(1, N):
    if max < n[i]: max = n[i]
    if min > n[i]: min = n[i]
    total += n[i]
print('{} {} {}'.format(min, max, total))


Measured memory_bytes: 6604
def f x,a,b,hps
  dif = a-b
  res = 0
  hps.each{|h|
    z = h-b*x
    z = 0 if z<0
    res += (z+dif-1)/dif
  }
  res <= x
end

n,a,b = gets.split.map &:to_i
hps = n.times.map{gets.to_i}

p (0..10**9).bsearch{|x| f(x,a,b,hps)}


Measured memory_bytes: 2996
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}


fn main() {
    let hn : Vec<usize> = get_vec();
    let h = hn[0];
    let n = hn[1];
    let mut v = Vec::new();
    for i in 0..n {
        let ab : Vec<i32> = get_vec();
        v.push((ab[0],ab[1]));
    }
    let mut dp : Vec<Vec<i32>> = vec!(vec!(0;h+1);n);
    for i in 1..h+1 {
        dp[0][i] = (((i as i32)+v[0].0-1) / v[0].0) * v[0].1;
    }

    for i in 1..n {
        for j in 1..h+1 {
            if (v[i].0 as usize) <= j {
                dp[i][j] = std::cmp::min(dp[i-1][j], dp[i][j-(v[i].0 as usize)] + v[i].1);
            }
            else {
                dp[i][j] = std::cmp::min(dp[i-1][j], v[i].1);
            }
        }
    }
    println!("{}", dp[n-1][h]);
}


Measured memory_bytes: 49404
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second

          int const N = 401;
          long long a[N];
          long long dp[N][N];
          long long const inf = 1e15;
          long long fun(int i,int j)
          {
               if(i == j)
                    return 0;
               else if(j == i+1)
                    return a[j] - a[i-1];
               else if(dp[i][j] != -1)
                    return dp[i][j];
               else
               {
                    dp[i][j] = inf;
                    for(int l = i; l <= j-1; l++)
                         dp[i][j] = min(dp[i][j], fun(i,l) + fun(l+1,j) + a[j] - a[i-1]);
                    // cout << i << " " << j << " " << dp[i][j] << endl;
                    return dp[i][j];

               }
          }
          int main()
          {
          // clock_t begin = clock();
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt", "r", stdin);
          // freopen("output.txt", "w", stdout);
          // #endif
          tani_nachi_ke  

          int n;
          cin >> n;
          for(int i = 1; i <= n; i++)
          {
               cin >> a[i];
               a[i] += a[i-1];
          }
          memset(dp,-1,sizeof(dp));
          cout << fun(1,n) << endl;         




          // #ifndef ONLINE_JUDGE 
          // clock_t end = clock();
          // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
          // #endif 
          // return 0;
          }

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys
# from collections import Counter

def solve(s: str):
    alpha_list = set(s)

    answer = 10**9
    for alpha in alpha_list: #全部をalphaにする
        S = s
        count = 0
        while len(set(S)) > 1:
            new_S = ""
            
            for i in range(len(S)-1):
                if S[i] == alpha or S[i+1] == alpha:
                    new_S += alpha
                else:
                    new_S += "@"
            S = new_S
            count += 1
        answer = min(answer,count)

    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
hw=list(map(int,input().split()))
s=[]
for i in range(hw[0]):
    s.append(input())
ans="Yes"
for i in range(hw[0]):
    if ans=="Yes":
        for j in range(hw[1]):
            if s[i][j]=="#":
                flag=0
                if i!=0 and s[i-1][j]=="#":
                    flag=1
                if flag==0 and i!=hw[0]-1 and s[i+1][j]=="#":
                    flag=1
                if flag==0 and j!=0 and s[i][j-1]=="#":
                    flag=1
                if flag==0 and j!=hw[1]-1 and s[i][j+1]=="#":
                    flag=1
                if flag==0:
                    ans="No"
                    break
    else:
        break
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n,k;
	string s;
	cin >> n >> k;
	cin >>s;
	for (int i =0;i<n;i++) {
		if (i == k-1) {
			s[i] = s[i] - ('A'-'a');
		}
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
private fun readAtOnce(): List<String> = readLine()!!.split(" ")
private fun readInts(): List<Int> = readAtOnce().map(String::toInt)
private fun readLongs(): List<Long> = readAtOnce().map(String::toLong)
private fun zeroArray(size: Int): IntArray = IntArray(size) { 0 }
private fun Int.repeat(predicate: (Int) -> Unit) = repeat(this, predicate)

fun main(array: Array<out String>) {
    val (N, M) = readInts()
    val s = zeroArray(M)
    val c = zeroArray(M)
    M.repeat {
        val (_s, _c) = readInts()
        s[it] = _s
        c[it] = _c
    }

    println(
            (0 until 1000)
                    .filter { it.toString().length == N }
                    .filter {
                        val text = "${it}XXXXXX"
                        (0 until M).all { m -> text[s[m] - 1].toString() == c[m].toString() }
                    }.min() ?: -1
    )
}

Measured memory_bytes: 37600
N = int(input())
a = list(map(int, input().split()))
ain2 = [0]*N
for i in range(N):
    k = a[i]
    count = 0
    while(k % 2 == 0):
        k = k / 2
        count += 1
    ain2[i] = count
print(sum(ain2))


Measured memory_bytes: 4148
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, ans[500 * 500 + 10], p, cnt;
vector<pair<int, int>>v;
bool b[510];
signed main() {
	cin >> n;
	for1(i, n) {
		cin >> p;
		ans[p] = i;
		v.push_back(make_pair(p, i));
	}
	p = 1;
	for1(i, n * n) {
		if (ans[i] == 0)cnt++;
		else {
			int u = ans[i] - 1;
			if (cnt < u) {
				cout << "No\n";
				return 0;
			}
			else {
				cnt -= u;
				for (int j = 0; j < u; j++) {
					if (ans[p] == 0) {
						ans[p] = ans[i];
					}
					else j--;
					p++;
				}
			}
		}
	}
	p = n * n; cnt = 0;
	for (int i = n * n; i >= 1; i--) {
		if (ans[i] == 0)cnt++;
		else if (!b[ans[i]]) {
			b[ans[i]] = 1;
			int u = n - ans[i];
			if (cnt < u) {
				cout << "No\n";
				return 0;
			}
			else {
				cnt -= u;
				for (int j = 0; j < u; j++) {
					if (ans[p] == 0) {
						ans[p] = ans[i];
					}
					else j--;
					p--;
				}
			}
		}
	}
	cout << "Yes\n";
	for1(i, n * n) { if (i > 1)printf(" "); cout << ans[i]; }printf("\n");
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define MAX 1000000
bool sosu[MAX];
int main(){
	string s;
	getline(cin,s);
	if(s.size()<5){cout<<s<<endl;return 0;}
	
	rep(i,s.size()-4){
		string tmp=s.substr(i,5);
		if(tmp=="apple")s.replace(i,5,"peach");
		else if(tmp=="peach")s.replace(i,5,"apple");
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,dp[200004][3],a[2000004],k[4];
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    
    for(int i=1; i<=n; i++){
        ll a,b,c;
        cin >> k[0] >> k[1] >> k[2];
        for(int j=0; j<3; j++)
            for(int l=0; l<3; l++)
                if(j != l)
                    dp[i][j] = max(dp[i][j] , dp[i - 1][l] + k[j]);
    }
    
    cout << max(dp[n][0] , max(dp[n][2] , dp[n][1]));
    
    return 0;
}


Measured memory_bytes: 4352
N = int(input())
ss = 0
sl = 0
ssl = 0
cou = 0
for i in range(N):
    s = input()
    cou += s.count("AB")
    if s[0] == "B" and s[-1] != "A":
        ss += 1
    if s[-1] == "A" and s[0] != "B":
        sl += 1
    if s[0] == "B" and s[-1] == "A":
        ssl += 1
if ssl == 0 and ss == 0 and sl == 0:
    print(cou)
elif ssl != 0 and ss == 0 and sl == 0:
    print(cou + ssl -1)
elif ssl != 0 and ss != 0 and sl == 0:
    print(cou + ssl)
elif ssl != 0 and ss == 0 and sl != 0:
    print(cou + ssl)
else:
    print(cou + ssl + 1 + min(ss - 1, sl - 1))

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;


int n,k;
const int max_n = 5005;
int a[max_n];

// a[x]が必要なカードならtrue、不必要ならfalseを返す
bool cond(int x){
	if(a[x] >= k) return true;

	// dp[a][b] : a-1番目(0-index)までのカードで総和dができるか。ただしカードxは使わない。
	bool dp[n+1][k+1];
	rep(i,n+1) rep(j,k+1) dp[i][j] = false;
	dp[0][0] = true;

	rep(i,n){
		rep(j,k+1){
			if(i == x){
				dp[i+1][j] = dp[i][j] || dp[i+1][j];
			} 
			else{
				if(j-a[i] < 0) dp[i+1][j] = dp[i][j] || dp[i+1][j];
				else dp[i+1][j] = dp[i][j] || dp[i][j-a[i]] || dp[i+1][j];
			}	
 		}
	}

	FOR(i,k-a[x],k){
		if(dp[n][i]) return true;
	}
	return false;
}

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

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

	sort(a,a+n);

	int lb = -1, ub = n;

	while(ub - lb > 1){
		int mid = (lb + ub) / 2;

		if(cond(mid)) ub = mid; // Answer is in (lb, mid]
		else lb = mid;            // Answer is in (mid, ub]
	}

	cout << ub << endl;
}

Measured memory_bytes: 24704
import sys

N=int(input())
s=list(input().strip())

#print(s)

k=0
i,j=0,N-1
while i<j:
    if s[i]=='R':
        i+=1
    elif s[j]=='W':
        j-=1
    else:
        s[i]='W'
        s[j]='R'
        k+=1
        i+=1
        j-=1

print(k)


Measured memory_bytes: 10632
N = int(input())
hat = list(map(int, input().split()))
hat.sort()
min, max = hat[0], hat[N - 1]
count_min = 0
count_max = N
if max - min > 1:
    print("No")
elif max == min:
    if max <= N // 2 or max == N-1:
        print("Yes")
    else:
        print("No")
else:
    for i in range(N):
        if hat[i] < max:
            count_min += 1
            count_max -= 1
        else:
            break
    # 種類はcount_min+1 <= max <= count_min + count_max // 2
    if count_min < max <= count_min + count_max // 2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 52676
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second>b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    int n;
    IN n;
    vll a(n);
    map<ll,ll> m;
    loop(i,0,n)
    {
        IN a[i];
        m[i+1-a[i]]++;
    }
    ll ans=0;
    loop(i,0,n)
    {
        ans+=m[a[i]+i+1];
    }
    OUT ans<<endl
    return 0;
}

Measured memory_bytes: 27332
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        a = in.nextInt();
        b = in.nextInt();
        c = in.nextInt();
        l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = in.nextInt();
        }
        System.out.println(backtrack(0, 0, 0, 0));
    }

    static int a;
    static int b;
    static int c;
    static int[] l;

    private static int backtrack(int currA, int currB, int currC, int i) {
        if (i == l.length) {
            if (currA == 0 || currB == 0 || currC == 0) {
                return Integer.MAX_VALUE - 80;
            }
            return Math.abs(a - currA) + Math.abs(b - currB) + Math.abs(c - currC) - 30;
        }
        int nothing = backtrack(currA, currB, currC, i + 1);
        int addToA = backtrack(currA + l[i], currB, currC, i + 1) + 10;
        int addToB = backtrack(currA, currB + l[i], currC, i + 1) + 10;
        int addToC = backtrack(currA, currB, currC + l[i], i + 1) + 10;
        return Math.min(nothing, Math.min(addToA, Math.min(addToB, addToC)));

    }
}


Measured memory_bytes: 24240
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int a, b;
	cin >> a >> b;
	cout << max({ a + b, a - b, a*b }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long c,a,b,k,i,sum=0;
  cin>>a>>b>>c>>k;
    sum+=min(a,k);
    k=k-min(a,k);
    if(k>0){
     sum+=min(b,k)*0;
     k=k-min(b,k);
    }
    if(k>0){
     sum+=min(c,k)*(-1);
     k=k-min(c,k);
    }
    cout<<sum;
    return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
   ll n,m;
   cin >> n >> m;
   if(n%3 == 0 || m%3 == 0 || (n+m)%3 == 0)
   cout << "Possible" << endl;
   else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    vector<int> x(3);
    REP(i, 3) cin >> x[i];

    sort(ALL(x), greater<>());

    cout << x[0] * 10 + x[1] + x[2] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
char b[6];
int main(){
	int a=0;
	for(int t=0;t<6;t++){
		cin>>b[t];
	}
		if(b[0]==b[3]){
			a++;
		}
		if(b[1]==b[4]){
			a++;
		}
		if(b[2]==b[5]){
			a++;
		}
		cout<<a<<endl;
	}


Measured memory_bytes: 256
n=int(input())
field=[[0 for i in range(20)]for j in range(15)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
for y in range(15):
    for x in range(20):
        if(y%4==3):field[y][x]='#'
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
    print()



Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define MAXN 100007
using namespace std;
long long a[MAXN],m[MAXN];
int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<=n;i++) scanf("%d",&a[i]);
	if(n==0)
	{
		if(a[0]==1) cout<<1;
		else cout<<-1;
		return 0;
	}
	long long rez=a[0]+a[n]; bool fas=false;
	m[0]=1-a[0];
	if(m[0]<=0) fas=true;
	for(int i=1;i<n;i++)
	{
		m[i]=2*m[i-1]-a[i];
		if(m[i]<=0) fas=true;
		if(m[i]>1000000000000000000LL) m[i]=1000000000000000000LL;
		rez+=a[i];
	}
	long long dt=a[n];
	for(int i=n-1;i>=0;i--)
	{
		if(dt>2*m[i]) fas=true;
		if(dt>m[i]) dt=m[i];
		rez+=dt;
		dt+=a[i];
	}
	if(fas) printf("-1");
	else printf("%lld",rez);
}

Measured memory_bytes: 5376
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);
 

void solve(){
    
	int n; cin>>n;
	string s; cin>>s;
	int i = 0, j = n-1;
	int cnt = 0;
	while(i<n and j>=0 and i<j){
		while(i<n and s[i]=='R') i++;
		while(j>=0 and s[j]=='W') j--;
		if(i<j and i<n and j>=0){
			swap(s[i],s[j]);
			cnt++;
		}
	}
	cout<<cnt;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

//最大公約数
ll GCD(ll a, ll b)
{
    if (a == b || b == 0) {
        return a;
    } else if (a < b) {
        return GCD(b, a);
    } else {
        return GCD(b, a % b);
    }
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return a * b / GCD(a, b);
}

vector<ll> primenum;
void get_prime_nembers(ll n)
{
    ll m = n;
    FOR(i,2,m+1) {
        bool flag = true;
        REPALL(j,primenum) {
            if (i % primenum[j] == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            primenum.push_back(i);
            while (m % i == 0) {
                m /= i;
            }
        }
        if (i > sqrt(n)+1) {
            primenum.push_back(m);
            break;
        }
    }
}

vector<pair<int, int>> prime_factorization(ll n)
{
    if (primenum.empty())
        get_prime_nembers(n);

    vector<pair<int, int>> rtn;
    REPALL(i,primenum) {
        int num = 0;
        ll tmpn = n;
        while(tmpn % primenum[i] == 0) {
            num++;
            tmpn /= primenum[i];
        }
        if (num > 0)
            rtn.push_back(make_pair(primenum[i],num));
    }
    return rtn;
}

ll mypow(ll a, ll b)
{
    ll r = 1ll;
    while(b != 0){
        if(b&1) r = r * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return r;
}

vector<ll> fac;
vector<ll> ifac;

void factorial_init(ll n)
{
    fac.resize(n+1);
    ifac.resize(n+1);
    fac[0] = 1;
    ifac[0] = 1;
    REP(i,n) {
        fac[i+1] = fac[i] * (i + 1) % MOD;
        ifac[i+1] = ifac[i] * mypow(i + 1, MOD - 2) % MOD;
    }
}

ll Combination(ll a, ll b)
{
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    ll r = ifac[a-b] * ifac[b] % MOD;
    return r * fac[a] % MOD;
}

ll a, b, n;

int main()
{
    cin>>a>>b;
    n = GCD(a,b);
    //cout<<n<<endl;
    int ans = 1;
    for (ll i = 2ll; i * i <= n; i++) {
        //cout<<n<<endl;
        if (n % i == 0) {
            ans++;
            while (n % i == 0) {
                n /= i;
            }
        }
    }
    if (n != 1)
        ans++;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
struct SA
{
	static const int N = 200000;
	int a[N], lcp[N];
	void build(const string &s)
	{
		build(s.c_str(), s.size());
	}
	void build(const char *t, int n)
	{
		static int g[N], b[N];
		for(int i = 0; i < n + 1; i++)
		{
			a[i] = i;
			g[i] = t[i];
		}
		b[0] = b[n] = 0;
		sort(a, a + n + 1, SAComp(0, g));
		for(int h = 1; b[n] != n; h *= 2)
		{
			SAComp comp(h, g);
			sort(a, a + n + 1, comp);
			for(int i = 0; i < n; i++)
			b[i + 1] = b[i] + comp(a[i], a[i + 1]);
			for(int i = 0; i < n + 1; i++)
			g[a[i]] = b[i];
		}
		for(int i = 0; i < n + 1; i++)
		b[a[i]] = i;
		int h = 0;
		for(int i = 0; i < n; i++)
		{
			const int j = a[b[i] - 1];
			while(j + h < n && i + h < n && t[j + h] == t[i + h])
			h++;
			lcp[b[i]] = h;
			if(h) h--;
		}
		lcp[0] = -1;
	}
	struct SAComp
	{
		const int h, *g;
		SAComp(int h, int *g): h(h), g(g) {}
		bool operator()(int l, int r)
		{
			return g[l] != g[r] ? g[l] < g[r] : g[l + h] < g[r + h];
		}
	};
} sa;
struct Manacher
{
	static const int N = 200000 * 2;
	int rad[N];
	void build(const string &s)
	{
		build(s.c_str(), s.size());
	}
	void build(const char *t, int n)
	{
		int k;
		for(int i = 0, j = 0; i < 2 * n; i += k, j = max(j - k, 0))
		{
			while(i - j >= 0 && i + j + 1 < 2 * n && t[(i - j) / 2] == t[(i + j + 1) / 2])
			j++;
			rad[i] = j;
			for(k = 1; i - k >= 0 && rad[i] - k >= 0 && rad[i - k] != rad[i] - k; k++)
			rad[i + k] = min(rad[i - k], rad[i] - k);
		}
	}
} mana;
struct BIT
{
	static const int N = 80000;
	LL x[N];
	void init()
	{
		memset(x, 0, sizeof(x));
	}
	void add(int k, LL a)
	{
		for(; k < N; k |= k + 1)
		x[k] += a;
	}
	LL sum(int k)
	{
		LL s = 0;
		for(; k >= 0; k = (k & (k + 1)) - 1)
		s += x[k];
		return s;
	}
	LL rsum(int i, int j)
	{
		return i == 0 ? sum(j) : sum(j) - sum(i - 1);
	}
	LL esum(int i)
	{
		return rsum(i, N - 1);
	}
} sum[2], cnt[2];
int of[200000];
int main()
{
	string S, T;
	cin >> S >> T;
	const string F(S + '$' + T);
	sa.build(F);
	mana.build(F);
	for(int i = 0; i < F.size() + 1; i++)
	of[i] = sa.a[i] > (int)S.size();
	LL ans = 0;
	for(int odd = 0; odd < 2; odd++)
	{
		for(int i = 0; i < 2; i++)
		{
			sum[i].init();
			cnt[i].init();
		}
		map<int, int> palindrome[2];
		for(int k = 1; k < (int)F.size() + 1; k++)
		{
			const int clen = sa.lcp[k];
			for(int i = 0; i < 2; i++)
			{
				map<int, int>::iterator it = palindrome[i].lower_bound(clen + 1);
				while(it != palindrome[i].end())
				{
					const int plen = it->first, p = it->second;
					sum[i].add(plen, -(LL)plen * p);
					cnt[i].add(plen, -p);
					sum[i].add(clen, (LL)clen * p);
					cnt[i].add(clen, p);
					palindrome[i][clen] += p;
					palindrome[i].erase(it++);
				}
			}
			const int plen = odd ? mana.rad[sa.a[k] * 2] / 2 + 1 : sa.a[k] ? mana.rad[sa.a[k] * 2 - 1] / 2 : 0;
			ans += sum[1 - of[k]].sum(plen) + (LL)plen * cnt[1 - of[k]].esum(plen + 1);
			sum[of[k]].add(plen, plen);
			cnt[of[k]].add(plen, 1);
			palindrome[of[k]][plen]++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10792
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n,x,t;
  cin>>n>>x>>t;
  int ans;
  int div = n/x;
  int r = n%x;
  if(r == 0){
    ans = div*t;
  }
  else{
    div++;
    ans = div*t;
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
char s[N];
int n, sum, a[N], f[N], last[5];
signed main() {
	scanf("%s", s + 1); n = strlen(s + 1);
	int flag = 1;
	for(int i = 1; i < n; ++ i) if(s[i] == s[i + 1]) flag = 0;
	if(flag) return puts("1"), 0;
	for(int i = 1; i <= n; ++ i) a[i] = (a[i - 1] + (s[i] == 'a' ? 1 : 2)) % 3;
	for(int i = 1; i <= n; ++ i) f[i] = (f[last[0]] + f[last[1]] + f[last[2]] + (a[i] >= 1) - f[last[a[i]]] + mod) % mod, last[a[i]] = i;
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 1920
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int r;
  cin>>r;
  cout<<fixed;
  cout<<2*r*M_PI<<endl;

}


Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int input[][] = new int[n][n];

		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				input[i][j] = sc.nextInt();
			}
		}

		long result = 0;
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				result += Math.min(input[i][j], input[j][i]);
			}
		}

		System.out.println(result);
	}

}



Measured memory_bytes: 42392
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forx(i, n) for(int i = 1 ; (i) <= (n) ; ++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x) * (x)
#define debug(x) cout << #x <<" = " << x << endl
#define printvpair(v) for(auto x : v) cout << x.first  <<" " << x.second << endl;
#define printv(v) for(auto x : v) cout << x << " "; cout << endl;

const int N = 1e5 + 7;
ll a[N];
ll n,x,ans;
int main() {
    cin >> n >> x; forn(i,n) cin >> a[i];
    sort(a,a+ n);
    for (int i = 0; i < n; ++i) {
        if (x - a[i] >= 0){
            ans++;
            x -= a[i];
        }
    }
    if (x > 0 && ans >= n){
        ans--;
    }
    cout << max(ans,0 * 1ll) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char s[100001];
    int n, q;
    int l, r;

    int i, j;
    int num[100001];

    scanf("%d %d", &n, &q);
    scanf("%s", s);

    num[0] = 0;
    for(i=1;i<n;i++){
        if(s[i] == 'C'){
            if(s[i-1] == 'A'){
                num[i] = num[i-1] + 1;
            }else{
                num[i] = num[i-1];
            }
        }else{
            num[i] = num[i-1];
        }
    }

    for(i=0;i<q;i++){
        scanf("%d %d", &l, &r);
        printf("%d\n", num[r-1] - num[l-1]);
    }

    return 0;
}

Measured memory_bytes: 1280