akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>
#include <bitset>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

template<typename T>
class DoublingMgr{
  //next[k][i]: iの2^k個次の要素
  const int n,log_n;
  std::vector<std::vector<T>> next;

public:
  DoublingMgr(std::vector<lint> next_vec):n(next_vec.size()),log_n(64),
                                         next(65,std::vector<T>(next_vec.size())){
    for(int i=0;i<n;i++){
      next[0][i]=next_vec[i];
    }
    for(int k=0;k<log_n-1;k++){
      for(int i=0;i<n;i++){
        if(next[k][i]==-1){
          next[k+1][i]=-1;
        }else{
          next[k+1][i]=next[k][next[k][i]];
        }
      }
    }
  }
  /// \brief p番目の要素のq個次を求める
  T GetValue(int p,lint q){
    bitset<64> bs(q);

    for(int k=63;k>=0;k--){
      if(p==-1){
        return p;
      }
      if(bs[k]){
        p=next[k][p];
      }
      // if((q>>k)&1){
      //   p=next[k][p];
      //   if(p==n-1) break;
      // }
    }
    return p;
  }
};

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint n,k;
  cin>>n>>k;
  vector<lint> a(n+1);
  for(int i=1;i<=n;i++){
    cin>>a[i];

  }

  DoublingMgr<lint> mgr(a);
  cout<<mgr.GetValue(1,k)<<endl;




  return 0;
}




Measured memory_bytes: 109572
#include <stdio.h>
long long n, a, b, x;
int main() {
	scanf("%lld%lld%lld", &n, &a, &b);
	x += a * (n / (a + b));
	n -= n / (a + b) * (a + b);
	if (n > a)n = a;
	x += n;
	printf("%lld\n", x);
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, ans=0;

    cin >> N;

    vector<int> A(N), B(N), C(N-1);

    rep(i,N) {
        cin >> A[i];
    }

    rep(i,N) {
        cin >> B[i];
    }

    rep(i,N-1) {
        cin >> C[i];
    }

    rep(i,N) {
        ans += B[A[i]-1];
        if(A[i]-1==A[i-1]) {
            ans += C[A[i]-2];
        }
    }

    cout << ans << endl;

    return 0;
    
}

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

using namespace std;

