akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a: i32 = read!();
    let mut b: i32 = read!();
    println!("{}",(b-a)*(b-a+1)/2-b)
}

Measured memory_bytes: 2072
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){

  ll n, d;
  cin >> n >> d;
  int count = 0;
  for(int i=0; i<n; i+=1){
    ll x, y;
    cin >> x >> y;
    double di = x*x + y*y;
    double dist = sqrt(di);

    if(dist<=d){
      count++;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3188
from bisect import bisect
N=int(input())
X=[int(x) for x in input().split()]
L=int(input())
inf=float("inf")
X.append(X[-1]+L)
Table=[[inf]*18 for i in range(N)]
r=1
for i in range(N):
  if r<=N:
    while X[r]-X[i]<=L:
      r+=1
      if r>N:
        break
  Table[i][0]=r-1
for k in range(1,18):
  for i in range(N):
    if Table[i][k-1]==N:
      Table[i][k]=N
      continue
    Table[i][k]=Table[Table[i][k-1]][k-1]

Q=int(input())
for q in range(Q):
  a,b=map(int,input().split())
  a-=1
  b-=1
  ans=0
  if a>b:
    a,b=b,a
  while a<b:
    i=bisect(Table[a],b)-1
    if i>=0:
      ans+=2**i
    else:
      ans+=1
    a=Table[a][i]
  
  print(ans)


Measured memory_bytes: 127512
import java.io.*;
public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
    try{
      int a,b,d,r;
      double f;
      String str=mBufferedReader.readLine();
      String[] arr=str.split(" ");
      a=Integer.parseInt(arr[0]);
      b=Integer.parseInt(arr[1]);
      d=a/b;
      r=a%b;
      f=(double)a/b;
      System.out.printf("%d %d %f\n",d, r, f);
    }catch(IOException e){
      System.out.println("Error");
    }
  }
}


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

using namespace std;
using ll = long long;

int main() {
  string S, T;
  cin >> S >> T;
  ll ret = 0;
  for (int i = 0; i < 3; ++i) {
    if(S[i]==T[i])
      ret++;
  }
  cout<<ret << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

const BASE int = 65536
const BASE_D int = 16

func big_rem(a []int, c int, D int) int {
	rem := a[0] % c
	for i := 1; i < D; i++ {
		rem = (rem*BASE + a[i]) % c
	}
	return rem
}

func f(n int, f_mem []int) int {
	if f_mem[n] != -1 {
		return f_mem[n]
	}
	c := 0
	m := n
	for m > 0 {
		c += m % 2
		m = m / 2
	}
	if c == 0 {
		fmt.Println("Error:", n)
	}
	f_mem[n] = f(n%c, f_mem) + 1
	return f_mem[n]
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	N := nextInt()
	D := (N-1)/BASE_D + 1
	orig := make([]int, N/BASE_D+1)
	X := next()
	C := 0

	bases := make([]int, BASE_D)
	bases[0] = 1
	for d := 1; d < BASE_D; d++ {
		bases[d] = bases[d-1] * 2
	}

	for i := 0; i < N; i++ {
		block := D - (N-i-1)/BASE_D - 1
		digit := (N - i - 1) % BASE_D
		// fmt.Println(i, block, digit)
		if X[i] == '1' {
			C++
			orig[block] += bases[digit]
		}
	}
	f_mem := make([]int, C+1)
	f_mem[0] = 0
	for i := 1; i <= C; i++ {
		f_mem[i] = -1
	}

	orig_rem1 := 0
	if C-1 > 0 {
		orig_rem1 = big_rem(orig, C-1, D)
	}
	orig_rem0 := big_rem(orig, C+1, D)

	BASE_EXP_REMs1 := make([]int, D+1)
	BASE_EXP_REMs1[0] = 1
	if C-1 > 0 {
		for i := 1; i <= D; i++ {
			BASE_EXP_REMs1[i] = (BASE_EXP_REMs1[i-1] * BASE) % (C - 1)
		}
	}

	BASE_EXP_REMs0 := make([]int, D+1)
	BASE_EXP_REMs0[0] = 1
	for i := 1; i <= D; i++ {
		BASE_EXP_REMs0[i] = (BASE_EXP_REMs0[i-1] * BASE) % (C + 1)
	}

	for i := 0; i < N; i++ {
		block := D - (N-i-1)/BASE_D - 1
		digit := (N - i - 1) % BASE_D
		rem := 0
		if X[i] == '1' {
			if C-1 <= 0 {
				fmt.Println(0)
				continue
			} else {
				diff_rem := (bases[digit] * BASE_EXP_REMs1[D-block-1]) % (C - 1)
				rem = (orig_rem1 - diff_rem + C - 1) % (C - 1)

			}
		} else {
			diff_rem := (bases[digit] * BASE_EXP_REMs0[D-block-1]) % (C + 1)
			rem = (orig_rem0 + diff_rem) % (C + 1)
		}

		fmt.Println(f(rem, f_mem) + 1)
	}
}


Measured memory_bytes: 5072
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int k, n;
    cin >> k >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }

    ll maxx = 0;
    FOR(i, 1, n){
        maxx = max(maxx, a[i] - a[i-1]);
    }
    maxx = max(maxx, k+a[0]-a[n-1]);

    cout << k - maxx << endl;

    return 0;
}

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

