akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
#define endll "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map<int,int>mp;
    string s;
    cin >> s;
    int c=0;
    for(int i=0;i<s.size();i++){
        if(mp.count(s[i])==false){
            mp.insert(make_pair(s[i],1));
        }
        else {
            mp[s[i]]++;
        }
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        

        if(it->second%2==0){

            continue;
        }
        else{
            cout << "No" << endl;
            return 0;
        }

    }
    cout << "Yes" << endl;

    return 0;
}



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

using namespace std;

int main(){
    int X,N,a,n;
    int p[120];

    cin >> X >> N;
    for(int i = 0;i <= 119;i++){
        p[i] = 0;
    }
    for(int i = 0;i < N;i++){
        cin >> a;
        p[a] = 1;
    }
    n = 0;
    while(1){
        if(X - n >= 1 && p[X - n] == 0) {cout << X - n << endl; break;}
        if(X - n < 1) {cout << 0 << endl; break;}
        if(X + n <= 100 && p[X + n] == 0) {cout << X + n << endl; break;}
        if(X + n > 100) {cout << 101 << endl; break;}
        n++;
    }
}

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


ll strbin2i (const std::string &s) {
    ll out = 0;
    for (int i = 0, size = s.size() ; i < size ; ++i ) {
        out *= 2;
        out += ((ll)s[i] == 49) ? 1 : 0;
    }
    return out;
}

ll f(ll x, ll i){
    return (x+1) / static_cast<ll>(pow(2,i+1)) * static_cast<ll>(pow(2,i)) + max(0LL, ((x+1) % static_cast<ll>(pow(2,i+1))) - static_cast<ll>(pow(2,i)));
}
int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);


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

    string bn = "";
    for(int i = 0; pow(2, i-1) < b; ++i){
        bn += (f(b, i)-f(a-1, i))%2 ? '1' : '0';
    }

    reverse(bn.begin(), bn.end());
    ppp(strbin2i(bn));
    return 0;
}


Measured memory_bytes: 512
import math

from sys import stdin
input = stdin.readline


def main():
  N, K = list(map(int, input().split()))
  A = list(map(int, input().split()))

  if K == 0:
    print(max(A))
    return

  def solve(L):
    ncut = 0
    for i in range(N):
      ncut += (math.ceil(A[i]/L) - 1)
      # ncut += math.floor(A[i]/L)
      if ncut > K:
        return False
    return True

  ok = 10**9
  ng = 0
  while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    bool_ = solve(mid)
    # print(mid, bool_)
    if bool_:
      ok = mid
    else:
      ng = mid

  print(ok)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 92292
//#include<bist_stdc++.h>
#include <iostream>
#include <vector>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > a(n, vector<int>(m));
    vector<int> b(m);
    rep(i, n) rep(j, m) cin >> a[i][j];
    rep(i, m) cin >> b[i];
    rep(i, n) {
        int ans = 0;
        rep(j, m) ans += a[i][j] * b[j];
        cout << ans << endl;
    }
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse
#define size(collection) ((ll) (collection).size())						// collection size

#endif

int main(void)
{
	string s; cin >> s;
	string sub1, sub2;

	ll ans = 1;
	ll i = 0;
	sub1 = s[i];
	while (1)
	{
		if (i + 1 == size(s))
			break;

		sub2 += s[++i];

		if (sub1 != sub2)
		{
			ans++;
			sub1 = sub2;
			sub2.clear();
		}
	}

	cout << ans;
	return 0;
}


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

import math

side, height, volume = [int(i) for i in input().split()]

fullvolume = side * side * height
space_height = (fullvolume - volume) / (side * side)

if volume*2 >= fullvolume:
    print(math.degrees(math.atan(space_height*2 / side)))
else:
    print(math.degrees(math.atan(height / (2*volume/side/height) )))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        int swapCount = 0;
        int flag = 1;
        while (flag == 1) {
            flag = 0;
            for (int j = N - 1; j >= 1; j--) {
                if (A[j] < A[j - 1]) {
                    int tmp = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = tmp;
                    swapCount++;
                    flag = 1;
                }
            }
        }
        String delimiter = "";
        for (int a : A) {
            System.out.print(delimiter + a);
            delimiter = " ";
        }
        System.out.println();
        System.out.println(swapCount);
        sc.close();
    }
}


Measured memory_bytes: 26556
#include<iostream>
#include<vector>

