akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>

using namespace std;


int main(){
    string s;
    cin >> s;
    int i;
    bool pr = 0;
    for (i = 0; i < s.length(); ++i){
        if (s[i] == 'C'){
            pr = 1;
            break;
        }
    }
    if (!pr){
        cout << "No";
        return 0;
    }
    pr = 0;
    for (; i < s.length(); ++i){
        if (s[i] == 'F'){
            pr = 1;
            break;
        }
    }
    if (!pr){
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

typedef long long i64;
typedef pair<i64, i64> pii;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  cout << (n + d * 2) / (d * 2 + 1) << "\n";
  return 0;
}

Measured memory_bytes: 256
from collections import deque

def sol():
  q = deque()
  q.append(H)
  ans = 0
  while len(q) != 0:
    prv_H = q.pop()
    min_h = min(prv_H)
    ans += min_h
    
    tmp_H = ''.join([',' if h-min_h == 0 else str(h-min_h)+' ' for h in prv_H])
    for sub_H in tmp_H.split(','):
      if len(sub_H.replace(' ','')) != 0 :
        q.append([int(h) for h in sub_H.split()])
    #print(ans, q) 
  return ans

N = int(input())
H = list(map(int,input().split()))
print(sol())


Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 2e6 + 5;
const int K = (1 << 17) + 10;
const ll INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;

ll A[N] , B[N];

int main(int argc, char const *argv[])
{
	fast;

	int n;
	cin >> n;

	frep(i , 1 , n) {
		cin >> A[i] >> B[i];
	}

	ll sum = 0;
	for(int i = n;i >= 1;i--) {
		A[i] += sum;
		if (A[i] % B[i] == 0)
			continue;
		ll rem = A[i] % B[i];
		sum += B[i] - rem;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g)
{
	for (int i = g; i < n; i++) {
		int j = i - g;
		int v = A[i];
		
		while (j >= 0 && A[j] > v) {
			A[j+g] = A[j];
			j -= g;
			cnt++;
		}
		A[j+g] = v;
	}
}

void shellSort(int A[], int n)
{
	int h = 1;
	while (h <= n) {
		G.push_back(h);
		h = 3 * h + 1;
	}
	
	for (int i = G.size()-1; i >= 0; i--) {
		insertionSort(A, n, G[i]);
	}
}

int main(int argc, char *argv[]) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	cnt = 0;
	
	shellSort(A, n);
	
	cout << G.size() << endl;
	for (int i = G.size()-1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i) {
			printf(" ");
		}
	}
	printf("\n");
	printf("%lld\n",cnt);
	for (int i = 0; i < n;i++) {
		printf("%d\n", A[i]);
	}
	
	return 0;
}


Measured memory_bytes: 7184
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        ll l,r,n;
        cin>>l>>r>>n;
        cout<<(r/n)-((l-1)/n);
    }
    return 0;
}

Measured memory_bytes: 3632
from collections import Counter
from math import factorial
# Mで割った余りが同じ累積和同士の組み合わせを数え上げればよい
N , M = map(int, input().split())
an = list(map(int,input().split()))
ca = [0] * N
ca[0] = an[0] % M
ans = 0
for i in range(N):
    if i > 0:
        ca[i] = (ca[i-1] + an[i]) % M
    if ca[i] % M == 0:
        ans += 1
# Mで割った余りが同じ個数をCounterを利用して求める
c = list(Counter(ca).items())
for ci in c:
    if ci[1] >= 2:
        ans += factorial(ci[1]) // (factorial(2) * factorial(ci[1]-2))
print(ans)

Measured memory_bytes: 19796
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int K;	cin >> K;
	int O = K / 2;
	int P;
	if (K % 2 == 0) {
		P = K / 2;
	}
	else {
		P = K / 2 + 1;
	}
	cout << O * P << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

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; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