int main(){
    char a, b;
    cin >> a >> b;
    bool honest_at;
    if(a == 'H') honest_at = true;
    else honest_at = false;
    if(b == 'H') {
        if(honest_at) puts("H");
        else puts("D");
    }else{
        if(honest_at) puts("D");
        else puts("H");
    }
}

Measured memory_bytes: 256
#!/bin/sh

read N
read S

max=0

for i in `seq $(($N-1))`
do
        j=$((i+1))
        X=$(echo $S | cut -c 1-$i  | grep -o . | sort | uniq )
        Y=$(echo $S | cut -c $j-$N | grep -o . | sort | uniq )

        sum=$( echo $X $Y | tr " " "\n" | sort | uniq -d | grep -c ^)

        [ $sum -gt $max ] && max=$sum

done

echo $max

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i] && a[i] != a[j] && a[j] != a[k] && a[k] != a[i]) {
					ans++;
					cerr << a[i] << " " << a[j] << " " << a[k] << '\n';
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5280
N = int(raw_input())
A = map(lambda x:int(x)%2, raw_input().split())
if len(A) == 1:
    print 'YES'

#print A
N_odd = sum(A)
N_even = N - N_odd
#print N_odd, N_even

if N_odd % 2 ==0:
    print 'YES'
else:
    print 'NO'

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

typedef long long ll;
using namespace std;

// ll mod = 1'000'000'000 + 7;
int main() {
    char X, Y;
    scanf("%c %c", &X, &Y);
    if (X < Y) {
        puts("<");
    } else if (X == Y) {
        puts("=");
    } else {
        puts(">");
    }
}

Measured memory_bytes: 256
input()
a=raw_input().split()
b=a.pop()
i=0
for j in range(len(a)):
    if int(a[j])<=int(b):
        a[i],a[j]=a[j],a[i]
        i+=1
a[i],b="["+b+"]",a[i]
print " ".join(a+[b])

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string A, B, C;
    cin >> A >> B >> C;
    if(A.back() == B.front() && B.back() == C.front()) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    cout << 180 * (n - 2) << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int n;
  map<int,int> data;
  cin>>n;
  rep(i,n){
    int a;cin>>a;
    data[a]++;
  }
  ll ans=0;
  for(auto itr : data){
    if(itr.first>itr.second){
      ans+=itr.second;
    }else{
      ans+=(itr.second-itr.first);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4736
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int h,w;cin >> h >> w;
    vector<vector<char> > a(h,vector<char>(w));
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cin >> a.at(i).at(j);
        }
    }

    queue<int> qx,qy,qxt,qyt;
    vector<vector<int> > itta(h,vector<int>(w));
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            if(a.at(i).at(j) == '#'){
                itta.at(i).at(j) = 1;
                qx.push(i);
                qy.push(j);
            }
        }
    }

    int ans = 0;

    while(qx.size() > 0){

        int x = qx.front();
        int y = qy.front();

        if(x-1 >= 0 && a.at(x-1).at(y) == '.' && itta.at(x-1).at(y) == 0){
            itta.at(x-1).at(y) = 1;
            qxt.push(x-1);
            qyt.push(y);
        }
        if(x+1 < h && a.at(x+1).at(y) == '.' && itta.at(x+1).at(y) == 0){
            itta.at(x+1).at(y) = 1;
            qxt.push(x+1);
            qyt.push(y);
        }
        if(y-1 >= 0 && a.at(x).at(y-1) == '.' && itta.at(x).at(y-1) == 0){
            itta.at(x).at(y-1) = 1;
            qxt.push(x);
            qyt.push(y-1);
        }
        if(y+1 < w && a.at(x).at(y+1) == '.' && itta.at(x).at(y+1) == 0){
            itta.at(x).at(y+1) = 1;
            qxt.push(x);
            qyt.push(y+1);
        }

        qx.pop();
        qy.pop();

        if(qx.size() == 0){
            ans ++;
            qx = qxt;
            qy = qyt;

            while(qxt.size() > 0){
                qxt.pop();
                qyt.pop();
            }
        }

    }
    cout << ans-1 << endl;
}


