akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, k) = readIntegerList()
    val set = mutableSetOf<Int>()
    repeat(k) {
        readInteger()
        set += readIntegerList()
    }
    println(n - set.size)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 39524
#include<stdio.h>

int main(void){
    unsigned long capa[5], N, totaltime, mincapa;
    int i, minnum=0;

    scanf("%lu", &N);
    getchar();

    for(i=0; i<5; i++){
        scanf("%lu", &capa[i]);
        getchar();
    }
    mincapa = capa[0];
    for(i=1; i<5; i++){
        if(capa[i] < mincapa){
             mincapa = capa[i];
             minnum = i;
        }
    }
    if(N < mincapa) totaltime = 5;
    else if(N % mincapa == 0){
        totaltime = (N / mincapa) + 4;
    }else {
        totaltime = (N / mincapa) + 5;
    }

    printf("%lu", totaltime);

    return 0;
}

Measured memory_bytes: 128
#coding:utf-8

N = int(input())

dik = {0:"a",
       1:"b",
       2:"c",
       3:"d",
       4:"e",
       5:"f",
       6:"g",
       7:"h",
       8:"i",
       9:"j",
       10:"k",
       11:"l",
       12:"m",
       13:"n",
       14:"o",
       15:"p",
       16:"q",
       17:"r",
       18:"s",
       19:"t",
       20:"u",
       21:"v",
       22:"w",
       23:"x",
       24:"y",
       25:"z"}

x = 0
ans = ""
n = N

while n > 0:
    n = n - 1
    x = n % 26
    ans += dik[x]
    n = n // 26

ans = ans[::-1]

print(ans)

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int X;
    cin >> X;
    int cnt = X / 100;
    int amri = X % 100;
    if(amri > cnt * 5 ){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int gcd;
		gcd = gcd(x, y);
		System.out.println(gcd);
	}

	public static int gcd(int x, int  y){
		int r;
		if(x < y){
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0){
			r = x % y;
			x = y;
			y = r;
		}
		return x;
	}

	public static int gcdB(int x, int y){
		int n = Math.min(x, y);
		for(int d = n; d > 0; d--){
			if((x % d == 0) && (y % d == 0)){
				return d;
			}
		}
	return -1;
	}
}

Measured memory_bytes: 26260
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;

// 文字列Sが与えられた時に、LCP配列を返す
// Zalgoの計算量はO(n), 全体でO(n^2)
vector<int> Zalgo(const string &S) {
  int N = (int)S.size();
  vector<int> res(N);
  res[0] = N;
  int i = 1, j = 0;
  while (i < N) {
    while (i+j < N && S[j] == S[i+j]) ++j;
    res[i] = j;
    if (j == 0) {
      ++i;
      continue;
    }
    int k = 1;
    while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
    i += k, j -= k;
  }
  return res;
}

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

  int N;
  string S;
  cin >> N >> S;

  int res = 0;
  rep(i, N) {
    string T = S.substr(i); // i番目以降の文字列
    auto lcp = Zalgo(T);

    rep(j, T.size()) {
      int l = min(lcp[j], j);
      res = max(res, l);
    }
  }
      
  cout << res << endl;

  return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A, B, C;
	cin >> A >> B >> C;
	set<int> vset;
	vset.insert(A);
	vset.insert(B);
	vset.insert(C);

	cout << SZ(vset) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
A = list(map(int, readline().split()))

d1 = {}
d2 = {}
for n in range(1, N+1):
    x1 = n + A[n-1]
    if x1 in d1:
        d1[x1] += 1
    else:
        d1[x1] = 1
    
    x2 = n - A[n-1]
    if x2 in d2:
        d2[x2] += 1
    else:
        d2[x2] = 1

ans = 0
for d in d1:
    if d in d2:
        ans += (d1[d] * d2[d])
print(ans)

Measured memory_bytes: 56444
#include<iostream>
using namespace std;
int main(){
while(1){
	int n,A,B,a,b;
	cin>>n;
	if(n == 0)break;
	A=0;
	B=0;
		for(int i =0; i <n;i++){
			cin >>a>>b;
		if(a>b){
		A +=(a+b);
		}
		else if(a<b){
		B +=(a+b);
		}
		else {
      A +=a;
	  B +=b;
		}
		}
		cout<<A<<" "<<B<<endl;
   }
return 0;
}