int main(void){
    //NとKを入力してもらう
    int n;
    int k;

    std::cin >> n >> k;

    //お菓子持ってるTrue,持ってないFalse
    std::vector<bool> okasiCheck(n,false);

    for(int i = 0;i < k;i++){
        int d;
        std::cin >> d;

        for(int j = 0;j < d;j++){
            int sunukeNumber;
            std::cin >> sunukeNumber;
            okasiCheck.at(sunukeNumber-1) = true;
        }

    }

    int answer = 0;

    for(int i = 0;i < n;i++){
        if(okasiCheck.at(i) == false){
            answer++;
        }
    }

    std::cout << answer << std::endl;

    //std::cout << n << k << std::endl;

    return 0;
}


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

namespace AtCoder.Abc
{
    class QuestionE
    {
        private static Dictionary<long, long> memoDic;
        private static List<Magic> magicList = new List<Magic>();

        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long resultH = inputLongArray[0];
            long n = inputLongArray[1];

            magicList = new List<Magic>();
            memoDic = new Dictionary<long, long>();

            for (int i = 0; i < n; i++)
            {
                var magicArray = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();
                magicList.Add(new Magic(magicArray[0], magicArray[1]));
            }


            Console.WriteLine(dp(resultH));

            Console.Out.Flush();
        }
    
        private static long dp(long n)
        {
            if(memoDic.ContainsKey(n))
            {
                return memoDic[n];
            }
            if(n <= 0)
            {
                return 0;
            }

            long min = long.MaxValue;
            foreach(var magic in magicList)
            {
                if(magic.b > min)
                {
                    continue;
                }
                var cost = magic.b + dp(n - magic.a);
                if(cost < min)
                {
                    min = cost;
                }
            }
            memoDic.Add(n, min);
            return min;
        }
    }

    public class Magic : IComparable
    {
        public long a { get; set; }
        public long b { get; set; }
        public double e { get; set; }

        public Magic(long a, long b)
        {
            this.a = a;
            this.b = b;
            this.e = ((double)a) / b;
        }

        public int CompareTo(object obj)
        {
            return (int)((obj as Magic).e - e);
        }
    }
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

const long long MOD = 1e9 + 7;


#define INPUT(x)                freopen(x,"r",stdin)
#define OUTPUT(x)               freopen (x,"w",stdout)


#define pb                      push_back
#define endl                    '\n'
#define LCM(a,b)                (a/__gcd(a,b))*b
#define GCD(a,b)                __gcd(a,b)
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define PI                      acos(-1.0)
#define distance(x1,y1,x2,y2)   sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define MAX                     1e9 + 9

#define taratari                ios_base::sync_with_stdio(0);cin.tie(NULL);


int main()
{
    taratari

    int n;
    cin>>n;

    vector <pair <int, int> > a;

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

        a.pb(make_pair(x,i+1));
    }

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

    for(int i=0;i<n;i++)
    {
        cout<<a[i].second<<" ";
    }


    return 0;

}



Measured memory_bytes: 4264
#include<cstdio>
#include<algorithm>
const int mod=1000000007;
int N,h[110];
int pw(int a,int n){
	int b=1;
	for(;n;n>>=1)n&1?b=1ll*b*a%mod:1,a=1ll*a*a%mod;
	return b;
}
std::pair<int,int>dfs(int l,int r,int mn){
	int m=l;
	for(int i=l;i<r;i++)if(h[i]<h[m])m=i;
	int s=pw(2,h[m]-mn);
	if(r-l==1)return std::make_pair(s,s);
	if(m==l){
		std::pair<int,int>sr=dfs(m+1,r,h[m]);
		return std::make_pair((2ll*sr.first+(s-1ll)*sr.second)%mod,1ll*s*sr.second%mod);
	}
	if(m==r-1){
		std::pair<int,int>sl=dfs(l,m,h[m]);
		return std::make_pair((2ll*sl.first+(s-1ll)*sl.second)%mod,1ll*s*sl.second%mod);
	}
	std::pair<int,int>sl=dfs(l,m,h[m]),sr=dfs(m+1,r,h[m]);
	return std::make_pair(
		(4ll*sl.first%mod*sr.first+(s-1ll)*sl.second%mod*sr.second)%mod,
		1ll*s*sl.second%mod*sr.second%mod
	);
}
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",h+i),--h[i];
	printf("%d\n",dfs(0,N,0).first*2%mod);
}

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