Measured memory_bytes: 25504
#include<stdio.h>
  
int Linear(int a[], int n, int key){
int i=0;
a[n]=key;
while(a[i] != key)
i++;
if(i==n){
return 0;
  }
 else {
return 1;
  }
}
  
int main(){
int i, n, a[10001], q, k;
int sum = 0;
scanf("%d", &n);
for (i=0; i<n; i++)
scanf("%d", &a[i]);
scanf("%d", &q);
for(i=0; i<q; i++) {
scanf("%d", &k);
if(Linear(a, n, k)==1)
sum++;
  }
printf("%d\n", sum);
return 0;
}

Measured memory_bytes: 2752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int max = m;
		int f = 1;
		for (int i = 0; i < n; i++) {
			m += scanner.nextInt() - scanner.nextInt();
			if (m > max) {
				max = m;
			}
			if (m < 0) {
				f = 0;
			}
		}
		scanner.close();
		System.out.println(f > 0 ? max : 0);
	}

}



Measured memory_bytes: 47712
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
using namespace std;

inline int getint()
{
    int x = 0, c = getchar();
    while (c > 47 && c < 58)
    {
        x = x * 10 + c - 48;
        c = getchar();
    }
    return x;
}

constexpr int MAX = 300000;
long bomb[MAX];
int posr[MAX], posc[MAX];

int main()
{
    int H = getint();
    int W = getint();
    int M = getint();

    long h, w, ans, x, y;
    int mxr = 0;
    int mxc = 0;
    int ctrow = 0;
    int ctcol = 0;
    for (int i = 0; i < M; ++i)
    {
        h = getint() - 1, w = getint() - 1;
        bomb[i] = h + (w << 20);

        x = ++posr[h], y = ++posc[w];

        if (x == mxr) ++ctrow;
        else if (x > mxr) mxr = x, ctrow = 1;

        if (y == mxc) ++ctcol;
        else if(y > mxc) mxc = y, ctcol = 1;
    }
    ans = mxr + mxc;

    long ct = ctrow;
    ct *= ctcol;
    if (ct > M)
    {
        printf("%d\n", ans);
        return 0;
    }

    for (int i = 0; i < M; ++i){
        long tmp = bomb[i] >> 20;
        if (posr[bomb[i] - (tmp << 20)] == mxr && posc[tmp] == mxc) --ct;
    }
    if (ct <= 0) --ans;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 6288
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>
#include <numeric>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int num(int n){
  // cout<<n<<endl;
  vector<int> x(n + 1);
	int num = n; // 素因数分解する変数num 
	int sq = n; // 素因数分解する変数num 
  int aaa =n;
  int ans=1;
  bool s =false;

	for (int i = 2; (i-1)*(i-1) <= n; i++) {
		while (num%i == 0) {
      // if(double(i)==double(sqrt(sq)))s=true;
			x.at(i)++;
			num /= i;
		}
	}
   if(num==n)x[n]=1;
	for (int i = 2; i*i <= n; i++)
	{	
		ans *= x.at(i) + 1;
	}
  ans*=x.at(n)+1;
  // return ans;
  // if(s)cout<<aaa<<endl;
  // cout<<'s'<<endl;
  // cout<<ans<<endl;
	// return fmod(sqrt(n),0)==0 ? ans : ans*2;
  return ans;
}

