akhauriyash/Code-Regression huggingface dataset:
N,K,C= map(int, input().split())
S=input()
A=[]
for i in range(N):
  if S[i]=='o':
    A.append(i)
M=[]
d=0
cnt=0
for i in A:
  if d<=i:
    M.append(i)
    d=i+C+1
    cnt+=1
  if cnt==K+1:
    print()
    exit()
    
U=[]
d=N-1
cnt=0
for i in A[::-1]:
  if i<=d:
    U.append(i)
    d=i-C-1
    cnt+=1
  if cnt==K+1:
    print()
    exit()
D=set(M)&set(U)
D=sorted(D)
for i in D:
  print(i+1)

Measured memory_bytes: 45636
N = int(input())
A = list(map(int,input().split()))
ans = 1000
m = A[0]
M = A[0]
for i in range(N):
    if A[i] < m:
        m = A[i]
    else:
        ans += (ans//m) * (A[i] - m)
        m = A[i]
print(ans)

Measured memory_bytes: 9156
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner sc  = new Scanner(System.in);

		int o= 0 ,p = 0,q = 0;
		long a = 0, b = 0, c = 0;
		char ch;
		String str="";
		

        String s1 = sc.next();
        
        if(s1.contains("C"))o++;
        if(s1.contains("F"))o++;

//      int s = Integer.parseInt(sc.next());
//	    int[] test  = new int[100000];
        char[] c1 = s1.toCharArray();
        for(int i=0; i < s1.length(); i++){
            
        if(c1[i]=='C') str += 'C' ;
        if(c1[i]=='F') str += 'F';
            
        }
/*
        while(true){
            test[o] = Integer.parseInt(sc.next());
            o++;
            if(o==s)break;
        }
*/

        if(str.contains("CF"))System.out.print("Yes");
        else System.out.print("No");

    //    System.out.print();
        System.out.println();
	}
}

Measured memory_bytes: 10196
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char c = sc.next().charAt(0);
    
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
      System.out.println("vowel");
    } else {
      System.out.println("consonant");
    }
  }
}

Measured memory_bytes: 22608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

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

const int MAX = 1300000;
bool prime[MAX];