int main() {
  int a[4];
  for (int i = 0; i < 4; i++) {
    scanf("%d", a + i);
    if (i > 0) a[i] = min(a[i], a[i - 1] * 2);
  }
  int n;
  scanf("%d", &n);
  printf("%lld\n", 1ll * n / 2 * a[3] + (n % 2) * a[2]);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#define maxsize 100000
using namespace std;
typedef  long long ll;
int h[maxsize];
int dp[maxsize];
int main(){
ll n;
int i,j;
while(scanf("%lld",&n)!=EOF){
    for(i=1;i<=n;i++)
        scanf("%d",&h[i]);

    dp[2]=fabs(h[2]-h[1]);

    int temp1=fabs(h[3]-h[1]);
    int temp2=dp[2]+fabs(h[3]-h[2]);

    if(temp1<temp2)
        dp[3]=temp1;
    else
        dp[3]=temp2;

    for(i=4;i<=n;i++){
        temp1 = dp[i-1]+fabs(h[i]-h[i-1]);
        temp2=dp[i-2]+fabs(h[i]-h[i-2]);
        if(temp1<temp2)
            dp[i]=temp1;
        else
            dp[i]=temp2;
    }
    cout<<dp[n]<<endl;

}




}


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

#define int long long

const int INF = 1e15;

int dp[55555];
int c[22];

int n, m;

int rec(int money) {
  // 終了条件
  if (money == 0) {
    return dp[money] = 0;
  }

  // 計算済みならその値を返す
  if (dp[money] != INF) {
    return dp[money];
  }

  int ans = INF;
  for (int i = 0; i < m; i++) {
    if (money - c[i] < 0) continue;
    ans = min(ans, rec(money - c[i]) + 1);
  }

  // 計算した値をメモする
  return dp[money] = ans;
}

signed main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> c[i];
  }

  fill(dp, dp + n + 10, INF);
  cout << rec(n) << endl;

  return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0, two = 1;
    rep(k, 60) {
        int x = 0;
        rep(i, n) if (a[i]>>k&1) ++x;
        ll now = (ll)x*(n-x) % mod * two % mod;
        ans = (ans + now) % mod;
        two = (two * 2) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5628
n,a=map(int,input().split())
x=list(map(lambda x:int(x)-a,input().split()))
m=0 if min(x)>0 else min(x)*n
M=1 if max(x)<0 else max(x)*n+1
dp=[[0]*(M-m) for _ in range(n)]
dp[0][x[0]]+=1
dp[0][0]+=1
for i in range(n-1):
    for j in range(m,M):
        if j+x[i+1] in range(m,M):dp[i+1][j+x[i+1]]+=dp[i][j]
        dp[i+1][j]+=dp[i][j]
print(dp[n-1][0]-1)

Measured memory_bytes: 4580
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int gcd(int a, int b){
    int m, n;
    m = min(a,b);
    n = max(a,b);
    if(m==0){
        return(n);
    }else{
        return(gcd(m, n%m));
    }
}

int main(){
    int n,g,k;
    cin >> n >> k;
    vector<int> a(n);
    g = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        g = gcd(g,a[i]);
    }
    string ans = "IMPOSSIBLE";
    for(int i=0; i<n; i++){
        if(a[i]-k>=0 and (a[i]-k)%g==0){
            ans = "POSSIBLE";
        }
    }
    cout << ans;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 100000000007
#define pi acos(-1.0)
ll n,m,j,k,l,t,arr[sz],brr[sz],crr[sz],drr[sz];
int main()
{
  scanf("%lld",&n);
  double l=double(n);
  l=pi*(n)*(2.0);
   printf("%f\n",l);
}


Measured memory_bytes: 3832
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	n := scanInt(sc)
	s, t := scanString(sc), scanString(sc)
	bu := bytes.NewBufferString("")
	for i := 0; i < n; i++ {
		bu.WriteByte(s[i])
		bu.WriteByte(t[i])
	}
	fmt.Println(bu.String())
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  bool can=false;
  if (b==1) can=true; else
  {
    for(int i=0; i<b; ++i)
    {
      int id =i*a-c;
      if (id%b==0) can=true;
    }
  }
  if (can) cout << "YES"; else cout << "NO";
  return 0;
}

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

bool	issame(const string &W, const string &T)
{
	size_t	len = W.size();
	if (len != T.size())
	   return false;
	for (size_t	i = 0; i < len; ++i) {
		if (W.at(i) != tolower(T.at(i)))
			return false;
	}
	return true;
}