int main() {
 
    int a,b;
    cin >> a >> b ;
    
    int i ;
    string aa,bb;
    
    vector<string> v(2);
    v[0]=v[1]="";
    
    aa = to_string(a);
    bb = to_string(b);
    
    for(i=0;i<b;i++){
        v[0]=v[0]+aa;
    }
    for(i=0;i<a;i++){
        v[1]=v[1]+bb;

        //v[1]=v[1] + string(b);
    }
    
    sort(v.begin(),v.end());
    
    cout << v[0] << endl;
    
   // cout << tmp ;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

fn _make_sieve<T: PrimInt>(mut maxu: usize) -> Vec<T> {
    maxu += 1;
    let mut sieve: Vec<T> = (0..maxu).map(|x| T::from(x).unwrap()).collect();

    let mut i = 2;
    while i*i < maxu {
        if sieve[i].to_usize().unwrap() < i { i+=1; continue; }
        for j in (i*i..maxu).step_by(i) {
            if sieve[j].to_usize().unwrap() == j { sieve[j] = T::from(i).unwrap() }
        }
        i += 1;
    }

    sieve
}

pub struct OsaK<T: PrimInt + std::hash::Hash + NumAssign > {
    sieve: Vec<T>
}

impl<T: PrimInt + std::hash::Hash + NumAssign > OsaK<T> {
    pub fn new(max: T) -> Self {
        // O(Nlog(max))
        let maxu = max.to_usize().unwrap();
        let sieve = _make_sieve(maxu);

        Self { sieve }
    }

    pub fn from(vec: Vec<T>) -> Self {
        // O(Nlog(max(vec)))
        let max = vec.iter().max().unwrap();
        let maxu = max.to_usize().unwrap();
        let sieve = _make_sieve(maxu);
        
        Self { sieve }
    }

    pub fn is_prime(&self, x: T) -> bool {
        // O(1)
        if x == one() || x == zero() { return false }
        self.sieve[x.to_usize().unwrap()] == x
    } 

    pub fn prime_factorize(&self, mut n: T) -> std::collections::HashMap<T, T> {
        // O(log log (n))
        let mut res: std::collections::HashMap<T, T> = std::collections::HashMap::new();
        while n > one() {
            *res.entry(self.sieve[n.to_usize().unwrap()]).or_insert(zero()) += one();
            n /= self.sieve[n.to_usize().unwrap()]
        }
        res
    }
}


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
    }

    let osa_k = OsaK::new(n);

    let mut ans = 0;
    for c in 1..n {
        let t = n - c;
        let primes = osa_k.prime_factorize(t);
        // let prime_sum = primes.iter().map(|x| *x.1).sum::<usize>() + 1;
        let div_sum = primes.iter().map(|x| *x.1).fold(1, |acc, x| acc * (x+1));

        if t == 1 {
            ans += 1;
        } else {
            ans += div_sum
        }
    }

    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

/*
vector<PII> G[110][1010];
int main(void){
	int32 W, H, N;
	cin >> W >> H >> N;
	vector<PII> vs(N+1);
	vs[0] = {1, 1};
	REP(i, N){
		cin >> vs[i+1].fs >> vs[i+1].sc;
	}
	vector<vector<int32>> d(110, vector<int32>(1010, INF));
	d[0][0] = 0;
	using tup = tuple<int32, int32, int32>;
	priority_queue<tup, vector<tup>, greater<tup>> pq;
	pq.push(tup(0, 0, 0));
	function<int32(int32,int32)> dis = [&](int32 a, int32 b){
		return abs(vs[a].fs-vs[b].fs)+abs(vs[a].sc-vs[b].sc);
	};
	while(pq.size()){
		int32 v, dd, r;
		tie(dd, v, r) = pq.top(); pq.pop();
		if(d[v][r] < dd) continue;
		REP(i, vs.size()){
			if(i == v) continue;
			int32 rr = max((int32)0, dis(i, v)-r);
			if(d[i][rr] > d[v][r]+rr){
				d[i][rr] = d[v][r]+rr;
				pq.push(tup(d[i][rr], i, rr));
			}
		}
	}
	vs.push_back({W, H});
	int32 res = INF;
	FOR(i, 1, vs.size()-1){
		REP(j, 1010){
			chmin(res, d[i][j]+max(dis(i, vs.size()-1)-j, (int64)0));
		}
	}
	cout << res << endl;
}
*/

struct BiMatch{
  int n;
  vector<vector<int> > G;
  vector<int> match,used;
  
