akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N,Q;
string s;
char t[SIZE],d[SIZE];
int a,b;

int main(){
  cin >> N >> Q;
  cin >> s;
  rep(i,0,Q) cin >> t[i] >> d[i];
  int l = 0,r = N;
  while(r-l>1){
    int m = (l+r)/2;
    int p = m;
    rep(i,0,Q){
      if(t[i] == s[p]){
        if(d[i] == 'L') p--;
        else p++;
      }
      if(p < 0 || p >= N)break;
    }
    if(p >= 0)r = m;
    else l = m;
  }
  a = l;
  l = 0,r = N;
  while(r-l>1){
    int m = (l+r)/2;
    int p = m;
    rep(i,0,Q){
      if(t[i] == s[p]){
        if(d[i] == 'L') p--;
        else p++;
      }
      if(p < 0 || p >= N)break;
    }
    if(p < N)l = m;
    else r = m;
  }
  b = l;
  cout << b-a << endl;
  return 0;
}


Measured memory_bytes: 900
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

const int N = 100005;
int x[N];
int nex[2][N][31];

int main() {
	int n, l, q;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &x[i]);
	scanf("%d%d", &l, &q);
	REP(i, n) {
		nex[0][i][0] = upper_bound(x, x + n, x[i] + l) - x - 1;
		nex[1][i][0] = lower_bound(x, x + n, x[i] - l) - x;
	}
	FOR(j, 1, 31) {
		REP(i, n) {
			nex[0][i][j] = nex[0][nex[0][i][j - 1]][j - 1];
			nex[1][i][j] = nex[1][nex[1][i][j - 1]][j - 1];
		}
	}
	REP(qq, q) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--, b--;
		int s = 20;
		int mask = 0;
		while (s > 0) {
			s--;
			if (a < b) {
				if (nex[0][a][s] < b) {
					mask |= 1 << s;
					a = nex[0][a][s];
				}
			}
			else{
				if (nex[1][a][s] > b) {
					mask |= 1 << s;
					a = nex[1][a][s];
				}
			}
		}
		printf("%d\n", mask + 1);
	}
	return 0;
}

Measured memory_bytes: 25472
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1].Replace(".", string.Empty));
            long res = a * b / 100;
            Console.WriteLine(res);

        }

    }
}



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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vector<int> res(n + 1);
	for (int i = 1; i <= n; ++i) {
		int a;
		cin >> a;
		res[a] = i;
	}
	for (int i = 1; i != n; ++i) cout << res[i] << ' ';
	cout << res[n] << endl;
}


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

#define int long long

using namespace std;

const int N = 200005;
int a[N], b[N];

class Node {
public:
    int val, pos;

    Node (int val, int pos) {
        this->val = val;
        this->pos = pos;
    }

    bool operator<(const Node &other) const {
        if (val != other.val) return val > other.val;
        return pos < other.pos;
    }
};

signed main(){
    int n;
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++) if (a[i] >= i) return !printf("-1");
    for (int i = 1; i <= n; i++) if (a[i] - a[i - 1] > 1) return !printf("-1");
    for (int i = 1; i <= n; i++) b[i] = a[i];

    priority_queue <Node, vector <Node> > pq;
    for (int i = 2; i <= n; i++) if (a[i] != 0) pq.push(Node(a[i], i));

    int ans = 0;
    while (!pq.empty()) {
        Node u = pq.top(); pq.pop();
        ans += a[u.pos];
        if (u.pos < n) a[u.pos + 1] -= b[u.pos];

        //cout << u.val << " " << u.pos << "\n";
        //for (int i = 1 ; i <= n; i++) cout << a[i] << " ";
        //cout << "\n";
    }

    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
 
//krishrawat
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e5 + 1;//                                                             |
//----------------------------------------------------------------------------------

string s;
ll n=2e5+1;
ll dp[N][13];