int	main()
{
	string	W;
	cin >> W;
	string	T;
	int	cnt = 0;
	while (cin >> T) {
		if (T == "END_OF_TEXT") break;
		if (issame(W, T))
			++cnt;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A;
  cin>>N>>A;
  int X;
  X = N-A;
  if(N<A||N%500<=A||N%500==0){
      cout<<"Yes"<<endl;
  }else{
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3592
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

#木なので一度に隣り合うマスを全て塗っても答えは同じ
N = ir()
edges = [[] for _ in range(N+1)] #1-indexed
for _ in range(N-1):
    a, b = lr()
    edges[a].append(b)
    edges[b].append(a)

fen = 0
snu = 0
used = set([1, N])
fen_list = [1]
snu_list = [N]
while fen_list or snu_list:
    f = []
    for x in fen_list:
        for next in edges[x]:
            if next in used:
                continue
            fen += 1
            f.append(next)
            used.add(next)
    fen_list = f
    s = []
    for y in snu_list:
        for next in edges[y]:
            if next in used:
                continue
            snu += 1
            s.append(next)
            used.add(next)
    snu_list = s

print('Fennec' if fen > snu else 'Snuke')
# 46

Measured memory_bytes: 42692
#include<stdio.h>

int main(){
	long int a,b,c,i;
	char input[32];
	
	fgets(input,sizeof input,stdin);
	sscanf(input,"%ld %ld",&a,&b);
	
	while(1){
		if(a>=b){
			if(a%b==0){
				printf("%d\n",b);
				break;
			}
			a=a%b;
		}else{
			if(b%a==0){
				printf("%d\n",a);
				break;
			}
			b=b%a;
		}
		
	}
	/*??????????????????
	if(a<=b){
		c=b%a;
		for(i=a;i>0;i--){
			if(c%i==0&&a%i==0){
				printf("%ld\n",i);
				break;
			}
		}
	}else{
		c=a%b;
		for(i=b;i>0;i--){
			if(c%i==0&&b%i==0){
				printf("%ld\n",i);
				break;
			}
		}
	}
	*/
	
	
	return 0;
}

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

int main(){
    double a,b,c;
    scanf("%lf %lf %lf",&a,&b,&c);
    double pi = acos(-1);
    double rad = pi*c/180;
    printf("%f\n",a*b*sin(rad)/2);
    printf("%f\n",sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(rad))+a+b);
    printf("%f\n",b*sin(rad));
}


Measured memory_bytes: 2100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int R = scanner.nextInt();
		
		if((0 <= R)&&(R < 1200)) {
			System.out.println("ABC");
		}else if ((1200 <= R)&&(R < 2800)) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}

	}

}

Measured memory_bytes: 21716
N,C = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
A.insert(0,[0,0])

F = [0 for _ in range(N+1)]
F[N] = A[N][1]-(C-A[N][0])
for i in range(N-1,0,-1):
    F[i] = F[i+1]+A[i][1]-(A[i+1][0]-A[i][0])
G = [0 for _ in range(N+1)]
for i in range(1,N+1):
    G[i] = G[i-1]+A[i][1]-(A[i][0]-A[i-1][0])
cmax = max(max(F),max(G))
dmax = 0
for i in range(N-1,0,-1):
    dmax = max(dmax,F[i+1])
    cmax = max(cmax,dmax+G[i]-A[i][0])
emax = 0
for i in range(2,N+1):
    emax = max(emax,G[i-1])
    cmax = max(cmax,emax+F[i]-(C-A[i][0]))
print(cmax)

Measured memory_bytes: 68568
def resolve():
    N = int(input())
    a = set([N])
    i = 1
    l = 1
    while True:
        i += 1
        if N % 2 == 0:
            N = N // 2
        else:
            N = 3 * N + 1
        a.add(N)
        if l == len(a):
            print(i)
            break
        else:
            l += 1


resolve()


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 1005;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int arr[MX][MX];
int dp[MX][MX];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int H,W; cin >> H >> W;

    F0R(y,H) F0R(x,W) {
        char c; cin >> c;

        if (c == '.') arr[y][x] = 0;
        else arr[y][x] = -INF;
    }

    dp[0][0] = 1;
    F0R(y,H) F0R(x,W) {
        dp[y][x] = (((dp[y][x]+((y-1 >= 0 && arr[y-1][x] != -INF)?dp[y-1][x]:0))%MOD)+((x-1 >= 0 && arr[y][x-1] != -INF)?dp[y][x-1]:0))%MOD;
    }

    cout << dp[H-1][W-1] << "\n";

}//4299578163927654889881600000/121645100408832000


Measured memory_bytes: 8192
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        long a=nl(),b=nl();

        pn((a+b)%2!=0?"IMPOSSIBLE":(a+b)/2l);
    }


    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;
    static long mod=(long)1e9+7l;

    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 21204
using System;

class A5{
  static int n;
  static string[] str;
  static int[] A;
  static int q;
  static string[] str2;
  static int[] M;

