akhauriyash/Code-Regression huggingface dataset:
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    while(1):
        N = int(input())
        if N == 0:
            break
        lines = [0] * (N+1)
        for i in range(N+1):
            M = int(input())
            # はじめはべつに
            line = [list(map(int,input().split()))]
            par = line[0].copy()
            line[0][0] -= par[0]
            line[0][1] -= par[1]
            for _ in range(M-1):
                line.append(list(map(int,input().split())))
                line[-1][0] -= par[0]
                line[-1][1] -= par[1]
            lines[i] = line
        # print(lines)
        # i が見るの
        for i in range(1, N+1):
            # はじめと終わりを反転
            for __ in range(2):
                for _ in range(4):
                    if lines[0] == lines[i]:
                        print(i)
                        # ans += 1
                        break
                    for j in range(len(lines[i])):
                        lines[i][j][0], lines[i][j][1] = lines[i][j][1], -lines[i][j][0]
                lines[i] = lines[i][::-1]
                # print(lines[i])
                par = lines[i][0].copy()
                lines[i][0][0] -= par[0]
                lines[i][0][1] -= par[1]
                for j in range(1, len(lines[i])):
                    lines[i][j][0] -= par[0]
                    lines[i][j][1] -= par[1]
        print("+++++")
if __name__ == "__main__":
    main()


Measured memory_bytes: 5636
#include<stdio.h>

int main(){

int a,b;
char op;

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

while(op!='?'){

if(op=='+'){

printf("%d\n",a+b);

}

else if(op=='-'){

printf("%d\n",a-b);

}

else if(op=='*'){

printf("%d\n",a*b);

}

else if(op=='/'){

printf("%d\n",a/b);

}
scanf("%d %c %d", &a, &op, &b);
}

return 0;
}

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

int main() {

	string s;
	cin >> s;
	int count = 0;
	
	for (int j = 0; j < (s.size())/2 ; j++) {
		if (s[j] != s[s.size() - j-1]) {
			count += 1;
		}
	}

	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  string s, t; cin >> s >> t;
  // sの末尾(= tの先頭)を何文字とるか
  int i = n;
  while (i > 0) {
    string l = s.substr(n - i, i);
    string r = t.substr(0, i);
    // debug2(l, r);
    if (l == r) break;
    i--;
  }
  outl(2 * n - i);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <deque>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e9 + 100;

vector<ll> pr, xr;
vector<ll> vec, srt;
vector<ll> nw;
vector<pair<ll, ll>> ps;

ll n, k, q, tree[SIZE * 4];

void build(int v, int l, int r) {
    if (l == r - 1) {
        tree[v] = vec[l];
    }
    else {
        int m = (l + r) / 2;
        build(v * 2 + 1, l, m);
        build(v * 2 + 2, m, r);
        tree[v] = min(tree[v * 2 + 1], tree[v * 2 + 2]);
    }
}

ll get(int v, int l, int r, int askl, int askr) {
    if (l >= askr || r <= askl) return INT64_MAX;

    if (l >= askl && r <= askr) return tree[v];

    ll mid = (l + r) / 2;
    return min(get(v * 2 + 1, l, mid, askl, askr), get(v * 2 + 2, mid, r, askl, askr));
}
ll check(ll lft) {
    ll vl = 0;

    ll pr = 0, s = 0, ans= 0;
    ll mx = 0, mn = 0;
    vector<ll> kt;
    vector<ll> added;
    for (int i = 0; i < vec.size(); i++) {
        if (vec[i] < lft) {
            sort(kt.begin(), kt.end());
            
            for (int t = 0; t < s - k + 1; t++) {
                added.push_back(kt[t]);
            }
            vl += (s - k + 1);
            s = 0;
            pr = 0;
            kt.clear();
        }
        else {
            s++;
            kt.push_back(vec[i]);
            pr = 1;
        }
    }

    sort(added.begin(), added.end());
    mn = INT64_MAX;
    for (int i = 0; i < q && i < added.size(); i++) {
        mx = max(mx, added[i]);
        mn = min(mn, added[i]);
    }
    if (added.size() >= q) return mx - mn;
    else {
        return -1;
    }
}

int main() {
    fastInp;

    string s;
    cin >> s;
    ll q = 0;
    if (s.front() == s.back()) {
        q++;
    }

    if ((s.size() - q) % 2 == 0) {
        cout << "Second";
    }
    else {
        cout << "First";
    }
    return 0;
}



Measured memory_bytes: 512
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def match(a, b):
    return a=="?" or b=="?" or a==b

a = input()
b = input()
c = input()



# aに対して(i-50000)個左にスライドした位置にbを置けるか？
ab = [True] * 100000
ac = [True] * 100000
bc = [True] * 100000

def check(a,b, ab):
    for i in range(len(a)):
        for j in range(len(b)):
            if not match(a[i], b[j]):
                ab[i-j+50000] = False

log("check end.")

check(a, b, ab)
check(a, c, ac)
check(b, c, bc)

len_max = 2000
len_a = len(a)
len_b = len(b)
len_c = len(c)

ans = 9999999999999999999999

for i in range(-2 * len_max, 2 * len_max + 1):
    for j in range(-2 * len_max, 2 * len_max + 1):
        if ab[i+50000] and ac[j+50000] and bc[j-i+50000]:
            left = min(0, i, j)
            right = max(len_a, len_b+i, len_c+j)
            ans = min(ans, right - left)

print(ans)



Measured memory_bytes: 52316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int money = scan.nextInt();
		int y500 = money / 500;
		int y5 = money%500 / 5;
		System.out.println(1000*y500 + y5*5);
	}
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        String s = scanner.next();
        System.out.println(s.charAt(0) == s.charAt(1) && s.charAt(0) == s.charAt(2) ? "No" : "Yes");
    }

}



