akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    H, W, A, B = mi()
    a = [[0 for i in range(W)]for j in range(H)]
    for i in range(H):
        for j in range(W):
            if (i < B and j < A) or (i >= B and j >= A):
                a[i][j] = 1
    for l in a:
        print(*l, sep="")

if __name__ == '__main__':
    main()


Measured memory_bytes: 79836
import java.awt.Point;
import java.util.Scanner;

/**
 * 
 * AOJ - 1130 Red and Black
 * 
 * @author yuichirw
 *
 */
public class Main {

	static int w,h,sx,sy;
	static int[] dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
	static String[] field;
	static boolean[][] visited;
	static Scanner sc = new Scanner(System.in);
	
	
	public static void main(String[] args) {
		while(read()) {
			visited = new boolean[h][w];
			System.out.println(dfs(sx, sy));
		}
	}
	
	static boolean read() {
		w = sc.nextInt(); h = sc.nextInt();
		if(w == 0 && h == 0) {
			return false;
		}
		field = new String[h];
		for(int i = 0; i < h; i++) {
			field[i] = sc.next();
			int tmp = field[i].indexOf('@');
			if(tmp != -1) {
				sy = i; sx = tmp;
			}
		}
		return true;
	}
	
	static int dfs(int x, int y) {
		if(!inField(x, y) || field[y].charAt(x) == '#' || visited[y][x] == true) {
			return 0;
		}
		
		visited[y][x] = true;
		int ret = 1;
		
		for(int i = 0; i < 4; i++) {
			ret += dfs(x + dx[i], y + dy[i]);
		}
		return ret;
	}
	
	static boolean inField(int x, int y) {
		if(x >= 0 && x < w && y >= 0 && y < h) {
			return true;
		} else {
			return false;
		}
	}
}

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