  public static void Main(){
    n = int.Parse(Console.ReadLine());
    str = Console.ReadLine().Split(' ');
    A = new int[n];
    q = int.Parse(Console.ReadLine());
    str2 = Console.ReadLine().Split(' ');
    M = new int[q];


    for(int i = 0;i < n;i++){
      A[i] = int.Parse(str[i]);
    }
    for(int i = 0;i < q;i++){
      M[i] = int.Parse(str2[i]);
    }

    for(int i = 0;i < q;i++){
      if(Solve(0,M[i]))
       Console.WriteLine("yes");
      else Console.WriteLine("no");
    }
}

  static bool Solve(int i,int m){
      if(m == 0) return true;
      if(i >= n) return false;
      bool res = Solve(i + 1,m)|| Solve(i + 1,m - A[i]);
      return res;
    }
}



Measured memory_bytes: 8836
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
ll dp[202][20011]={1},ans;
int n,W,w[201],sum[201];

int main(){
  cin>>n>>W;
  for(int i=0;i<n;i++)cin>>w[i];
  sort(w,w+n,greater<int>());
  sum[n-1]=w[n-1];
  for(int i=n-2;i>=0;i--) sum[i]=w[i]+sum[i+1];
  
  for(int i=0;i<n;i++){
    for(int j=0;j<=W&&sum[i+1]<=W;j++)if(sum[i+1]+j<=W&&sum[i+1]+w[i]+j>W) ans=(ans+dp[i][j])%mod;

    for(int j=0;j<=W;j++){
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j+w[i]]=(dp[i+1][j+w[i]]+dp[i][j])%mod;
    }
  }

  cout << max(1LL,ans)<<endl;
  return 0;
}

Measured memory_bytes: 22640
from math import *

a=[]
for i in range(-501,501):
	a.append([int(pow(i,5)),i])

b=[]
for i in range(len(a)):
	for j in range(len(a)):
		if a[i][0]-a[j][0]>0:
			b.append([a[i][0]-a[j][0],a[i][1],a[j][1]])

x=int(input())

for i in range(len(b)):
	if b[i][0]==x:
		print(b[i][1],b[i][2])
		break

Measured memory_bytes: 80872
//*******************************By Harry Singh From Phillaur.
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000006
const ll mo=1000000007;
#define string_to_any_base(s,base) stoll(s, 0, base);
#define vc vector
// #define mp map<ll,ll> mp;
#define bt(M,value) bitset<M> b(value)
#define S set<ll> s;
#define ST set<string> s;
#define INF 1e15
using namespace std;
set<ll> primes;
vector<pair<ll,ll>> adj[MAX];
vector<ll> ad[MAX];
///******************************ALL important functions;
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b);} 
ll lcm(ll a, ll b)  {  return (a*b)/gcd(a, b);  } 
void Sieve(){ bool prime[MAX+1]; memset(prime, true, sizeof(prime)); for (int p=2; p*p<=MAX; p++) { if (prime[p] == true) {for (int i=p*p; i<=MAX; i += p) prime[i] = false; } } for(int i=2;i<=MAX;i++)if(prime[i]==true)primes.insert(i);} 
ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;}
ll modpow(ll a, ll n=mo-2) {ll r=1;while(n)r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;return r;}





int main()
{
	ll n;
	cin>>n;
	ll a[n+1];
   ll dp[4]={0};
	ll sum=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		ll count=0;
		for(int j=0;j<3;j++)
		if(dp[j]==a[i])count++;
		for(int j=0;j<3;j++){
		if(dp[j]==a[i]){dp[j]++;;break;}}
		sum=(sum*count)%mo;
		
	}
	cout<<sum<<endl;
}



Measured memory_bytes: 48128
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= n;++i){
		cin >> a[i];
	}
	int j = 1;
	int count = 0; 
	for(int i = 1;i <= n;++i){
		if(a[i] == j){
			j += 1;
		}
		else{
			count += 1;
		}
	}
	if(count != n)
		cout << count;
	else{
		cout << "-1" ;
	}
	return 0;
}

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

  double ans;

  double k;

  if ( n == 1 ) {
    k = n;    
  } else if ( n%2 == 0 ) {
    k = n/2;
  }else {
    k = n/2 + 1;
  }

  ans = k/n;

  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

