akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define maxn 5005
using namespace std;
int arr[maxn];
int pre[maxn][maxn],suf[maxn][maxn];
void build(int n,int k,int (*dp)[maxn]) {
	dp[0][0] = 1;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<k;j++)
			dp[i][j] = dp[i-1][j];
		if(arr[i] >= k)	continue;
		for(int j=k-1;j>=arr[i];j--)
			if(dp[i][j-arr[i]] == 1)
				dp[i][j] = 1;
	}
}
int query(int i,int l,int r) {
	return suf[i][r] - (l == 0 ? 0 : suf[i][l-1]);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	build(n,k,pre);
	reverse(arr+1,arr+1+n);
	build(n,k,suf);
	reverse(arr+1,arr+1+n);
	reverse(suf,suf+1+n+1);
	for(int i=2;i<=n+1;i++)
		for(int j=1;j<k;j++)
			suf[i][j] += suf[i][j-1];
	
	int ans = n;
	for(int i=1;i<=n;i++) {
		if(arr[i] >= k) {
			ans--;
			continue;
		}
		for(int j=0;j<k;j++)
			if(pre[i-1][j] == 1) {
				int l = max(0,k - arr[i] - j) , r = k - 1 - j;
				if(query(i+1,l,r) > 0) {
					ans--;
					break;
				}
			}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 195968
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int maxx = 1;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (h[i] >= maxx) {
            maxx = h[i];
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
//a, b, cツつェツ禿シツ療債つウツづェツつスツづつォツ、ツつサツづ個三ツ陛督づーツ篠敖づつ三ツ角ツ形ツつェツ陳シツ角ツ三ツ角ツ形YESツづーツ、ツつサツつ、ツづづ按つ「ツづ按づァNOツづーツ出ツ療債つケツづヲ
//ツ暗ェツ行ツ姪堋づ可表ツつウツづェツづゥnツ嘉アツ閉ェツ、ツデツーツタツセツッツトツづ債堕カツ催敖つキツづゥ

#include<iostream>
#include<algorithm>
using namespace std;

inline int Squere(int x)
{
	return x*x;
}

int main(void)
{
	const int N = 3;
	int a[N];
	int n;
	int i, j;

	cin >> n;
	for(i = 0; i < n; i++)
	{
		for(j = 0; j < N; j++)
			cin >> a[j];
		sort(a, a+N);
		
		if( Squere(a[0]) + Squere(a[1]) == Squere(a[2]) )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

		if (s.substring(2, 3).equals(s.substring(3, 4)) && s.substring(4, 5).equals(s.substring(5, 6))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22868
#include <stdio.h>
#include <string.h>
#define MAX 301

int main(void) {
    int H, W;
    char buf[MAX];
    for(; scanf("%d %d", &H, &W), H || W; printf("\n")) {
        for(memset(buf, '#', W), buf[W] = 0; H--; printf("%s\n", buf));
    }
    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>
using namespace std;

long long int N = 1000000007;
int main()
{
  string s;
  cin >> s;
  if(s[0] == s[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var H = Console.ReadLine().Split().Select(int.Parse).ToArray();

        bool frag = true;
        for(int i = 0; i < N - 1; i++)
        {
            if (H[i] <= H[i + 1])
            {
                continue;
            }
            else if(H[i]==H[i+1] + 1)
            {
                H[i + 1]++;
            }
            else
            {
                frag = false;
                break;
            }
        }

        Console.WriteLine(frag?"Yes":"No");
    }
}

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

int main(){
  int now=0;
  int c[6];
  int cn[6]={1,5,10,50,100,500};
  for(int i=0; i<6; i++)
    cin >> c[i];
  bool ans = false;
  for(int i=5; i>=0; i--){
    for(int j=0; j<c[i]; j++){
      if(now+cn[i] < 1000)
	now+=cn[i];
      else if(now+cn[i]==1000){
	ans = true;
	break;
      }
      else
	break;
    }
    if(ans)
      break;
  }
  if(ans)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 1160
n, a, b = map(int, input().split())

some_sum = 0
for num in range(n+1):
	tmp_num = num
	
	sum_num = 0
	while tmp_num > 0:
		sum_num += tmp_num % 10
		tmp_num //= 10
	
	if a <= sum_num and sum_num <= b:
		some_sum += num
		#print(num)

print(some_sum)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main(){
    string s;
    cin >>s;
    ll n=s.size();
    ll cnt=0;
    for (int i = 0; i < n; ++i) {
        if(i%2==s[i]%2)cnt++;
    }
    cout <<min(cnt,n-cnt)<< endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;
int n;
ll s[100005]; 
int main()  
{  
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%I64d",s+i);
	}
	sort(s,s+n);
	ll ans,k=0;
	for(int i=n-1;i>0;i--){
		if(s[i]==s[i-1]){
			if(k==0){
				ans=s[i];
				i--;k++; 
			}else{
				ans*=s[i];
				cout<<ans<<endl;
				return 0;
			}
		}
	}
	cout<<0<<endl;
	return 0;  
}  


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, sum int
	fmt.Scan(&n)
	for _, v := range strconv.Itoa(n) {
		t, _ := strconv.Atoi(string(v))
		sum += t
	}
	if n%sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(char i = '0'; i<= '9';  i++) for(char j = '0'; j<= '9';  j++) for(char k = '0'; k<= '9';  k++) {
        bool flag1 = false, flag2 = false;
        REP(l, n) {
            if(s[l] == i && !flag1) {
                flag1 = true;
                l++;
            }
            if(s[l] == j && flag1 && !flag2) {
                flag2 = true;
                l++;
            }
            if(s[l] == k && flag2) {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    p  = 0
 
    for i in range(K-1,N):
        #lst= A[i-K+1:i+1]
        #p = sum(lst)
        #p = mul(lst)
        #p = functools.reduce(operator.mul,lst)
        if i != K-1:
            if A[i] <= A[i-K]:
                print('No')
            else:
                print('Yes')
        
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 94276
package main

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

func main() {
	sc := NewScanner()
	S := sc.Next()

	L := 0
	A := make([]int, len(S))
	for i := L; i < len(S); i++ {
		if S[i] == 'L' {
			step := 0
			if i > 0 && S[i-1] == 'L' {
				A[i] = A[i-1] - 1
			} else {
				for j := i; j >= L; j-- {
					A[j] = step
					step++
				}
			}
			L = i + 1
		}

	}

	ans := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if A[i]%2 == 0 {
			ans[i+A[i]] += 1
		} else {
			ans[i+A[i]-1] += 1
		}
	}
	PrintI(ans...)
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

vector<int> R;
vector<int> C;
vector<vector<int>> dp;

long long int rec(int l,int r){
  if(dp[l][r]!=-1) return dp[l][r];
  if(abs(r-l)<=1)return 0;
  long long int res=10000007;
  for(int mid=l+1;mid<r;mid++){
    res=min(res,rec(l,mid)+rec(mid,r)+R[l]*C[mid-1]*C[r-1]);
  }
  return dp[l][r]=res;
}

int main(){

  int n;
  cin >> n;

  dp.resize(n+1);
  for(int i=0;i<n+1;i++)dp[i].resize(n+1);

  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      dp[i][j]=-1;
    }
  }

  R.resize(n);
  C.resize(n);
  for(int i=0;i<n;i++)cin >> R[i] >> C[i];

  int c=rec(0,n);

  cout << c << endl;


}


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

int main(){
  char b;
  cin >> b;
  char answer;
  if(b=='A') answer='T';
  else if(b=='T') answer='A';
  else if(b=='C') answer='G';
  else answer='C';
  
  cout << answer << endl;
}

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

using ll=long long;
ll dp[110][100010];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, W;
  cin >> n >> W;
  int w[n], v[n];
  rep(i,n) cin >> w[i] >> v[i];
  rep(i,n){
    rep(now,W+1){
      if(now - w[i] >=0) dp[i+1][now] = max(dp[i+1][now], dp[i][now - w[i]] + v[i]);
      dp[i+1][now] = max(dp[i+1][now], dp[i][now]);
    }
  }
  cout << dp[n][W] << endl;
}

Measured memory_bytes: 79360
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int N,Q,size;
	int[] segment;

	public void init(int _size){
		size = 1;

		while(size < _size)size *= 2;
		segment = new int[2 * size];
		for(int i = 0;i < 2 * size - 1;i++){
			segment[i] = Integer.MAX_VALUE;
		}
	}

	public void update(int i,int a){
		i += size - 1;
		segment[i] = a;

		while(i > 0){
			i = (i - 1) / 2;
			segment[i] = Math.min(segment[i * 2 + 1], segment[i * 2 + 2]);
		}
	}

	public int query(int a,int b,int k,int l,int r){
		if(r <= a || b <= l)return Integer.MAX_VALUE;

		if(a <= l && r <= b)return segment[k];
		else{
			int vl = query(a,b,k * 2 + 1,l,(l + r) /2);
			int vr = query(a,b,k * 2 + 2,(l + r) / 2,r);

			return Math.min(vl, vr);
		}
	}

	public void solve() {
		N = nextInt();
		Q = nextInt();

		init(N);

		for(int i = 0;i < Q;i++){
			int c = nextInt();
			int x = nextInt();
			int y = nextInt();

			if(c == 0){
				update(x,y);
			}else{
				out.println(query(x,y + 1,0,0,size));
			}
		}
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 62332
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, k, c;
string s;
int l[MAX], r[MAX], cnt[MAX];

void solve() {
	cin >> n >> k >> c >> s;
	memset(l, 0, sizeof l);
	// memset(r, 0, sizeof r);
	fill(r, r+MAX, k+1);
	fill(cnt, cnt+MAX, 0);
	for(int i=1; i<=n; i++) {
		if(s[i-1] == 'o') {
			if(i <= c) l[i]++;
			else l[i] = l[i-c-1]+1;
		} else {
			l[i] = l[i-1];
		}
	}
	for(int i=n; i; i--) {
		if(s[i-1] == 'o') {
			if(i+c >= n) r[i]--;
			else r[i] = r[i+c+1]-1;
		} else {
			r[i] = r[i+1];
		}
	}
	for(int i=1; i<=n; i++) {
		if(s[i-1] == 'o' && l[i] == r[i]) cnt[l[i]]++;
	}
	for(int i=1; i<=n; i++) {
		if(s[i-1] == 'o' && l[i] == r[i] && cnt[l[i]] == 1) cout << i << "\n";
	}
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 15460
import math

N=int(input())
P=[list(map(int,input().split())) for i in range(N)]

def div2(x,y):
    if x>0:
        return (1,y/x)
    elif x<0:
        return (-1,y/x)
    else:
        if y>0:
            return (-1,-float("inf"))
        else:
            return (1,-float("inf"))

P.sort(key=lambda x:div2(x[0],x[1]))

ANS=0

for i in range(N):
    for j in range(i,N):
        x0=y0=0
        x1=y1=0

        for k in range(N):
            if i<=k<=j:
                x0+=P[k][0]
                y0+=P[k][1]
            else:
                x1+=P[k][0]
                y1+=P[k][1]

        ANS=max(ANS,x0**2+y0**2,x1**2+y1**2)

print(math.sqrt(ANS))


Measured memory_bytes: 42220
#include<stdio.h>

int main(void)
{
   long long int a,b,n,x,y,i;
   i=0;
   scanf("%lld%lld%lld", &n, &a, &b);
   if(a==0){printf("%d\n",a); return 0;}

   x=(n/(a+b))*a;
   y=n%(a+b);
   if     (a<y){i=a;}
   else if(a>y){i=y;}
   printf("%lld\n",x+i);
   return 0;
}


Measured memory_bytes: 128
import java.math.BigDecimal;
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
      
      	BigDecimal maximum = new BigDecimal("1000000000000000000");
        // 整数の入力
        int N = sc.nextInt();
        boolean isbiggerthan = false;
		BigDecimal bdNum1 = new BigDecimal(sc.next());
        for(int i=1;i<N;i++){
          String s = sc.next();
          if(s.equals("0")){
			System.out.println(0);
			return;
          }
          if (!isbiggerthan){
          BigDecimal bdNumx = new BigDecimal(s);
          bdNum1 = bdNum1.multiply(bdNumx); 
          }
         if(bdNum1.compareTo(maximum) == 1){
            isbiggerthan = true;
         }
        }
        if(isbiggerthan){
          System.out.println(-1);
        }else{
        System.out.println(bdNum1);
        
    }
        }
}

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

vector<int> dx, dy;
set<int> S[5000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int gx, gy;
	string s;
	cin >> s >> gx >> gy;

	int N = s.size();
	int i = 0;
	while(i < N && s[i] == 'F'){
		gx--;
		i++;
	}
	i++;
	bool xdir = false;
	while(i < N){
		int cnt = 0;
		while(i < N && s[i] == 'F') cnt++, i++;
		i++;
		if(xdir) dx.push_back(cnt);
		else dy.push_back(cnt);
		xdir ^= 1;
	}

	for(int loop = 0; loop < 2; loop++){
		for(int i = 0; i < dx.size() + 1; i++){
			S[i].clear();
		}
		S[0].insert(0);
		for(int i = 0; i < dx.size(); i++){
			for(auto a : S[i]){
				S[i + 1].insert(a - dx[i]);
				S[i + 1].insert(a + dx[i]);
			}
		}
		if(S[dx.size()].count(gx) == 0){
			cout << "No" << endl;
			return 0;
		}

		swap(dx, dy);
		swap(gx, gy);
	}
	cout << "Yes" << endl;

}


Measured memory_bytes: 190848
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

int a[200500];
void solve(){
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(a[x] == 0) cnt++;
        a[x]++;
    }
    sort(a, a + 200500);
    int ans = 0;
    if(cnt > k){
        int t = cnt - k;
        for(int i = 0; i < 200500; i++){
            if(t == 0) break;
            if(a[i] > 0) {
                ans += a[i];
                t--;
            }
        }
    }
    cout << ans;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



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

std::vector<int64_t> calc_seq(std::vector<int64_t> & xs) {
    auto seq = std::vector<int64_t>{};
    auto count = 1;
    for (size_t i = 0; i < xs.size() - 1; i++) {
        if (xs[i] == xs[i+1]) {
            count++;
        } else {
            seq.push_back(count);
            count = 1;
        }
    }
    seq.push_back(count);
    return seq;
}

std::vector<int64_t> form_seq(std::vector<int64_t> & xs) {
    auto seq = calc_seq(xs);
    if (xs[0] == 0) {
        seq.insert(begin(seq), 0);
    }
    if (seq.size() % 2 == 0) {
        seq.push_back(0);
    }
    return seq;
}

int64_t sum(std::vector<int64_t> xs, int64_t i0, int64_t i1) {
    auto val = 0LL;
    for (auto i = i0; i <= i1; i++) {
        val += xs[i];
    }
    return val;
}

void calc(int64_t n, int64_t k, std::vector<int64_t> & xs) {
    auto seq = form_seq(xs);
    auto m = seq.size();
    auto i = 1LL;
    if (i + 2*k > m) {
        std::cout << n;
        return;
    }
    auto val = sum(seq, i-1, i-1 + 2*k);
    auto biggest = val;
    i += 2;
    while (i + 2*k <= m) {
        val += seq[i-1+2*k-1] + seq[i-1+2*k] - seq[i-1-2] - seq[i-1-1];
        if (biggest < val) {
            biggest = val;
        }
        i += 2;
    }
    std::cout << biggest;
}

int main() {
    std::string s1, s2;
    std::cin >> s1 >> s2;
    auto n = stoi(s1);
    auto k = stoi(s2);

    std::string s3;
    std::cin >> s3;
    std::vector<int64_t> xs(n);
    for (size_t i = 0; i < n; i++) {
        xs[i] = stoi(s3.substr(i, 1));
    }
    calc(n, k, xs);
}

Measured memory_bytes: 2868
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;
const double PI = 3.14159265358979323846;
int main() {
    int a, b, k;
    cin >> k >> a >> b;
    bool res = false;
    for(int i = a; i <= b; i++) {
        if(i % k == 0)
            res = true;
    }
    if(res) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3632
def main():
    import sys
    from collections import deque

    input = sys.stdin.readline
    k = int(input())
    q = deque(range(1, 10))

    for i in range(k):
        x = deque.popleft(q)
        if x % 10 != 0:
            q.append(x * 10 + (x % 10) - 1)
        q.append(10 * x + (x % 10))
        if x % 10 != 9:
            q.append(x * 10 + (x % 10) + 1)
    print(x)

if __name__ == "__main__":
    main()

Measured memory_bytes: 11924
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a[][]=new int[2][n];
		int sum[][] = new int[2][n+1];
		for(int i=0; i<2; i++) {
			for(int j=0; j<n; j++) {
				a[i][j]=sc.nextInt();
				sum[i][j+1]=sum[i][j]+a[i][j];
			}
		}
		int max=0;
		for(int i=1; i<=n; i++) {
			max = Math.max(max, sum[0][i] + sum[1][n] - sum[1][i-1]);
		}
		System.out.println(max);
		sc.close();
	}
}


Measured memory_bytes: 23892
# データ構造：ヒープ
import heapq
class heapque:
    def __init__(self, *args):
        self.que = []
        for arg in args:
            self.push(arg)
    def push(self, v):
        heapq.heappush(self.que, v)
    def pop(self):
        return heapq.heappop(self.que)

# 定数
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1

# エントリーポイント
def main():
    N, Q = map(int, input().split())
    S = input()
    LR = tuple(map(int1, input().split()) for _ in range(Q))

    add_sum = [0]
    for n in range(1, N):
        add_sum += [add_sum[-1] + (S[n - 1:n + 1] == "AC")]

    for l, r in LR:
        print(add_sum[r] - add_sum[l])

main()


Measured memory_bytes: 53732
require 'complex'
n, d = gets.split(" ").map(&:to_i)
data = n.times.map { gets.strip.split.map(&:to_i) }
cnt = 0

(0..n-1).each do |i|
  j = data[i][0]
  k = data[i][1]
  x = j**2 + k**2
  y = Math.sqrt(x)
  if y <= d
    cnt += 1
  end
end

puts cnt

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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pull pair<ull, ull>
#define m_p make_pair

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;
	
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
s=list(input())
count=0
for i in range(len(s)-1):
	if s[i+1]=='0' and s[i]=='0':
		s[i+1]='1'
		count+=1
	elif s[i+1]=='1' and s[i]=='1':
		s[i+1]='0'
		count+=1
print(count)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_N = 1e4;
int N, n;
vector<int> es[MAX_N];
int c[MAX_N];
bool used[MAX_N];

void dfs(int now){
    c[now] = n;
    used[now] = true;
    n--;
    for(auto &e: es[now]){
        if(!used[e]) dfs(e);
    }
}

int main(){
    cin >> N;
    rep(i, N-1){
        int u, v;
        cin >> u >> v;
        u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    int sum = 0, a[N];
    rep(i, N){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+N);
    cout << sum-a[N-1] << endl;
    n = N-1;
    dfs(0);
    rep(i, N) cout << a[c[i]] << ' ';
    cout << endl;
}

Measured memory_bytes: 1280
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int main() {
    ll n,w;
    
    cin >> n >> w;
    ll mono[n][2];
    rep(i, n) {
        cin >> mono[i][0] >> mono[i][1];
    }

    ll dp[n+1][100100];
    memset(dp, 0, sizeof(dp));

    rep(i, n) {
        rep(weight, w+1) {
            if(weight-mono[i][0]>=0) {
                chmax(dp[i+1][weight], dp[i][weight-mono[i][0]]+mono[i][1]);
            }
            chmax(dp[i+1][weight], dp[i][weight]); 
        }
    }

    print(dp[n][w]);
    return 0;
}


Measured memory_bytes: 79232
#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()
{
  int n, m; cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  rep(i, m) cin >> p[i] >> s[i];

  vector<bool> f(n, false);
  vector<int> c(n);

  rep(i, m) {
    if(s[i] == "AC") f[p[i]-1] = true;
    else if(!f[p[i]-1]) ++c[p[i]-1];
  }

  int ac = 0, wa = 0;
  rep(i, n) {
    if(f[i]) {
      ++ac;
      wa += c[i];
    }
  }
  cout << ac << " " << wa << endl;
}

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

int n, k;
int cal[13][7];
int num[13], num_sum = 0;
int ans = 0;

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

  for(int i = 0; i < 13; i++){
    for(int j = 0; j < 7; j++){
      cal[i][j] = (i * 7 + j + 1) % 11;
    }
  }

  for(int i = 0; i < 11; i++){
    for(int j = 0; j < 5; j++){
      int sum = 0;
      for(int i2 = 0; i2 < 3; i2++){
	for(int j2 = 0; j2 < 3; j2++){
	  sum += cal[i + i2][j + j2];
	}
      }
      if(sum % 11 == k){
	num[i]++;
	num_sum++;
      }
    }
  }

  n -= 2;
  
  ans += num_sum * (n / 11);

  for(int i = 0; i < n % 11; i++){
    ans += num[i];
  }

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


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main() {
    string SA,SB,SC;
    cin >> SA >> SB >> SC;
    queue<char> A,B,C;
    for(int i = 0; i < SA.size(); i++) A.push(SA[i]);
    for(int i = 0; i < SB.size(); i++) B.push(SB[i]);
    for(int i = 0; i < SC.size(); i++) C.push(SC[i]);
    int i = 0;
    char x = A.front();
    A.pop();
    while(i == 0){
        if(A.size() == 0 && x == 'a'){
            cout << 'A' << endl;
            return 0;
        }
        else if(B.size() == 0 && x == 'b'){
            cout << 'B' << endl;
            return 0;
        }
        else if(C.size() == 0 && x == 'c'){
            cout << 'C' << endl;
            return 0;
        }
        if(x == 'a'){
            x = A.front();
            A.pop();
        }
        else if(x == 'b'){
            x = B.front();
            B.pop();
        }
        else if(x == 'c'){
            x = C.front();
            C.pop();
        }
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

string s;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//	freopen("memory.in", "r", stdin);
	//	freopen("memory.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	if (s == "SUN")
	{
		cout << 7;
		return 0;
	}
	if (s == "SAT")
	{
		cout << 1;
		return 0;
	}
	if (s == "FRI")
	{
		cout << 2;
		return 0;
	}
	if (s == "THU")
	{
		cout << 3;
		return 0;
	}
	if (s == "WED")
	{
		cout << 4;
		return 0;
	}
	if (s == "TUE")
	{
		cout << 5;
		return 0;
	}
	if (s == "MON")
	{
		cout << 6;
		return 0;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& e : a) cin >> e;
  int min = *min_element(a.begin(), a.end());
  int max = *max_element(a.begin(), a.end());
  long long sum = accumulate(a.begin(), a.end(), 0LL);
  cout << min << " " << max << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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 (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N;cin >> N;
    vector<LL> a(N);
    rep(i,N)cin >> a[i];
    vector<LL> rui(N);
    rep(i,N){
        if(i == 0)rui[i] = a[i];
        else {
            rui[i] = rui[i-1] + a[i];
        }
    }
    LL tmp1 = 0;
    LL ct1 = 0;
    LL tmp2 = 0;
    LL ct2 = 0;
    LL now = 0;
    rep(i,N){   //スタートが正
        if(i%2==0){ // 正であるべき
            if(rui[i]+tmp1 > 0)continue;
            else if(rui[i]+tmp1 == 0){
                now = rui[i] + tmp1;
                tmp1 += 1;
                ct1 += 1;
            }
            else{
                now = rui[i] + tmp1;
                tmp1 += abs(now)+1;
                ct1 += abs(now)+1;
            }
        }
        else {  // 負であるべき
            if(rui[i]+tmp1 < 0)continue;
            else if(rui[i]+tmp1 == 0){
                tmp1 -= 1;
                ct1 += 1;
            }
            else{
                now = rui[i] + tmp1;
                tmp1 += -(abs(now)+1);
                ct1 += abs(now)+1;
            }
        }
    }
        rep(i,N){   //スタートが負
        if(i%2==0){ // 負であるべき
            if(rui[i]+tmp2 < 0)continue;
            else if(rui[i]+tmp2 == 0){
                tmp2 -= 1;
                ct2 += 1;
            }
            else{
                now = rui[i] + tmp2;
                tmp2 += -(abs(now)+1);
                ct2 += abs(now)+1;
            }
        }
        else {  // 正であるべき
            if(rui[i]+tmp2 > 0)continue;
            else if(rui[i]+tmp2 == 0){
                tmp2 += 1;
                ct2 += 1;
            }
            else{
                now = rui[i] + tmp2;
                tmp2 += (abs(now)+1);
                ct2 += abs(now)+1;
            }
        }
    }
    LL ans = min(ct1,ct2);
    cout << ans << endl;
}


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

const int N = 100005;
int n, cost, ans, mxd[N], mxd2[N];
vector<int> g[N];
char s[N];

void dfs(int u, int fa) {
	int deg = 0;
	for (int v : g[u])
		if (v != fa) {
			dfs(v, u);
			if (s[v] != 1) ++deg;
		}
	if (!deg && s[u] == 'B') { s[u] = 1; return; }
	deg &= 1;
	if (fa) deg ^= 1;
	int val = 2 * (s[u] == 'W' ^ deg);
	cost += s[u] == 'W' ^ deg;
	if (fa) cost += 2;
	for (int v : g[u])
		if (s[v] != 1 && v != fa) {
			ans = max(ans, val + mxd[u] + mxd2[v]);
			ans = max(ans, mxd2[u] + mxd[v]);
			mxd[u] = max(mxd[u], mxd[v]);
			mxd2[u] = max(mxd2[u], val + mxd2[v]);
		}
	ans = max(ans, mxd[u]);
	mxd[u] += val;
	ans = max(ans, mxd2[u]);
}

int main() {
	scanf("%d", &n);
	for (int i = 1, x, y; i < n; ++i) {
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	scanf("%s", s + 1);
	int rt = -1;
	for (int i = 1; i <= n; ++i)
		if (s[i] == 'W') rt = i;
	if (rt == -1) puts("0");
	else {
		dfs(rt, 0);
		printf("%d\n", cost - ans);
	}
	return 0;
}


Measured memory_bytes: 16000
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

ll A,B,C,D;

inline void file() {
	freopen("AGC026B.in","r",stdin);
	freopen("AGC026B.out","w",stdout);
}

int main() {
//	file();
	int T; scanf("%d",&T);
	while (T--) {
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		if (A<B) {
			puts("No"); continue;
		}
		if (B<=C) {
			if (B<=D) {
				puts("Yes"); continue;
			}
			else {
				puts("No"); continue;
			}
		}
		if (B>D) {
			puts("No"); continue;
		}
		ll G=__gcd(B,D),Y=A%G;
/*		int flag=1;
		for (ll E=C+1;E<=B-1;++E)
			if (E%G==Y) {
				puts("No"); flag=0; break;
			}
		if (flag) puts("Yes");*/
		ll K=(C/G)*G;
		if (C+1<=K+Y && K+Y<=B-1) {
			puts("No"); continue;
		}
		K+=G;
		if (C+1<=K+Y && K+Y<=B-1) {
			puts("No"); continue;
		}
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3.4

# abc127_a

import itertools
import functools

def main():
    # Input
    a, b = [int(s) for s in input().split()]
    # Get ans
    if a >= 13:
        ans = b
    elif 6 <= a <= 12:
        ans = b//2
    elif a <= 5:
        ans = 0
    # Output
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    bool f;
    for(int k = 0;k < n - m + 1;k++){
        for(int i = 0;i < a.size() - b.size() + 1;i++){
            f = true;
            rep(j,m){
                rep(l,b.size()){
                    if(a[k + j][i + l] != b[j][l]){
                        f = false;
                    }
                }
            }
            if(f){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b && b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 1916
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) {
    if (i) {
      cout << ", ";
    }
    cout << vec.at(i);
  }
  cout << "]...size: " << vec.size() << endl;
}

int main() {
  int n;
  cin >> n;
  int count = 0;

  rep(i, n) {
    int x;
    cin >> x;

    if (x == 2) {
      count++;
    } else if (x % 2 == 0) {
      continue;
    } else {
      bool bl = true;
      int j = 3;
      while (j <= sqrt(x)) {
        if (x % j == 0) {
          bl = false;
          break;
        }
        j += 2;
      }
      if (bl) {
        count++;
      }
    }
  }

  printf("%d\n", count);
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
const ll INF = 100000000000;
// グラフ
using Edge = pair<int, ll>;         // {重み, 行き先}
using Graph = vector<vector<Edge>>; // グラフ

set<pair<int, int>> use;
long ROOT[1000000];

void dijkstra(const Graph &G, int s){
  vector<ll> dist((int)G.size(), INF);
  vector<vector<int>> prev((int)G.size()); // prev[v] := v から復元できる辺たち
  dist[s] = 0;
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
  que.push(make_pair(0, s));
  while(!que.empty()) {
    auto cur = que.top(); que.pop();
    ll cur_dist = cur.first;
    int v = cur.second;
    if(cur_dist > dist[v]) continue; //枝狩り
    for(auto e : G[v]) {
      if(dist[e.first] > dist[v] + e.second){
        dist[e.first] = dist[v] + e.second;
        que.push(make_pair(dist[e.first], e.first));
        prev[e.first].clear();
        prev[e.first].push_back(v);
      }else if(dist[e.first] == dist[v] + e.second){
        prev[e.first].push_back(v);
      }
    }
  }
  for (int i = 1; i < (int)G.size(); i++){
    for(auto u : prev[i]){
      cout << u+1 << endl;
      break;
    }
  }
  
}

int main() {
  int n, m;
  cin >> n >> m;
  Graph G(n);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(Edge(b,1));
    G[b].push_back(Edge(a,1));
  }
  cout << "Yes" << endl;
  dijkstra(G, 0);
}

Measured memory_bytes: 22008
// by Balloons
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,maxn=1e5+5;

int n,m,a[maxn],vis[maxn],b[maxn],c;
vector<int>g[maxn];

void dfs(int x){
//	printf("x=%d\n",x);
	++ b[x];++ b[a[x]];
	if(b[x] == 2)++c;
	if(b[a[x]] == 2)++c;
	if(x == a[x])-- c;
	vis[x] = 1;
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i];
		if(!vis[u])dfs(u);
	}
//	-- b[x];-- b[a[x]];
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		g[x].push_back(y);g[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			dfs(i);
			memset(b,0,sizeof b);
//			for(int j=1;j<=10;j++)printf("%d ",b[j]);
		}
	printf("%d\n",c);

	return 0;
}


Measured memory_bytes: 9344
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

def dist(A, B):
	return abs(A[0]-B[0]) + abs(A[1]-B[1])

N = INT()
xy = [LIST()+[i] for i in range(N)]

xy1 = [[xy[i][0]+xy[i][1], i] for i in range(N)]
xy1.sort(key=lambda x:x[0])
idx_a = xy1[0][1]
idx_b = xy1[-1][1]
a = xy[idx_a]
b = xy[idx_b]

xy2 = [[-xy[i][0]+xy[i][1], i] for i in range(N)]
xy2.sort(key=lambda x:x[0])
idx_c = xy2[0][1]
idx_d = xy2[-1][1]
c = xy[idx_c]
d = xy[idx_d]

print(max(dist(a, b), dist(a, c), dist(a, d), dist(b, c), dist(b, d), dist(c, d)))

Measured memory_bytes: 113300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; ll l;
    cin >> n >> l;
    VL a(n);
    cin >> a;

    string ans = "Impossible\n";
    int t = -1;
    FOR(i, 0, n - 1)if (a[i] + a[i + 1] >= l) {
        ans = "Possible\n";
        t = i;
    }
    
    cout << ans;
    if (t == -1)return 0;
    FOR(i, 0, t)cout << i + 1 << "\n";
    rFOR(i, t, n - 1)cout << i + 1 << "\n";
}

Measured memory_bytes: 1664
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    string s;
    cin >> s;
    ll n = sz (s);
    vl ans (n + 1);
    FOR (i, 0, n) {
        if (s[i] == '<') {
            ans[i + 1] = max (ans[i] + 1, ans[i + 1]);
        }
    }
    FORd (i, 0, n) {
        if (s[i] == '>') {
            ans[i] = max (ans[i], ans[i + 1] + 1);
        }
    }
    ll res = 0;
    FOR (i, 0, n + 1) res += ans[i];
    cout << res << '\n';
}


Measured memory_bytes: 4764