Measured memory_bytes: 24148
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let n = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let x = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut d = 0;
	let mut cnt = 1;
	for i in iter {
		if d + i.parse::<i32>().ok().unwrap() > x {
			break;
		}
		d += i.parse::<i32>().ok().unwrap();
		cnt += 1;
	}
	println!("{}", cnt);
}

Measured memory_bytes: 2112
def main():
    x = int(input())
    limit = int(x**0.5)+2
    ans = 0
    for i in range(limit):
        for j in range(2,limit):
            p=i**j
            if p <= x:
                ans = max(ans, p)
            else:
                break
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e9;
const double EPS = 1e-9;
const ll MOD = (ll)(23 + 99);
const ll MAXV = (ll)(2e5 + 10);
const ll MAXE = (ll)(1e6 + 10);

ll B = 53LL;
ll n;
map <string, ll> cnt;
ll aux[30];

int main(){
	cin.sync_with_stdio( 0 );cin.tie( 0 );

	cin >> n;

	string s;
	ll sol = 0;

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

		sort(s.begin(), s.end());

		sol += cnt[s];
		cnt[s] ++;
	}

	cout << sol << "\n";

	return 0;
}


Measured memory_bytes: 11264
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end
def comb(n,a)
	return $fact[n] * $finv[a] % $mod * $finv[n-a] % $mod;
end
def pow(a,n)
	prd = 1;
	exp = a;
	while(n > 0)
		if((n&1)==1)
			prd *= exp;
			prd %= $mod;
		end
		exp *= exp;
		exp %= $mod;
		n >>= 1;
	end
	return prd;
end
# constant
NMAX = 100015;
$mod = 998244353;
$mod = 10**9+7;
$fact = Array.new(NMAX);
$finv = Array.new(NMAX);
# read
N,_=gets.chomp.split(' ').map{|n| n.to_i}
A=gets.chomp.split(' ').map{|n| n.to_i}
# preprocess
$fact[0] = 1;
$finv[0] = 1;
for i in 1..(NMAX)
	$fact[i] = $fact[i-1] * i % $mod;
	$finv[i] = pow($fact[i], $mod-2);