#define ll long long
priority_queue <ll> qu;
int main()
{
    ll x,y,z,k,a[1005],b[1005],c[1005];
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++)
        cin>>a[i];
    for(int i=0;i<y;i++)
        cin>>b[i];
    for(int i=0;i<z;i++)
        cin>>c[i];
        sort(a,a+x,greater<ll>());
        sort(b,b+y,greater<ll>());
        sort(c,c+z,greater<ll>());
    for(int i=0;i<x;i++)
    {
        for(int j=0;j<y;j++)
        {
            for(int q=0;q<z;q++)
            {
                qu.push(a[i]+b[j]+c[q]);
                if((i+1)*(j+1)*(q+1)>3000)
                {
                    break;
                }
            }
        }
    }
    for(int i=0;i<min(k,x*y*z);i++)
    {
        ll ans=qu.top();
        qu.pop();
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 18792
#!/usr/bin/env python3
#CODEFESTIVAL2016 qual A C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
k = I()
n = len(s)
alpha = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
for i in range(n-1):
    a = 26 - alpha.index(s[i])
    if s[i] == 'a':
        ans += s[i]
        continue
    if a <= k:
        k -= a
        ans += 'a'
    else:
        ans += s[i]
if k > 0:
    tmp = alpha.index(s[-1])
    ans += alpha[(tmp + k % 26) % 26]
else:
    ans += s[-1]
print(ans)


Measured memory_bytes: 3880
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

int main() {
    init();
    double t, x;
    cin >> t >> x;

    cout << t/x << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 256
N=int(input())
A=input().split()
A=[int(a) for a in A]

ans="APPROVED"
for i in range(N):
    if  A[i]%2==0:
        if (A[i]%3!=0) and (A[i]%5!=0):
            ans="DENIED"
            break

print(ans)
            
        

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n, m;
    cin >> n >> m;

    vector<int> cnt(n + 3);
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        ++cnt[l]; --cnt[r + 1];
    }
    for (int i = 1; i <= n; ++i)
        cnt[i] += cnt[i - 1];

    int num = 0;
    for (int i = 0; i <= n; ++i)
        if (m <= cnt[i]) ++num;

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int n,a,b;
    cin >> n >> a >> b;
    if(a + b <= n){
      cout << min(a, b) << " " << 0 << endl;
    }else{
      cout << min(a, b) << " " << a + b - n << endl;
    }
}

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

public class Main {
	static String str;
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args) {
		str = scan.nextLine();
		//???????????????????????°???dice???????´?
		String[] dice = str.split(" ");
		//?????????????´?????????????
		String[] designate;
		int q = Integer.parseInt(scan.nextLine());
		
		for (int i = 0; i < q; i++) {
			str = scan.nextLine();
			designate = str.split(" ");
			sort(dice, designate);
		}
	}
	

	private static void sort(String[] dice, String[] designate){
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				for (int h = 0; h < 4; h++) {
					String[] direction = new String[i+j+(h*3)];
					String[] dice2 = Arrays.copyOf(dice, dice.length);
					for (int k = 0; k < i; k++) {
						direction[k] = "N";
					}
					for (int l = 0; l < j; l++) {
						direction[i+l] = "E";
					}
					for (int f = 0; f < h; f++) {
						int num = f * 3;
						direction[i+j+num] = "W";
						direction[i+j+(num+1)] = "S";
						direction[i+j+(num+2)] = "E";
					}
				
					move(dice2, direction);
					
					
					if(dice2[0].equals(designate[0]) && dice2[1].equals(designate[1])){
						System.out.println(dice2[2]);
						return;
					}
				}
				}
				
		}
	}
	
	/**
	 * move
	 * ???????????????????????°???????????????
	 * @param dice
	 * @param designate
	 * @return dice[2] (????????????????????´?????????)
	 */
	private static String[] move(String[] dice, String[] direction) {
		for (int i = 0; i < direction.length; i++) {
			if(direction[i].equals("E")){
				str = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = str;
			}else if(direction[i].equals("W")){
				str = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = str;
			}else if(direction[i].equals("S")){
				str = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = str;
			}else if(direction[i].equals("N")){
				str = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = str;
			}
		}
		return dice;		
	}
}