  BiMatch(){}
  BiMatch(int sz):n(sz),G(sz),match(sz),used(sz){}
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  bool dfs(int v){
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      int u=G[v][i],w=match[u];
      if(w<0||(!used[w]&&dfs(w))){
	match[v]=u;
	match[u]=v;
	return true;
      }
    }
    return false;
  }

  int build(){
    int res=0;
    fill(match.begin(),match.end(),-1);
    for(int v=0;v<n;v++){
      if(match[v]<0){
	fill(used.begin(),used.end(),0);
	if(dfs(v)){
	  res++;
	}
      }
    }
    return res;
  }
};
int main(void){
	int32 N, A, B;
	vector<int32> ele;
	cin >> N >> A >> B;
	int32 res = 0;
	REP(i, N){
		int32 a, b;
		cin >> a >> b;
		if(abs(a-b) <= A || (B<=abs(a-b) && abs(a-b) <= 2*A)){
			res++;
		}else{
			ele.push_back(a-b);
		}
	}
	BiMatch bi(ele.size());
	REP(i, ele.size()){
		FOR(j, i+1, ele.size()){
			if(abs(ele[i]+ele[j]) <= A || (B <= abs(ele[i]+ele[j]) && abs(ele[i]+ele[j]) <= 2*A)){
				bi.add_edge(i, j);
			}
		}
	}
	cout << res+bi.build() << endl;
}


Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;