Measured memory_bytes: 2964
L, R = map(int,input().split())

min = 2020

if (R - L) > 2019:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i * j) % 2019
            if tmp < min:
                min = tmp
    print(min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
void m_mul(vector<vector<vector<int>>> &table,int n,int d,int m){
    int i,j,k;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            table[d+1][i][j]=0;
            for(k=0;k<n;k++){
                table[d+1][i][j]+=table[d][i][k]*table[d][k][j];
            }
            table[d+1][i][j]%=m;
        }
    }
}

vector<int> mul(vector<int> A, vector<vector<int>> table,int n,int m){
    int i,j;
    vector<int> ans(n);
    for(i=0;i<n;i++){
        ans[i]=0;
        for(j=0;j<n;j++){
            ans[i]+=A[j]*table[i][j];
        }
        ans[i]%=m;
    }
    return ans;
}

int main(void){
    int n,m,a,b,c,t;
    while(cin>>n>>m>>a>>b>>c>>t,n){
        int i;
        vector<vector<vector<int>>> table(31,vector<vector<int>>(50,vector<int>(50)));
        for(i=0;i<n;i++){
            if(i-1>=0) table[0][i][i-1] = a;
            table[0][i][i] = b;
            if(i+1<n) table[0][i][i+1] = c;
        }
        int d=0;
        for(i=2;i<=t;i*=2){
            m_mul(table,n,d,m);
            d++;
        }
        vector<int> ans(n);
        for(i=0;i<n;i++){
            cin>>ans[i];
        }
        for(i=0;t!=0;t/=2,i++){
            if(t%2==1){
                ans=mul(ans,table[i],n,m);
            }
        }
        for(int z=0;z<n;z++){
            cout<<ans[z];
            if(z+1==n){
                cout<<endl;
            }else{
                cout<<' ';
            }
        }
    }
}



Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        test();
        Scanner sc = new Scanner(System.in);
        int h, w;
        int[][] directions = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
        String[] input;
        input = sc.nextLine().trim().split(" ");
        h = Integer.parseInt(input[0]);
        w = Integer.parseInt(input[1]);

        int[][] map = new int[h][w];
        for (int i = 0; i < h; i++) {
            input = sc.nextLine().trim().split("");
            for (int j = 0; j < w; j++) {
                map[i][j] = input[j].equals("#") ? 1 : 0;
            }
        }

        int x = 0;
        int y = 0;
        int nx = 0;
        int ny = 0;
        int count;
        String ans = "Possible";
        outer:
        while (true) {
            map[y][x] = 0;
            count = 0;
//            System.out.println(Arrays.deepToString(map));
            for (int[] direction : directions) {
                if ( y + direction[0] >= 0 && y + direction[0] < map.length &&
                        x + direction[1] >= 0 && x + direction[1] < map[0].length) {
                    if (map[y + direction[0]][x + direction[1]] == 1) {
                        nx = x + direction[1];
                        ny = y + direction[0];
                        if (direction[0] < 0 || direction[1] < 0) {
                            ans = "Impossible";
//                            System.out.println("here");
//                            System.out.println(nx + " " + ny);
                            break outer;
                        }
                        count++;
                    }
                }
            }
            if (count > 1) {
                ans = "Impossible";
                break;
            }
            x = nx;
            y = ny;
            if (x == map[0].length - 1 && y == map.length - 1
                    && map[y-1][x] == 0 && map[y][x-1] == 0) break;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 9684
N, M = map(int, input().split())
C = [int(x) for x in input().split()]
C.sort()
A = [0 for _ in range(N + 1)]
for c in C:
    if c > N:
        break
    A[c] = 1
for i in range(1, N + 1):
    pos = []
    for c in C:
        if i - c < 0:
            break
        pos.append(A[i - c])
    A[i] = min(pos) + 1
print(A[-1])



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

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

char H[M][L];
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;
}

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 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 find(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)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: 14280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    // printf("%d\n", N);
    return 0;
}

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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	ll arr[30];
	memset(arr,0,sizeof(arr));
	for(int i=0;i<n;i++) arr[s[i]-'a']++;
	ll ans=1;
	for(int i=0;i<26;i++)
	{
		if(arr[i])
		{
			ans*=(1LL+arr[i]);
			ans%=Mod;
		}
	}
	cout<<(ans-1)%Mod;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include "string.h"