int main() {
 
  int64_t N,a=1,b,c;
  cin>>N;
  //vector<int64_t> A(N);
  for(int i=2; i<N; i++){
    a+=2;
    // cout<<i<<" "<<num(i)<<endl;
    for(int j=2; j*j<=i; j++){
      if(i%j==0)a+=2;
    }
    if(fmod(sqrt(i),1)==0)a--;
    // a+=num(i);
  }
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){
  //   for(int j=0; j<M; j++){
  //       cin>>A[i][j];
  //   }
  // }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << a << endl;
}


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


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

long long ans = 0;
int i = 1;
  int count = 0;
while(count !=n){
	if(i%3==0||i%5==0){
		
	}
  else{
    ans += i;
		
  }
	i++;
  count++;
}

cout << ans <<endl;
}

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

namespace ConsoleApp42 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int X = st[0];
            int A = st[1];
            int B = st[2];

            if (A - B >= 0) {
                Console.WriteLine("delicious");
            } else if (B - A <= X) {
                Console.WriteLine("safe");
            } else {
                Console.WriteLine("dangerous");
            }

        }
    }
}


Measured memory_bytes: 13268
def main():
    N,M = map(int, input().split())
    ac = [0]*N
    wa = [0]*N
    pen = 0
    for i in range(M):
        p,s = input().split()
        p = int(p)-1
        if ac[p]==0:
            if s=='AC':
                ac[p] = 1
                pen += wa[p]
            else:
                wa[p] += 1
    ans = [sum(ac), pen]
    print(*ans)

main()


Measured memory_bytes: 4596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int usepc[10010][1310];
int main(void)
{
  for(;;){
    REP(i,10010) REP(j,1310){
      usepc[i][j]=0;
    }
    int N,M;
    cin >> N >> M;
    if(!N&&!M) return 0;
    int r;
    cin >> r;
    REP(i,r){
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      usepc[m][t]+=1-2*s;
    }
    REP(i,M+1) REP(j,1300){
      usepc[i][j+1]+=usepc[i][j];
    }
    REP(i,M+1) REP(j,1300){
      if(usepc[i][j+1]) usepc[i][j+1]=usepc[i][j]+1;
      else usepc[i][j+1]=usepc[i][j];
    }
    int q;
    cin >> q;
    REP(i,q){
      int ts,te,m;
      cin >> ts >> te >> m;
      cout << usepc[m][te-1]-usepc[m][ts-1] << endl;
    }
  }
}

Measured memory_bytes: 52384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    int64_t n;cin>>n;
    vector<int64_t> num(100001, 0);
    rep(i, n){
        int64_t a;cin>>a;
        num[a]++;
    }

    int64_t q;cin>>q;
    int64_t ans=0;
    FOR(i, 1, 100000) ans+=num[i]*i;

    rep(i, q){
        int64_t b, c;cin>>b>>c;
        ans+=(c-b)*num[b];
        cout<<ans<<endl;
        num[c]+=num[b];
        num[b]=0;
    }

}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 200010, M = 25;

int n;
int a[N], cnt[N][M];