Measured memory_bytes: 17196
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
#define mod  100007
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline ll add(ll a, ll b) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bpw(ll a, ll p){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

ll ar[1<<17], br[1<<17];

int main(){
	ll n; read(n);
	FER(i, 1, n+1) {
		read(ar[i]);
		br[ar[i]] = i;
	}
	FER(i, 1, n+1) cout<<br[i]<<" "; cout<<"\n";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcm(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcm(b, a % b); 
}
ll lcm(ll a, ll b) {
    return a * b / gcm(a, b);
}
int d(ll n) {
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    cout << lcm(2, n) << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  double ans;
  cin >> N;
  
  if (N % 2 == 0)
    ans = 0.5;
    
  else {
    double n;
    n = N;
    ans = ( (n + 1) / 2 ) / n;  
  }
    
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    int m;
    cin >> m;
    while(m--){
        int x, y;
        cin >> x >> y;
        int ans = 0;
        for(int i = 0; i < n; ++i){
        if((i + 1) == x) ans += y;
        else ans += arr[i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3704
#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
#define MOD 1000000007
#define yes "YES"
#define no "NO"
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;

int main() {
    fastcin;
    int n, ans, a, b = 0;
    string x;
    cin >> n;
    if(n<=10) ans = n;
    else {
        x = to_string(n);
        a = x[0] - '0';
        rep(i, 1, x.size()) {
            b += x[i] - '0';
        }
        if(b==0) {
            if(a==1) {
                a = 5;
                b = 5;
            } else {
                a -= 1;
                b = 1;
            }
        }
        ans = a + b;
    }
    print(ans);
    return 0;
}

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

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

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

  string n;
  cin >> n;

  if (n.at(0) == n.at(2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	int a,b;
	cin >> a >> b;
    string s(a, '0'+b);
    string t(b, '0'+a);
	cout << min(s,t) << endl;
	return 0;
}


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

int main() {
 int N;
 cin >> N;
  vector<int> kazu(N-1);
  for(int i = 0; i < N-1; i++){
    cin >> kazu.at(i);
  }
  int sum = kazu.at(0);
  for(int i = 0; i < N-2; i++){
      sum += min(kazu.at(i), kazu.at(i+1));
  }
  sum += kazu[N-2];
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=100000000;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)

int main(){
	int a,b,c;
	cin>>a;
	if(a==1){
		cout<<"Hello World"<<endl;
	}
	else{
		cin>>b>>c;
		cout<<b+c<<endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
int main() {
	int N;
	cin >> N;
	for (int i = 0; i * 4 <= N; i++) {
		if ((N - i * 4) % 7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 896
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    r=ii()
    print(3*r*r)

main()




Measured memory_bytes: 3700
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    H_li = LI()

    now_count = 0
    max_count = 0
    now_height = H_li[0]

    for h in H_li[1:]:
        if now_height >= h:
            now_count += 1
        else:
            max_count = max(max_count, now_count)
            now_count = 0
        now_height = h
    max_count = max(max_count, now_count)

    print(max_count)

main()

Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)
int main()
{
    ll n,i,j,k,l,a,b,c,d;
    double x;
    cin>>n;
    x=2*pi*n;
    cout<<fixed<<setprecision(2)<<x<<endl;
    return 0;

}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    string ans = "YES";
    rep(i, n - 1)
    {
        if (a[i] == a[i + 1])
        {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int c = 0;
  for (int i=0; i<s.size(); i++) {
    if (s[i] == 'o') {
      c++;
    }
  }
  cout << 700 + 100 * c << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    xs = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    ps = [
        sum((x & (1<<i)) >> i for x in xs)
        for i in range(60)
    ]
    ms = [n - p for p in ps]

    ans = 0

    for i in range(60):
        s = 0
        for x in xs:
            b = (x & (1<<i)) >> i
            if b == 1:
                ps[i] -= 1
                s += ms[i]
            else:
                ms[i] -= 1
                s += ps[i]
        ans += s * (2**i % mod)
        ans = ans % mod

    print(ans)

main()

Measured memory_bytes: 125624
f=!1
while (n = gets.to_i) != 0
  if f;puts;end;f=1
  puts (1..n).map{
    t,a,b,c=gets.split;
    [t,a.to_i*3+c.to_i]
  }.sort_by.with_index{|v,i|[-v[1],i]}.map{|x|
    x.join","
  }.join"\n"
end

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector


int n,w;
int value[N],weight[N];
int dp[120][100002];
int get(int ind,int val)
{
    if(val<0)return MOD*MOD;
    if(ind==n+1)
    {
        if(val == 0)return 0;
        else return MOD*MOD;
    }
    int&ans=dp[ind][val];
    if(ans!=-1)return ans;
    ans=min(weight[ind]+get(ind+1,val-value[ind]),get(ind+1,val));
    return ans;
}

signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    forn(i,0,100)forn(j,0,100000)dp[i][j]=-1;
    cin>>n>>w;
    forn(i,1,n)cin>>weight[i]>>value[i];
    forn(i,1,100000)int a = get(1,i);
    //cout<<get(1,30);
    rfor(i,100000,0)
    if(get(1,i)<=w)
    {
        cout<<i;
        return 0;
    }
    




     return 0;

}

//       g++ -g c.cpp ; ./a.exe

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

int main(){
	string s;
	cin>>s;
	int aa,bb;
	aa=0;
	bb=0;
	
	
	for(int i=0;i<=s.length()-1;i++){
		if(s[i]!='1' and i%2==0){
			aa++;
		}
		else if(s[i]!='0' and i%2==1){
			aa++;
		}
	}
	for(int i=0;i<=s.length()-1;i++){
		if(s[i]!='0' and i%2==0){
			bb++;
		}
		else if(s[i]!='1' and i%2==1){
			bb++;
		}
	}
	cout<<min(aa,bb)<<"\n";
}


Measured memory_bytes: 512
import sys

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret


import math

def get_primenumber(number):#エラトステネスの篩
    prime_list = []
    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
    while search_list[0] <= math.sqrt(number):
      #search_listの先頭の値が√nの値を超えたら終了
      #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        search_list = [num for num in search_list if num % head_num != 0]
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list

#p=get_primenumber(79000)

n=int(input())
ap=list(map(int,input().split()))
amin=min(ap)
amax=max(ap)

if amax==1:
    print("pairwise coprime")
    sys.exit()

if amin!=1:
    bp=enum_div(amin)+[amin]
    bp=bp[1:]
    for bpi in bp:
        yn=""
        for ai in ap:
            if ai%bpi!=0:
                yn="coprime"
                break
        if yn=="":
            print("not coprime")
            sys.exit()

if n>=78500 :
    print("setwise coprime")
    sys.exit()

p=get_primenumber(amax)

aa=[0]*(amax+1)
for ai in ap:
    aa[ai]+=1
    
#for pp in range(2,amax+1):
for pp in p:
#    psum=0
#    for pi in range(pp,amax+1,pp):
#        psum+=aa[pi]
    psum=sum(aa[pp: :pp])
#    print("pp:",pp,psum)
    if psum>=2:
            print("setwise coprime")
            sys.exit()
## max_13.txt ... max_16.txt : "setwise coprime"
print("pairwise coprime")
   


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

long long int N, a[114514], m[114514], k[114514], b, d, i;

static inline long long modinv(long long n){
    long long ret = 1, a = 1000000005;
    n %= 1000000007;
    while(a){
        if(a % 2){
            ret = (ret * n) % 1000000007;
        }
        n = (n * n) % 1000000007;
        a /= 2;
    }
    return ret;
}

int main(){
    scanf("%lld", &N);
    m[0] = 1;
    k[0] = 1;
    for(i = 0; i <= N; ++i){
        m[i + 1] = (((m[i] * (N + 1 - i)) % 1000000007) * modinv(i + 1)) % 1000000007;
    }
    for(i = 0; i <= N; a[b] = ++i){
        scanf("%lld", &b);
        if(a[b] != 0){
            d = i - a[b];
            break;
        }
    }
    for(i = 0; i <= N; ++i){
        k[i + 1] = (((k[i] * (N - d - 1 - i)) % 1000000007) * modinv(i + 1)) % 1000000007;
    }
    for(i = 1; i <= N + 1; ++i)cout << (m[i] - k[i - 1] + 1000000007) % 1000000007 << endl;
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int VW, int VH> struct Ruisekiwa2D {
    int v[VH][VW];
    void set(int x, int y, int c) { v[y][x] = c; }
    void build() {
        rep(y, 0, VH) rep(x, 0, VW) {
            if (0 < y) v[y][x] += v[y - 1][x];
            if (0 < x) v[y][x] += v[y][x - 1];
            if (0 < y && 0 < x) v[y][x] -= v[y - 1][x - 1];
        }
    }
    int get(int sx, int sy, int tx, int ty) {
        assert(sx <= tx && sy <= ty);
        int rs = v[ty][tx];
        if (0 < sx) rs -= v[ty][sx - 1];
        if (0 < sy) rs -= v[sy - 1][tx];
        if (0 < sx && 0 < sy) rs += v[sy - 1][sx - 1];
        return rs;
    }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, K, X[101010], Y[101010]; string C[101010];
//---------------------------------------------------------------------------------------------------
Ruisekiwa2D<4020, 4020> BR, WR;
int B[2010][2010], W[2010][2010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    int KK = K * 2;
    rep(i, 0, N) cin >> X[i] >> Y[i] >> C[i];

    rep(i, 0, N) {
        if (C[i] == "B") B[Y[i] % KK][X[i] % KK]++;
        else W[Y[i] % KK][X[i] % KK]++;
    }
    rep(y, 0, 2 * KK) rep(x, 0, 2 * KK) {
        BR.set(x, y, B[y % KK][x % KK]);
        WR.set(x, y, W[y % KK][x % KK]);
    }
    BR.build();
    WR.build();

    int ans = 0;
    rep(y, 0, KK) rep(x, 0, KK) {
        int b = BR.get(x, y, x + K - 1, y + K - 1) + BR.get(x + K, y + K, x + KK - 1, y + KK - 1);
        int w = WR.get(x + K, y, x + KK - 1, y + K - 1) + WR.get(x, y + K, x + K - 1, y + KK - 1);
        int sm = b + w;
        chmax(ans, sm);
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=1e18;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,k;

    cin>>n>>k;

    ld a[n];

    for(li i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]=(a[i]+1.0)/2.0;
    }

    vector<ld> ans(n-k+1);

    f(i,0,k-1)
    {
        ans[0]+=a[i];
    }

    ld mx=ans[0];

    f(i,1,n-k)
    {
        ans[i]=ans[i-1]-a[i-1]+a[i+k-1];
        mx=max(mx,ans[i]);
    }

    cout<<fixed<<setprecision(8)<<mx;

    return 0;
}

Measured memory_bytes: 6528
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    ans = [1 for i in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        if H[a-1] > H[b-1]:
            ans[b-1] = 0
        elif H[a-1] < H[b-1]:
            ans[a-1] = 0
        else:
            ans[a-1], ans[b-1] = 0, 0
    count = 0
    for v in ans:
        if v == 1:count+=1
    print(count)
if __name__ == "__main__":
    main()

Measured memory_bytes: 91176