int main()
{
	int s, m, h, x;
	cin >> s;
	
	if (s >= 60) {
		m = s / 60;
	}
	if (m>=60){
		h = m / 60;
	}
	m = m - h * 60;
	x = s - (h * 3600 + m * 60);
	s = x; 
	cout << h << ":" << m << ":" << s<<endl;
}

Measured memory_bytes: 1164
'use strict';
const p = s => console.log(s);

function main(input) {
  let s,w = 0;
  [s, w] = input[0].trim().split(" ").map(i => parseInt(i));

  s <= w ? p('unsafe') : p('safe');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


Measured memory_bytes: 29620
#include <bits/stdc++.h>
using namespace std;
 
int main()
{

    string S;
    cin >> S;

    char spell[2];
    spell[0] = S[0];
    spell[1] = 'a';

    int count[2] = {0, 0};

    bool flag = false;

    for (int i = 0; i < S.size(); i++)
    {
        if(S[i] == S[0]){
            count[0]++;
        } else if(spell[1] == 'a'){
            spell[1] = S[i];
            count[1]++;
        } else if(S[i] == spell[1]){
            count[1]++;
        } else {
            break;
        }
    }
    if(count[0] == 2 && count[1] == 2){
        flag = true;
    }

    string result;
    flag ?  result = "Yes" : result = "No";
    
    cout << result << endl;
    return 0;
}

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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n), s(n, 0);
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
        s[i] = sum;
    }

    vector<ll> e(n), o(n);
    for(int i = 0; i < n; i++) {
        if(i % 2 == 0) e[i] = -1, o[i] = 1;
        else e[i] = 1, o[i] = -1;
    }

    vector<ll> se = s, so = s;
    ll ce = 0, co = 0;
    ll cnte = 0, cnto = 0;
    for(int i = 0; i < n; i++) {
        se[i] += ce;
        so[i] += co;
        if(se[i] * e[i] <= 0) cnte += abs(e[i] - se[i]), ce += (e[i] - se[i]), se[i] = e[i];
        if(so[i] * o[i] <= 0) cnto += abs(o[i] - so[i]), co += (o[i] - so[i]), so[i] = o[i];    
    }

    ll ans = min(cnte, cnto);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
lis=[]
count=0
for i in a:
    count+=1
    for j in range(i):
        lis.append(count)
for i in range(h):
    for j in range(w):
        if i%2==0:
            print(lis[i*w+j],end=" ")
        else:
            print(lis[(i+1)*w-1-j],end=" ")
    print()

Measured memory_bytes: 3828
var N,i,ans,cnt,pre:Longint;
H:Array[1..100000]of Longint;
begin
read(N);
for i:=1 to N do read(H[i]);
i:=1;
while i<=N do begin
pre:=i;
inc(i);
while(i<=N)and(H[i]<=H[i-1])do inc(i);
if ans<i-pre-1 then ans:=i-pre-1;
end;
writeln(ans);
end.

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.Arrays;

class Main {
    public static void main(String... args) {
        int N = IN.nextInt();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans += IN.nextInt();
        }
        puts(ans - N);
    }
    static final Scanner IN = new Scanner(System.in);
    static <T> void puts(T arg) { System.out.println(arg); }
}

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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long int lli;