end
# main
from = -1
to = -1
dupval = -1
h = {}
A.each{|a|
	if(!h[a].nil?)
		dupval = a
		break
	end
	h[a]=1
}
A.each_with_index{|a,i|
	if(a==dupval)
		from == -1 ? from = i : to = i
	end
}
duprng = from+(N+1-1-to)
dputs "from:#{from}"
dputs "to:#{to}"
dputs "duprng:#{duprng}"
for i in 1..(N+1)
	puts (comb(N+1,i)-(duprng>=i-1 ? comb(duprng,i-1) : 0)) % $mod
end


Measured memory_bytes: 20728
from pprint import pprint
def arr_scan():
    return list(map(int, input().split(' ')))

n, m = arr_scan()
# todo: improve description
# dp[n][letters]: represents the max
# length of letter achievable upto dp[i]: ith length strings  
dp = ['' for _ in range(n + 1)]
costs = [0,2,5,5,4,5,6,3,7,6]

# keep in mind the off-set of 1 because 
# available digits for forming the letters
# is from 1-9 i.e. 9 digits only

letters = arr_scan()

# row wise
for wt in range(1, n + 1):
    # do for all available digits
    for l in letters:
        # lookback
        if wt - costs[l] >= 1 and dp[wt - costs[l]] != '':
            if len(dp[wt - costs[l]]) + 1 > len(dp[wt]):
                dp[wt] = max(dp[wt - costs[l]] + str(l), str(l) + dp[wt - costs[l]])
            elif len(dp[wt- costs[l]]) + 1 == len(dp[wt]): 
                dp[wt] = max(dp[wt], dp[wt - costs[l]] + str(l), str(l) + dp[wt - costs[l]])
        elif wt == costs[l]:
            if len(dp[wt]) == 1:
                dp[wt] = max(dp[wt], str(l))
            elif dp[wt] == '':
                dp[wt] = str(l)
        # check with current cost of n and the letter
# pprint(dp)
print(dp[n])


Measured memory_bytes: 138332
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();
        
        
        for(int i = A; i <= B; i++) {
            if(i % K == 0) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");

    }

}


Measured memory_bytes: 35804
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
	}
	var sum float64
	for i := 0; i < N; i++ {
		sum += 1 / float64(A[i])
	}
	fmt.Println(1 / sum)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
def grand_garden(hlist):
    all_zero = False
    count = 0
    while(not all_zero):
        nonzero = False
        for i, h_i in enumerate(hlist):
            if h_i != 0:
                nonzero = True
                hlist[i] = hlist[i] -1
            elif nonzero:
                break


        if nonzero:
            count = count + 1
        else:
            all_zero = True


    return count




n = int( input())
hlist = input().split()
for i, h_i in enumerate(hlist):
    hlist[i] = int(hlist[i])

count = grand_garden(hlist)

print(count)


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

int main(){
    int n;
    cin >> n;
    vector<int> score(n);

    for( int i = 0; i < n; i++ ){
        cin >> score[i];
    }
    
    int t_score = 0;
    for( int i = 1; i <= n; i++ ){
        int j = 0;
        int count = 0;
        for( ;j < n; j++ ){
            if( score[j] >= i ){
                count++;
            }
        }
        if( count >= i ){
            t_score = i;
        }
    }
    
    cout << t_score << endl;
}


Measured memory_bytes: 3084
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
x,y,z,k = ma()
A = lma()
B=lma()
C=lma()
AB = [a+b for a in A for b in B]
AB.sort(reverse=True)
C.sort(reverse=True)
ans=[]
iab=min(k,x*y)
ic=min(k,z)
for i in range(ic):
    for j in range(iab):
        ans.append(AB[j]+C[i])
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])