#include <algorithm>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <queue>
using namespace std;

int main() {

    int n;
    cin>>n;
    int k = 1;
    int i = 1;

    while (k < n) k += ++i;

    if (k == n) {
        vector<vector<int> > v(i+1, vector<int>(i));
        int k = 1;
        for (int j=0; j<=i; j++) {
            for (int t=j; t<i; t++) v[j][t] = k++;
            for (int t=0; t<j; t++) v[j][t] = v[t][j-1];
        }

        cout<<"Yes"<<endl;
        cout<<i+1<<endl;
        for (int j=0; j<=i; j++) {
            cout<<v[j].size()<<" ";
            for (int t=0; t<i; t++) cout<<v[j][t]<<" ";
            cout<<endl;
        }
    }
    else {
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 2176
import sys
sys.setrecursionlimit(10**5)
def solve():
    N, K = map(int,input().split())
    MOD = 10 ** 9 + 7
    ans = []
    for i in range(1,K+1):
        com1 = COM(K-1,i-1,MOD)
        if N-K-(i-1) < 0:
            ans.append(0)
            continue
        com2 = COM(N-K+1,N-K-(i-1),MOD)
        ans.append(com1*com2%MOD)
    
    print(*ans,sep='\n')

def COM(n,r,MOD):
    return calcNumerator(n,r,MOD) // calcDenominator(r,MOD)

def calcNumerator(n,r,MOD):
    res = 1
    for i in range(r):
        res *= n % MOD
        n -= 1
    return res

def calcDenominator(r,MOD):
    res = 1
    a = r
    for i in range(r):
        res *= a % MOD
        a -= 1
    return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 45532
n = gets.chomp.to_i
even_ = 0
odd_ = 0
gets.chomp.split(" ").each do |x|
  x = x.to_i
  if x.even? then
    even_ += 1
  else
    odd_ += 1
  end
end
if odd_.odd? then
  puts "NO"
else
  puts "YES"
end


Measured memory_bytes: 8708
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int a, b;
    cin >> a >> b;
    vi v;
    v.resize(a);
    rep(i, a)
    {
        cin >> v[i];
    }
    sort(all(v));
    int ans = 0;
    rep(i, b)
    {
        ans += v[i];
    }
    cout << ans << endl;

    return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000
int N,M,L;
int K[MAX_N];
int ans;
vector<char> C;
bool bool_ans;

int solve(void) {

  ans = (N * 3 + M)/ 2;
  return ans;
}

int main (void)
{
  cin >> N >> M;

  ans = solve();
  put(ans);

  return 0;
}


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

int main(){
    int n,a;
    long long int sum=0;
    cin >>n>>a;
    long long int ar [n];
    for (int i=0;i<n;i++){
        cin >> ar[i];
    }
    sort(ar, ar+n); 
    for (int i=0;i<n-a;i++){
        sum = sum + ar[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int minj,i,j,a=0,count=0;
  int N,A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<=N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj]){
	minj=j;
	
      }
    }
    if(minj!=i){
    a=A[i];
    A[i]=A[minj];
    A[minj]=a;
    
    count++;
    }
    
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
}
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int n;
	cin >> n;
	int sol = 0;
	
	for (int a = 1; a < n; a++) {
		sol += (n - 1)/a;		
	}

	cout << sol << '\n';
}


Measured memory_bytes: 3616
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	ans := 0
	a, b, c := 0, 0, 0
	for i := 0; i < n; i++ {
		s := scanString()
		ans += strings.Count(s, "AB")
		if s[0] == 'B' && s[len(s)-1] == 'A' {
			c++
		} else if s[0] == 'B' {
			b++
		} else if s[len(s)-1] == 'A' {
			a++
		}
	}

	ans += max(0, c-1)
	if c>0 {
		if a != 0 {
			ans++
			a--
		}
		if b != 0 {
			ans++
			b--
		}
	}
	ans += min(a, b)
	fmt.Fprintln(wr, ans)

}


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