int main()
{
	fio;
	int white,black;
	cin>>white>>black;
	char a[100][100];
	for(int i=0;i<=49;i++)
	{
		for(int j=0;j<=99;j++) a[i][j]='.';
	}
	for(int i=50;i<=99;i++)
	{
		for(int j=0;j<=99;j++) a[i][j]='#';
	}
	white--;
	black--;
	for(int i=1;i<=48;i+=2)
	{
		if(black==0) break;
		if(i%2==0)
		{
			for(int j=0;j<=98;j+=2)
			{
				a[i][j]='#';
				black--;
				if(black==0) break;
			}
			if(black==0) break;
		}
		else
		{
			for(int j=1;j<=98;j+=2)
			{
				a[i][j]='#';
				black--;
				if(black==0) break;
			}
			if(black==0) break;
		}
	}
	for(int i=51;i<=99;i+=2)
	{
		if(white==0) break;
		if(i%2==0)
		{
			for(int j=0;j<=99;j+=2)
			{
				a[i][j]='.';
				white--;
				if(white==0) break;
			}
			if(white==0) break;
		}
		else
		{
			for(int j=1;j<=98;j+=2)
			{
				a[i][j]='.';
				white--;
				if(white==0) break;
			}
			if(white==0) break;
		}
	}
	cout<<"100 100"<<endl;
	for(int i=0;i<=99;i++)
	{
		for(int j=0;j<=99;j++) cout<<a[i][j];
			cout<<endl;
	}
	cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
using namespace std;
#define INF 1000000000;
#define MOD 1000000007;
typedef long long int ll;
int main(void){
    string s;
    cin>>s;
    int a,b;
    a=stoi(s.substr(0,2));
    b=stoi(s.substr(2));
    bool con1,con2;
    con1=(a>=1 and a<=12);
    con2=(b>=1 and b<=12);
    //cout<<con1<<" "<<con2<<endl;
    if(con1 and con2){
        cout<<"AMBIGUOUS"<<endl;
    }else if(con1){
        cout<<"MMYY"<<endl;
    }else if(con2){
        cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 256
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    while(true){
    String str1 = br.readLine();
    String[] str2 = str1.split(" ");
    int H = Integer.parseInt(str2[0]);
    int W = Integer.parseInt(str2[1]);

    if(H == 0 && W == 0) {break;}

    for (int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        sb.append("#");
      }
      sb.append("\n");
    }
    sb.append("\n");
    }
    System.out.print(sb);
  }
}

Measured memory_bytes: 25260
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int m = Math.min(a,b);
		int cou = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 1; i < m+1; i++){
			if(a%i == 0 && b%i == 0){
				list.add(i);
				cou++;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		System.out.print(list.get(k-1));
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(true) {
        C -= B;
        if(C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if(A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AACOrWA solver = new AACOrWA();
        solver.solve(1, in, out);
        out.close();
    }

    static class AACOrWA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            if (n == m) {
                out.println("Yes");
                return;
            }

            out.println("No");
        }

    }
}



Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main()
{
	char S[100];
	cin>>S;
	if ((S[0]==S[1] && S[1]==S[2]) && (S[2]==S[3] && S[3]==S[0]) )
	{
		cout<<"No"<<endl;
	}
	else if (S[0]==S[1] && S[2]==S[3])
	{
		cout<<"Yes"<<endl;
	}
	else 
		if (S[0]==S[2] && S[1]==S[3])
		{
			cout<<"Yes"<<endl;
		}
	else
		if (S[0]==S[3] && S[1]==S[2])
		{
			cout<<"Yes"<<endl;
		}
		 
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a,b,c,d;
	int tmax,tmin;

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

	if(a<c){
		tmin =c;}
	else{
		tmin =a;}
	if(b<d){
		tmax =b;}
	else{
		tmax =d;}
	if(tmax-tmin>0){
	printf("%d",tmax-tmin);}
	else{
	printf("0");}
	return 0;
}


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

using namespace std;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


typedef long long ll;

int main(){
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k % 2 == 0){
		cout << a - b << endl;
	}
	else{
		cout << b - a << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}

vector<pair<long long,long long>> prime_factorize(long long N){
  vector<pair<long long,long long>> res;
  
  for(long long i=2;i*i<=N;i++){
    if(N%i!=0){
    continue;
    }
    
    long long ex=0;
    while(N%i==0){
      ex++;
      N/=i;
    }
    
    res.push_back({i,ex});
  }
  
  if(N!=1){
  res.push_back({N,1});
  }
  
  return res;
}


int main() {
  
  long long N;
  cin>>N;
  
  if(N==1){
    cout<<0<<endl;
  }
  else{
  vector<pair<long long,long long>> P=prime_factorize(N);
  
  long long ans=0;
  
  
  long long i=0;
  
  
  while(P[i].first!=0){
    int j=1;
    int sum=1;
    while(sum<=P[i].second){
      ans++;
      j++;
      sum+=j;
    }
    i++;
  }
  
  cout<<ans<<endl;
  }
}

Measured memory_bytes: 3632
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);
        int mod = 10007;

        int n = sc.nextInt();
        char[] line = sc.next().toCharArray();
        int[] tanto = new int[n];
        for(int i=0; i<n; i++){
            if(line[i]=='J') tanto[i] = 0;
            if(line[i]=='O') tanto[i] = 1;
            if(line[i]=='I') tanto[i] = 2;
        }

        int[][] dp = new int[n][1<<3];
        int idx = 1;
        int sum = 0;
        for(int i=0; i<n; i++){
            for(int bit=0; bit<(1<<3); bit++){
                if((bit&(1<<tanto[i]))==0) continue;
                if(i==0){
                    if((bit&1)>0) dp[i][bit] = 1;
                    continue;
                }
                for(int bit2=0; bit2<(1<<3); bit2++){
                    if((bit&bit2)>0){
                        dp[i][bit] += dp[i-1][bit2];
                        dp[i][bit] %= mod;
                    }
                }
                if(i==n-1){
                    sum += dp[i][bit];
                    sum %= mod;
                }
            }
        }
        System.out.println(sum);
    }

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