Measured memory_bytes: 220284
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	vector<int> p(3);
	cin>>p[0]>>p[1]>>p[2];
	cout<<accumulate(p.begin(),p.end(),-*max_element(p.begin(),p.end()));
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	while(!cin.eof()&&!cin.bad()&&!cin.fail()){
		int a=-1,b=-1;
		cin>>a>>b;
		if(!cin.eof()&&!cin.bad()&&!cin.fail()&&a>=0&&b>=0){
		cout<<toString(a+b).size()<<endl;
		}else{
			break;
		}
		
	}
}

Measured memory_bytes: 1212
#include<iostream>
#include<climits>
#include<algorithm>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
	int n, i, j, *a, coun=0, mini;
	cin >> n;
	a = new int(n);
	bool flag=false;
	r(i, n)cin >> a[i];

	r(i, n-1)
	{	flag=false;
		mini = i;
		for(j=i;j<n;j++)
			if (a[j] < a[mini])
			{
					mini = j;
					flag=true;
			}
		if(flag)
		{			
		swap(a[mini],a[i]);
		coun++;
		}
	}
	
	r(i, n)
	{
		if (i)cout << " ";
		cout << a[i];
	}

	cout << endl << coun << endl;
	return 0;
}


Measured memory_bytes: 3096
x1,y1,x2,y2=map(int,input().split())

x3 = x2+(y1-y2)
y3 = y2-(x1-x2)
x4 = x3+(x1-x2)
y4 = y3+(y1-y2)

print(x3,y3,x4,y4)

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

int main() {
    int N, X; cin >> N >> X;
    vector<int> D(N + 1);
    D[0] = 0;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        D[i + 1] = D[i] + x;
    }
    int ans = 0;
    for (int i = 0; i <= N; ++i) {
        if (D[i] <= X) {
        ans++;
        }
    }
cout << ans << endl;
return 0;
}


Measured memory_bytes: 3604
S = input()
 
 
if S[0] != "A":
    print("WA")
 
elif "C" in S:
    a = S.index("C")
 
    if 2 <= a <= len(S)-2:
        S = S.replace("A", "", 1).replace("C", "", 1)
        
        if S.islower():
            print("AC")
        
        else:
            print("WA")
 
    else:
        print("WA")
 
else:
    print("WA")

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

long long int attackCount(long long int H){
	if(H<1)return 0;
	if(H==1)return 1;
	return 2*attackCount(H>>1)+1;
}

int main(){
	long long int H;
	cin >> H;
	cout << attackCount(H) << endl;
	return 0;
}


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

string func(string s){
	for(int i=0;i<s.size();i++){
		if('a'<=s[i] && s[i]<='y')s[i]++;
		else if(s[i]=='z')s[i]='a';
	}
	return s;
}

int main(){
	
	string s;
	while(getline(cin,s)){
		while(true){
			if(s.find("the")!=string::npos)break;
			if(s.find("this")!=string::npos)break;
			if(s.find("that")!=string::npos)break;
			s=func(s);
		}
		cout<<s<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1184
#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];
  }
  sort(A.begin(), A.end());
  cout << A[N - 1] - A[0] << endl;
}


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