bool check(int x, int y)
{
	for (int i = 0; i < M; i ++ )
		if (cnt[y][i] - cnt[x][i] >= 2)
			return false;
	return true;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++ )
	{
		scanf("%d", &a[i]);
		for (int j = 0; j < M; j ++ )
		{
			cnt[i][j] += (a[i] >> j) & 1;
			cnt[i][j] += cnt[i - 1][j];
		}
	}
	
	LL res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		int l = 0, r = i - 1;
		while (l < r)
		{
			int mid = l + r >> 1;
			if (check(mid, i)) r = mid;
			else l = mid + 1;
		}
		res += i - r;
	}
	printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 24124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int a, b, c;
	ll k;
	cin >> a >> b >> c >> k;

	if (k <= a) {
		cout << k << endl;
	}
	else if (k <= a + b) {
		cout << a << endl;
	}
	else {
		ll num = k - a - b;
		cout << a - num << endl;
	}

	return 0;
}

Measured memory_bytes: 3608
package main

import "fmt"

var a, b int

func main(){
  fmt.Scan(&a, &b)
  if a < b {
    for i := 0; i < b; i++ {
      fmt.Print(a)  
    }
  } else {
    for i := 0; i < a; i++ {
      fmt.Print(b)  
    }
  }
}

Measured memory_bytes: 512
#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 = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vector<ll> luca;
    luca.push_back(2); luca.push_back(1);
    rep(i, N-1){
        luca.push_back(luca[luca.size()-2] + luca[luca.size()-1]);
    }
    cout << luca.back() << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
	int C,A,N,a,i,X;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		X=0;
		scanf("%d%d%d",&C,&A,&N);
		while(1){
			if(C==0||A==0||N==0) break;
			C--; A--; N--;
			X++;
		}
		while(1){
			if(C<2||A<1) break;
			C=C-2; A--;
			X++;
		}
		while(1){
			if(C<3) break;
			C=C-3;
			X++;
		}
		printf("%d\n",X);
	}
	return 0;
}

Measured memory_bytes: 1028
#  --*-coding:utf-8-*--


MOD = 10**9 + 7

def getModInv(a, b):
    return 1 if (a == 1) else (1-b*getModInv(b%a, a))//a%b


def modPow(a, b):
    x = 1
    
    while b > 0:
        if b & 1:
            x = (x*a)%MOD

        a = (a**2)%MOD
        b //= 2

    return x


def modComb(n, r):
    p = 1
    q = 1

    for i in range(r):
        p = p*(n-i)%MOD
        q = q*(i+1)%MOD

    return p*getModInv(q, MOD)%MOD



N,A,B = map(int, input().split())
print((modPow(2,N) - modComb(N,A) - modComb(N,B) - 1)%MOD)


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

int main(void){
    char s[11];
    cin >> s;

    char m[3];
    for(int i = 0; i < 4; i++){
        m[i] = s[i+5];
    }
    m[2] = '\0';

    int mi = atoi(m);

    if(mi > 4){
        cout << "TBD";
    }else{
        cout << "Heisei";
    }
    cout << endl;
}

Measured memory_bytes: 256
N ,M = map(lambda x: int(x),input().split())

min = 1
max = N
for i in range(M):
    L,R = map(lambda x: int(x),input().split())
    if min<L:
        min = L
    if max>R:
        max = R
if max>=min:
    print(max-min+1)
else:
    print(0)


Measured memory_bytes: 3060
import math

n = int(input())
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1 is not prime

    # eratnes
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0 and prime%5 == 1]

r = primes(5555)
result = []
for i in range(n):
    result.append(r[i])
l = list(map(str,result))
print(' '.join(l))



Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// import java.util.Arrays;
// import java.util.Random;
import java.util.StringTokenizer;

public class Main {
     public static void main(String[] args) {
         FastScanner fs=new FastScanner();
         int T=1;
         for (int tt=0; tt<T; tt++) {
                    String s = fs.next();
                    int maxc = 0;
                    int maxg = 0;
                    for(int i=0;i<s.length();i++){
                        if(s.charAt(i) == 'R'){
                            maxc++;
                            maxg = Math.max(maxc,maxg);
                        }
                        else{
                            maxc = 0;
                        }
                        
                    }
                    System.out.println(maxg);


                 }
}
 