int main(){
  string str;
  cin >>str;
  if (str.size()==1){
    cout << 0 <<endl;
    return 0;
  }
  int cnt1=0;
  int cnt2=0;
  for(int i=0; i<str.size(); i++){
    if (i%2==0 && str[i]=='1') cnt1++;
    if (i%2==1 && str[i]=='0') cnt1++;
  }
  for(int i=0; i<str.size(); i++){
    if (i%2==0 && str[i]=='0') cnt2++;
    if (i%2==1 && str[i]=='1') cnt2++;
  }
  int ans=min(cnt1, cnt2);
  cout << ans <<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
using namespace std;
multiset <int> mp;
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i){
		int x;
		cin >> x;
		mp.insert(x);
	}
	int ans = 0;
	while (! mp.empty()){
		multiset <int> :: iterator it = mp.end();
		it --;
		int x = *it;
		mp.erase(it);
		for (int i = 30; i; -- i){
			int sum = 1 << i;
			if (mp.find(sum - x) != mp.end()){
				++ ans;
				mp.erase(mp.find(sum - x));
				break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool ana(string s)
{
    int ct[26]={};
    rep(i,s.size()) ++ct[s[i]-'A'];

    rep(i,26)
    {
        if(i+'A'=='A' || i+'A'=='N')
        {
            if(ct[i]!=2) return false;
        }
        else if(i+'A'=='I' || i+'A'=='D' || i+'A'=='U' || i+'A'=='Y')
        {
            if(ct[i]!=1) return false;
        }
        else
        {
            if(ct[i]!=0) return false;
        }
    }
    return true;
}

int main()
{
    string d;
    cin >>d;

    int D = d.size();
    int i = 0;
    string ans = "";
    while(i<D)
    {
        if(i+7<D && ana(d.substr(i,8)))
        {
            ans += "AIZUNYAN";
            i += 8;
        }
        else ans += d[i++];
    }

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

Measured memory_bytes: 3204
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n; in(n);
  vector<ll> H(n);
  loop(i,0,n) in(H[i]);
  ll cur = H[0];
  int cnt = 0;
  int max_ = 0;
  loop(i,1,n) {
    if (cur >= H[i]) {
      max_ = max(++cnt, max_);
    } else {
      cnt = 0;
    }
    cur = H[i];
  }
  print(max_);
  return 0;
}


Measured memory_bytes: 3948
N = int(input())
S = input()
rcount = 0
gcount = 0
bcount = 0
for i in range(N):
  if S[i] == 'R':
    rcount += 1
  elif S[i] == 'G':
    gcount += 1
  elif S[i] == 'B':
    bcount += 1

total = rcount * gcount * bcount
count = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    k = 2*j - i
    if k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      count += 1
print(total - count)


Measured memory_bytes: 68280
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll tot,n,a[maxn],c,k,d[maxn],f;

int main()
{
	n=read(); rep(i,1,n) a[i]=read(),tot+=a[i]; c=n*(n+1)/2;
	if(tot%c!=0) return puts("NO"),0; k=tot/c;
	rep(i,2,n) d[i]=a[i]-a[i-1]; d[1]=a[1]-a[n];
	rep(i,1,n) if((k-d[i])%n!=0||d[i]>k) f=1;
	printf(f?"NO":"YES");
	return 0;
}

Measured memory_bytes: 5196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			
			int n = Integer.parseInt(tmpArray[0]);
			int m = Integer.parseInt(tmpArray[1]);
			
			if(n == 0 && m == 0){
				break;
			}
			
			int[] code = new int[m];
			
			for(int i = 0; i < m; i++){
				code[i] = Integer.parseInt(br.readLine());
			}
			
			int[] signal = new int[n];
			
			for(int i = 0; i < n; i++){
				signal[i] = Integer.parseInt(br.readLine());
			}
			
			int[][] dp = new int[256][n + 1];
			//init
			for(int i = 0; i <= 255; i++){
				Arrays.fill(dp[i], Integer.MAX_VALUE);
			}
			
			//1つ目のシグナルについて初期化
			dp[128][0] = 0;
			
			for(int i = 1; i <= n; i++){
				for(int j = 0; j <= 255; j++){
					if(dp[j][i - 1] == Integer.MAX_VALUE){
						continue;
					}
					
					for(int k = 0; k < m ; k++){
//						System.out.println(i+" "+j+" "+k);
						int tmpValue = Math.min(255, Math.max(0, j + code[k]));
//						System.out.println("new signal "+ tmpValue);
						dp[tmpValue][i] = Math.min(dp[tmpValue][i], dp[j][i - 1] + (int)Math.pow((tmpValue - signal[i - 1]), 2));
					}
				}
			}
			//debug
			
//			for(int i = 1; i <= n; i++){
//				int tmp = Integer.MAX_VALUE;
//				for(int j = 0; j <= 255; j++){
//					tmp = Math.min(tmp, dp[j][i]);
//				}
//				
//				System.out.print(tmp+" ");
//			}
//			System.out.println();
			
			int result = Integer.MAX_VALUE;
			
			for(int i = 0; i <= 255 ; i++){
				result = Math.min(result, dp[i][n]);
//				System.out.println("i = "+i+" dp = "+dp[i][n]);
			}
			
			System.out.println(result);
		}
	}

}