int main(){

	ll temp, n, arr[200005], fre[200005]={0};
	ll pro=0;
	cin >> n;
	for(ll i = 0; i < n; i++){
		cin >> arr[i];
		fre[arr[i]]++;
	}
	for(ll i = 0; i < 200005; i++){
		pro += (fre[i]*(fre[i]-1))/2;
	}
	// cout << pro;
	for(ll i = 0; i < n; i++){
		temp = fre[arr[i]] - 1;
		cout << pro - ((fre[arr[i]]*(fre[arr[i]]-1))/2) + ((temp*(temp-1))/2) << endl;
	}
	return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int i;
  int count = 0;
  for(i = 0; i < 6; i++)
  {
    if(s.at(i) == '1')
    {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    ll count=0;
    rep(i,3){
        if(count==0){
            if(s[i]=='R') count++;
        }else{
            if(s[i]=='S') break;
            else count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3648
N = int(input())
S = input()
dp = [[0] * N for _ in range(N)]
ans = 0
for i, s in enumerate(S):
  if i != 0 and S[i] == S[0]:
    dp[i][0] = 1
    dp[0][i] = 1

for i in range(1, N):
  for j in range(1, N):
    if i != j and S[i] == S[j]:
      if i + dp[i-1][j-1] == j or j + dp[i-1][j-1] == i:
        dp[i][j] = dp[i-1][j-1]
      else:
        dp[i][j] = dp[i-1][j-1] + 1
      ans = max(ans, dp[i][j])
print(ans)

Measured memory_bytes: 231560
#include<iostream>
#include<vector>
#include<queue>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int> vi;
typedef vector<vi > vvi;

//priority_queue.
//refering to exp.
int main(){
	int n,m;
	cin>>n>>m;
	
	vvi v(m+1);
	REP(i,n){
		int a,b;
		cin>>a>>b;
		if(a<=m) v[a].push_back(b);//point.
	}
	
	int ans=0;
	priority_queue<int> q;//point.
	for(int i=1;i<=m;++i){
		REP(j,v[i].size()) q.push(v[i][j]);
		if(!q.empty()){
			ans+=q.top();
			q.pop();
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 5504
using System;
using System.Collections.Generic;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var rs = new int[n - 1].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		var map = rs.Concat(rs.Select(r => new[] { r[1], r[0] })).ToLookup(r => r[0], r => r[1]);

		var tour = new int[n + 1].Select(_ => new List<int>()).ToArray();
		var c = 0;
		var q = new Stack<int>();
		var parents = new Stack<int>();
		var u = new bool[n + 1];

		q.Push(1);
		parents.Push(0);
		while (q.Any())
		{
			var p = q.Peek();
			if (!u[p])
			{
				u[p] = true;
				var p0 = parents.Peek();
				if (p != 1) tour[p0].Add(++c);
				foreach (var x in map[p])
				{
					if (x == p0) continue;
					q.Push(x);
				}
				parents.Push(p);
			}
			else
			{
				if (p != 1) tour[p].Add(++c);
				q.Pop();
				parents.Pop();
			}
		}

		Console.WriteLine((tour.Select(l => Hole(l, rs.Length)).Aggregate((x, y) => x + y) / 2).V);
	}

	static MInt Hole(List<int> l, int m)
	{
		if (l.Count < 2) return 0;
		var whites = Enumerable.Range(0, l.Count).Select(i => ((l[(i + 1) % l.Count] - l[i]) / 2 + m) % m).Select(x => 1 / ((MInt)2).Pow(x)).ToArray();
		var allWhite = whites.Aggregate((x, y) => x * y);
		return 1 - allWhite * (1 + whites.Select(x => 1 / x - 1).Aggregate((x, y) => x + y));
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x) => x;
	public static MInt operator -(MInt x) => -x.V;
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Pow(int i) => MPow(V, i);
	public MInt Inv() => MPow(V, M - 2);

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 75816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll n;
void dfs(string s,char t,ll i) {
    if (i == n){
        cout << s << endl;
    }
    else {
        for (char k = 'a'; k <= t;k++){
			char x;
            if (k == t) x = t + 1;
			else
                x = t;
            dfs(s + k, x, i + 1);
        }
    }
}
int main(){
    cin >> n;
    dfs("",'a',0);
}

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

int main() {
    int N;
    string S;
    cin >> N >> S; 
    int x = 0, ans = 0;
    for (int i=0;i<N;i++){
        if (S[i]=='I') x += 1;
        else x -= 1;
        if (x>ans) ans = x;
    }
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int t[1000005];

int main(){
    cin.tie(0);
    
    int N, C, K;
    cin >> N >> C >> K;
    for (int i = 0; i < N; i++){
        cin >> t[i];
    }
    sort(t, t+N);
    int i = 1;
    int crt = t[0];
    int cnt = 1;
    int ans = 0;
    while (i < N){
        if (crt + K >= t[i] && cnt < C){
            cnt++;
        }else{
            crt = t[i];
            cnt = 1;
            ans++;
        }
        i++;
    }
    ans++;
    cout << ans << endl;
} 


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

#define N 100

int data[N],num1,num2;

bool flag=false;

bool solve(int i,int m){

  if(i>num1) return false;
  else if(m<0) return false;
  if(m== 0 || m-data[i] == 0){
    flag=true;
    return true;
  }
    else{
      solve(i+1,m);
      solve(i+1,m-data[i]);
  }   
}

int main(){

  int i,m;


  cin >>num1;

  for(i=0;i<num1;i++){
    cin >>data[i];
  }

  cin >>num2;

  for(i=0;i<num2;i++){
    cin >>m;
    flag=false;

    solve(-1,m);
    if(flag==true){
      cout <<"yes"<<endl;
    }  
    else cout <<"no"<<endl;
  }

  return 0;
}

Measured memory_bytes: 856
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;


int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		int tall[128][128];
		int up[128][128];
		memset(tall, 0, sizeof(tall));
		memset(up, 0, sizeof(up));

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				scanf("%d", &tall[i][j]);

		for (int i = 0; i < n; ++i)
		{
			int minTall = 1000000;
			int maxTall = -1;
			for (int j = 0; j < n; ++j)
			{
				minTall = min(minTall, tall[i][j]);
				maxTall = max(maxTall, tall[j][i]);
			}
			for (int j = 0; j < n; ++j)
			{
				if (tall[i][j] == minTall)
					up[i][j] |= 1;
				if (tall[j][i] == maxTall)
					up[j][i] |= 2;
			}
		}
		bool any = false;
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				if (up[i][j] == 3)
				{
					printf("%d\n", tall[i][j]);
					any = true;
					break;
				}
			}
			if (any)
				break;
		}
		if (!any)
			printf("0\n");
	}

	return 0;
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
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 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))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N,i;
    cin >> N >> i;
    cout << N - i + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, c = 0;  cin >> n;
    for(int i = 1; i <= n; i++){
        int p; cin >> p;
        if(p != i)  c++;
    }
    if(c == 0 || c == 2)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

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

//1 <= N <=10000
//0 <= A <= 1000

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

Measured memory_bytes: 256
def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            ret.add(i)
            ret.add(n//i)
    return(ret)


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

    ans = set()
    for i in range(N-1, -1, -1):
        a[i] %= 2
        # print(a)
        if a[i]:

            for j in divisors(i+1):
                # print(j-1)
                a[j-1] += 1
            ans.add(i+1)

    print(len(ans))

    print(*ans)


main()


Measured memory_bytes: 71232
while 1:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break

    odd = '#.' * 150
    even = '.#' * 150

    for i in range(h):
        if i%2 == 0:
            print(odd[:w])
        else:
            print(even[:w])
    print()

Measured memory_bytes: 5612
import sys
import heapq

N,M = [int(k) for k in sys.stdin.readline().split()]

job=[]
for i in range(N):
    A,B = [int(k) for k in sys.stdin.readline().split()]
    job.append((A,-B))

job.sort(key=lambda t: -t[0])

heap=[]
heapq.heapify(heap)

ans=0

for i in range(1,M+1):
    if len(job)!=0:
      while job[-1][0]==i:
          heapq.heappush(heap,job.pop()[1])
          if len(job)==0:
             break
    if len(heap) == 0:
        continue
    ans -= heapq.heappop(heap)
    
print(ans)


Measured memory_bytes: 66268
import qualified Data.ByteString.Char8 as C
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

d :: Int -> Int -> Float
d x y = fromIntegral x / fromIntegral y

main :: IO ()
main = do
    n <- readLn
    as <- r (n+1)
    let minima = U.scanr1 (\nw ac -> ceiling (d ac 2) + nw) as
    if minima U.! 0 > 1 then print (-1)
        else do
            let strings = U.scanr1 (+) as

            knots <- UM.new (n+1)
            UM.write knots 0 (1 :: Int)

            generateKnots as strings knots 1

            finalKnots <- U.freeze knots
            print $ U.sum finalKnots

generateKnots :: U.Vector Int -> U.Vector Int -> UM.IOVector Int -> Int -> IO ()
generateKnots leafs strings acc cur -- assuming cur >= 1
    | U.length leafs <= cur = return ()
    | otherwise = do
    parentNodes <- UM.read acc (cur-1)
    let parentLeafs = leafs U.! (cur-1)

    let parentNonLeafs = parentNodes - parentLeafs
    let currentNodes = min (strings U.! cur) (2 * parentNonLeafs)

    UM.write acc cur currentNodes

    generateKnots leafs strings acc (cur+1)

Measured memory_bytes: 10544
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define all(s) s.begin(), s.end()
#define fuck_you_scanf ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define si size()
 
const int N = 1e6 + 5;
int arr[N];
int DP[N];
int k;

int f(int idx, int n)
{
    if(idx == n - 1) return 0;
    if(idx > n) return N * N * N;
    if(DP[idx] != -1) return DP[idx];
    int ans = N * N * N;
    for(int i = 1; i <= k; i++)
    {
        ans = min(ans, abs(arr[i + idx] - arr[idx]) + f(idx + i, n));
    }
    return DP[idx] = ans;
}

int32_t main()
{
    memset(DP, -1, sizeof(DP));
    int n;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> arr[i];
    cout << f(0, n);
}

Measured memory_bytes: 15104
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string s,t;
  cin>>s>>t;
  if(s=="H" && t=="H")cout<<"H"<<endl;
  else if(s=="H" && t=="D")cout<<"D"<<endl;
  else if(s=="D" && t=="H")cout<<"D"<<endl;
  else cout<<"H"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll M = 1e9+7;


int main() {
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  ll dp[n+1][k+1]={0};
  dp[0][0] = 1;
  for(int j=0;j<=a[0];j++) dp[1][j] = 1;
  ll sum[k+1];
  for(int i=2;i<=n;i++) {
    sum[0] = dp[i-1][0];
	for(int j=1;j<=k;j++) sum[j]=(dp[i-1][j]+sum[j-1])%M;
  	for(int j=0;j<=k;j++) {
      if(j<=a[i-1]) dp[i][j] = sum[j];
      else {
          int p = j-a[i-1];
          dp[i][j] = (sum[j]-sum[p-1]+M)%M;
      }
    }
  }
  cout<<dp[n][k]%M<<endl;
}

Measured memory_bytes: 79104
H, W, M = map(int,input().split())
from collections import Counter
HC = Counter()
WC = Counter()

cache = set()
for _ in range(M):
    h, w = map(int, input().split())
    HC.update([h])
    WC.update([w])
    cache.add((h, w))

HCS = sorted(HC.items(), key=lambda x: x[1],reverse=True)
WCS = sorted(WC.items(), key=lambda x: x[1],reverse=True)

hmax = HCS[0][1]
hmaxkeys = [HCS[0][0]]
for hi in range(1, len(HCS)):
    if HCS[hi][1] == hmax:
        hmaxkeys.append(HCS[hi][0])
    else:
        break

wmax = WCS[0][1]
wmaxkeys = [WCS[0][0]]
for wi in range(1, len(WCS)):
    if WCS[wi][1] == wmax:
        wmaxkeys.append(WCS[wi][0])
    else:
        break

for hi in hmaxkeys:
    for wi in wmaxkeys:
        if not (hi, wi) in cache:
            print(hmax + wmax)
            exit(0)

print(hmax + wmax - 1)

Measured memory_bytes: 230360
n = gets.to_i
s = gets.chomp

#white[i]:左端から数えてi個の石のうち，白い石が何個あるか
#ただし，white[0] = 0
white = Array.new(n+1, 0)
#black[i]: 黒について同様の定義
black = Array.new(n+1, 0)

for i in 0..n-1 do
  if s[i] == "."
    white[i+1] = white[i] + 1
    black[i+1] = black[i]
  else
    white[i+1] = white[i]
    black[i+1] = black[i] + 1
  end
end

min = 10**9

for i in 0..n do
  tmp = (black[i] - black[0]) + (white[n] - white[i])
  min = tmp if tmp < min
end

puts min


Measured memory_bytes: 5244
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      mut p: [Usize1; n]
   }

   let mut ans = 0;
   for i in 0..n - 1 {
      if p[i] == i {
         let temp = p[i];
         p[i] = p[i + 1];
         p[i + 1] = temp;
         ans += 1;
      }
   }
   if p[n-1] == n-1 {
      ans += 1;
   }
   println!("{}", ans);
}


Measured memory_bytes: 3332
n=int(input())
a=[int(i) for i in input().split()]
m=max(a)
m2 = m / 2

f = m
ans = -m
for i in a:
  if i != m and abs(m2 - i) <=f:
    f = abs(m2 - i)
    ans = i
print(m,ans)

Measured memory_bytes: 14052
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int fiveHundred = Integer.parseInt(sc.next());
        int hundred = Integer.parseInt(sc.next());
        int fifty = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i <= fiveHundred; i++) {
            for (int j = 0; j <= hundred; j++) {
                for (int k = 0; k <= fifty; k++) {
                    int total = (i * 500) + (j * 100) + (k * 50);
                    if (total == target) {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);

    auto u = new string[](n);
    bool[string] e;

    foreach (i ; 0 .. n) {
        string ui = readln.chomp;
        e[ui] = 1;
    }

    int m;
    scan(m);

    bool open;

    foreach (i ; 0 .. m) {
        string t = readln.chomp;
        if (t in e) {
            writefln("%s by %s", open ? "Closed" : "Opened", t);
            open ^= 1;
        }
        else {
            writeln("Unknown", " ", t);
        }
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2548
n,k = map(int,input().split())
st = []
for i in range(k):
  x,y = map(int,input().split())
  st.append((x,y))
total = [1]
 
for i in range(1,n):
  s = 0
  for (x,y) in st:
    if i > y:
      s = (s + total[i-x] - total[i-y-1]) % 998244353
    elif i >= x:
      s = (s + total[i-x]) % 998244353
  total.append((s+total[-1]) % 998244353)   
  
print((total[-1]-total[-2]) % 998244353)
  
  
    
  

Measured memory_bytes: 81140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);

    	int N = sc.nextInt();

    	int q = N%10;

    	if(q==2||q==4||q==5||q==7||q==9) {
    		System.out.println("hon");
    	} else {
    		if(q==0||q==1||q==6||q==8) {
    			System.out.println("pon");
    		} else {
    			System.out.println("bon");
    		}
    	}
    }
}

Measured memory_bytes: 27072
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
typedef long long llong;

int n;
int a[52],b[52];
int F[52][52]; ///Bottleneck costs
bool TFO[52][52];

bool isFree[52];

int solve(int A,int B)
{
    if (TFO[A][B])
        return F[A][B];
    if (A<B)
        return -1;
    if (A==B)
        return 0;

    TFO[A][B]=true;

    int i;
    int cost=-1;
    int res;

    for (i=1;i<=A;i++)
    {
        res=solve(A%i,B);

        if (!isFree[i] && res!=-1)
        {
            res=i;
        }

        if (res!=-1)
        {
            if (cost==-1 || cost>res)
                cost=res;
        }
    }

    F[A][B]=cost;

    return cost;
}

int getBottleneck()
{
    int i;
    int val;
    int neck=0;

    for (i=1;i<=n;i++)
    {
        val=solve(a[i],b[i]);

        if (val==-1)
            return -1;

        if (val>neck)
            neck=val;
    }

    return neck;
}

int main()
{
    int i;
    int neck;
    llong totalCost=0;

    scanf("%d",&n);

    for (i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }

    for (i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
    }

    while(true)
    {
        memset(TFO,false,sizeof(TFO));
        neck=getBottleneck();

        if (neck==-1)
        {
            printf("-1\n");
            return 0;
        }

        if (neck==0)
            break;

        totalCost+=(1LL<<(llong)neck);

        isFree[neck]=true;
        //cout<<"Neck is "<<neck<<endl;
    }

    printf("%lld\n",totalCost);

    return 0;
}


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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll A,B;

void solve(){
    if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
}

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

    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	vector<ll> a;
	int q;
	cin>>q;
	for(int i = 0; i < q; i++){
		int b;
		cin>>b;
		if(b==0){
			int x;
			cin>>x;
			a.push_back(x);
		}else if(b==1){
			int p;
			cin>>p;
			cout<<a[p]<<endl;
		}else{
			a.pop_back();
		}
	}

	return 0;
}


Measured memory_bytes: 4916
import math

s = []
c = 0

while True:
    ss = 0
    n = int(input())
    if n == 0:
        break
    else:
        score = list(map(int, input().split()))
        ave = sum(score) / n

        for i in range(n):
            ss += (score[i] - ave) ** 2

        s.append(math.sqrt(ss / n))
    c += 1

for i in range(c):
    print(s[i])



Measured memory_bytes: 5700
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    string a;
    cin >> a;
    if (a[0] == 'A'){
        int count = 0;
        for (int i = 2; i < a.size()-1; i++){
            if (a[i] == 'C'){
                count++;
            }
        }
        if (count == 1){
            int countc = 0;
            for (int j = 0; j < a.size(); j++){
                if (a[j] >= 'A' && a[j] <= 'Z'){
                    countc++;
                }
            }
            if (countc == 2){
                cout << "AC" << endl;
            } else {
                cout << "WA" << endl;
            }
        } else {
            cout << "WA" << endl;
        }
    } else {
        cout << "WA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <sstream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int d[N];
    for(int i = 0; i < N; i++)
        cin >> d[i];

    sort(d, d + N);

    int cnt = 0;
    for(int i = 0, tmp = 0; i < N; i++){
        if(tmp != d[i]){
            cnt++;
            tmp = d[i];
        }
    }

    cout << cnt << endl;
    return 0;
}

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

int main() {
	string S;
	cin >> S;
	vector<int> sa = suffix_array(S);
	long long answer = 1ll * S.size() * (S.size() + 1) / 2;
	for (auto x : lcp_array(S,sa)) answer -= x;
	cout << answer << endl;
}


Measured memory_bytes: 15620
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<LL, LL>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    string s;
    cin >> s;
    if (s.size() % 2) {
        puts("No");
        return 0;
    }
    for (int i = 0; i < s.size(); i += 2) {
        if (s[i] != 'h' || s[i + 1] != 'i') {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;
bool flag=0;
int dfs(int y,int x);
int h,w;  
char table[100][100];
int dp[100][100];

int main(){
  ll n;  cin >> n;
  ll ruiseki[n];//iまでの和
  ll a[n];  
  rep(i,n){
     cin >> a[i];
     cnt+=a[i];
     ruiseki[i] = cnt;
     
   }
   if(n == 2){
      cout << abs(a[0]-a[1]) << endl;
      return 0;
   }
   ll ans=INF;
   for(int i=1;i<n-1;i++){
      ans=min(abs(2*ruiseki[i]-cnt),ans);
   }
   cout << ans << endl;


}

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

int main()
{
	string n;
	cin >> n;
	
	for(int i=0;i<3;i++){
		if(n[i]=='1') n[i]='9';
		else{
			if(n[i]=='9') n[i]='1';
		}
	}
	
	cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>

using namespace std;

char c[10]={'0','1','2','3','4','5','6','7','8','9'};



void solve(){
    
    int n;
    cin>>n;
    vi v(n);
    for(auto& x : v) cin>>x;
    
    ll sum=0;
    
    for(int i=1; i<n; i++){
        sum+=max(0, v[i-1]-v[i]);
        if(v[i-1]>v[i]) v[i]=v[i-1]; 
    }
    
    cout<<sum<<endl;
}


int main(){
    
   
    solve();
}

Measured memory_bytes: 3996
h,w=map(int,input().split())
min_ = h*w
if h % 3 == 0:
  min_ = 0
else:
  min_ = min(min_, w)
if w % 3 == 0:
  min_ = 0
else:
  min_ = min(min_, h)
for i in range(1, w):
  p1 = h//2*i
  p2 = (h-h//2)*i
  p3 = h*(w-i)
  min_ = min(min_, max(p1,p2,p3)-min(p1,p2,p3))
for i in range(1, h):
  p1 = w//2*i
  p2 = (w-w//2)*i
  p3 = w*(h-i)
  min_ = min(min_, max(p1,p2,p3)-min(p1,p2,p3))
print(min_)

Measured memory_bytes: 9140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();
        int Y = sc.nextInt();

        for (int i = 0; i <= X; i++) {
            if (2 * i + 4 * (X - i) == Y) {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");

    }
}


Measured memory_bytes: 35748
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
string s;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
int n;
double a[1000];
double wa;
int main()
{
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)
    {
        wa+=(double)(1.00000000/a[i]);
    }
    cout<<1.00000000/wa<<endl;
    return 0;
}

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

void Main() {
    // input

    int INF = 1000000;
    int N, M;
    cin >> N >> M;
    int d[N+1]; // とりあえず 10^6, INF のつもり
    for (int i = 0; i <= N; i++) {
        d[i] = INF;
    }

    vector< vector<int> > path(N+1);
    int from, to;
    for (int i = 0; i < M; i++) {
        cin >> from >> to;
        path[from].push_back(to);
        path[to].push_back(from);
    }


    // translate
    int start = 1;
    d[start] = 0;
    queue<int> next;
    next.push(start);

    while (!next.empty()) {
        int from = next.front();
        next.pop();
        for (auto it = path[from].begin(); it != path[from].end(); it++) {
            int to = *it;
            // cout << from << "->" << to << endl; 
            if (d[to] == INF) {
                d[to] = from;
                next.push(to);
            }
        }
    }



    
    // output
    cout << "Yes" << endl;
    for (int i = 2; i <= N; i++) {
        cout << d[i] << endl;
    }


}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 10220
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e6 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;

bool vis[N];
int n, ff = 0;
map<int, int> mp;

void backtrack(int total, int rem, int start) {
	if(!rem) {
		mp[total]++;
		++ff;
		return;
	}
	for (int i = start; i < n; ++i) {
		if(vis[i]) continue;
		vis[i] = 1;
		backtrack(total + i, rem - 1, i);
		vis[i] = 0;
	}
}

ll fact[N], inv[N];

ll add(ll a, ll b) {
	a += b;
	while(a >= MOD) a -= MOD;
	while(a < 0) a += MOD;
	return a;
}

ll mul(ll a, ll b) {
	return (1ll * a * b) % MOD;
}

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	int n, m;
	cin >> n >> m;
	++n;
	ll ans = 0;
	for (int i = m; i <= n; ++i) {
		ans = add(ans, add(1, mul(n - i, i)));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  REP(i,10){
    FOR(j,i,10){
      if(n == i * j){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int W,H,x,y,i,a=0;
	double ans;
  scanf("%d%d%d%d",&W,&H,&x,&y);
	if(W%2==0&&H%2==0&&W/2==x&&H/2==y)a=1;
	ans=(double)W*(double)H/2;

  printf("%lf %d\n",ans,a);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

// Graph
struct UsedEdge{
    int nextNode;
    bool used;
    int invIndex;
};

class UsedEdgeGraph{
public:
    vector<vector<UsedEdge>> E;

    UsedEdgeGraph(int n){
        E.resize(n);
    }

    void add(int node, int nextNode){
        E[node].emplace_back((UsedEdge){nextNode, false, (int)E[nextNode].size()});
        E[nextNode].emplace_back((UsedEdge){node, false, (int)E[node].size() - 1});
    }
};

// lowlink
class Lowlink{
public:
    vector<int> ord, low;
    vector<vector<int>> dfsTree;
    int root;
    
    Lowlink(vector<vector<UsedEdge>>& E, int root){
        int n = (int)E.size();
        this->root = root;
        ord.assign(n, -1);
        low.resize(n);
        dfsTree.resize(n);

        tempOrd = 0;
        dfs(E, root);
    }

    bool isBridge(int u, int v){
        if(ord[u] < low[v]){
            return true;
        }
        else{
            return false;
        }
    }

    bool isPoint(int node){
        if(node == root){
            if((int)dfsTree[node].size() > 1){
                return true;
            }
            else{
                return false;
            }
        }
        else{
            for(int nextNode: dfsTree[node]){
                if(ord[node] <= low[nextNode]){
                    return true;
                }
            }
            return false;
        }   
    }

private:
    int tempOrd;

    void dfs(vector<vector<UsedEdge>>& E, int node){
        ord[node] = tempOrd;
        tempOrd++;
        low[node] = ord[node];
        for(auto& e: E[node]){
            if(ord[e.nextNode] == -1){
                e.used = true;
                E[e.nextNode][e.invIndex].used = true;
                dfsTree[node].push_back(e.nextNode);

                dfs(E, e.nextNode);
                low[node] = min(low[node], low[e.nextNode]);
            }
            else if(!e.used){
                low[node] = min(low[node], ord[e.nextNode]);
            }
        }
    }
};

int main(){

    int V, E;
    cin >> V >> E;
    UsedEdgeGraph graph(V);
    
    int s, t;
    for(int i = 0; i < E; i++){
        cin >> s >> t;
        graph.add(s, t);
    }

    Lowlink lowlink(graph.E, 0);

    vector<pair<int, int>> ans;
    for(int i = 0; i < V; i++){
        for(int nextNode: lowlink.dfsTree[i]){
            if(lowlink.isBridge(i, nextNode)){
                int a = min(i, nextNode);
                int b = max(i, nextNode);
                ans.emplace_back(make_pair(a, b));
            }
        }
    }

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

    for(auto temp: ans){
        cout << temp.first << " " << temp.second << endl;
    }

    return 0;
}


Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int h,w,n,x,i=1,j=1,a[105][105],id=1;

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> h >> w >> n;
    for(int t=1;t<=n;t++){
        cin >> x;
        for(int k=1;k<=x;k++){
            a[i][j]=t;
            j+=id;
            if(j>w || !j){
                j-=id;
                id*=-1;
                i++;
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout << a[i][j] << ' ';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 384
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<bool>a(100001);
	rep(i, a.size()) {
		a[i] = true;
	}
	a[0] = a[1] = false;
	for (int i = 2; i < a.size(); i++) {
		if (!a[i]) { continue; }
		for (int j = i * 2; j < a.size(); j+=i){
			a[j] = false;
		}
	}
	vector<int>dp(100001);
	for (int i = 0; i < dp.size(); i++) {
		dp[i] = 0;
	}
	for (int i = 3; i < dp.size(); i++){
		if (a[i]&&a[(i+1)/2]) {
			dp[i] = dp[i - 1] + 1;
		}
		else 
		{
			dp[i] = dp[i - 1]; 
		}
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		ll ans = 0;
		int u, u1;
		cin >> u >> u1;
		ans += dp[u1] - dp[u - 1];
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  int ac = 0, wa = 0, tle = 0, re = 0;
  for(int i=0; i<N; i++){
      cin >> S;
      if(S.at(0) == 'A') ac++;
      if(S.at(0) == 'W') wa++;
      if(S.at(0) == 'T') tle++;
      if(S.at(0) == 'R') re++;
  }
  cout << "AC x " << ac << endl << "WA x " << wa << endl << "TLE x " << tle << endl << "RE x " << re << endl;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
  int a,b,c,sum=0,coin=0;
  cin>>a>>b>>c;
  if(a<c){
    while(coin<c){
      sum++;
      coin=coin+a;
      if(sum%7==0){
        coin=coin+b;
      }
    }
  }
  else sum=1;
  cout<<sum<<endl;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 1;

void solve() {
    ll n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        if(a[i] % 2 != 0) continue;
        if(a[i] % 3 != 0 && a[i] % 5 != 0 ){
            cout << "DENIED" << endl;
            return;
        }
    }
    cout << "APPROVED" << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	int a[3];
	cin >> a[0] >> a[1] >> a[2] >> k;

	sort(a, a+3);

	rep(i, k){
		a[2] *= 2;
	}

	cout << a[0] + a[1] + a[2] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v;
  rep(i,M){
    int k;
    cin >> k;
    vector<int> w;
    rep(j,k){
      int s;
      cin >> s;
      s--;
      w.push_back(s);
    }
    v.push_back(w);
  }
  vector<int> p;
  rep(i,M){
    int a;
    cin >> a;
    p.push_back(a);
  }

  int ret = 0;
  for(int S=0; S<(1<<N); S++){
    vector<int> x;
    rep(i,N){
      if((S>>i)&1) x.push_back(1);
      else x.push_back(0);
    }

    bool flg = true;
    rep(i,M){
      int y = 0;
      rep(j,v[i].size()){
        if(x[v[i][j]]==1) y++;
      }
      if(y%2 != p[i]) flg = false;
    }

    if(flg) ret++;
  }

  cout << ret << endl;
  
  return 0;
}



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

using namespace std;

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

  set<int> st;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (st.find(a) != st.end()) st.erase(a);
    else st.insert(a);
  }

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

  return 0;
}

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

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

    int numberOfABC[3];
    for(int i = 0; i < 3; i++) numberOfABC[i] = 0;
    int size = S.size();
    for(int i = 0; i < size; i++)
        if(S[i] == 'a') numberOfABC[0]++;
        else if(S[i] == 'b')    numberOfABC[1]++;
        else    numberOfABC[2]++;

    sort(numberOfABC, numberOfABC+3);

    if(numberOfABC[0] != (size/3)){
        cout << "NO" << "\n";
        return 0;
    }
    numberOfABC[1] -= numberOfABC[0];
    numberOfABC[2] -= numberOfABC[0];
    numberOfABC[0] = 0;
    
    size %= 3;
    if(size == 2){
        if(numberOfABC[1] == 1 && numberOfABC[2] == 1){
            cout << "YES" << "\n";
            return 0;
        }else{
            cout << "NO" << "\n";
            return 0;
        }
    }
    cout << "YES" << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>    
#include <cmath>
#include <map>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <set>
#include <functional>
#define int long long
#define mod(int)(1000000007)
using namespace std;
const int INF = 1000000000000000;
int cnt[345678], test[345678];
signed main() {
	int n, m; string s; cin >> s;
	if (s.size() % 2 == 0) { cout << "No" << endl; return 0; }
	for (int h = 0; h < s.size(); h++) {
		if (s[h] != s[s.size() - h - 1]) { cout << "No" << endl; return 0; }
	}
	for (int h = 0; h < (s.size() - 1) / 2; h++) {
		if (s[h] != s[(s.size() - 1) / 2 - h - 1]) { cout << "No" << endl; return 0; }
	}
	for (int h = (s.size() + 3) / 2 - 1; h < s.size(); h++) {
		if (s[h] != s[s.size() - h + (s.size() + 3) / 2 - 1 - 1]) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for(int i=0;i<=N;i++) {
        for(int j=0;j<=N;j++) {
            int a = N - R*i - G*j;
            if(a%B == 0 && a >= 0) ans++; 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 200005
vector<int> adj[MAX];
bool vis[MAX];
set<int> st;
int c;
int col[MAX];

void dfs(int node) {
    if(vis[node]) return;
    
    vis[node] = true;
    
    col[node] = c;
    
    ++c;
    
    for(int v:adj[node]){
        if(!vis[v]){
            dfs(v);
        }
    }
}

int main() 
{
    int n,m;
    cin >> n >> m;
    memset(vis, false,sizeof vis);
    int x,y;
    
    for(int i=0;i<m;i++){
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            c = 0;
            dfs(i);
        }
    }
    
    for(int i=1;i<=n;i++) st.insert(col[i]);
    
    cout<<st.size()<<endl;
    
    return 0;
}

Measured memory_bytes: 31096