ll check(ll x, ll y){
    if(x==n && y==5){
        
        return 1;
    }
    ll k=0;
    
    if(s[x]=='?'){
        for(ll i=0;i<10;i++){
            ll tmp=y*10;
            tmp+=i;
            tmp%=13;
            if(dp[x+1][tmp]!=-1){
                k+=dp[x+1][tmp];
            }
            else k+=check(x+1,tmp);
            k%=mod;
        }
    }
    else if(x!=n){
        ll tmp=y*10;
        ll z=(s[x]-'0');
        tmp+=z;
        tmp%=13;
        if(dp[x+1][tmp]!=-1){
            k+=dp[x+1][tmp];
        }
        else k+=check(x+1,tmp);
    }
    
    dp[x][y]=k%mod;
    return k%mod;
}

void solve()
{   
    cin>>s;
    n=s.size();
    memset(dp,-1,sizeof(dp));
    cout<<check(0,0);
}
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t; t=1;
    //cin>>t;
    while(t--) solve(); return 0;
}

Measured memory_bytes: 33428
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = getc code >>= mapM_ putStrLn

code :: String -> String
code = fromBin . split5 . toBin

toBin :: String -> String
toBin = concatMap f
  where
    f c
      | c == ' ' = "101"
      | c == '\'' = "000000"
      | c == ',' = "000011"
      | c == '-' = "10010001"
      | c == '.' = "010001"
      | c == '?' = "000001"
      | c == 'A' = "100101"
      | c == 'B' = "10011010"
      | c == 'C' = "0101"
      | c == 'D' = "0001"
      | c == 'E' = "110"
      | c == 'F' = "01001"
      | c == 'G' = "10011011"
      | c == 'H' = "010000"
      | c == 'I' = "0111"
      | c == 'J' = "10011000"
      | c == 'K' = "0110"
      | c == 'L' = "00100"
      | c == 'M' = "10011001"
      | c == 'N' = "10011110"
      | c == 'O' = "00101"
      | c == 'P' = "111"
      | c == 'Q' = "10011111"
      | c == 'R' = "1000"
      | c == 'S' = "00110"
      | c == 'T' = "00111"
      | c == 'U' = "10011100"
      | c == 'V' = "10011101"
      | c == 'W' = "000010"
      | c == 'X' = "10010010"
      | c == 'Y' = "10010011"
      | c == 'Z' = "10010000"

split5 :: String -> [String]
split5 ss
  | b == [] = [c]
  | otherwise = a : split5 b
  where
    (a,b) = splitAt 5 ss
    c = take 5 $ a ++ "0000"

fromBin :: [String] -> String
fromBin = map f
  where
    f s
      | s == "00000" = 'A'
      | s == "00001" = 'B'
      | s == "00010" = 'C'
      | s == "00011" = 'D'
      | s == "00100" = 'E'
      | s == "00101" = 'F'
      | s == "00110" = 'G'
      | s == "00111" = 'H'
      | s == "01000" = 'I'
      | s == "01001" = 'J'
      | s == "01010" = 'K'
      | s == "01011" = 'L'
      | s == "01100" = 'M'
      | s == "01101" = 'N'
      | s == "01110" = 'O'
      | s == "01111" = 'P'
      | s == "10000" = 'Q'
      | s == "10001" = 'R'
      | s == "10010" = 'S'
      | s == "10011" = 'T'
      | s == "10100" = 'U'
      | s == "10101" = 'V'
      | s == "10110" = 'W'
      | s == "10111" = 'X'
      | s == "11000" = 'Y'
      | s == "11001" = 'Z'
      | s == "11010" = ' '
      | s == "11011" = '.'
      | s == "11100" = ','
      | s == "11101" = '-'
      | s == "11110" = '\''
      | s == "11111" = '?'

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

Measured memory_bytes: 4304
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int x = in.nextInt();
        int a = in.nextInt();
        out.println((x < a) ? 0 :10);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

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

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

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 21588
package main

import "fmt"

func min(arr []int) int {
	min := arr[0]
	for i := 1; i < len(arr); i++ {
		if min > arr[i] {
			min = arr[i]
		}
	}
	return min
}

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	arr := []int{a + b, a + c, b + c}
	fmt.Println(min(arr))
}


Measured memory_bytes: 512
while True:
    hit=0
    bro=0
    try:
        a = [int(i) for i in input().split()]
        b= [int(j) for j in input().split()]
        for g in range(4):
            for p in range(4):
                if a[g]==b[p]:
                    bro+=1
        for l in range(4):
            if a[l]==b[l]:
                hit+=1
                bro-=1
        print(hit,bro)
    except:break