Measured memory_bytes: 75252
#include <bits/stdc++.h>
using namespace std;
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

int32_t main()
{
    speed upp
    int n,k;
    cin>>k>>n;
    int a[n+1];
    f(i,1,n)
        cin>>a[i];
    int x=a[n]-a[1];
    f(i,2,n)
        x=min(x,k-a[i]+a[i-1]);
    cout<<x;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
  int n;
  int debt = 100000;
  scanf("%d",&n);
  while ( n-- > 0 ) {
    debt *= 1.05;
    if ( debt % 1000 ) {
      debt /= 1000;
      debt += 1;
      debt *= 1000;
    }
  }
  printf("%d\n", debt);
  return 0;
}
    

Measured memory_bytes: 592
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
    string a;
    cin >> a;
    if (a == "RRR") cout << '3' << "\n";
    if (a == "RRS" || a == "SRR") cout << '2' << "\n";
    if (a == "RSS" || a == "SRS" || a == "SSR"||a=="RSR") cout << '1' << "\n";
    if(a=="SSS") cout << '0' << "\n";


    return 0;
}

Measured memory_bytes: 3124
import java.util.*;
import java.util.function.BiConsumer;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();    
        int X = stdIn.nextInt();    
        int Y = stdIn.nextInt();    
        stdIn.close();
        X--; Y--;
        int INF = 1001001001;
        int[] ans = new int[N];
        for (int sv = 0; sv < N; sv++) {
            int[] dist = new int[N];
            for (int i = 0; i < N; i++) {
                dist[i] = INF;
            }
            Queue<Integer> queue = new ArrayDeque<>();
            BiConsumer<Integer, Integer> push = (v, d) -> { 
                if (dist[v] != INF) return;
                dist[v] = d;
                queue.add(v);
            };
            push.accept(sv, 0);
            while(queue.peek() != null) {
                int v = queue.poll();
                int d = dist[v];
                if (v - 1 >= 0) push.accept(v - 1, d + 1);
                if (v + 1 < N) push.accept(v + 1, d + 1);
                if (v == X) push.accept(Y, d + 1);
                if (v == Y) push.accept(X, d + 1);
            }
            for (int i = 0; i < N; i++) {
                ans[dist[i]]++;
            }
        }
        for (int i = 0; i < N; i++) {
            ans[i] /= 2;
        }
        for (int i = 1; i <= N - 1; i++) {
            System.out.println(ans[i]);        
        }
    }
}

Measured memory_bytes: 93028
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;
	return 0;
}

Measured memory_bytes: 256
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  const [x, y] = content
    .trim()
    .split(' ')
    .map(n => +n);
  console.log(gcd(x, y));
});

const gcd = (x, y) => {
  if (x === 0 || y === 0) {
    return x || y;
  }

  // ensure x >= y
  if (x < y) {
    const tmp = x;
    x = y;
    y = tmp;
  }

  return gcd(y, x % y);
};