 static class FastScanner {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     StringTokenizer st=new StringTokenizer("");
     String next() {
     while (!st.hasMoreTokens())
         try {
             st=new StringTokenizer(br.readLine());
         } catch (IOException e) {
             e.printStackTrace();
         }
         return st.nextToken();
     }
     
     int nextInt() {
         return Integer.parseInt(next());
     }
     int[] readArray(int n) {
         int[] a=new int[n];
         for (int i=0; i<n; i++) a[i]=nextInt();
         return a;
     }
     long nextLong() {
         return Long.parseLong(next());
     }
 }

 
}


Measured memory_bytes: 32368
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	int N, A;
	cin >> N >> A;
	if (N % 500 <= A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, x; cin >> N >> x;
    if(x == 1 or x == 2*N - 1) {
        puts("No");
    }
    else {
        puts("Yes");
        vector<int> ans(2*N - 1, -1), pos(2*N);
        ans[N-1] = x; pos[x] = true;
        ans[N-2] = x-1; pos[x-1] = true;
        if(N-3 >= 0) {
            if(x+2 <= 2*N-1) ans[N-3] = x+2, pos[x+2] = true;
            else ans[N+1] = x-2, pos[x-2] = true;
        }
        ans[N] = x+1, pos[x+1] = true;

        vector<int> rem;
        for(int i=1; i<=2*N-1; i++) if(!pos[i]) rem.emplace_back(i);
        for(int i=0; i<2*N-1; i++) {
            if(ans[i] < 0) {
                ans[i] = rem.back();
                rem.pop_back();
            }
        }

        for(auto e : ans) printf("%d\n", e);
    }
    return 0;
}


Measured memory_bytes: 5872
K,N=map(int,input().split())
a=list(map(int,input().split()))

maximum=0

for i in range(len(a)-1):
    if maximum<a[i+1]-a[i]:
        maximum=a[i+1]-a[i]
if maximum<=min(a[N-1]-a[0],K-a[N-1]+a[0]):
    maximum=min(a[N-1]-a[0],K-a[N-1]+a[0])

print(K-maximum)

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