int main() {
    int n,k,hoge,piyo,ans=0;
    bool sunuke[200] = {false};
    cin >> n >> k;
    for(int i=0;i<k;i++){
        cin >> hoge;
        for(int j=0;j<hoge;j++){
            cin >> piyo;
            sunuke[piyo-1]=true;
        }
    }
    for(int i=0;i<n;i++){
        if(sunuke[i])ans++;
    }
    cout << n - ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
const int N = 4e4 + 5;
const double inf = 1e9;
using namespace std;

int n, p[N], f[N];
double a[N], b[N], c[N], bit[N];

void update(int i){
    while (i < N){
        bit[i]++;
        i += i&(-i);
    }
}

int get(int i){
    int ans = 0;
    while (i > 0){
        ans += bit[i];
        i -= i&(-i);
    }
    return ans;
}

bool check(double x){
    int cnt = 0;
    for (int i = 0; i < N; i++) bit[i] = 0;
    sort(p+1, p+1+n, [x](int i, int j){return ((-a[i]/b[i] * x + c[i] / b[i]) < (-a[j]/b[j] * x + c[j] / b[j]) || ((-a[i]/b[i] * x + c[i] / b[i]) == (-a[j]/b[j] * x + c[j] / b[j]) && (-a[i]/b[i]) > (-a[j] / b[j])));});
    for (int i = 1; i <= n; i++) f[p[i]] = i;
    sort(p+1, p+1+n, [](int i, int j){return (-a[i]/b[i]) < (-a[j]/b[j]);});
    for (int i = 1; i <= n; i++){
        cnt += (i-1) - get(f[p[i]]);
        update(f[p[i]]);
    }
    return (cnt > ((n*(n-1)/2)/2));
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
        p[i] = i;
    }
    double l = -inf, r = inf;
    for (int i = 1; i <= 100; i++){
        double mid = (l + r) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    cout << l << " ";
    for (int i = 1; i <= n; i++) swap(a[i], b[i]);
    l = -inf, r = inf;
    for (int i = 1; i <= 100; i++){
        double mid = (l + r) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    cout << l << " ";
}


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

int main(void){
	int N, i,v,n;
  int x, y, z;
   int ans[10000];
  
  
  scanf("%d", &N);
   n=sqrt(N);
  for(i = 0;i<=N;i++){
    ans[i] = 0;
  }  

   for(x = 1; x <=n;x++){
    for(y= 1; y<=n; y++){
      	for(z = 1; z<=n; z++){
           v = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
        	if(v<=N){
          		ans[v] = ans[v]+1;
            }
      	}
    }
   }
    for(i = 1; i<=N; i++){
    printf("%d\n", ans[i]);
  }
    return 0;
}

Measured memory_bytes: 2100
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    long a,b,c,i,gcd;

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

    c=(a<b)? a:b;

    for ( i = 1; i <= c; i++)
    {
        if(a%i==0&&b%i==0) gcd=i;
    }

    printf("%ld",(a*b)/gcd);

    return 0;
}

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

typedef long long ll;

ll dp[51][2501];

int main(){
	int n, A;
	cin >> n >> A;
	vector <int> a(n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; i++){
		int x = a[i];
		for (int k = 50; k >= 0; k--){
			for (int y = 0; y <= 2500; y++) {
				if (!dp[k][y]) continue;
				dp[k + 1][y + x] += dp[k][y];
			}
		}
	}
	ll ans = 0;
	for (int k = 1; k <= 50; k++){
		for (int y = 0; y <= 2500; y++){
			if (k * A == y) ans += dp[k][y];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 1e5+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}

ll facpower(ll x){
	if(x==0)
		return 1;
	return ((x%mod)*(facpower(x-1)%mod))%mod;
}



ll n;ss a,b,ans="";
int main() {
    cin >> n >> a >> b;
    rep(i,0,n){
        ans+=a[i];
        ans+=b[i];
    }
    cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// cout << fixed << setprecision(10);
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    int N, odd = 0; cin >> N;
    long long a[100010],a2[100010],a3[100010];
    bool flg = false;
    long long sum = 0;


    for (int i = 0; i < N; i++){
        cin >> a[i];
        if (a[i] == 0) flg = true;
        if (a[i] < 0) odd++;
        sum += abs(a[i]);
    }
    if (flg || (odd % 2 == 0)){
        cout << sum << endl;
        return 0;
    } else {
        //cout << "check" << endl;
        long long mn = MM;
        for (int i = 0; i < N; i++){
            mn = min(abs(a[i]),mn);
        }
        //cout << "sum = " << sum << ", mn = " << mn << endl;
        cout << sum-2*mn << endl;
    }
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int t;
int main(){
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[110];
        int up_ans=0,down_ans=0;
        REP(i,n)cin>>a[i];
        REP(i,n-1){
            if(a[i]>a[i+1])up_ans=max(up_ans,a[i]-a[i+1]);
            else down_ans=max(down_ans,a[i+1]-a[i]);
        }
        cout<<down_ans<<" "<<up_ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String s;
		try (Scanner scanner = new Scanner(System.in)) {
			s = scanner.next();
		}

		boolean canObtain = s.replace("eraser",  " ")
				.replace("erase",   " ")
				.replace("dreamer", " ")
				.replace("dream",   " ")
				.trim()
				.isEmpty();

		if (canObtain) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 28904
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int d; readV(d);

  write("Christmas");
  foreach (_; 0..25-d) write(" Eve");
  writeln;
}


Measured memory_bytes: 256
//写一个将二维数组传入函数的函数
#include<stdio.h>
int main(void)
{
    int h,a,f=0,count;
    scanf("%d%d",&h,&a);
    count=a;
    for(f=1;a*f<h;f++)
        ;
    printf("%d",f);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

struct UnionFind{
	vi par;		//par[i]:=(0以上の場合iの親. 0未満の場合はiを含むグループのサイズ).
	int num;	//num:=(グループの数).
	
	UnionFind(int n):par(n,-1),num(n){}//Constructor.
	
	void init(){fill(ALL(par),-1), num=par.size();}
	int root(int x){return (par[x]<0)?x:par[x]=root(par[x]);}//Recrusion.
	int size(int x){return -par[root(x)];}
	bool same(int x,int y){return root(x)==root(y);}
	bool unite(int x,int y){
		x=root(x), y=root(y);
		if(x==y) return false;//Do nothing.
		if(size(x)<size(y)) swap(x,y);//Merge technique(x<-y).
		par[x]+=par[y];
		par[y]=x;
		num--;
		return true;
	}
};

int main(){//Refering other editorials.
	int n,m;
	cin>>n>>m;
	
	vi p(n);
	REP(i,n){
		cin>>p[i];
		p[i]--;
	}
	
	UnionFind uf(n);
	REP(i,m){
		int x,y;
		cin>>x>>y;
		x--, y--;
		uf.unite(x,y);
	}
	
	int ans=0;
	REP(i,n){
		if(uf.root(i)==uf.root(p[i])) ans++;
	}
	
	cout<<ans<<endl;
}

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

int main() {
  int n,x;
  cin >> n;
  map<int, int> m;
  REP(i,n) {
    cin >> x;
    m[x]++;
    if (m[x] >= 2) { cout << "NO" << endl; return 0; }
  }
  cout << "YES" << endl;
}

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

string ask(int i) {
    cout << i << endl;
    string s;
    cin >> s;
    if (s == "Vacant") {
        exit(0);
    }
    return s;

}
void solve (int i, int j, string s1, string s2) {
    int mid = (i+j) >> 1;
    string s0 = ask(mid);
    if ((s0 == s1 && (mid-i)%2 != 0) || (s0 != s1 && (mid-i)%2 == 0)) {
        solve (i, mid, s1, s0);
    }
    else solve(mid, j, s0, s2);

}
int main() {
    int n;
    cin >> n;
    string s1 = ask(0);
    string s2 = ask(n-1);
    solve(0, n-1, s1, s2);
    return 0;
}

Measured memory_bytes: 852
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
	if ( ch == 'A') return 1;
	else if ( ch == 'C') return 2;
	else if ( ch == 'G') return 3;
	else if ( ch == 'T') return 4;
	else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for ( i = 0; i < strlen(str); i++ ){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
	long long key = key, i, h;
		key = getKey(str);
		for (i = 0;; i++) {
			h = (h1(key) + i * h2(key)) % M;
			if (strcmp(H[h], str) == 0) {
				return 1;
			}else if (strlen(H[h]) == 0) {
				return 0;
			}
		}
		return 0;
}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) {
			return 1;
		}else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i, n, h;
	char str[L], com[9];
	for ( i = 0; i < M; i++ ) H[i][0] = '\0';
		
	scanf("%d", &n);
		
	for ( i = 0; i < n; i++ ){
		scanf("%s %s", com, str);
	
		if ( com[0] == 'i' ){
	  	  	insert(str);
		} else {
	   	 	if (find(str)){
			printf("yes\n");
	    	} else {
			printf("no\n");
	    	}
		}
	}

	return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i=0; i<n; i++) cin >> l[i];
    sort(l.begin(), l.end());

    int ans = 0;
    for (int i=0; i<n-2; i++) {
        for (int j=i+1; j<n-1; j++) {
            for (int k=j+1; k<n; k++) {
                if (l[k] < l[i]+l[j]) ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s;
    t = "";
    for(int i=0; i<s.size(); i++)
        if(s[i] != 'x') t.push_back(s[i]);

    for(int i=0; i<t.size(); i++){
        if(t[i] != t[t.size()-1-i]){
            cout << -1 << endl;
            return 0;
        }
    }
    int b = t.size() / 2;
    int L, R;
    if(t.size() % 2 == 1){
        L = b; R = b;
    }else{
        L = b-1; R = b;
    }
    vector<int> v(t.size()+1);
    int pos = 0;
    int cnt = 0;
    s.push_back('o');
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'x') cnt++;
        else{
            v[pos] = cnt;
            cnt = 0;
            pos++;
        }
    }


    int ans = 0;
    for(int i=0; i<v.size()/2; i++){
        ans += abs(v[i] - v[v.size()-1-i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 976
#include <stdio.h>
int main(){
  long	n, a, max=0, min=1000000001;
  
  scanf("%ld",&n);
  for(int i=0; i<n; i++){
    scanf("%ld", &a);
    if( a < min ){ min = a; }
    if( a > max ){ max = a; }
  }
  printf("%ld\n", max-min);
  return 0;
}

Measured memory_bytes: 1732
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto K = RD;
	auto A = RDA;

	auto index = new long[](N);
	foreach (i; 0..N) index[i] = i;
	foreach (_; 0..K)
	{
		long[] nIndex;
		BinaryHeap!(Array!long, "a > b") heap1, heap2;
		auto nA = new long[](index.length);
		nA[] = 1;
		long cnt1, cnt2;
		foreach (ii, i; index)
		{
			while (!heap1.empty)
			{
				if (heap1.front >= i) break;
				heap1.removeFront;
			}
			nA[ii] += i - cnt1;
			nA[ii] += heap1.length;
			heap1.insert(A[i] + i);
			++cnt1;
		}
		debug writeln(nA);
		foreach_reverse (ii, i; index)
		{
			while (!heap2.empty)
			{
				if (heap2.front >= (N-i-1)) break;
				heap2.removeFront;
			}
			nA[ii] += (N-i-1) - cnt2;
			nA[ii] += heap2.length;
			heap2.insert(A[i] + (N-i-1));
			++cnt2;
		}
		debug writeln(nA);
		foreach (ii, i; index)
		{
			A[i] = nA[ii];
			if (A[i] < N)
				nIndex ~= i;
		}
		index = nIndex;
	}

	A.map!(to!string).join(" ").writeln;
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 29292
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

// GCC __gcd(long long A, long long B)

ll gcd(ll a, ll b){
  if(a == 0) return b;
  return gcd(b%a, a);
}

ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}



int main(){
  ll A, B;

  cin >> A >> B;

  ll g = gcd(A, B);

  int counter = 0;

  for(ll i=2; i*i<=g; i++){
    bool ok = false;
    while (g % i == 0) {
      ok = true;
      g /= i;
    }
    counter += ok;
  }

  counter++;
  counter += g > 1;

  cout << counter << endl;

  return 0;
}


Measured memory_bytes: 256
def dfs(nums, length, right_num):
    max_score = 0
    if length == N:
        score = 0
        for a,b,c,d in req:
            if nums[b] - nums[a] == c:
                score += d
        return score
    else:
        for num in range(right_num,M+1):
            new_nums = nums + [num]
            score = dfs(new_nums,length+1,num)
            max_score = max(max_score,score)
    return max_score        

N,M,Q = map(int,input().split())
req = [list(map(int,input().split())) for _ in range(Q)]
print(dfs([-1],0,1))

Measured memory_bytes: 80148
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

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

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

int main() {

  ll a, b, n;
  cin >> a >> b >> n;

  ll res;
  if(b-1<=n) {
    res = (a*(b-1))/b - a*((b-1)/b);
  }else {
    res = (a*(n))/b - a*((n)/b);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3620
N,K=gets.chomp.split(' ').map{|n| n.to_i}
if(N==2 && K>0)
	puts -1
	exit(0)
elsif(N==2)
	puts "1"
	puts "1 2"
	exit(0)
end
max = (N-1)*(N-2)/2
if(max < K)
	puts -1
	exit(0)
end
M = N-1+(max-K)
puts M
for i in 1..(N-1)
	puts "#{1} #{1+i}"
end
cnt = 0
for i in 2..(N-1)
	for j in (i+1)..(N)
		if(cnt == max-K)
			exit(0)
		end
		puts "#{i} #{j}"
		cnt += 1
	end
end


Measured memory_bytes: 1788
nb = int(input())
totale = 0
t = []
for i in range(nb):
   a = int(input())
   totale = totale + a
   t.append(a)
if totale % 10 == 0:
   m = 1000000
   for i in range(nb):
      if (t[i]) % 10 != 0:
         m = min(m,t[i])
   if m%10 != 0:
      print(totale-m)
   else:
      print(0)
else:
   print(totale)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
static decimal result;
static List<int>[] s;
  static decimal L,R;
    static void Main()
    {
      
      //N=int.Parse(Console.ReadLine());
      string[] tmp=Console.ReadLine().Split(' ');
      L=decimal.Parse(tmp[0]);
      R=decimal.Parse(tmp[1]);
if(R-L>2019){Console.WriteLine(result.ToString());}
      else{
        result=2020;
for(decimal i=L;i<=R;i++){
for(decimal j=i+1;j<=R;j++){
if(result>(i*j)%2019){result=(i*j)%2019;}
}  
}

        Console.WriteLine(result.ToString());
      }
      
                    //Console.WriteLine(result.ToString());
    }

static void Read()
{
  string[] tmp=Console.ReadLine().Split(' ');
//for(int i=0;i<N;i++){s.Add(int.Parse(tmp[i]));}
}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
ll arr[MAX];
int n;
ll solve(ll val){
	ll res=0;
	for(int i=0;i<n;i++)
		res=res+abs(arr[i]-val);
	return res;
}
int main() 
{
	string s;
	int n;
	cin>>n;
	cin>>s;
	if((int)(s.size()<=n))
		cout<<s;
	else{
		string ans="";
		for(int i=0;i<n;i++)
			ans=ans+s[i];
		ans=ans+"...";
		cout<<ans;
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int x,y;
    cin >> x >> y;
    rep(i, 101){
        rep(j, 101){
            if(i + j == x && i * 2 + j * 4 == y){
                print("Yes");
                return 0;
            }
        }
    }
    print("No");

}



Measured memory_bytes: 3644
# coding: utf-8
# Your code here!

while True:
   n = int(input())
   if n == 0: break
   
   c = 0
   while n != 1:
      if n % 2 == 0:
         n /= 2
      else:
         n = n * 3 + 1
      c += 1
   print(c)
      



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
set<int> check1[26], check2[26];
char s[200005], t[200005];

int main(){
	scanf("%s%s", s+1, t+1);
	int n = strlen(s+1);
	for(int i=1;i<=n;i++){
		check1[t[i]-'a'].insert(s[i]);
		check2[s[i]-'a'].insert(t[i]);
	}
	for(int i=0;i<26;i++){
		if(check1[i].size() > 1) return !printf("No\n");
		if(check2[i].size() > 1) return !printf("No\n");
	}
	printf("Yes\n");
}

Measured memory_bytes: 640