Measured memory_bytes: 15332
#include <iostream>
#include <vector>
#include <map>

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


struct mint{
    static const long long MOD = 998244353LL;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    map<ll, ll> num;
    REP(i, n){
        cin >> d.at(i);
        num[d.at(i)]++;
    }
    if(d.at(0) != 0 || num[0] > 1){
        cout << 0 << endl;
        return 0;
    }
    mint ans = 1;
    for(auto it = num.begin(); it != num.end(); ++it){
        if(it->first == 0){ continue; }
        REP(j, it->second){
            ans *= num[it->first - 1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
N = list(input())
M = [ int(i) for i in N[::-1] ]
M.append(0)
c = 0

for i in range(len(M)-1):
    if M[i] >= 6 or ( M[i] >=5 and M[i+1] >= 5):
        M[i+1] += 1
    c += min(M[i],10-M[i])
c += M[len(M)-1]

print(c)

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

int main() {
  int n,k,ans = 0;
  cin >> n >> k;
  vector<int> data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  for(int i = 0;i < k;i++){
    ans += data.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a = input()
b, c = '01' <= a[:2] <= '12', '01' <= a[2:] <= '12'

if b and c:
    answer = 'AMBIGUOUS'
elif not(b or c):
    answer = 'NA'
elif b:
    answer = 'MMYY'
elif c:
    answer = 'YYMM'
print(answer)

Measured memory_bytes: 2940
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, a;

	cin >> n;

	vector<ll> v;

	REP(i, n) {
		cin >> a;
		v.push_back(a);
	}

	vector<ll> ans(n, 0);
	ll x = n / 2 + 1;

	FOR(i, x, n) {
		ans[i] = v[i];
	}

	for (int i = x - 1; i >= 0; i--) {
		ll sum = 0;
		ll now = i + 1;
		ll cnt = 2;
		while (now * cnt <= n) {
			sum += ans[now * cnt - 1];
			cnt++;
		}
		if (sum % 2 == v[i]) {
			ans[i] = 0;
		}
		else {
			ans[i] = 1;
		}
	}

	ll cnt = 0;
	vector<ll> ans2;

	REP(i, n) {
		if (ans[i] > 0) {
			cnt++;
			ans2.push_back(i + 1);
		}
	}

	cout << cnt << endl;

	if (cnt != 0) {
		cout << ans2 << endl;
	}
}

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

int main(){
    int k,a,b;
    cin >> k>> a >> b;
    if(a%k==0||b%k==0){
        cout <<"OK" << endl;
        return 0;
    }
    if(a/k-b/k==0){
        cout<< "NG" <<endl;
    }
    else{
        cout << "OK" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import sys

input = sys.stdin.buffer.readline


class FenwickTree:
    """FenwickTree (Binary Indexed Tree, 0-index)

    Queries:
        1. add(i, val): add val to i-th value
        2. sum(n): sum(bit[0] + ... + bit[n-1])

    complexity: O(log n)

    See: http://hos.ac/slides/20140319_bit.pdf
    """

    def __init__(self, a_list):
        self.N = len(a_list)
        self.bit = a_list[:]
        for _ in range(self.N, 1 << (self.N - 1).bit_length()):
            self.bit.append(0)
        for i in range(self.N-1):
            self.bit[i | (i+1)] += self.bit[i]

    def add(self, i, val):
        while i < self.N:
            self.bit[i] += val
            i |= i + 1

    def sum(self, n):
        ret = 0
        while n >= 0:
            ret += self.bit[n]
            n = (n & (n + 1)) - 1
        return ret

    def query(self, low, high):
        return self.sum(high) - self.sum(low)


def yosupo():
    # https://judge.yosupo.jp/problem/point_add_range_sum
    _, Q = map(int, input().split())
    fwt = FenwickTree([int(x) for x in input().split()])
    for _ in range(Q):
        type_, l, r = map(int, input().split())
        if type_ == 0:
            fwt.add(l, r)
        else:
            print(fwt.query(l-1, r-1))


def aoj():
    # https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_B
    N, Q = map(int, input().split())
    fwt = FenwickTree([0] * N)
    for _ in range(Q):
        type_, l, r = map(int, input().split())
        if type_ == 0:
            fwt.add(l-1, r)
        else:
            print(fwt.query(l-2, r-1))


if __name__ == "__main__":
    yosupo()
    # aoj()


Measured memory_bytes: 130596
# 2019/04/16
# AtCoder Beginner Contest 096 - C

h, w = map(int, input().split())
s = list()
for i in range(h):
    ws = input()
    wsl = list()
    for j in range(w):
        wsl.append(ws[j])
    s.append(wsl)

ans = "Yes"

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            if i == 0:
                if j == 0:
                    if s[i][j+1] != "#" and s[i+1][j] != "#":
                        ans = "No"
                        break
                elif j == w-1:
                    if s[i][j-1] != "#" and s[i+1][j] != "#":
                        ans = "No"
                        break
                else:
                    if s[i][j-1] != "#" and s[i+1][j] != "#" and s[i][j+1] != "#":
                        ans = "No"
                        break
            elif i == h - 1:
                if j == 0:
                    if s[i][j+1] != "#" and s[i-1][j] != "#":
                        ans = "No"
                        break
                elif j == w-1:
                    if s[i][j-1] != "#" and s[i-1][j] != "#":
                        ans = "No"
                        break
                else:
                    if s[i][j-1] != "#" and s[i-1][j] != "#" and s[i][j+1] != "#":
                        ans = "No"
                        break
            else:
                if j == 0:
                    if s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                        ans = "No"
                        break
                elif j == w-1:
                    if s[i][j-1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                        ans = "No"
                        break
                else:
                    if s[i][j-1] != "#" and s[i-1][j] != "#" and s[i][j+1] != "#" and s[i+1][j] != "#":
                        ans = "No"
                        break
    if ans == "No":
        break

print(ans)


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  if(a > b || (a != b && n < 2)) {
    cout << 0 << endl;
    return 0;
  }
  cout << (b-a)*(n-2) +1 << endl;
}

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

long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

vector<pair<long long int, long long int>> prime_factorize(long long int n){// (prime, power)'s vector
    
    vector<pair<long long int, long long int>> prime_power;
    for (long long int p=2; p*p<=n; p++) {
        if(n % p != 0) continue;// break and proceed to p+1

        int power = 0;
        while(n % p == 0){
            power += 1;
            n /= p;
        }
        prime_power.push_back(make_pair(p, power));
    }

    // n has been divided by all primes (with power) smaller than sqrt(n)
    if(n != 1){
        prime_power.push_back(make_pair(n, 1));
    }

    return prime_power;
}

int main(){
    long long int a, b;
    cin >> a >> b;
    
    cout << prime_factorize(gcd(a,b)).size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int b[5000],n,m;
short c[5000][5000];
vector<int> a[1001];
int fn(int p,int q){  
  if(p==m)
    return 0;
  vector<int>::iterator it=upper_bound(a[b[p]].begin(),a[b[p]].end(),q);
  if(it==a[b[p]].end())
    return 0;
  if(c[p][*it])
    return c[p][*it];
  return c[p][*it]=fn(p+1,*it)+1;
}
int main(){
  int i;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;++i){
    int p;
    scanf("%d",&p);
    a[p].push_back(i);
  }
  for(i=0;i<m;++i)
    scanf("%d",b+i);
  int mx=0;
  for(i=0;i<m-mx;++i)
    mx=max(mx,fn(i,-1));
  printf("%d\n",mx);
  return 0;
}

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

def main():
    N=int(input())
    A=[0]+list(map(int,input().split()))+[0]
    S=0
    for i in range(N+1):
        S+=abs(A[i+1]-A[i])
    for i in range(N):
        print(S-abs(A[i+1]-A[i])-abs(A[i+2]-A[i+1])+abs(A[i+2]-A[i]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 64620
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self,x):
        if(self.parents[x] < 0):
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def size(self, x):
        return self.parents[ self.find(x) ] * -1

    def same(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)
        return (x_root == y_root)

    def union(self,x,y):
        x_root = self.find(x)
        y_root = self.find(y)
        if(x_root == y_root):
            return

        #　番号が大きい方を新しい根にする
        if( x_root > y_root ):
            self.parents[x_root] += self.parents[y_root]
            self.parents[y_root] = x_root
        else:
            self.parents[y_root] += self.parents[x_root]
            self.parents[x_root] = y_root

    def members(self,x):
        root = self.find(x)
        ret = [ i for i in range(self.n) if self.find(i) == root ]
        return ret

    def roots(self):
        ret = [ i for i in range(self.n) if self.parents[i] < 0]
        return ret

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n,m = map(int,readline().split())
x = list(map(int,readline().split()))
aby = list(map(int,read().split()))

edges = []
it = iter(aby)
for a,b,y in zip(it,it,it):
    edges.append((y,a,b))
edges.sort()

n_bi = n*2
bitree = [[0,-1,-1,-1,0] for _ in range(n_bi)]
for i,xi in enumerate(x,1):
    bitree[i][0] = xi

uf = UnionFind(n_bi)

e_ind = 0
for i in range(n+1,n_bi):
    while(True):
        e1 = edges[e_ind][1]
        e2 = edges[e_ind][2]
        if(uf.same(e1,e2)):
            e_ind += 1
            continue
        break

    left = uf.find(e1)
    right = uf.find(e2)
    edge_cost = edges[e_ind][0]

    bitree[i] = [bitree[left][0] + bitree[right][0],
                 -1,
                 left,
                 right,
                 edge_cost]
    bitree[left][1] = i
    bitree[right][1] = i

    uf.union(left,i)
    uf.union(right,i)

tree_group = [-1] * (n+1)
tree_group_cost = []
tree_group_ind = -1
stack = [n_bi-1]
while(stack):
    i = stack.pop()
    if(bitree[i][0] >= bitree[i][4]):
        #連結
        tree_group_ind += 1
        tree_group_cost.append(bitree[i][0])
        stack2 = [i]
        while(stack2):
            j = stack2.pop()
            if(j > n):
                stack2.append(bitree[j][2])
                stack2.append(bitree[j][3])
            else:
                tree_group[j] = tree_group_ind
    else:
        #非連結
        stack.append(bitree[i][2])
        stack.append(bitree[i][3])

ans = 0
for y,a,b in edges:
    if(tree_group[a]==tree_group[b]):
        tg = tree_group[a]
        if(tree_group_cost[tg] >= y):
            ans += 1

ans = m - ans
print(ans)

Measured memory_bytes: 177572
N = int(input())
X = list(map(int, input().split()))
MOD = 10**9+7
S = 0
res = 0
F = 1
for i in range(1,N):
    S += pow(i,MOD-2,MOD)
    res += (X[i]-X[i-1])*S
    res%=MOD
    F*=i
    F%=MOD
print(res*F%MOD)



Measured memory_bytes: 85064
H, W = [int(_) for _ in input().split()]
N = int(input())
A = [int(_) for _ in input().split()]
B = []
for i in range(N):
    B += [i + 1] * A[i]
for j in range(H):
    print(' '.join(map(str, B[j * W:(j + 1) * W][::(-1)**(1&j)])))


Measured memory_bytes: 3572
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		int[] arr = new int[6];
        int num = 0;
        Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			if (num==0){
				num = sc.nextInt();
			}else{
				Double dbl = sc.nextDouble();
				
				if(dbl < 165){
					arr[0]++;
				}else if(dbl < 170){
					arr[1]++;
				}else if(dbl < 175){
					arr[2]++;
				}else if(dbl < 180){
					arr[3]++;
				}else if(dbl < 185){
					arr[4]++;
				}else{
					arr[5]++;
				}
			}
		}
		Output(arr);
	}
	
	private static void Output(int[] arr){
		String str = "";
		for(int i=0; i<arr.length; i++){
			str = i + 1 + ":";
			for(int j=0; j<arr[i]; j++){
				str = str + "*";
			}
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 18460
#include "bits/stdc++.h"

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<ll, ll>;
double PI = 3.1415926535;
signed main() {
	string s; cin >> s;
	int a = s.back() - '0';
	if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
		cout << "hon" << endl;
	}
	else if (a == 3) {
		cout << "bon" << endl;
	}
	else cout << "pon" << endl;
	return 0;
}



Measured memory_bytes: 3584