int main(){
	int N,K;
	string S;
	cin >> N >> S >> K;
	for(int i=0;i<N;i++){
		if(S[i]!=S[K-1]){
			S[i]='*';
		}
	}
	for(int i=0;i<N;i++){
		cout << S[i];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define TRACE
#define M 1000000007
#define oo 1000000000000000007
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 1000009
#define M5 500009
#define pi 3.14159265
#define epsilon 1e-6

#ifdef TRACE
    #define trace1(x)                cerr << #x << ": " << x << endl;
    #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
    #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
    #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
    #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
    #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
    #define trace1(x)
    #define trace2(x, y)
    #define trace3(x, y, z)
    #define trace4(a, b, c, d)
    #define trace5(a, b, c, d, e)
    #define trace6(a, b, c, d, e, f)
 
#endif
ll power(ll x,ll n,ll m){
    ll res=1;
    while(n>0){
        if(n&1) res=(res*x)%m;
        n/=2;
        x=(x*x)%m;
    }
    return res;
}

ll n,m,A[M5],timer=0,st[M5],en[M5],sum[M5],id[M5];
vector<ll> g[M5];
void dfs(ll cur,ll par){
    st[cur] = ++timer;
    id[cur] = timer;
    for(auto u:g[cur]) if(u!=par) dfs(u,cur);
    en[cur] = timer;
}
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,a,b,c,d,l,r;
    //cin>>tc;
    while(t++<tc){
        //cout<<"Case #"<<t<<": ";
        cin>>n>>m;
        for(i=1;i<n;i++){
            cin>>a>>b;
            g[a].pb(b);
            g[b].pb(a);
        }
        dfs(1,0);
        while(m--){
            cin>>a>>b;
            sum[st[a]]+=b;
            sum[en[a]+1]-=b;
        }
        for(i=1;i<=n;i++) sum[i] += sum[i-1];
        for(i=1;i<=n;i++) cout<<sum[id[i]]<<" ";
    }
    return 0;
}

Measured memory_bytes: 46720
#include <stdio.h>

int main(void){
    int n=0;
  scanf("%d",&n);
  int L[n];
  int sum=0;
  for(int i=0;i<n;i++){
 	scanf("%d",&L[i]);
 }
for(int i=0;i<n;i++){
  	for(int j=i+1;j<n;j++){
  	    for(int k=j+1;k<n;k++){
  	        if(L[i]<L[j]+L[k]&&L[j]<L[k]+L[i]&&L[k]<L[i]+L[j]){
  	        sum++;
  	        }
  	    }
    }
  }
  printf("%d",sum);
}


Measured memory_bytes: 128
/*||>>>> Praveen Ojha <<<<>>>> 30 June 2019 <<<<>>>> 01:09:32 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=2200;
int dp[N][N];
int ncr(int n, int r){
	if(n==r)
		return 1;
	if(r==1)
		return n;
	if(n<r || n<0 || r<0)
		return 0;
	if(dp[n][r]!=-1)
		return dp[n][r];
	else 
		return dp[n][r]=(ncr(n-1,r-1)+ncr(n-1,r))%mod;
}
int32_t main(){__
	memset(dp,-1,sizeof dp);
	int n,k;
	cin>>n>>k;
	int red=n-k;
	for(int i=1;i<=k;i++){
		cout<<(ncr(red+1,i)*ncr(k-1,i-1))%mod<<"\n";
	}
return 0;
}

Measured memory_bytes: 38144
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int kaizyo(int x){
    if(x==1)return x;
    else return x*kaizyo(x-1);
}

vector<int> v(10);
int n,s;
int ans=0;
void dfs(int sum,int ct,int i){
    if(ct==n){
        if(sum==s)ans++;
        return;
    }
    if(i==10)return;
    
    dfs(sum+v[i],ct+1,i+1);
    dfs(sum,ct,i+1);
    return;
}
int main() {
    rep(i,0,10)v[i]=i;
    while(1){
        ans=0;
        cin>>n>>s;
        if(n==0&&s==0)break;
        dfs(0,0,0);
        cout<<ans<<endl;
    }
  
    return 0;
}



Measured memory_bytes: 2992
#include <fstream>
#include <algorithm>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

lli N, M, V, P;
lli arr [100000];
lli psum [100000];

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M >> V >> P;
    F0R(i,N) cin >> arr[i];
    sort(arr,arr+N);
    reverse(arr,arr+N);
    FOR(i,P-1,N) {
        psum[i] = arr[i];
        if (i != 0) psum[i] += psum[i-1];
    }

    int ans = 0;
    F0R(i,N) {
        if (i < P) {ans++; continue;}
        if (arr[i]+M < arr[P-1]) break;
        // cout << (arr[i]+M)*(i-P+1) - psum[i-1] << " **\n";
        if ((arr[i]+M)*(i-P+1) - psum[i-1] >= max(0ll, V-(N-i + P-1))*M) {
            ans++;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 5216
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let s: String = scan(tokens);
    let s: Vec<usize> = s
        .chars()
        .map(|ch| {
            if ch == 'R' {
                0
            } else if ch == 'G' {
                1
            } else {
                2
            }
        })
        .collect();
    let mut cnt: Vec<usize> = vec![0, 0, 0];
    let mut ans = 0;
    for j in 0..n {
        for k in j + 1..n {
            if s[j] != s[k] {
                let a = 3 - s[j] - s[k];
                ans += cnt[a];
                if 2 * j >= k && s[2 * j - k] == a {
                    ans -= 1;
                }
            }
        }
        cnt[s[j]] += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a, b;

    while (true) {
      a = scanner.nextInt();
      b = scanner.nextInt();
      if (a == 0 && b == 0) break;
      for (int i = 0; i < a; ++i) {
        for (int j = 0; j < b; ++j) System.out.printf("#");
        System.out.println();
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 60560
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,0,n){
		cin>>a[i];
	}
	rep(i,0,n){
		if(a[i]%2==0){
			if(a[i]%3==0 || a[i]%5==0){
			}
			else{
				cout<<"DENIED\n";
				return;
			}
		}
	}
	cout<<"APPROVED\n";
}

signed main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N+1)
	var count int
	for i := 1; i <= N; i++ {
		if i%2 == 0 {
			continue
		}
		for j := 1; j <= i; j++ {
			if i%j == 0 {
				a[i]++
			}
		}
		if a[i] == 8 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
from collections import defaultdict, deque
import sys

INF = float('inf')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


b = S()
ans = 'T' if b == 'A' else 'A' if b == 'T' else 'C' if b == 'G' else 'G'
print(ans)


Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int ans=700;
int main() {
    char a,b,c;
    cin>>a>>b>>c;
    if(a=='o') ans+=100;
    if(b=='o') ans+=100;
    if(c=='o') ans+=100;
    cout<<ans<<endl;
    return 0;
}

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

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

int main(void){

	int a[100010];
	int n; cin >> n;
	rep(i, n) cin >> a[i];

	int all = 0;
	int base = 0;
	rep(i, n){
		all += abs(base-a[i]);
		base = a[i];
	}
	all += abs(base);

	rep(i, n){
		int ans;
		if(i==0){
			ans = all + abs(a[i+1]) - (abs(a[i])+abs(a[i]-a[i+1]));
		}else if(i==n-1){
			ans = all + abs(a[i-1]) - (abs(a[i-1]-a[i])+abs(a[i]));
		}else{
			ans = all + abs(a[i-1]-a[i+1]) - (abs(a[i-1]-a[i])+abs(a[i]-a[i+1]));
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 1664
import statistics
import math

n = int(input())
aa,bb = [],[]

for i in range(n):
    a,b = map(int,input().split())
    
    aa.append(a)
    bb.append(b)
    
aa.sort()
bb.sort()
    
if n % 2 == 1:
    am = aa[n//2]
    bm = bb[n//2]
    
    ans = bm - am + 1
    
else:
    am = (aa[n//2] + aa[n//2-1]) / 2
    bm = (bb[n//2] + bb[n//2-1]) / 2
    
    ans = (bm - am)*2 + 1
    
print(int(ans))

Measured memory_bytes: 104708
from fractions import gcd

A, B, C, D = map(int, input().split())
l = C * D // gcd(C, D)
x = (A - 1) - (A - 1) // C - (A - 1) // D + (A - 1) // l
y = B - B // C - B // D + B // l
print(y - x)

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1000000007;
const int INF = 1<<18;
const lint INFLINT = 1LL << 60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

int main() {
    int a, n;
    cin >> n;
    vector<int> tmp(n);
    rep(i, n-1) {
        cin >> a;
        tmp[a-1]++;
    }
    
    rep(i, n) {
        cout << tmp[i] << endl;
    }
    
    
    return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
const int mod = 1e9+7;

const double pi = acos(-1);

int main(){
    int n;
    scanf("%d",&n);
    vector<int>arr(n+1,0);
    for(int i=0;i<n-1;i++){
        int num;
        scanf("%d",&num);
        arr[num]++;
    }
    for(int i=1;i<=n;i++) cout<<arr[i]<<endl;

	return 0;
}


Measured memory_bytes: 4056
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	string s;
	cin >> s;
	cout << "2018";
	rep(i,4,s.size())
		cout << s[i];
	
	P("");
	ret 0;
}

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

using namespace std;

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (auto &_p : p) {
        cin >> _p;
    }

    vector<double> e(n);
    vector<double> se(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        e[i] = (double) (p[i] + 1) / 2.0;
        se[i + 1] = se[i] + e[i];
    }

    double max_e = 0.0;

    for (int i = 0; i <= n - k; ++i) {
        auto dse = se[i + k] - se[i];
        max_e = max(max_e, dse);
    }

    printf("%.12f\n", max_e);
}

Measured memory_bytes: 4096