public class Main {
    final int MAX_N = 2 * 100000;
    void run() {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for (int i = 1; i <= n; i++)
            a[i - 1] = scan.nextInt() - i;
        Arrays.sort(a);
        int b = (n % 2 == 0) ? (a[n / 2] + a[n / 2 - 1]) / 2 : a[n / 2];
        long ans = 0;
        for (int i = 1; i <= n; i++)
            ans += Math.abs(a[i - 1] - b);
        System.out.println(ans);
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 89064
import java.util.*;
 
class Main{
    public static void main(String[] args){
        int n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 1; i <= n; i++){
            int num = i;
            if (i % 3 == 0){
                System.out.print(" " + i);
                continue;
            }
            while(num > 0){
                if (num % 10 == 3){
                    System.out.print(" " + i);
                    break;
                }
                num/= 10;
            }
        }
 
        System.out.println();
    }
}

Measured memory_bytes: 28572
package main

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

func find(parent []int, i int) int {
	if parent[i] == -1 {
		return i
	}
	parent[i] = find(parent, parent[i])
	return parent[i]
}

func unite(parent []int, i, j int) {
	i = find(parent, i)
	j = find(parent, j)
	if i == j {
		return
	}
	parent[i] = j
}

func main() {
	n := readInt()
	k := readInt()
	l := readInt()

	roads := make([]int, n)
	rails := make([]int, n)
	for i := 0; i < n; i++ {
		roads[i] = -1
		rails[i] = -1
	}

	for i := 0; i < k; i++ {
		p := readInt()
		q := readInt()
		unite(roads, p-1, q-1)
	}

	for i := 0; i < l; i++ {
		p := readInt()
		q := readInt()
		unite(rails, p-1, q-1)
	}

	d := map[int]int{}
	result := make([]int, n)
	for i := 0; i < n; i++ {
		t := 2000001*find(roads, i) + find(rails, i)
		if _, ok := d[t]; ok {
			d[t] += 1
		} else {
			d[t] = 1
		}
	}

	for i := 0; i < n; i++ {
		result[i] = d[2000001*find(roads, i)+find(rails, i)]
	}

	printIntln(result...)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func printIntln(v ...int) {
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	fmt.Println(string(b))
}


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

using ll = long long;
const int MAXN = 1.1e5;
int N;
int A[3 * MAXN];

ll pans[3 * MAXN];
ll sans[3 * MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < 3 * N; i++) {
		cin >> A[i];
	}
	multiset<int> st;
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		st.insert(A[i]);
		sum += A[i];
	}
	for (int i = N; i < 2 * N; i++) {
		pans[i] = sum;
		sum += A[i];
		st.insert(A[i]);
		sum -= *st.begin();
		st.erase(st.begin());
	}
	pans[2 * N] = sum;
	st = {};
	sum = 0;
	for (int i = 2 * N; i < 3 * N; i++) {
		st.insert(-A[i]);
		sum += -A[i];
	}
	for (int i = 2 * N - 1; i >= N; i--) {
		sans[i+1] = sum;
		sum += -A[i];
		st.insert(-A[i]);
		sum -= *st.begin();
		st.erase(st.begin());
	}
	sans[N] = sum;
	ll ans = -1e18;
	for (int i = N; i <= 2 * N; i++) {
		ans = max(ans, pans[i] + sans[i]);
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 9984
n=int(input())
p=list(map(float,input().split()))
# 最初の ii 枚のコインを投げたときに、表が jj 枚となる確率
dp=[[0.0]*(n+1) for i in range(n+1)]
dp[0][0]=1.0
for i in range(n):
  for j in range(n):
    dp[i+1][j+1]+=dp[i][j]*p[i]
    dp[i+1][j]+=dp[i][j]*(1-p[i])
    
ans=0.0
for i in range((n+1)//2,n+1):
  ans+=dp[n][i]
print(ans)



Measured memory_bytes: 112476
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var line = Input.Line();

            for (int i = line.Length; i > 4;) {
                if (line.Substring(i - 5, 5).Equals("erase")) {
                    i -= 5;
                } else if (line.Substring(i - 5, 5).Equals("dream")) {
                    i -= 5;
                } else if (i < 6) {
                    Console.WriteLine("NO");
                    return;
                } else if (line.Substring(i - 6, 6).Equals("eraser")) {
                    i -= 6;
                } else if(i < 7) {
                    Console.WriteLine("NO");
                    return;
                } else if (line.Substring(i - 7, 7).Equals("dreamer")) {
                    i -= 7;
                } else {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Console.WriteLine("YES");
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

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

int main() {
  int s1,s2,s3,S;
  cin >> S;
  s1 = S / 100;
  s2 = ( S - s1 * 100 ) / 10;
  s3 = S - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define gc getchar
#define ll long long
#define db double
#define pii pair<int,int>
#define fi first
#define se second
#define Vi vector<int>
#define Vp vector<pii>

using namespace std;

inline void cmax(int &x,int y){y>x?x=y:0;}
inline void cmin(int &x,int y){y<x?x=y:0;}

int read(){
	char ch=gc(); int x=0,op=1;
	for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}

const int N=2e5+10;
int n,cnt0[N],cnt1[N],ans; char s[N];

int main(){
	scanf("%d%s",&n,s+1);
	rep (i,1,n) cnt0[i]+=s[i]=='#',cnt1[i]+=s[i]=='.';
	rep (i,1,n) cnt0[i]+=cnt0[i-1],cnt1[i]+=cnt1[i-1];
	ans=n;
	rep (i,0,n) ans=min(ans,cnt0[i]+cnt1[n]-cnt1[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define yn YN
int n,k,ys[23333],yn=0;
ll f[23333];
const ll MOD=1e9+7;
ll qp(ll a,ll b)
{
	ll x=1;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i*i<=n;++i) if(n%i==0)
	{ys[++yn]=i; if(i!=n/i) ys[++yn]=n/i;}
	sort(ys+1,ys+1+yn); ll ans=0;
	for(int i=1;i<=yn;++i)
	{
		f[i]=qp(k,(ys[i]+1)/2);
		for(int j=1;j<i;++j) if(ys[i]%ys[j]==0)
			f[i]-=f[j];
		ans+=f[i]%MOD*ys[i]/(2-ys[i]%2); ans%=MOD;
	}
	ans=(ans%MOD+MOD)%MOD;
	printf("%d\n",int(ans));
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int a, b, c; scan(a, b, c);

    int ans = min(b / a, c);
    writeln(ans);
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _f64 r; cin >> r;
        cout << fixed << setprecision(6);
        cout << pow(r, 2) * M_PI << " " << r * 2 * M_PI << endl;
    }
    return 0;
}


Measured memory_bytes: 3260
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		long N = scan.nextLong();

		long con = 1000000007L;

		long res8 = 1L;
		long res9 = 1L;
		long res10 = 1L;

		for (int i = 0; i < N; i++) {
			res8 *= 8L;
			res9 *= 9L;
			res10 *= 10L;
			res8 = rest(res8);
			res9 = rest(res9);
			res10 = rest(res10);
		}

		long result = res10 - 2 * res9 + res8;

		while (result < 0L || result >= con) {
			if (result < 0L) {
				result += con;
			} else {
				result -= con;
			}
		}
		//結果出力
		System.out.println(result);
	}

	public static long rest(long res) {

		long con = 1000000007L;

		return res % con;
	}
}

Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m,a;
    cin>>n>>m;
    long long int dp[100001];
    for (int i=0;i<=100000;i++) {
        dp[i]=0;
    }
    for (int i=0;i<m;i++) {
        cin>>a;
        dp[a]=-1;
    }
    dp[0]=1;
    for (int i=1;i<=n;i++) {
        if (dp[i]!=-1) {
            if (dp[i-1]!=-1) {
                dp[i]=(dp[i]+dp[i-1])%1000000007;
            }
            if (i>1) {
                if (dp[i-2]!=-1) {
                    dp[i]=(dp[i]+dp[i-2])%1000000007;
                }
            }
        }
    }
    cout<<dp[n]%1000000007<<endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<string> w(n);
    map<string,int> m;
    rep(i,n) cin >> w[i];
    rep(i,n) m[w[i]]++;
    bool flag = true;
    rep(i,n-1) if(w[i][w[i].size()-1] != w[i+1][0]) flag = false;
    for(auto p : m) if(p.second > 1) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3544
n, q, s, t = map(int, input().split())
a = [int(input()) for _ in range(n + 1)]
for i in range(1, n + 1)[::-1]:
    a[i] -= a[i - 1]
count = 0
for i in range(n + 1):
    count -= a[i] * s if a[i] > 0 else a[i] * t
for _ in range(q):
    l, r, x = map(int, input().split())
    count += a[l] * s if a[l] > 0 else a[l] * t
    a[l] += x
    count -= a[l] * s if a[l] > 0 else a[l] * t
    if r < n:
        count += a[r + 1] * s if a[r + 1] > 0 else a[r + 1] * t
        a[r + 1] -= x
        count -= a[r + 1] * s if a[r + 1] > 0 else a[r + 1] * t
    print(count)


Measured memory_bytes: 13628
#include <bits/stdc++.h>
using namespace std;
long long a[100005],dp[100005],n,b,c;
int k;
int main(){

cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>a[i];}
dp[0]=0;
dp[1]=abs(a[0]-a[1]);

for(int i=2;i<n;i++){
dp[i]=1e18;

    for(int j=1;j<=k;j++){
      if(i-j<0)break;
   dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));}
}
cout<<dp[n-1];

        return 0;
}


Measured memory_bytes: 5180
from collections import Counter
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
result = []
for i in range(K):
    result.append(T[i])
for j in range(K, N):
    if result[j-K] == T[j]:
        result.append("d")
    else:
        result.append(T[j])

result = Counter(result)
print(result["r"]*P+result["s"]*R+result["p"]*S)


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int sum = 0;
  if (k > a){
	sum += a;
	k -= a;
	if (k > b){
		k -= b;
		cout << sum - k << "\n";
	}else{
	cout << sum << "\n";
	}
  }else{
	cout << k << "\n";
  } 
return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	bool ok=1;
	for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1])ok=0;
	}
	if(ok){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			HashSet<int> set = new HashSet<int>();
			int ans = 1;
			int a = n;
			System.Diagnostics.Debug.Write($"{a} ");
			set.Add(a);
			ans++;
			while (true) {
				int i = 0;
				if (a % 2 == 0) {
					i = a / 2;
				} else {
					i = 3 * a + 1;
				}
				//System.Diagnostics.Debug.Write($"{i} ");
				if (set.Contains(i)) {
					break;
				}
				a = i;
				set.Add(a);
				ans++;
			}
			//System.Diagnostics.Debug.WriteLine("");
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cstring>

typedef struct node {
    int key;
    node *prev, *next;
} NODE;

NODE *sentinel;

void init() {
    sentinel = (NODE *) malloc(sizeof(NODE));
    sentinel->next = sentinel;
    sentinel->prev = sentinel;
}

void insert(int key) {
    NODE *x = (NODE *) malloc(sizeof(NODE));
    x->key = key;
    x->next = sentinel->next;
    x->prev = sentinel;
    x->next->prev = x;
    sentinel->next = x;
}

void deleteNode(NODE *t) {
    if ( t == sentinel) return;

    t->next->prev = t->prev;
    t->prev->next = t->next;
    free(t); 
}

NODE *listSearch(int key) {
    NODE *cur = sentinel->next;
    while (cur != sentinel && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void deleteFirst() {
    deleteNode(sentinel->next);
}

void deleteLast() {
    deleteNode(sentinel->prev);
}

void printList() {
    NODE *cur = sentinel->next;
    int isf = 0;
    while (1) {
        if (cur == sentinel) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    puts("");
}

int main() {
    int key, n, i;
    char com[20];
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s", com);
        if (com[0] == 'i') {
                scanf("%d", &key);
                insert(key);
        } else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if ( com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else {
                scanf("%d", &key);
                deleteKey(key);
            }
        }
    }
    printList();

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=1e5+5;

int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    int A[3]; cin >> A[0] >> A[1] >> A[2];

    sort(A,A+3);

    int ans = A[2]-A[0];
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n;
    cin >> n;
    vector<ll> a1(n+1), a2(n+1);
    rep(i, n){
        cin >> a1[i];
        if(i > 0) a2[i] = abs(a1[i-1] - a1[i]);
        else a2[i] = abs(0 - a1[i]);
    }
    a1[n] = 0;
    a2[n] = abs(a1[n-1] - a1[n]);
    ll sum = accumulate(a2.begin(), a2.end(), 0LL);
    rep(i, n){
        ll d = 0;
        if(i == 0){
            d = sum - a2[i] - a2[i+1] + abs(0 - a1[i+1]);
        }else{
            d = sum - a2[i] - a2[i+1] + abs(a1[i-1] - a1[i+1]);
        }
        cout << d << endl;
    }
    return 0;
}

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

int main() {
  string n;
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n.size(); i++){
    sum += (int)(n.at(i) - '0');
    sum %= 9;
  }
  if (sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
  int a[5];
  for(int i=0;i<5;i++) cin >> a[i];
  int ans=0;
  int x=0;
  for(int i=0;i<5;i++){
    x=max((200-a[i])%10,x);
  }
  for(int i=0;i<5;i++){
    if(a[i]%10!=0){
      a[i]=a[i]-a[i]%10+10;
    }
    ans+=a[i];
  }
  cout << ans-x << endl;
}

Measured memory_bytes: 256
/* ****Ragnar7**** */
/* It's Going to be Hard, but hard does not mean Impossible. */
#include<bits/stdc++.h>
#define ll          long long
#define hell        1000000007
using namespace std;

ll v[500][500];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,k,m;
	cin>>n>>m;
	char a[25][25];
	for(ll i=0;i<25;i++)
		for(ll j=0;j<25;j++)
			a[i][j]='#';
	for(ll i=1;i<=n;i++)
		for(ll j=1;j<=m;j++)
			cin>>a[i][j];
	for(ll i=0;i<500;i++)
		for(ll j=0;j<500;j++)
			v[i][j]=hell;
	
	ll x,y;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=m;j++)
		{
			x=m*(i-1)+j;
			if(a[i][j]!='.')
				continue;
			v[x][x]=0;
			if(a[i+1][j]=='.')
			{
				v[x][m*i+j]=1;
				v[m*i+j][x]=1;
			}
			if(a[i-1][j]=='.')
			{
				v[x][m*(i-2)+j]=1;
				v[m*(i-2)+j][x]=1;
			}
			if(a[i][j+1]=='.')
			{
				v[x][x+1]=1;
				v[x+1][x]=1;
			}
			if(a[i][j-1]=='.')
			{
				v[x][x-1]=1;
				v[x-1][x]=1;
			}
		}
	}
	for(ll k=0;k<=m*n;k++)
		for(ll i=0;i<=m*n;i++)
			for(ll j=0;j<=m*n;j++)
				if(v[i][k]+v[k][j]<v[i][j])
					v[i][j]=v[i][k]+v[k][j];
	ll mx=m*n+1;
	ll ans=0;
	for(ll i=0;i<mx;i++)
		for(ll j=0;j<mx;j++)
			if(!(v[i][j]>=hell))
				ans=max(ans,v[i][j]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int count=0;
  while(1){
    bool TF=true;
  	for(int i=0;i<n;i++){
    	if(a[i]%2==0 && TF){
      		a[i]/=2;
      		TF=false;
    	}else{
      		a[i]*=3;
    	}
  	}
    if(TF==true){
      cout<<count<<endl;
      return 0;
    }
    count++;
  }
}

Measured memory_bytes: 3560
#include<iostream>
#include<cfloat>
#include<cassert>
#include<cmath>
#include<vector>

using namespace std;

#define EPS (1e-8)
#define equals(a, b) (fabs((a) - (b)) < EPS )
#define dle(a, b) (equals(a, b) || a < b )

static const double PI = acos(-1);

class Point{
    public:
    double x, y;
    
    Point ( double x = 0, double y = 0): x(x), y(y){}
    
    Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
    Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
    Point operator * ( double a ){ return Point(x*a, y*a); }
    Point operator / ( double a ){ return Point(x/a, y/a); }

    double abs() { return sqrt(norm());}
    double norm() { return x*x + y*y; }

    bool operator < ( const Point &p ) const {
	return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == ( const Point &p ) const {
	return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;

class Segment{
    public:
    Point p1, p2;
    Segment(Point s = Point(), Point t = Point()): p1(s), p2(t){}
};

typedef Segment Line;


double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double abs( Vector a ){ return sqrt(norm(a)); }
Point polar( double a, double r ){ return Point(cos(r)*a, sin(r)*a);}
double getDistance( Vector a, Vector b ){ return abs(a - b); }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }



static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

// EPS can be 0
// need to check for 920, 833, 866
int ccw( Point p0, Point p1, Point p2 ){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
    if ( cross(a, b) < -EPS ) return CLOCKWISE;
    if ( dot(a, b) < -EPS ) return ONLINE_BACK;
    if ( norm(a) < norm(b) ) return ONLINE_FRONT;
    return ON_SEGMENT;
}

/*
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
*/

void compute(Point p, Vector v, double D){
    assert( 0.1 <= p.abs() && p.abs() <= 0.9 );
    assert( 0.1 <= v.abs() && v.abs() <= 10.0 );
    assert( 0.1 <= D && D <= 50.0 );
  
    Point c = Point(0, 0);
    int dir = ccw(p, p+v, c);
    double dist = 0.0;

    if ( dir == ONLINE_FRONT || dir == ON_SEGMENT ){
	dist = getDistance(c, p);
    } else if ( dir == ONLINE_BACK ){
	dist = 2.0 - getDistance(c, p);
    } else {
	cout << "impossible" << endl;
	return;
    }

    if ( D < dist ){
	cout << "impossible" << endl;
    } else {
	assert(  D-(1.0e-3) > dist );
	printf("%.12lf\n",  dist);
    }
    
}


int main(){
  Point p;
    Vector v;
    double D;
    while(1){
	cin >> D;
	if ( D == 0 ) break;
	cin >> p.x >> p.y >> v.x >> v.y; 
	compute(p, v, D);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;
typedef vector<ll>		VLL;
typedef vector<VLL>		VVLL;
typedef vector<VVLL>	VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;
	
	ll ans = 0;
	string myRes = T;
	REP(i, N) {
		char game = T[i];
		char resOne;
		ll ansOne;

		if (game == 'r') {
			ansOne = P;
			resOne = 'p';
		} else if (game == 's') {
			ansOne = R;
			resOne = 'r';
		} else {
			ansOne = S;
			resOne = 's';
		}
		
		if (K <= i) {
			if (myRes[i - K] == resOne) {
				ansOne = 0;
				resOne = 'X';
			}
		}

		ans += ansOne;
		myRes[i] = resOne;
	}

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


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        String s = in.next();
        String t = in.next();
        int a = in.nextInt();
        int b = in.nextInt();
        if (s.equals(in.next())) {
            a--;
        } else {
            b--;
        }
        out.println(a, b);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;



int main() {
    int a,b,ans;
    cin>>a>>b;
    
    if(a>=13){
        ans=b;
    }
    else if(a<=5){
        ans=0;
    }
    else{
        ans=b/2;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
using namespace std;

const ll N = 1e6+5;
const ll MOD = 1e9+7;

int main()
{


    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    int ans= 0;
    for(int i =0;i<n;i++){
        for(int  j = i;j<n;j++){
            bool poss = true;
            for(int k =i;k<=j;k++){
                poss &= (s[k] == 'A' || s[k] == 'C' || s[k] == 'T' || s[k] == 'G');
            }
            if(poss){
                ans = max(ans,j-i+1);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=[int(x) for x in input().split()]
Q=[0]*n
R=[0]*n
for i in range(m):
  P,s=input().split()
  p=int(P)
  if s=="AC" and Q[p-1]==0:
    Q[p-1]=1
  elif s=="WA" and Q[p-1]==0:
    R[p-1]+=1
ok=sum(Q)
for j in range(n):
  if Q[j]==0 and R[j]!=0:
    R[j]=0
bad=sum(R)
print(str(ok)+" "+str(bad))

Measured memory_bytes: 10228
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
typedef long long ll;
using namespace std;
ll n, ans;
int a[10000000+1];
int main(){
	ll i, j;
	cin >> n;

	ans = 0;

	for(i=1;i<=n;i++){
		ll t = n/i*i;
		ll temp = (t)*(t+i)/(2*i);
		ans += temp;
	}

	cout << ans;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N,M,K;
    cin>>N>>M>>K;
    vll A(N),B(M),Sa(N+1),Sb(M+1);
    for (size_t i = 0; i < N; i++)
    {
        cin>>A[i];
        Sa[i+1]=Sa[i]+A[i];
    }
    
    for (size_t i = 0; i < M; i++)
    {
        cin>>B[i];
        Sb[i+1]=Sb[i]+B[i];
    }
    ll ans=0,cur=0;
    ll a=0,b=0;
    for (ll i = 0;i <= N; i++)
    {
        cur = Sa[i];
        if(cur > K)
        break;
        ll idx = distance(Sb.begin(),upper_bound(all(Sb),K-cur))-1;
        chmax(ans,idx+i);
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    FOR(i, A, B + 1) {
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

R calc(int n,R d,R x){
	R ret=d+(n-1)/2.0*x;
	if(n-2>0) ret+=calc(n-2,((n+2.0)*d+5.0*x)/n,(n+4.0)*x/n);
	return ret; 
}

int main(void){
	R n,d,x;
	cin >> n >> d >> x;
	cout.precision(20);
	cout << fixed << calc(2*n,d,x) << endl;
	return 0;
}

Measured memory_bytes: 15872
from collections import defaultdict

D = defaultdict(int)

N = int(input())

x = N
y = 2
while y*y <= x:
    while x % y == 0:
        D[y] += 1
        x //= y
    y += 1
if x > 1:
    D[x] += 1

res = 0
for k, v in D.items():
    i = 1
    c = 0
    v -= 1
    while v >= 0:
        c += 1
        i += 1
        v -= i
    res += c

print(res)

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vi a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll cnt = 0;
    for(int i = 0; i < n; ++i) {
        int B = b[i];
        ll Acomb = (lower_bound(all(a), B) - a.begin());
        ll Ccomb = n - (upper_bound(all(c), B) - c.begin());
        // debug(Acomb);
        // debug(Ccomb);
        cnt += Acomb*Ccomb;
    }

    cout << cnt << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll int

ll n,m,a[100100],dp[102002],A,h,l,r;

int main()
{
    cin>>n;
    for(int i = 1;i<=n;i++)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    if(n==2){cout<<dp[2]<<endl;return 0;}
    for(int i = 3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024