int main() {
	prime[0] = prime[1] = true;
	for(int i=2; i*i<MAX; i++) {
		if(!prime[i]) {
			for(int j=i+i; j<MAX; j+=i) {
				prime[j] = true;
			}
		}
	}
	vector<int> primes;
	for(int i=2; i<MAX; i++) {
		if(!prime[i])
			primes.push_back(i);
	}

	int n;
	while(cin >> n, n) {
		int l = 0;
		while(primes[l+1]<n) l++;
		if(n==2 || n == primes[l+1]) cout << 0 << endl;
		else cout << primes[l+1]-primes[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 2984
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let flip f a b = f b a

let (|Nil|Cons|) list =
  match List.tryHead list with
  | None -> Nil 
  | Some head -> Cons (head, List.tail list)

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

type Query =
  | Reverse
  | PushFront of string
  | PushBack of string

let readQuery () =
  readStr().Split()
  |> Array.toList
  |> function
  | [T] when int T = 1 -> Reverse
  | [T; F; C] when int T = 2 -> if int F = 1 then PushFront C else PushBack C
  | _ -> failwith "owatta"

type State = State of string list * string list

let S = readStr()
let Q = readInt()
let Query = [for _ in 1..Q -> readQuery ()]

let initialState = State (S.Split() |> Array.toList, [])

let reverse (str: string) =
  let chars = str.ToCharArray()
  Array.Reverse chars
  String.Concat chars

Query
|> List.fold (fun (rev, State (front, rBack)) query ->
  let rec f = function
  | Reverse -> not rev, State(front, rBack)
  | PushFront c -> if not rev then rev, State(c::front, rBack) else rev, State(front, c::rBack)
  | PushBack c -> if not rev then rev, State(front, c::rBack) else rev, State(c::front, rBack)
  f query
) (false, initialState)
|> (fun (rev, State (front, rBack)) ->
  let raw = (String.Concat front) + reverse (String.Concat rBack)
  if rev then reverse raw else raw
)
|> printfn "%s"

Measured memory_bytes: 44684
#include<iostream>
using namespace std;
int main()
{
  long int n,i=0,count=0,count1=0;
  cin>>n;
  char ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
    if(ar[i]=='R')
      count++;
  }
  if(count==0||count==n)
	cout<<"0";
  else
  {
  for(i=0;i<count;i++)
    if(ar[i]=='W')
      count1++;
  cout<<count1;
  }
  return 0;
} 
    

Measured memory_bytes: 3388
N = int(input())

ans = [0] * (N+1)

for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            tmp = i**2+j**2+k**2+i*j+j*k+k*i
            if 1 <= tmp <= N:
                ans[tmp] += 1
for i in range(1, N+1):
    print(ans[i])

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

using namespace std;

typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1000000000;

int main() {
    int K;
    string S;

    cin >> K >> S;

    if (K >= S.size()) {
        cout << S << endl;
    } else {
        string s = "";
        rep (i, K) {
            s += S[i];
        }
        cout << s+"..." << endl;
    }
}


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

int main(void){
  int n, m, p, x, acc, winner, i;
  while(1){
    cin >> n >> m >> p;
    if(n == 0){
      break;
    }
    acc = 0;
    winner = 0;
    for(i=0;i<n;i++){
      cin >> x;
      acc += 100 * x;
      if(i == m - 1){
        winner = x;
      }
    }
    acc = acc * (100 - p) / 100;
    if(winner == 0){
      cout << 0 << endl;
    }else{
      cout << acc / winner << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3084
import java.util.*;
class Main{
	static String a;
	static boolean solve(int p,int q){
	//	System.out.println(p+" "+q);
		if(p==q)return true;
		boolean ok=false;
		if(a.charAt(p)==')')return false;
		else if(a.charAt(p)==']')return false;
		else if(a.charAt(p)=='('){
			int c=0;
			for(int i=p;i<q;i++){
				if(a.charAt(i)=='(')c++;
				if(a.charAt(i)==')')c--;
				if(c==0){
					if(solve(p+1,i)&&solve(i+1,q))ok=true;
					break;
				}
			}
		}else if(a.charAt(p)=='['){
			int c=0;
			for(int i=p;i<q;i++){
				if(a.charAt(i)=='[')c++;
				if(a.charAt(i)==']')c--;
				if(c==0){
					if(solve(p+1,i)&&solve(i+1,q))ok=true;
					break;
				}
			}
		}
		return ok;
	}
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		while(true){
			String str=s.nextLine();
			if(str.equals("."))System.exit(0);
			a="";
			for(int i=0;i<str.length();i++)if(str.charAt(i)=='('||str.charAt(i)==')'||str.charAt(i)=='['||str.charAt(i)==']')a=a+str.charAt(i);
		//	System.out.println(a);
			System.out.println(solve(0,a.length())?"yes":"no");
		}
	}
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int h, a;
  int ans;
  
  cin >> h >> a;
  
  ans = h / a;
  if(h % a != 0) ans++;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
n = int(input())
pop = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    b,f,r,v = map(int, input().split())
    pop[b - 1][f - 1][r - 1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {}'.format(pop[i][j][k]), end = '')
        print('')
    if i != 3: print('#' * 20)



Measured memory_bytes: 5624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int h,n;
  int sum=0;
  
  cin>>h>>n;
  rep(i,n) {
    int a;
    cin>>a;
    sum=sum+a;
  }
  
  if(h-sum<=0){
    cout<<"Yes";
  } else {
    cout<<"No";
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: i32,
        b: i32,
        p: [i32; n],
    }
    let mut cnt = [0; 3];
    for p in p {
        if p <= a {
            cnt[0] += 1;
        } else if p <= b {
            cnt[1] += 1;
        } else {
            cnt[2] += 1;
        }
    }
    puts!("{}\n", cnt.iter().min().unwrap());
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define yes() cout << "Yes"<< endl;
#define no() cout << "No"<< endl;

int main() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	if((a1+a2+a3)>=22){
		cout << "bust\n";
	}
	else {
		cout << "win\n";
	}
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;

    int n = s.size();

    s += s;

    int n2 = s.size();
    
    vector< vector<int> > nxt(n2, vector<int>(26, n2));
    for (int i = n2 - 2; i >= 0; i--) {
        nxt[i] = nxt[i + 1];
        nxt[i][s[i + 1] - 'a'] = i + 1;
    }

    int m = t.size();
    int cur = 0;
    ll ans = 1;

    if (s[0] == t[0]) cur = 0;
    else if (nxt[0][t[0] - 'a'] == n2) {
        cout << -1 << endl;
        return 0;
    } else {
        ans += nxt[0][t[0] - 'a'];
        cur = nxt[0][t[0] - 'a'] % n;
    }

    for (int i = 1; i < m; i++) {
        int nex = nxt[cur][t[i] - 'a'];
        if (nex == n2) {
            cout << -1 << endl;
            return 0;
        }

        ans += (nex - cur);
        nex %= n;
        cur = nex;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27116
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    map<string, bool> m;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        m[s] = true;
    }

    cout << m.size() << endl;

    return 0;
}


Measured memory_bytes: 18868
<?php
// D
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$l = max($a);
unset($a[array_search($l, $a)]);
$d = PHP_INT_MAX;
foreach ($a as $v) {
    $td = abs($l / 2 - $v);
    if ($td < $d) {
        $d = $td;
        $r = $v;
    }
}
echo implode(' ', [$l, $r]);

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

using namespace std;

int main(void) {
  string S; cin >> S;
  char c = S[0]^S[1]^S[2];

  if (c == '`') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, x;
    cin >> N >> x;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    int cnt = 0;
    for(int i=0; i<N; ++i){
        if(x>= A[i]){
            x -= A[i];
            cnt++;
        }
        else if(x) x = 0; 
    }
    if(x) cnt--;
    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;


int main() {
    ll a, b; cin>>a>>b;
    ll A = a;

    ll ans = 0LL;
    for (ll i = 2LL; i * i <= A; i += 1LL) {
        if (a % i == 0LL) {
            if (b%i == 0LL) ++ans;
            while (a%i == 0LL) a /= i;
        }
    }
    if (a != 1 && b%a == 0LL) ++ans; 

    cout << ans + 1LL << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
#include <array>

int main(void) {
	int X;
	std::cin >> X;
	int c = X % 100;
	int n = X / 100;
	if (c <= 5 * n) {
		std::cout << 1;
	} else {
		std::cout << 0;
	}
	return 0;
}

Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    b = [int(i) for i in ipt().split()]
    c = [int(i) for i in ipt().split()]

    a.sort()
    b.sort()
    c.sort()

    sb = [0]*n
    na = 0
    for i,bi in enumerate(b):
        for j in range(na,n):
            if a[j] >= bi:
                sb[i] = j
                na = j
                break
            if j == n-1:
                na = n
                break
        if na == n:
            sb[i] = n
    ssb = [0]
    for i in sb:
        ssb.append(ssb[-1]+i)

    ans = 0
    nb = 0
    for i,ci in enumerate(c):
        for j in range(nb,n):
            if b[j] >= ci:
                ans += ssb[j]
                nb = j
                break
            if j == n-1:
                nb = n
                break
        if nb == n:
            ans += ssb[-1]
    print(ans)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 106552
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

double r;

int main() {
	ll n, m;
	cin >> n >> m;
	REP(i, m) {
		ll a;
		cin >> a;
		n -= a;
	}
	if (n < 0)cout << -1 << endl;
	else cout << n << endl;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	bool flag = true;
	int ans = 0;
	while (flag)
	{
		for (int i = 0; i < N; i++)
		{
			if (A[i]%2==0)
			{
				A[i] /= 2;
			}
			else
			{
				flag = false;
				break;
			}
		}
		if (flag)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int p=a+b;
    int q=a-b;
    int r=a*b;
    
    priority_queue<int> que;
    que.push(p);que.push(q);que.push(r);
    cout<<que.top();
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
while True:
    try:
        list = [int(x) for x in raw_input().split(" ")]
        list.sort(lambda x, y: y - x)
        gcd = lcm = 0
        m = list[0]
        n = list[1]
        while True:
            r = m%n
            if r == 0:
                gcd = n
                break
            m = n
            n = r
        lcm = list[0] * list[1] / gcd
        print(str(gcd) + " " + str(lcm))
    except EOFError:
        break

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

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

	map<long long, long long> sum_map;

	int N;
	scanf("%d", &N);

	long long a, sum = 0;
	sum_map[0]++;
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a);
		sum += a;
		sum_map[sum]++;
	}

	long long result = 0;
	for (auto i : sum_map) {
		// cout << i.first << ":" << i.second << "\n";
		result += i.second * (i.second - 1) / 2;
	}
	cout << result;
	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  if(n<105)
    cout<<0;
  else if(n<135)
    cout<<1;
  else if(n<165)
    cout<<2;
  else if(n<189)
    cout<<3;
  else if(n<195)
    cout<<4;
  else
    cout<<5;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <set>

typedef unsigned long long int ulli;

ulli str2int(const std::string &s)
{
    std::istringstream iss(s);
    ulli n;
    iss >> n;
    return n;
}

ulli calc(const std::vector<ulli> &v)
{
    ulli s = 0;
    for(auto &x : v)
    {
        s += x;
    }
    return s;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
    const std::string delim = ", ";
    for(typename std::vector<T>::size_type i=0; i<v.size(); ++i)
    {
        os << v[i];
        if((i + 1) < v.size()) os << delim;
    }
    return os;
}

std::vector<ulli> expr2intvec(const std::string &expr)
{
    std::vector<ulli> v;
    
    auto itr = expr.begin();
    std::string integer;
    while(itr != expr.end())
    {
        if(*itr == '+')
        {
            v.push_back( str2int(integer) );
            integer.clear();
        }
        else
        {
            integer.push_back(*itr);
        }
        ++itr;
    }
    v.push_back( str2int(integer) );

    return v;
}

std::string build_expr(const std::bitset<16> &bs, const std::string &S, unsigned L)
{
    std::string T(S);
    unsigned p = 1;

    for(unsigned i=0; i<L; ++i)
    {
        if(bs[i])
        {
            T = T.insert(i + p, "+");
            ++p;
        }
    }

    return T;
}

int main(void)
{
    std::string S;
    std::cin >> S;

    //std::cout << str2int(S) << std::endl;
    //std::cout << expr2intvec(S) << std::endl;
    
    ulli sum = 0;
    ulli N = 1 << (S.size() - 1);
    for(unsigned n=0; n<N; ++n)
    {
        std::bitset<16> bs(n);
        
        //std::cout << bs.to_string() << std::endl;
        //std::cout << build_expr(bs, S, S.size()) << std::endl;
        //std::cout << expr2intvec(build_expr(bs, S, S.size())) << std::endl;
        //std::cout << calc(expr2intvec(build_expr(bs, S, S.size()))) << std::endl;
        
        sum += calc(expr2intvec(build_expr(bs, S, S.size()))); 
    }

    std::cout << sum << std::endl;

	return 0;
}

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

using namespace std;

int main() {
		string S, T;
		cin >> S >> T;

		vector<int> d1(26, 0);
		vector<int> d2(26, 0);
		int flg = 0;
		for ( int i = 0; i < S.size(); i++ ) {
				int t = T[i];
				if ( d1[S[i] - 'a'] == 0 && d2[T[i] - 'a'] == 0) {
						d1[S[i] - 'a'] = T[i];
						d2[T[i] - 'a'] = S[i];
				} else if ( d1[S[i] - 'a'] != T[i] || d2[T[i] - 'a'] != S[i] ) {
						flg = 1;
						break;
				}
		}

		if (flg) cout << "No" << endl;
		else cout << "Yes" << endl;
		
		return 0;
}


Measured memory_bytes: 776
Scanf.scanf "%d %d" (fun n k ->
    let h = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare h;

    let rec loop i acc =
        if i + k > n then acc else
            loop (i + 1) (min acc (h.(i + k - 1) - h.(i)))
    in
    loop 0 max_int |> Printf.printf "%d\n"
)

Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N >> M;
  vector<lli>P(N),Q(0,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,1,N){
    if(P[i]!=P[i-1]){
      C++;
      Q.pb(i);
    }
    if(i==N-1)Q.pb(i+1);
  }
  for(int i=C-1;i>0;i--)Q[i]=Q[i]-Q[i-1];
  D=M-C;
  Sort(Q);
  rep(i,0,C){
    if(D>-1)break;
    else E+=Q[i];
    D++;
  }
  Out(E);
}

Measured memory_bytes: 3956
// AOJ ALDS1_7_A Rooted Trees
// 2018.5.1 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) { pc('0'); return; }
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}

void sout(char *s) { while (*s) pc(*s++); }

typedef struct { int parent; int depth; int k; int *c; } TREE;
TREE tbl[100002];

void calc_depth(int node, int d)
{
	int i;
	tbl[node].depth = d;
	for (i = 0; i < tbl[node].k; i++) calc_depth(tbl[node].c[i], d+1);
}

int main()
{
	int n, i, j, k, id;
	int root;

	n = in();
	for (i = 0; i < n; i++) {
		id = in(), tbl[id].k = k = in();
		tbl[id].c = malloc(k << 2);
		for (j = 0; j < k; j++) {
			int _c = in();
			tbl[_c].parent = id+1;
			tbl[id].c[j] = _c;
		}
	}
	for (root = 0; root < n; root++) {
		if (tbl[root].parent == 0) break;
	}
	calc_depth(root, 0);

	for (i = 0; i < n; i++) {
		sout("node "), out(i);
		sout(": parent = ");
		if (i == root) sout("-1");
		else out(tbl[i].parent - 1);
		sout(", depth = "), out(tbl[i].depth);
		sout(", ");
		if (i == root)          sout("root");
		else if (tbl[i].k == 0) sout("leaf");
		else                    sout("internal node");
		sout(", [");
		if (tbl[i].k > 0) {
			out(tbl[i].c[0]);
			for (j = 1; j < tbl[i].k; j++) {
				pc(','), pc(' '), out(tbl[i].c[j]);
			}
		}
		sout("]\n");
	}
	return 0;
}


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

int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}

int main(){
    int K,S;
    cin >> K >> S;

    int count=0;
    for(int X=max(0,S-2*K);X<=min(K,S);X++){
        for(int Y=max(0,S-X-K);Y<=min(K,S-X);Y++){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
s1 = input()
s2 = input()
dict_s1 = {}
dict_s2 = {}
for i in range(len(s1)):
    if s1[i] not in dict_s1:
        dict_s1[s1[i]] = s2[i]
    else:
        if dict_s1[s1[i]] != s2[i]:
            print('No')
            quit()
    if s2[i] not in dict_s2:
        dict_s2[s2[i]] = s1[i]
    else:
        if dict_s2[s2[i]] != s1[i]:
            print('No')
            quit()
print('Yes')


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    ll x, y;
    cin >> x >> y;
    REP(numturtle, x + 1){
        ll y2 = 4 * numturtle + 2 * (x - numturtle);
        if(y == y2){
            cout << YES << endl;
            return 0;
        }
    }
    cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3624
#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 pb push_back

typedef long long ll;
typedef pair<int,int> P;

//-----------------------------------------------------------------------

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

    int n,m;
    while(cin>>n>>m,n|m)
    {
        int cnt[11]={0};
        int sum=0;
        REP(i,n){
            int d,p; cin>>d>>p;
            cnt[p]+=d,sum+=p*d;
        }

        for(int i=10;i>=0;i--){
            if(m>cnt[i]){
                m-=cnt[i];
                sum-=i*cnt[i];
            } else{
                sum-=i*m;
                break;
            }
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3140
from itertools import accumulate 
from math import factorial
def cmb(n,r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def resolve():
    n = int(input())
    li =list(map(int, input().split()))

    li2 = list(accumulate(li))

    sun = [0]
    sun = sun + li2

    stsm = sorted(sun)
    stsm.append(-5000)

    ans = 0
    sli = []
    memo = 0
    for i in range(n + 1):
        if stsm[i] != stsm[i + 1]:
           sli.append(stsm[memo : i + 1]) 
           memo = i + 1
    
    for i in sli:
        a = len(i)
        if a < 2:
            continue
        else:
            ans += cmb(a,2)

    print(ans)
resolve()

Measured memory_bytes: 44436
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100

int n,M[N][N];
int color[N],d[N],f[N],time;

void visit(int u){
  int v;
  color[u] = GRAY ;// White vertex u has just been discovered
  d[u] = ++time;
  for(v=0;v<n;v++){// Explore edge (u,v)
    if(M[u][v]==0) continue;
    if(color[v] == WHITE){
      visit(v);
    }
  }
  color[u] = BLACK; // Blacken u; it is finished
  f[u] = ++time;
}

void dfs(){
  int u;
  for(u=0;u<n;u++){
    color[u] = WHITE;
  }
  time = 0;
  for(u=0;u<n;u++){
    if(color[u] == WHITE){
      visit(u);
    }
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;

}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

int main(){

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

        int pow_m = 1;
        for(int i = 0; i < m; i++ ) pow_m *= 2;
        cout << pow_m * (100*n + 1800*m);



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	long size,s,i;
	s=i=0;
	cin>>size;
	long* a=new long[size];
	long* b=new long[size]; 
	for(i=0;i<size;i++)
	{
		cin>>a[i];
		s+=a[i];
		b[i]=s;
	}
	long k=abs(s-b[0]*2);
	for(i=0;i<size-1;i++)
	{
		if(abs(s-b[i]*2)<k)
		{
			k=abs(s-b[i]*2);
		}
	}
	cout<<k;
	delete [] a;
	delete [] b;
	return 0;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var a = input[0];
            var b = input[1];
            var c = input[2];

            var buff = 0;
            var flag = false;


            for (int i = 0; i < b+1; i++)
            {
                buff += a;

                if (buff % b == c)
                {
                    flag = true;
                    break;
                }
            }

            if (flag)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13396
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
const int mod=1e9+7;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
ll binpow(ll a, ll b, ll m) 
{a %= m;b%=(m-1);ll res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1; }return res;}
void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,temp,x,y;
string str;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
vll v(n);
read(v);
ll mx=llmax;
for(int i=1;i<=100;i++)
{
    temp=0;
    for(int j=0;j<n;j++)
    {
      temp+=((i-v[j])*(i-v[j]));  
    }
    mx=min(mx,temp);
}
cout<<mx;







return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n;
  while (cin >> n) {
    lli small = 1;
    lli large = 1LL << 30;
    while (small + 1 < large) {
      lli mid = (small + large) / 2;
      lli x = mid * (mid - 1) / 2;
      if (n <= x) large = mid;
      else small = mid;
    }
    // cout << make_pair(small, large) << endl;
    cout << small << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(9+(n-100)+1)
elif n < 10000:
    print(9+900)
elif n < 100000:
    print(9+900+(n-10000)+1)
else:
    print(90909)

Measured memory_bytes: 38384
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

int main(){
	int n,k,r,s,p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	vector<vector<int>> dp(n+1,vector<int>(3,0));
	rip(i,n,0){
		if(i - k  > -1){
			rip(j,3,0){
				rip(l,3,0){
					if(j!=l) dp[i+1][j] = max(dp[i-k+1][l], dp[i+1][j]);
				}
			}
		}
		if(t[i] == 'r') dp[i+1][2] += p;
		else if(t[i] == 's') dp[i+1][0] += r;
		else if(t[i] == 'p') dp[i+1][1] += s;
	}
	int ans = 0;
	rip(i,n,n-k){
		int add = 0;
		rip(j,3,0) 
		{add = max(add, dp[i+1][j]);}
		ans += add;
	}
	cout << ans << endl;
	//vvdeb(dp);
}

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

int main(){
	int N, count;
  cin >> N; 
for(int i =0; i < N; i++){
   int x, l;   cin >> x >> l;
    if(x > l){
   count += x - l + 1;
    }
    else if(x <= l){
   count += l - x + 1;
    }
	}
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long h,a,n,ok;
int main (){
ios::sync_with_stdio(0);
scanf("%lld %lld",&h,&n);
for(int i=0;i<n;i++){
	 scanf("%lld",&a);
	 ok=ok+a;
}
if(ok>=h)
printf("Yes");
else
printf("No");
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 10000
using namespace std;
vector<int> l(0);
void topo_sort(vector<vector<int>> g,int n, vector<int> a){
    //入ってくるへんが0の頂点をkに入れる
    queue<int> k;
    for(int i=0; i<n; i++){
        if(a[i]==0)k.push(i);
    }
    int x;
    while(!(k.empty())){
        x = k.front();
        k.pop();
        l.push_back(x);
        for(int i=0; i<g[x].size();i++){
            a[g[x][i]]-=1;
            if(a[g[x][i]]==0)
            {
                k.push(g[x][i]);
            }
        }
    }
}
int main(){
    int n,m,i,j;
    
    cin >>n >> m;
    vector<vector<int>> g(n);
    vector<int>a(n);
    for(i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        g[x-1].push_back(y-1);
        a[y-1]+=1;
    }
    topo_sort(g,n,a);
    vector <int> dp(n+1,0);
    int res=0;
    for(i=n-1;i>-1;i--)
    {
        for(j=0;j<g[l[i]].size();j++){
            dp[l[i]] = max(dp[g[l[i]][j]]+1, dp[l[i]]);
            res = max(res,dp[l[i]]);
        }
        /*
        cout << l[i] << ": ";
        for(int k=0;k<n;k++)cout << dp[k] <<" ";
        cout << endl;
        */
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 12544
import networkx as nx
n, m = map(int, input().split())
nodes = [0 for i in range(n)]
L = []
for i in range(m):
    a, b = map(int, input().split())
    L.append((a,b))
    nodes[a-1] += 1
    nodes[b-1] += 1

num = 0

for node in nodes:
    if node == 0:
        num += 1

graph = nx.from_edgelist(L)
num += len(list(nx.connected_components(graph)))

print(num-1)

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

const int inf = 1e9 + 7;

int partition(vector<pair<char, int>>& A, int p, int r) {
  int x = A[r].second;
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j].second <= x) {
      i++;
      int tmp = A[j].second;
      char tmpch = A[j].first;
      A[j].second = A[i].second;
      A[j].first = A[i].first;
      A[i].second = tmp;
      A[i].first = tmpch;
    }
  }
  int tmp = A[i + 1].second;
  char tmpch = A[i + 1].first;
  A[i + 1].second = A[r].second;
  A[i + 1].first = A[r].first;
  A[r].second = tmp;
  A[r].first = tmpch;
  return i + 1;
};

void quickSort(vector<pair<char, int>>& A, int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  };
};

void merge(vector<pair<char, int>>& A, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  vector<pair<char, int>> L(n1 + 1);
  vector<pair<char, int>> R(n2 + 1);
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  L[n1].second = inf;
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  R[n2].second = inf;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    if (L[i].second <= R[j].second) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
};

void mergeSort(vector<pair<char, int>>& A, int left, int right) {
  if (right - left > 1) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n;
  cin >> n;
  vector<pair<char, int>> A(n);
  vector<pair<char, int>> B(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i].first >> A[i].second;
    B[i].first = A[i].first;
    B[i].second = A[i].second;
  }
  quickSort(A, 0, n - 1);
  mergeSort(B, 0, n);
  bool isStable = true;
  for (int i = 0; i < n; i++) {
    if (A[i].first != B[i].first) {
      isStable = false;
      break;
    }
  }
  if (isStable) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  for (int i = 0; i < n; i++) {
    cout << A[i].first << ' ' << A[i].second << endl;
  }
};



Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(m),s(m-1);
  for(int i=0; i<m; i++){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }
  int ans = x[m-1]-x[0];
  for(int i=0; i<m-1; i++){
    s[i] = x[i+1]-x[i];
  }
  sort(s.begin(),s.end());
  reverse(s.begin(),s.end());
  for(int i=0; i<n-1; i++){
    ans -= s[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}


void solve(){
  int N;
  cin >> N;
  rep(i, N){
    int a;
    cin >> a;
    if(a % 2) continue;
    if(a % 3 && a % 5){
      cout << "DENIED" << endl;
      return;
    }
  }
  cout << "APPROVED" << endl;
}


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


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def checkp(X):
    p=3
    pmax=X**0.5
    while X%p!=0:
        p+=2
        if p>pmax:
            return True
    return False

def solve(X: int):
    if X==2:
        print(2)
        return
    if X%2==0:
        X+=1
    while not checkp(X):
        X+=2
    print(X)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
use proconio::input;

const MOD: u64 = 1_000_000_007;

fn main() {
    input!(n: usize);

    // dp[i][j]: 長さ i, |{0,9} ∩ {A_i}| = j
    let mut dp = vec![[0; 3]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..2 {
            dp[i + 1][j + 1] += dp[i][j] * (2 - j as u64);
        }
        for j in 0..3 {
            dp[i + 1][j] += dp[i][j] * (8 + j as u64);
            dp[i + 1][j] %= MOD;
        }
    }
    let ans = dp[n][2];

    println!("{}", ans);
}


Measured memory_bytes: 25360
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define str string

#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);
  vector<str> s(n);VECCIN(s);
  set<str> ss;
  REP(i,n)ss.insert(s[i]);
  SANKOU(ss.size()==3,Three,Four);



  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
p=list(map(float,input().split()))
maxexp=float(0)


def expected(n):
    return (1+n)/2


p=list(map(expected,p))

for i in range(K):
    maxexp+=p[i]
now=maxexp
for i in range(N-K):
    now=now+p[i+K]-p[i]
    maxexp=max(now,maxexp)
print(maxexp)


Measured memory_bytes: 23992
import math
n, d =  [int(i) for i in input().split()]
count = 0

for i in range(n):
    x, y = [int(i) for i in input().split()]
    ab = math.sqrt(x**2+y**2)
    if ab <= d:
        count += 1
    else:
        pass
print(count)

Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n);
    for (int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }

    long long ans = 0;

    auto function = [&](int a1, int a2, int b1) {
        if (a1 <= b1)
        {
            ans += a1;
            b1 -= a1;
            if (a2 <= b1)
            {
                ans += a2;
                a2 = 0;
            }
            else
            {
                ans += b1;
                a2 -= b1;
            }
        }
        else
        {
            ans += b1;
            b1 = 0;
        }

        return a2;
    };

    for (int i = 0; i < n; i++)
    {
        a[i + 1] = function(a[i], a[i + 1], b[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024