Measured memory_bytes: 18080
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    string S;
    cin >> N >> S;
    int r=0,b=0;
    REP(i,N){
        if(S[i]=='R'){
            r++;
        }else{
            b++;
        }
    }
    Yes(r>b);
    
    return 0;
}


Measured memory_bytes: 256
N, S = map(int,input().split())
A = list(map(int,input().split()))

MOD = 998244353

dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S + 1):
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= MOD
        if j + A[i] <= S:
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= MOD

print(dp[N][S])


Measured memory_bytes: 139148
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------


int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL X;
	cin >> X;
	LL nowi = 0, ans = 0;

	while (1) {
		nowi++;
		ans += nowi;
		if (ans >= X) {
			O(nowi);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
s = set()
for i in range(1000):
  p = str(i).zfill(3)
  if S.find(p[0])==-1:
    continue
  S1 = S[S.find(p[0])+1:]
  if S1.find(p[1])==-1:
    continue
  S2 = S1[S1.find(p[1])+1:]
  if S2.find(p[2])==-1:
    continue
  s.add(p)
print(len(s))

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

int main() {
	int A; int B;
	cin >> A >> B;

	if (A == B) {
		cout << "Draw" << endl;
	} else if (A == 1 || A > B && B != 1 ){
		cout << "Alice" << endl;
	} else {
		cout << "Bob" << endl;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        Arrays.sort(A);
        System.out.println(A[N-1]-A[0]);
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int add(int a, int b) {
	a += b;
	if (a >= mod) {
		return a - mod;
	}
	return a; 
}
void add_self(int& a, int b) {
	a = add(a, b);
}
int mult(int a, int b) {
	return 1ll * a * b % mod;
}
void mult_self(int& a, int b) {
	a = mult(a, b);
}
int bin_pow(int a, int b) {
	if (b == 0) {
		return 1;
	}
	if (b % 2 == 0) {
		return bin_pow(mult(a, a), b / 2);
	}
	return mult(a, bin_pow(a, b - 1));
}
int inv(int a) {
	return bin_pow(a, mod - 2);
}
vector<int> fact, inv_fact;
int C(int a, int b) {
	assert(a >= b);
	return mult(mult(fact[a], inv_fact[b]), inv_fact[a - b]);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	fact.resize(n + 1, 1);
	inv_fact.resize(n + 1);
	for (int i = 1; i <= n; ++i) {
		fact[i] = mult(fact[i - 1], i);
	}
	//~ debug(fact);
	for (int i = 0; i <= n; ++i) {
		inv_fact[i] = inv(fact[i]);
	}
	//~ debug(inv_fact);
	sort(a.begin(), a.end());
	int answer = 0;
	for (int i = 0; i < n; ++i) {
		//~ fast
		int x = mult(bin_pow(2, n + i), a[i]);
		//~ debug(x);
		int p = 0;
		if (i != n - 1) {
			p = mult(n - i - 1, bin_pow(2, n - i - 2));
			//~ debug(p);
		}
		add_self(p, bin_pow(2, n - i - 1));
		mult_self(x, p);
		//~ debug(x);
		add_self(answer, x);
		//~ slow
		//~ for (int D = 1; D <= n - i; ++D) {
			//~ int x = mult(C(n - i - 1, D - 1), bin_pow(2, n - 1));
			//~ mult_self(x, bin_pow(2, i + 1));
			//~ add_self(answer, mult(x, mult(D, a[i])));
		//~ }
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>

int main() {
	int N;
	std::cin >> N;
	std::vector<std::pair<std::string, int> > st(N);
	std::string X;
	for (int i = 0; i < N; i++) {
		std::cin >> st[i].first >> st[i].second;
	}
	std::cin >> X;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += st[i].second;
		if (st[i].first == X) {
			sum = 0;
		}
	}
	std::cout << sum << std::endl;
}


Measured memory_bytes: 256
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2], reverse=True)

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if flag==False:
    break
    
  for cy in range(0,101):
    ansh = 0
    for pira in xyh:
      if ansh==0:
        ansh=pira[2]+(abs(cx-pira[0])+abs(cy-pira[1]))
        ans[0]=[cx,cy,ansh]
        
      elif len(ans[0])>0 and max(ansh -(abs(cx-pira[0])+abs(cy-pira[1])), 0) != pira[2]:
        ans[0]=[]
    if len(ans[0])>0:
      flag=False
      break
print(*ans[0])


Measured memory_bytes: 9220
/* ~ Programmer >> Tushar Mahajan */
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL); 

int main() {
	ios;
    int a[4];
    for(int i=0;i<3;i++)
    {
      cin>>a[i];
    }
  sort(a,a+3);
  if(a[0]==5 && a[1]==5 && a[2]==7)
  {
    cout<<"YES";
  }
  else
  {
    cout<<"NO";
  }
	return 0;
}


Measured memory_bytes: 256
// AtCoder Beginner Contest 174
// B - Distance

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;
//using namespace std::chrono;


int main()
{
	//steady_clock::time_point start = steady_clock::now();
	int N,D;
	cin >> N >> D;
	long long X[N], Y[N];
	for (int i=0; i<N; i++) {
		cin >> X[i] >> Y[i];
	}
	// 制約確認
	if (N < 1 || 200000 < N)  {
        cout << "Nは条件を満たしていません!\n";
        return 0;
    }
	
	int cnt = 0;
	double temp;
	//cout << "Calc start:" << endl;
	long long Xtemp, Ytemp;
	for (int i=0; i<N; i++) {
		//cout << "X:" << X[i] << " Y:" << Y[i] << endl;
		Xtemp = X[i]*X[i];
		//cout << "Xtemp:" << Xtemp << endl;
		Ytemp = Y[i]*Y[i];
		//cout << "Ytemp:" << Ytemp << endl;
		temp = sqrt(Xtemp + Ytemp);
		//cout << temp << endl;
		if (temp <= D) cnt++;
	}
	cout << cnt << endl;
	//計算時間集計
	/*
	steady_clock::time_point end = steady_clock::now();
    steady_clock::duration d = end - start;
	cout << "計算時間は" << duration_cast<milliseconds>(d).count() << "ミリ秒です。\n";
	*/
}



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

int main(){
  int a[200000];
  int n;
  long long ans = 0;
  cin >> n;
  for(int i = 0;i < n;i++) cin >> a[i];
  if(a[0] != 0){
    cout << -1 << endl;
    return 0;
  }
  for(int i = 1;i < n;i++){
    if(a[i-1]+1 != a[i] && a[i-1] < a[i]){
      cout << -1 << endl;
      return 0;
    }
  }

  ans = a[n-1];
  for(int i = n-1-1;i >= 0;i--){
    if(a[i]+1 != a[i+1]){
      ans += a[i];
    }
  }

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


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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+100000000
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}




void solve() {
            
            ll n;
            cin >> n;
            
            ll A[n + 1];
            ll B[n + 1];
            
            for(ll i = 1; i <= n; i++) {
                    cin >> A[i];
            }
            
            for(ll i = 1; i <= n; i++) {
                    cin >> B[i];
            }
            
            sort(B + 1, B + 1 + n, greater<ll>());
            
            ll l = n + 1;
            ll r = 0;
            
            for(ll i = 1; i <= n; i++) {
                    if(A[i] == B[i]) {
                            l = i;
                            break;
                    }
            }
            
            for(ll i = n; i >= 1; i--) {
                    if(A[i] == B[i]) {
                            r = i;
                            break;
                    }
            }
            
            
            ll l1 = l;
            ll r1 = r;
            
            for(ll i = 1; i < l; i++) {
                    if(l1 <= r1) {
                            if(A[i] != A[l1] && B[i] != B[l1]) {
                                    swap(B[i], B[l1]);
                                    l1++;
                            }
                    }
            }
            
            for(ll i = n; i > r; i--) {
                    if(l1 <= r1) {
                            if(A[i] != A[l1] && B[i] != B[l1]) {
                                    swap(B[i], B[l1]);
                                    l1++;
                            }
                    }
            }
            
            if(l1 <= r1) {
                    cout << "No" << endl;
            } else {
                    cout << "Yes" << endl;
                    for(ll i = 1; i <= n; i++) {
                            cout << B[i] << " ";
                    }
                    cout << endl;
            }
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 6792
package main

import (
        "fmt"
)

func min(x, y int) int {
        if x > y {
                return y
        }
        return x
}

func main() {
        var N, A, B int
        fmt.Scanf("%d %d %d", &N, &A, &B)
        fmt.Println(N/(A+B)*A + min(N%(A+B), A))
}

Measured memory_bytes: 512
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let x: usize = input();
    let y: usize = input();

    let v = vec![0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1];
    println!("{}", if v[x] == v[y] { "Yes" } else { "No" });
}


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

int main(){
    ll n,q; cin>>n>>q;
    vector<int> h(n+1,n),w(n+1,n);
    ll ans = (n-2)*(n-2);
    int maxH = n, maxW = n;

    while(q--){
        int t,x; cin>>t>>x;
        if(t==1){
            if(x < maxW){
                for(int i=x;i<maxW;i++) w[i] = maxH;
                maxW = x;
            }
            ans -= w[x] - 2;
        }else{
            if(x < maxH){
                for(int i=x;i<maxH;i++) h[i] = maxW;
                maxH = x;
            }
            ans -= h[x] - 2;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	ll ans = 0;
	map<pii,ll> m;
	for(int i = 1; i <= n; i++){
		int r = i, l = i % 10;
		while(r >= 10) r /= 10;
		if(l == 0) continue;
		m[mp(r,l)]++;
	}
	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 10; j++){
			ans += m[mp(i,j)] * m[mp(j,i)];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t=0#たお4
for i in range(n):
    if a[i] < b[i]:
        t += a[i]
        b[i] -= a[i]
        a[i]=0
        if a[i+1] > b[i]:
            a[i+1] -= b[i]
            t += b[i]
        else:
            t += a[i+1]
            a[i+1]=0
    else:
        a[i] -= b[i]
        t += b[i]
print(t)

Measured memory_bytes: 19156
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF ((int)(2e9))
#define LINF ((int)(1e18))
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define ll long long
#define B cout << "BreakPoint\n";
#define read(_nowans) scanf("%d",&_nowans)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_nowans1,_nowans2) scanf("%d %d",&_nowans1,&_nowans2)
#define msn(_data,_nowans) memset(_data,_nowans,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_nowans1,_nowans2,_nowans3) scanf("%d %d %d",&_nowans1,&_nowans2,&_nowans3)
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print( int _x ){ printf("%d\n",_x); }
_tp<_tyn T>void print( T _data[] , int _size ){
	for( int i = 1 ; i <= _size ; i++ )
		cout << _data[i] << " ";
	cout << endl;
}
#define MAXN 110
#define sqr(x) ((x)*(x))

int n;
int dat[MAXN];

int main(){
	//fin( "C.txt" );

	while( scanf("%d",&n) != EOF ){
		int ans = INF;
		for( int i = 1 ; i <= n ; i++ )
			read( dat[i] );
		for( int i = -100 ; i <= 100 ; i++ ){
			int tans = 0;
			for( int j = 1 ; j <= n ; j++ )
				tans += sqr( dat[j]-i );
			mymin( ans , tans );
		}
		printf("%d\n",ans);
	}
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<pii> a;
  pii now = pii(0, s[0] - '0');
  rep (i, n) {
    if (now.second == s[i] - '0') {
      now.first++;
    }
    else {
      a.push_back(now);
      now = pii(1, s[i] - '0');
    }
  }
  a.push_back(now);

  int l = 0, r = 0;
  int m = a.size();
  int nokori = k;
  ll ans = 0;
  ll sum = 0;
  while (r < m) {
    if (nokori > 0 || a[r].second) {
      if (a[r].second) sum += a[r].first;
      else {
        sum += a[r].first;
        nokori--;
      }
      chmax(ans, sum);
      r++;
    }
    else {
      if (a[l].second) {
        sum -= a[l].first;
      }
      else {
        sum -= a[l].first;
        nokori++;
      }
      l++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1528
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int n,m,a[200005],b[200005];
set <int> st;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for (int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		if (a[i]==1){
			st.insert(b[i]); 
		}
		if (b[i]==1){
			st.insert(a[i]); 
		}
	}
	for (int i=0;i<m;i++){
		if (a[i]==n){
			if (st.count(b[i])){
				cout<<"POSSIBLE";
				return 0;
			}
		}
		if (b[i]==n){
			if (st.count(a[i])){
				cout<<"POSSIBLE";
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 6528
def scores(card1, card2):
    """returns scores of a card game.

    >>> scores('cat', 'dog')
    (0, 3)
    >>> scores('fish', 'fish')
    (1, 1)
    >>> scores('tiger', 'lion')
    (3, 0)
    """
    if card1 == card2:
        return (1, 1)
    elif card1 > card2:
        return (3, 0)
    else:
        return (0, 3)


def run():
    c = int(input())
    taro, hanako = 0, 0

    for i in range(c):
        pt, ph = scores(*(input().split()))
        taro += pt
        hanako += ph

    print(taro, hanako)


if __name__ == '__main__':
    run()


Measured memory_bytes: 5612
import java.util.Scanner;

public class Main {

    public static void main(String[] arg) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((b - a - 1) % 2 == 0) {
            System.out.println("Borys");
        } else {
            System.out.println("Alice");
        }
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n ;i++)cin>>arr[i];
    int k;
    cin>>k;
    int q, cnt=0;
    for(int i=0; i<k; i++){
        cin>>q;
        for(int j=0; j<n; j++){
            if(q==arr[j]){
                cnt++;
                break;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>

using namespace std;

const int MAX = 11;
typedef pair<int,int> P;
int pyon_x[] = {-2,-2,-2,-1,-1,0,0,1,1,2,2,2};
int pyon_y[] = {1,0,-1,2,-2,2,-2,2,-2,1,0,-1};
int sp_x[] = {-1,-1,-1,0,0,0,1,1,1};
int sp_y[] = {1,0,-1,1,0,-1,1,0,-1};

bool able[MAX];
P pos[MAX];
int n;

void init(){
  fill(able,able+MAX,false);
}

bool save(int x, int y, int num){
  for(int i = 0; i < 9; i++)
    if(pos[num].first + sp_x[i] == x && 
       pos[num].second + sp_y[i] == y) return true;

  return false;
}

void solve(int x,int y, int num){
  if(num < n)
  for(int i = 0; i < 12; i++){
    if(0 <= x + pyon_x[i] && x + pyon_x[i] <= 9 &&
       0<= y+pyon_y[i] && y+pyon_y[i] <= 9){
      if(save(x+pyon_x[i],y+pyon_y[i],num+1)){
	able[num+1] = true;
	solve(x+pyon_x[i],y+pyon_y[i],num+1);
      }
    }
  }
}

string ans(){
  for(int i = 1; i <= n; i++)
    if(!able[i]) return "NA";

  return "OK";
}
int main(){
  int x,y;
  while(cin >> x >> y && x+y){
    init();
    cin >> n;

    for(int i = 1; i <= n; i++){
      P p;
      cin >> p.first >> p.second;
      pos[i] = p;
    }
    solve(x,y,0);
    cout << ans() << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();
		sc.close();

		int min = 1000;

		int[] val = { p + q, p + r, q + r };
		for (int i : val) {
			min = Math.min(min, i);
		}
		System.out.println(min);

	}

}


Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;

typedef long long ll;

vector<int> res(1000001);

void dfs(int cp,vector<vector<int> > &v,vector<int> &myPoint,int sump){
	int nsump = myPoint[cp] + sump;
	
	res[cp] = nsump;
	
	for(int i=0;i<v[cp].size();++i){
		int next = v[cp][i];
		dfs(next,v,myPoint,nsump);
	}
	
}


int main(){
	int n,q;
	cin >> n >> q;
	vector<vector<int> > v(n+1);
	
	int a,b;
	for(int i=0;i<n-1;++i){
		cin >> a >> b;
		v[a].push_back(b);
	}
	
	vector<int> myPoint(n+1);
	
	for(int i=0;i<q;++i){
		cin >> a >> b;
		myPoint[a] += b;
	}
	
	dfs(1,v,myPoint,0);

	
	for(int i=1;i<n;++i){
		cout << res[i] <<" ";
	}cout << res[n] <<endl;
	
	return 0;
}



Measured memory_bytes: 27392