Measured memory_bytes: 5604
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

using namespace std;

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

int Read()
{
	char c;
	c=getchar();

	int tsqua=0;

	while(c!=' '&&c!='\n')
	{
		tsqua=(((tsqua<<1)<<1)<<1)+(tsqua<<1)+(int)(c-'0');

		c=getchar();
	}

	return tsqua;
}

typedef long long ll;

int n,m;
vector<int> v[123456];
int len[123456];
stack<int> stk;
int Deg[123456];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>m;
	
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		
		v[--x].pb(--y);
		Deg[y]++;
	}
	
	for(int i=0;i<n;i++)if(!Deg[i])stk.push(i);
	
	while(stk.size())
	{
		int p=stk.top();stk.pop();
		
		for(int i=0;i<v[p].size();i++)
		{
			len[v[p][i]]=max(len[v[p][i]],len[p]+1);
			
			Deg[v[p][i]]--;
			
			if(!Deg[v[p][i]])stk.push(v[p][i]);
		}
	}
	
	cout<<*max_element(len,len+n);
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
 
int main()
{
    long long int h,w;cin >> h >> w ;

    if(h%3==0 || w%3==0){
        p(0)
        return 0;
    }

    long long int ans=h*w;

    if(h>3){
        ans = min(ans,w);
    }

    if(w>3){
        ans = min(ans,h);
    }

    long long int l1=h;
    long long int l2=w;

    long long int l1_1=l1/2,l1_2=l1/2;
    if(l1%2!=0) l1_1+=1;

    for(long long int i=1;i<l2;i++){
        long long int s1 = l1*i;
        long long int s2 = l1_1*(l2-i);
        long long int s3 = l1_2*(l2-i);

        long long int s_ma = max(s1,s2);
        long long int s_mi = min(s1,s3);
        ans = min(ans,s_ma-s_mi);
    }

    l1=w;
    l2=h;

    l1_1=l1/2,l1_2=l1/2;
    if(l1%2!=0) l1_1+=1;

    for(long long int i=1;i<l2;i++){
        long long int s1 = l1*i;
        long long int s2 = l1_1*(l2-i);
        long long int s3 = l1_2*(l2-i);

        long long int s_ma = max(s1,s2);
        long long int s_mi = min(s1,s3);
        ans = min(ans,s_ma-s_mi);
    }
    p(ans)
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

in_str = input()
in_sp = in_str.split(' ')
a = int(in_sp[0])
b = int(in_sp[1])

if (a < b) :
    print("a < b")
elif(a > b) :
    print("a > b")
elif(a == b) :
    print("a == b")
else :
    print("Wrong input")
    

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

int main(void){
    string str;
    cin >> str;
    int n=0, s=0, e=0, w=0;
    for (int i=0; i<str.size(); i++){
        if (str[i] == 'S') s++;
        else if (str[i] == 'N') n++;
        else if (str[i] == 'E') e++;
        else w++;
    }
    if (s!=0 && n==0 || s==0 && n!=0 || e!=0 && w==0 || e==0 && w!=0){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
use itertools::Itertools;
use proconio::input;
use std::{iter::once, mem::swap};

const MOD: i64 = 1_000_000_007;

fn main() {
    let mul = |x: i64, y: i64| x * y % MOD;
    let inv = |mut x: i64| {
        let mut y: i64 = MOD;
        let mut u: i64 = 1;
        let mut v: i64 = 0;
        while x != 0 {
            let q = y / x;
            y -= x * q;
            v -= u * q;
            swap(&mut x, &mut y);
            swap(&mut u, &mut v);
        }
        if 0 <= v {
            v
        } else {
            v + MOD
        }
    };
    let div = |x: i64, y: i64| mul(x, inv(y));

    input!(n: usize, m: usize);
    let fact = once(1)
        .chain((1..=m as i64).scan(1, |acc, x| {
            *acc = mul(*acc, x);
            Some(*acc)
        }))
        .collect_vec();
    let binom = |x: usize, y: usize| div(fact[x], mul(fact[y], fact[x - y]));

    println!(
        "{}",
        (0..=n)
            .map(|i| mul(
                if i % 2 == 0 { 1 } else { MOD - 1 },
                mul(
                    binom(n, i),
                    mul(
                        fact[m],
                        mul(fact[m - i], mul(inv(fact[m - n]), inv(fact[m - n])))
                    )
                )
            ))
            .fold(0, |x, y| (x + y) % MOD)
    );
}


Measured memory_bytes: 5972
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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 (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	rep(h, 1, 3501)rep(n, 1, 3501) {
		int a = N*h*n;
		int b = 4 * h*n - N*n - N*h;
		if (b > 0 && a%b == 0) {
			cout << h << " " << n << " " << a / b << endl;
			return 0;
		}
	}
	return 0;
}

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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;

    vector <int> point_ichiran(N);
    for(int i = 0; i < Q; i++) {
        int tmp;
        cin >> tmp;
        tmp --;
        point_ichiran[tmp] ++;
    }
    for(int i = 0; i < N; i++) {
        int point = point_ichiran[i];
        point += K;
        point -= Q;
        if(point > 0) {
            cout << "Yes";
        }
        else cout << "No";
        if(i != N-1) {
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
shops = "ABCDE"
while true
    scores = [0, 0, 0, 0, 0]
    scores[0] = gets.chomp.split.map(&:to_i).inject(:+)
    break if scores[0] == 0
    1.upto(4){|i| scores[i] = gets.chomp.split.map(&:to_i).inject(:+)}
    puts "#{shops[scores.index(scores.max)]} #{scores.max}"
end



Measured memory_bytes: 6856
package main

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

type Card struct{ Number, Stock int }
type Cards []Card

func (c Cards) Len() int           { return len(c) }
func (c Cards) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
func (c Cards) Less(i, j int) bool { return c[i].Number > c[j].Number }

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	var sum int64
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sum += int64(as[i])
	}
	sort.Ints(as)
	var cs Cards = make([]Card, m)
	for i := range cs {
		sc.Scan()
		cs[i].Stock, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		cs[i].Number, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(cs)
	var p int
label:
	for _, v := range cs {
		for i := 0; i < v.Stock; i++ {
			if p >= len(as) || v.Number < as[p] {
				break label
			}
			sum += int64(v.Number - as[p])
			p++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

void solve(string &S,int k){
	long long D=0,M=0,DM=0,ans=0;
	for(int i=0;i<S.size();i++){
		if(i-k>=0){
			if(S[i-k]=='M'){
				M--;
			}
			if(S[i-k]=='D'){
				D--;
				DM -= M;
			}
		}
		
		if(S[i]=='D')D++;
		if(S[i]=='M'){
			M++;
			DM += D;
		}
		if(S[i]=='C'){
			ans += DM;
		}
	}
	
	cout<<ans<<endl;
}


int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	int Q;
	cin>>Q;
	
	for(int i=0;i<Q;i++){
		int k;
		cin>>k;
		solve(S,k);
	}
	
    return 0;
}


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

#define EPS 1e-7

int main()
{
	double x1, y1, x2, y2, x3, y3, x4, y4;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		if (x1 == x2 && x3 == x4){
			cout << "YES" << endl;
		}
		else if (x1 == x2 || x3 == x4){
			cout << "NO" << endl;
		}
		else if (abs((y2 - y1) / (x2 - x1) - (y4 - y3) / (x4 - x3)) < EPS){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
#include <stdio.h>

using namespace std;

int v[] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int w;
stack<int> spent;

int main(void) {
    while(~scanf("%d", &w)) {
        for(int i = 0; i < 10; i++) {
            if(w >= v[i]) {
                w -= v[i];
                spent.push(v[i]);
            }
        }
        while(!spent.empty()) {
            if(spent.size() == 1) {
                cout << spent.top();
            } else {
                cout << spent.top() << " ";
            }
            spent.pop();
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s,t; cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
    string ans;
    for(int i=0;i<=s.size()-t.size();i++){
        if(s[i]==t[0]||s[i]=='?'){
            bool ok=true;
            for(int j=1;j<t.size();j++){
                if(s[i+j]!=t[j]&&s[i+j]!='?') ok=false;
            }
            if(ok){
                for(int k=0;k<i;k++){
                    if(s[k]=='?') ans.push_back('a');
                    else ans.push_back(s[k]);
                }
                 ans+=t;
                for(int k=i+t.size();k<s.size();k++){
                    if(s[k]=='?')  ans.push_back('a');
                    else  ans.push_back(s[k]);
                }
                reverse(ans.begin(),ans.end());
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<"UNRESTORABLE"<<endl;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int h;
    while(cin >> h, h){
        vvi f(h, vi(5));
        rrep(i,h) rep(j,5) cin >> f[i][j];
        int ans = 0;
        while(1){
            bool update = false;
            rep(i,h){
                REP(x,1,10){
                    REP(j,1,4){
                        if(f[i][j-1] == x && f[i][j] == x && f[i][j+1] == x){
                            REP(k,j-1,5){
                                if(f[i][k] == x) f[i][k] = 0, ans += x;
                                else break;
                            }
                            update = true;
                            break;
                        }
                    }
                }
            }
            rep(j,5){
                int bottom = -1;
                rep(i,h) if(f[i][j] == 0){
                    REP(k,i+1,h) if(f[k][j] != 0){
                        swap(f[i][j], f[k][j]);
                        break;
                    }
                }
            }
            if(!update) break;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
ll two(ll a){
  ll key=0;
  while(a%2==0) {
    a/=2;
    key++;
  }
  return min((ll)2,key);
}
int main(){
  ll n ; cin >>n;
  vector<ll> a(n);
  rep(i,n)  cin >>a[i];
  rep(i,n) a[i]=two(a[i]);
  map<ll,ll> mp;
  rep(i,n)mp[a[i]]++;
  if(mp[1]==0&&mp[0]<=mp[2]+1) cout <<"Yes"<<endl;
  else if(mp[1]>0&&mp[0]<=mp[2]) cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}

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

int main() {
  int n, d, x, ans = 0, temp;

  cin >> n >> d >> x;

  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (temp == 1) {
      ans += d;
    } else if (d % temp == 0) {
      ans += d / temp;
    } else {
      ans += d / temp + 1;
    }
  }

  cout << ans + x;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

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

	vector<vector<int>> g(n * n);
	vector<int> vin(n * n, -1);
	rep(i, n) {
		vector<int> node;
		rep(_, n - 1) {
			int x, y = i;
			cin >> x;
			x--;
			if (x > y) swap(x, y);

			int v = x * n + y;
			vin[v] = max(0LL, vin[v]);
			node.emplace_back(v);
		}
		rep(j, node.size() - 1) { g[node[j]].emplace_back(node[j + 1]); }
	}

	rep(i, g.size()) {
		for (auto to : g[i]) { vin[to]++; }
	}

	queue<int> q;
	vector<int> dis(n * n);
	rep(i, n * n) if (vin[i] == 0) {
		q.emplace(i);
		dis[i] = 1;
	}

	while (not q.empty()) {
		int cur = q.front();
		q.pop();
		for (auto to : g[cur]) {
			vin[to]--;
			if (vin[to] == 0) {
				dis[to] = dis[cur] + 1;
				q.emplace(to);
			}
		}
	}

	bool f = true;
	rep(i, vin.size()) {
		if (vin[i] != -1 and vin[i] != 0) f = false;
	}

	if (f) cout << *max_element(all(dis)) << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 54912
#include <iostream>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main() {

    vector<long long int> a;
    unsigned long long int n;
    
    unsigned long long int ans = 1;
    cin >> n;
    unsigned long long int temp;
    bool b = false;
    for (unsigned long long int i = 0; i < n; i++) {
        cin >> temp;
        a.push_back(temp);


        if (18446744073709551615 / ans <= temp) {
            b = true;
        }

        if (temp == 0) {
            cout << 0;
            return 0;
        }
        if (b == false) {
            ans *= temp;
        }

        if (ans > 1000000000000000000) {
            b = true;
        }



    }

    if (b == true) {
        cout << -1;
        return 0;
    }

    cout << ans;




    return 0;
}

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

int main(){
    int n; string s; string t;
    string ans;
    cin>>n;
    cin>>s>>t;
    for(int i=0;i<n;i++){
        ans+=s[i];
        ans+=t[i];
    }
    cout<<ans<<endl;

}

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

int main(){
    int N,K;
    cin >> N >> K;
    vector <int> A(N);
    rep(i,N){
        cin >> A[i];
    }

    if((A[0] == 1) || (A[N-1] == 1)){
        if((N-1)%(K-1) == 0){
            cout << (N-1)/(K-1) << endl;
            return 0;
        }
        else{
            cout << (N-1)/(K-1) + 1 << endl;
            return 0;
        }
    }
    else{
        int place1 = 0;
        rep(i,N){
            if(A[i] == 1){
                place1 = i;
                break;
            }
        }
        if((N-1)%(K-1) == 0){
            int ans1 = (N-1)/(K-1);
            cout << ans1 << endl;
            return 0;
        }
        else{
            int ans2 = (N-1)/(K-1) + 1;
            cout << ans2 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 640
"""

https://atcoder.jp/contests/agc006/tasks/agc006_e

まず、ちゃんと並んでない場合はだめ

3x+0
3x+1
3x+2
またはこれが上下反転されているもの以外が存在したら即NO
これを xと表すことにする。上下反転を-xと表すこととする
すると初期状態はxで表すと
1,2,3,4,5…,N　となる。

操作は、連続する3つを選び、両端を入れ替え、3つの項に-1を掛ける
となる。

そのため、偶奇が違う数があるとout
次に転倒数を考える。転倒数は交換するたびに1減る or 1増える
偶奇番目を分けて考える

交換すると、両端の偶奇の正負のパリティは変化しないが、反対側が変化する
よって、偶奇が逆の集合の転倒数を求める
→奇数ならば積は負・偶数なら積は正　が保たれる　そうでない場合はNO

それ以外はすべて作れるのか…？証明したい

 1 2 3 4
-3-2-1 4
-3-4 1 2

分からん…とりあえず出してみよう

"""

from sys import stdin
import sys

def bitadd(a,w,bit): #aにwを加える(1-origin)
 
    x = a
    while x <= (len(bit)-1):
        bit[x] += w
        x += x & (-1 * x)
 
def bitsum(a,bit): #ind 1～aまでの和を求める
 
    ret = 0
    x = a
    while x > 0:
        ret += bit[x]
        x -= x & (-1 * x)
    return ret

N = int(stdin.readline())

a = []
for i in range(3):
    tmp = list(map(int,stdin.readline().split()))
    a.append(tmp)

lis = []
bi  = []

for j in range(N):
    a[0][j] -= 1
    a[1][j] -= 1
    a[2][j] -= 1
    if a[0][j]//3 == a[1][j]//3 == a[2][j]//3 and a[0][j]//3%2 == j%2:
        if a[0][j] > a[1][j] > a[2][j]:
            lis.append(a[0][j]//3)
            bi.append(-1)
        elif a[0][j] < a[1][j] < a[2][j]:
            lis.append(a[0][j]//3)
            bi.append(1)
        else:
            print ("No")
            sys.exit()
    else:
        print ("No")
        sys.exit()

evenall = 1
for i in range(0,N,2):
    evenall *= bi[i]
oddall = 1
for i in range(1,N,2):
    oddall *= bi[i]


a = lis
#print (a,bi)
#even
BIT = [0] * (N+2)
ans = 0
for i in range(0,N,2):
    ans += i//2 - bitsum(a[i]+1,BIT)
    bitadd(a[i]+1,1,BIT)

#print (ans , oddall)
if (ans % 2 == 0 and oddall == -1) or (ans % 2 == 1 and oddall == 1):
    print ("No")
    sys.exit()

#odd
BIT = [0] * (N+2)
ans = 0
for i in range(1,N,2):
    ans += i//2 - bitsum(a[i]+1,BIT)
    bitadd(a[i]+1,1,BIT)

#print (ans , evenall)
if (ans % 2 == 0 and evenall == -1) or (ans % 2 == 1 and evenall == 1):
    print ("No")
    sys.exit()

print ("Yes")


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

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


    for(int j=0;j<N;j++){
        if(nVec[j]*4*M>=sum){
            nCnt++;
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s;

  cin >> s;

  string s1 = s.substr(0,2);
  string s2 = s.substr(2,2);

  bool YYMM = false;

  bool MMYY = false;

  if(s1 <= "12" && s1 >= "01"){
      MMYY = true;
  }

  if(s2 <= "12" && s2 >= "01"){
      YYMM = true;
  }

  if(YYMM && MMYY){
      cout << "AMBIGUOUS" << endl;
  }
  else if(YYMM){
      cout << "YYMM" << endl;
  }
  else if(MMYY){
      cout << "MMYY" << endl;
  }
  else{
      cout << "NA" << endl;
  }

  return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[131231] = {};
    Scs(s);

    int N = strlen(s);
    Rep(i,N){
        if( s[i] == ( i%2 ? 'R' : 'L' ) ) s[114] = 1;
    }

    YesNo( s[114] == 0 );

    return 0;
}





Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class40
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var x = Console.ReadLine().Split().Select(long.Parse).ToArray();

            
            
            long sum = long.MaxValue;
            for(long i = 0; i <= x.Max(); i++)
            {
                long k = 0;
                for(int j = 0; j < n; j++)
                {
                    k += (long)Math.Pow(i - x[j], 2);
                }
                sum = Math.Min(sum, k);
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
    ll n,k; cin>>n>>k;
    // ll ans=ncrfermet(n+k,k);
    // // ans*=(n-k);
    // ans%=mod;
    ll ans=0;
    if(n==1&&k==1)
      ans=3;
    // else if(n==1&&k>n+1)
    //   ans=0;
    else if(n==1)
      ans=1;
    else{
      for(ll i=k;i<=n+1;i++){
        ans+=(i*(n-i+1)+1)%mod;
        ans%=mod;
      }
    }
    cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(){
	int n;
	int t;
	for(int i=0;i<4;i++){
		cin>>t>>n;
		if(t==1){
			cout<<6000*n<<endl;
		}else if(t==2){
			cout<<4000*n<<endl;
		}else if(t==3){
			cout<<3000*n<<endl;
		}else if(t==4){
			cout<<2000*n<<endl;
		}
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

const long long INF = 1LL<<60;
long long solve(const vector<long long> &A) {
    long long X = A[0] + A[1];
    long long Y = 0;
    for (int i = 2; i < A.size(); ++i) Y ^= A[i];
    long long M = A[1];

    if ((A[0] ^ A[1]) == Y) return 0;

    //COUT(X); COUT(Y); COUT(M);

    long long res = INF;
    for (int d = 50; d >= 0; --d) {
        if (M & (1LL<<d)) continue;

        long long a = 0;
        for (int e = 50; e > d; --e) {
            if (M & (1LL<<e)) a |= (1LL<<e);
        }
        a |= (1LL<<d);

        long long b = a ^ Y;
        if (a + b > X) continue;

        long long diff = X - (a + b);

        //COUT(diff);

        if (diff & 1) continue;

        bool ok = true;
        long long na = a;
        for (int e = 50; e >= 0; --e) {
            if (diff & (1LL<<(e+1))) {
                if (e >= d) ok = false;
                if (b & (1LL<<e)) ok = false;
                na |= (1LL<<e);
            }
        }

        if (ok) {
            //COUT("-----"); COUT(d); COUT(a); COUT(b); COUT(diff); COUT(na);
        }

        if (ok && na < X) chmin(res, na - M);
    }
    if (res < INF) return res;
    else return -1;
}

int main() {
    int N;
    while (cin >> N) {
        vector<long long> A(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        cout << solve(A) << endl;
    }
}

















Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const ull kMax = 1000100;

// a >= b
ull gcd(ull a, ull b) {
  if (a % b) {
    return gcd(b, a % b);
  } else {
    return b;
  }
}

int main()
{
  ull a, b;
  cin >> a >> b;

  if (b > a) {
    ull temp = a;
    a = b;
    b = temp;
  }
  ull cnt = 1;
  ull g = gcd(a, b);
  for (ull i = 2; i < kMax; ++i) {
    if (g % i == 0) {
      ++cnt;
      do {
        g /= i;
      } while (g % i == 0);
    }
  }

  cout << cnt + (g >= kMax);

  return 0;
}




Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  bool eq(pii q)
  {
  return q.fi==q.se;
  }
  void solve()
  {

int n;
cin>>n;
vpi v(n);
forn(i,n)
{

	cin>>v[i].fi>>v[i].se;
}
bool is=false;
for(int i=0;i+2<n;i++)
{
if(eq(v[i])&&eq(v[i+1])&&eq(v[i+2]))is=true;
}

if(is)cout<<"Yes";
else cout<<"No";
  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 3660
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n;

int main(){
	cin >> n;
	
	cout << 24-n+24 << endl;
	return 0;
}


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

int main() {
	int a, b, c, d, e; int ans = 0;
	cin >> a >> b >> c >> d >> e;
	if (a <= 0) { ans = ans + c * abs(a); a = 0; }
	if (a == 0) ans = ans + d;
	if (a >= 0) { ans = ans + e * (b - a); a = b; }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    int a;
    int count;
    do{
        getline(cin,s);
        if (s=="0")
            break;
        count=0;
        for (int i=0;i<s.size();i++){
            a=s[i];
            count+=a-48;
        }
        cout << count << endl;
    }while (s!="0");
    return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

vector<int> g[200000];
int n, m;

bool to_n(int num, int c){
    if (c == 1){
        rep(i, g[num].size()){
            if (g[num][i] == n - 1){
                return true;
            }
        }
        return false;
    }
    rep(i, g[num].size()){
        if (to_n(g[num][i], c + 1)){
            return true;
        } 
    }
    return false;
}

int main(){
    cin >> n >> m;
    int a, b;
    rep(i, m){
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if (to_n(0, 0)){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    
}

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

int main() {

	string S; cin >> S;
	int w; cin >> w;
	for (int i = 0; i < S.size(); i += w) {
		cout << S[i];
	}
	cout << endl;
	return 0;
}

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

typedef long long ll;

int main() {
	//freopen("input.txt","r",stdin);

	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL); 
	int n;
	cin>>n;
	string s;
	cin>>s;
	ll r = 0, g = 0, b = 0;

	for(char x : s){
		switch(x){
			case 'R':	++r;
			break;
			case 'G':	++g;
			break;
			case 'B':	++b;
		}
	}

	ll ans = r * g * b;

	for(int l= 1; l <= (n/2+1); ++l){
		for(int i = 0; i+2*l < n; ++i){
			if(s[i] != s[i+l] && s[i] != s[i+2*l] && s[i+l] != s[i+2*l]){
				--ans;
			}
		}
	}

	cout<< ans << endl;

}



Measured memory_bytes: 3656
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	nums := scanNums(N)
	var div float32
	for i := 0; i < N; i++ {
		div += 1 / nums[i]
	}
	fmt.Println(1 / div)
}

func scanNums(len int) (nums []float32) {
	var num float32
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


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

double dp[303][303][303];
vl cnt(3);
ll n;

double rec(ll x, ll y, ll z){
	if(dp[x][y][z] != -1) return dp[x][y][z];
	dp[x][y][z] = 0.0;
	double num = 1.0 * n / (double)x;
	if(x != y){
		dp[x][y][z] += (rec(x-1,y,z) + num) * (x-y) / (double)x;
	}
	if(y != z){
		dp[x][y][z] += (rec(x,y-1,z) + num) * (y-z) / (double)x;
	}
	if(z > 0){
		dp[x][y][z] += (rec(x,y,z-1) + num) * z / (double)x;
	}
	return dp[x][y][z];
}

int main(){
	cin >> n;
	vl a(n); rep(i,n) cin >> a[i], a[i]--;
	rep(i,n) cnt[a[i]]++;
	cnt[1] += cnt[2];
	cnt[0] += cnt[1];
	rep(i,cnt[0]+1) rep(j,cnt[1]+1) rep(k,cnt[2]+1) dp[i][j][k] = -1;
	dp[0][0][0] = 0;
	printf("%.10f\n",rec(cnt[0],cnt[1],cnt[2]));
}

Measured memory_bytes: 219368