akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

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

	sort(a.begin(), a.end());
	if (a[n - 1] - a[0] > 1) {
		cout << "No" << endl;
		return 0;
	}

	int cnt = 0;
	int al = a[n - 1];
	for (int i = 0; i < n; i++) {
		if (a[i] != al) {
			cnt++;
		}
	}
	//cout << cnt << endl;

	if (cnt == 0) {
		if (n - al == 1) {
			cout << "Yes" << endl;
			return 0;
		}
		if (al * 2 > n) {
			cout << "No" << endl;
			return 0;
		}


	}

	if (al - cnt <= 0) {
		cout << "No" << endl;
		return 0;
	}

	if (cnt < 2 * al - n) {
		cout << "No" << endl;
		return 0;
	}
	


	cout << "Yes" << endl;

}

Measured memory_bytes: 3792
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i, ans,numc(0:100000)
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    numc(:) = 0
    do i=1,n
        numc(a(i)) = numc(a(i)) + 1
    end do
    ans=0

    do i=1,ubound(numc,1)-1
        ans=max(ans,sum(numc(i-1:i+1)))
    end do

    print*, ans
end program name

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n];
    REP(i,n){
        cin >> a[i];
    }
    ll now = 0;
    ll cnt1 = 0, cnt2 = 0;
    REP(i,n){
        now += a[i];
        if(i % 2 == 0){
            if(now <= 0){
                cnt1 += 1 - now;
                now = 1;
            }
        }else{
            if(now >= 0){
                cnt1 += now + 1;
                now = -1;
            }
        }
    }
    now = 0;
    REP(i,n){
        now += a[i];
        if(i % 2 == 1){
            if(now <= 0){
                cnt2 += 1 - now;
                now = 1;
            }
        }else{
            if(now >= 0){
                cnt2 += now + 1;
                now = -1;
            }
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  cin>>a>>b;
  if(a>9 || a<1){cout<<-1; return 0;}
  if(b>9 || b<1){cout<<-1; return 0;}
  cout<<a*b<<endl; 
  return 0;}

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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <=b; ++i) {
        string s = to_string(i);
        string t = s;
        reverse(s.begin(), s.end());
        if (s == t) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)1e5 + 5;

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

template<typename T>
T lcm(T m, T n)
{
	return ((m / gcd(m, n)) * n);
}

signed main() {
	ll a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int c=0;
	double  a,b,sum=0.0;
	double x[21]={},y[21]={};
	while(scanf("%lf,%lf",&a,&b)!=EOF){
		//if(a==-1) break;
		if(c==0){
			x[c]=a; y[c]=b;
		}else{
			x[c]=a-x[0]; y[c]=b-y[0];
		}
		c++;
	}
	rep(i,1,c-1){
		sum+=0.5*abs(x[i]*y[i+1]-x[i+1]*y[i]);
	}
	printf("%.10lf\n",sum);
}
/*
double dist(double x1,double y1,double x2,double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

double solve(double x1,double y1,double x2,double y2,double x3,double y3){
	double a,b,c,z,s;
	a=dist(x1,y1,x2,y2);
	b=dist(x2,y2,x3,y3);
	c=dist(x3,y3,x1,y3);
	z=(a+b+c)*0.5;
	s=sqrt(z*(z-a)*(z-b)*(z-c));
	return s;
}

int main(){
	char c;
	double x1,y1,x2,y2,x3,y3,sum=0;
	cin>>x1>>c>>y1>>x2>>c>>y2;
	//scanf("%lf,%lf%c%lf,%lf",&x1,&y1,&c,&x2,&y2);
	while(scanf("%lf,%lf",&x3,&y3)!=EOF){
		sum+=solve(x1,y1,x2,y2,x3,y3);
		x2=x3; y2=y3;
		o(" "<<sum);
	}
	printf("%.10lf",sum);
}*/
/*
typedef complex<double> xy_t;

//??????????¬?????????¢????????????
double cross_product(xy_t a,xy_t b){
	return (conj(a)*b).imag();
}

xy_t P[110];

int main(){
	int n=0;
	double x,y;
	while(~scanf("%lf,%lf",&x,&y)){
		P[n++]=xy_t(x,y);
	}
	double sum=0.0;
	rep(i,0,n-2){
		xy_t a=P[0],b=P[i+1],c=P[i+2];
		sum+=0.5*cross_product(b-a,c-a);
	}
	printf("%.6lf\n",abs(sum));
}*/

Measured memory_bytes: 1240
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

def qsort(seq):
	if len(seq) < 2:
		return seq
	else:
		beg, end = 0, len(seq) - 1
		mid = (beg + end) // 2
		smaller = [c for c in seq if seq[mid] > c]
		equal = [c for c in seq if seq[mid] == c]
		larger = [c for c in seq if seq[mid] < c]
		return (qsort(smaller) + equal + qsort(larger)) 

n = int(input())
a = qsort(list(int(i) for i in input().split()))

for i in range(1, n):
	if a[i - 1] == a[i]:
		print('NO')
		exit(0)
print('YES')
exit(0)

Measured memory_bytes: 35136
h,w=map(int,input().split())
c=[[0]*10 for _ in range(10)]
for i in range(10):
    c[i]=list(map(int, input().split()))

a=[[0]*w for _ in range(h)]
for i in range(h):
    a[i]=list(map(int, input().split()))


def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d


ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]>-1:
            ans+=warshall_floyd(c)[a[i][j]][1]
print(ans)

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

const int INF = 1000000000;

int a[12][12];

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s,1 << n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if(s>>i&1){
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
      bool ok = true;
      rep(i,m) if(d[i] < x) ok = false;
      if(ok) ans = min(ans,cost);
  }

  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	if (h[0] > 1) h[0]--;
	for (int i = 1; i < n; i++) {
		if (h[i] - 1 >= h[i - 1]) {
			h[i]--;
		}
	}
	for (int i = 1; i < n; i++) {
		if (h[i] < h[i - 1]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include <tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
#define N 1000000007
using namespace std;
int main() {
	string s; cin >> s;
	int len = s.length(),cnt=0;
	for (int i = 0; i < len / 2; ++i) {
		if (s[i] != s[len - (i + 1)]) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

pow2 = [1]
mod = 1000000007

for i in range(1,61):
    pow2.append(pow2[-1]*2 % mod)

seq = list(map(lambda x: bin(int(x))[2:], input().split()))

onec = [0 for i in range(61)]

for i in range(n):
    ln = len(seq[i])
    for j in range(ln):
        if seq[i][ln-1-j] == '1':
            onec[j] += 1

sm = 0

for i in range(61):
    sm += onec[i]*(n-onec[i]) * pow2[i] % mod
    
print(sm % mod)

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

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <=N; i++)
	{
		if (i<=9 ||(1e2 <= i && i <= 1e3-1)|| (1e4 <= i && i <= 1e5 - 1))
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,i,p[n],c;
	c=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	scanf("%d",&p[i]);
	}


	for(i=1;i<=n;i++){
		if(p[i]!=i){
			c++;
			
		}
		
	}
	if(c<=2){
		printf("YES");
	}else{
		printf("NO");
	}
	// your code goes here
	return 0;
}


Measured memory_bytes: 128
(defun read-list-from-string (str)
  (read-from-string (concatenate 'string "(" str ")")))

(defun read-list (&optional (stream *standard-input*))
  (read-list-from-string (read-line stream)))

(defun beauty-p (a b c)
  (let ((ab (- b a))
	(bc (- c b)))
    (= ab bc)))

(let ((list (read-list)))
  (if (apply #'beauty-p list)
      (format t "YES~%")
      (format t "NO~%")))


Measured memory_bytes: 12384
import collections

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M, K = ZZ()
    F = [0] * (N+1)
    output = []

    par = [i for i in range(N+1)]
    rank = [0] * (N+1)

    # 要素xの親ノードを返す
    def find(x):
        if par[x] == x:
            return x
        par[x] = find(par[x])
        return par[x]

    # 要素x, yの属する集合を併合
    def unite(x, y):
        x, y = find(x), find(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
        return

    # xとyが同じ集合に属するか？
    def same(x, y):
        return find(x) == find(y)

    for _ in range(M):
        a, b = ZZ()
        F[a] += 1
        F[b] += 1
        unite(a, b)

    for i in range(1, N+1): find(i)
    cnt = collections.Counter(par)

    for _ in range(K):
        c, d = ZZ()
        if same(c, d):
            F[c] += 1
            F[d] += 1
    for i in range(1, N+1):
        cc = cnt[par[i]] - F[i] - 1
        output.append(cc)

    print(*output)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 18300
N=int(input())
a = [int(input()) for i in range(N)]
check=[False for i in range(N)]
pos=0
cnt=0

while True:
    if(pos==1):
        print(cnt)
        break
    elif (check[pos]):
        print(-1)
        break
    else:
        check[pos]=True
        pos=a[pos]-1   
        cnt+=1
     

Measured memory_bytes: 7852
package main

import "fmt"

func color(a int) int {
	if a >= 3200 {
		return 8
	}
	return a / 400
}

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}

	cols := make([]int, 9)
	for _, a := range as {
		cols[color(a)]++
	}

	num_normal_color := 0
	for i := 0; i < 8; i++ {
		if cols[i] > 0 {
			num_normal_color++
		}
	}
	if num_normal_color == 0 {
		fmt.Println(1, cols[8])
	} else {
		fmt.Println(num_normal_color, num_normal_color+cols[8])
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int zero_P=100005;
struct segtree{
private:
  vector<ll> node;
  int siz;
public:
  segtree(vector<ll> v){
    int n=v.size();
    siz=1;
    while(siz<n) siz*=2;
    node.resize(siz*2,0);
    for(int i=0;i<n;i++) node[i+siz-1]=v[i];
    for(int i=siz-2;i>=0;i--) node[i]=node[i*2+1]+node[i*2+2];
  }
  void add(int a,int x){
    a+=siz-1;
    node[a]+=x;
    while(a>0){
      a=(a-1)/2;
      node[a]=node[2*a+1]+node[2*a+2];
    }
  }
  ll q_sum(ll a,ll b,ll x,ll l,ll r){
    if(r<=a||b<=l) return 0;
    if(a<=l&&r<=b) return node[x];
    ll lsum=q_sum(a,b,2*x+1,l,(l+r)/2);
    ll rsum=q_sum(a,b,2*x+2,(l+r)/2,r);
    return lsum+rsum;
  }
  ll sum(ll a){
    return q_sum(a,siz,0,0,siz);
  }
};
int main(){
  ll n;
  cin>>n;
  ll border=(n*(n-1)/2+n)/2+1;
  vector<ll> vec,sort_vec;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
    sort_vec.push_back(a);
  }
  sort(sort_vec.begin(),sort_vec.end());
  sort_vec.erase(unique(sort_vec.begin(),sort_vec.end()),sort_vec.end());
  ll l=-1,r=sort_vec.size()-1;
  while(r-l>1){
    ll mid=(l+r)/2;
    ll mid_v=sort_vec[mid];
    ll kans=0;
    vector<ll> delta(200010,0);
    ll under=0,over=0;
    for(int i=0;i<n;i++){
      if(vec[i]<=mid_v) under++;
      else over++;
      delta[under-over+zero_P]++;
    }
    segtree seg=segtree(delta);
    under=0;
    over=0;
  //  cout<<mid<<" "<<mid_v<<" K:";
    for(int i=0;i<n;i++){
      kans+=seg.sum(zero_P+1+under-over);
      if(vec[i]<=mid_v) under++;
      else over++;
      seg.add(under-over+zero_P,-1);
    //  cout<<kans<<" ";
    }
    if(kans<border) l=mid;
    else r=mid;
    //cout<<kans<<endl;
  }
  cout<<sort_vec[r]<<endl;
}


Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    
    bool a = false;
    for (int i = 0; i <= x; i++) {
        if (i * 2 + (x - i) * 4 == y) {
            a = true;
        }
    }

    if (a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

int main() {
	int N, S[100], count = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		count += S[i];
	}
	if (count % 10 == 0) {
		sort(S, S + N);
		bool check = true;
		for (int i = 0; i < N; i++) {
			if (S[i] % 10 != 0) {
				count -= S[i];
				check = false;
				break;
			}
		}
		if (check) count = 0;
	}
	cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int t1,t2;
  cin>>t1>>t2;
  PII a,b;
  
  cin>>a.F>>a.S>>b.F>>b.S;
  
  
  a.F*=t1;
  a.S*=t2;
  b.F*=t1;
  b.S*=t2;
  int f=a.F-b.F,s=a.S-b.S;
  if(f>0){
    f*=-1;
    s*=-1;
  }
  if((f+s)==0){cout<<"infinity"<<endl;return 0;}
  else if((f+s)<0){cout<<0<<endl;return 0;}
  else{
    int x=-f/(f+s),y=f%(f+s);
    if(y!=0) cout<<x*2+1<<endl;
    else cout<<x*2<<endl;
  }
       
  
    
    
    


  return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <complex>
#include <iostream>
#include <vector>
#include <utility>
#define EPS (1e-10)
#define X real()
#define Y imag()
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;

double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

P intersection(L a, L b){
  //??´???a??¨??´???b?????????
  return a.first + cross(b.second-b.first,a.first-b.first)/(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first))*(a.second-a.first);
}

  
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if( cross(b,c) > EPS ) return +1;
  if( cross(b,c) < -EPS ) return -1;
  if( dot(b,c) < 0 ) return +2;
  if( abs(b-a) + EPS < abs(c-a) ) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}

int main(){
  double W, H;
  int N;
  while(cin >> W >> H >> N, W){
    vector<L> V;
    double x, y;
    vector<double> S;
    S.push_back(0);
    for(int i = 0; i < 2*N; ++i){
      cin >> x >> y;
      L tmp;
      if(abs(x) > EPS && abs(W-x) > EPS){
	tmp = L(P(0, W*y/x), P(W*y/(W-x), 0));
	S.push_back(W*y/(W-x));
      }else if(abs(x) > EPS){
	tmp = L(P(0, y), P(H, y));
	S.push_back(H);
      }else{
	tmp = L(P(y, 0), P(y, H));
	S.push_back(y);
      }
      V.push_back(tmp);
      if((abs(cross(tmp.first-tmp.second, P(H,0))) > EPS) && is_cross(tmp,L(P(0,H),P(H,H)))){
	S.push_back(intersection(tmp,L(P(0,H),P(H,H))).X);
      }
    }
    for(int i = 0; i < 2*N; ++i){
      for(int j = 0; j < i; ++j){
	if((abs(cross(V[j].first-V[j].second, V[i].first-V[i].second)) > EPS) && is_cross(V[i],V[j]))
	  S.push_back(intersection(V[i],V[j]).X);
      }
    }
    S.push_back(H);
    sort(S.begin(), S.end());
    int k = (int)S.size();
    double ans = 0;
    for(int i = 1; i < k; ++i){
      double s_r = S[i], s_l = S[i-1];
      L l_r = L(P(s_r,0),P(s_r,H)), l_l = L(P(s_l,0),P(s_l,H));
      vector<double> T_l, T_r;
      if(s_r > H + EPS) break;
      for(int j = 0; j < 2*N; ++j){
	//??°??¢????????´
	if((abs(cross(V[j].first-V[j].second, P(0,H))) > EPS) && is_cross(V[j],l_r)){
	  T_r.push_back(min(intersection(V[j],l_r).Y, H) );
	}else if(V[j].second.X < s_r && V[j].first.X < s_r){
	  T_r.push_back(0);
	}else if(abs(V[j].first.X - s_r) < EPS && abs(V[j].second.X - s_r) < EPS){
	  T_r.push_back(H);
	}else{
	  T_r.push_back(H);
	}
	//??°??¢????????´
	if((abs(cross(V[j].first-V[j].second, P(0,H))) > EPS) && is_cross(V[j],l_l)){
	  T_l.push_back(min(intersection(V[j],l_l).Y, H));
	}else if(V[j].second.X < s_l && V[j].first.X < s_l){
	  T_l.push_back(0);
	}else if(abs(V[j].first.X - s_l) < EPS && abs(V[j].second.X - s_l) < EPS){
	  T_l.push_back(0);
	}else{
	  T_l.push_back(H);
	}
      }
      sort(T_l.begin(), T_l.end());
      sort(T_r.begin(), T_r.end());
      ans += (T_l[N]-T_l[N-1]+T_r[N]-T_r[N-1])*(s_r-s_l)/2.0;
    }
    printf("%.11f\n", ans/H/H);
  }
  return 0;
}

Measured memory_bytes: 3428
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class A2FightingOverCandies {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b, c;
	    in >> a >> b >> c;
	    if(a+b == c || b+c == a || c+a == b) ans(true, out);
	    else ans(false, out);
	}
};


int main() {
	A2FightingOverCandies solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vi ws(n,0);
    vi es(n,0);
    
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'W') {
            ws[i] = ws[i - 1] + 1;
        } else {
            ws[i] = ws[i - 1];
        }
    }
    for (int i = n - 2; i >= 0; i--) {
        if (s[i + 1] == 'E') {
            es[i] = es[i + 1] + 1;
        } else {
            es[i] = es[i + 1];
        }
    }
    
    i64 nin = 1e9;
    for (int i = 0; i < n; i++) {
        nin = min(nin, ws[i] + es[i]);
    }
    
    cout << nin << endl;
}

Measured memory_bytes: 5380
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
bool solve(int a){
    int tmp=1,cnt=1;
    int r=3;
    while(a/r){
        if(a%r==0){
            cnt++;
            a/=r;
        }else{
            tmp*=cnt;
            r+=2;
            cnt=1;
        }
    }
    tmp*=cnt;
    if(tmp==8)return true;
    return false;
}
int main(){
    int n;
    cin >> n;
    if(n%2==0) n--;
    int t=1,ans=0;

    while (t<=n){
        if(solve(t)){
            ans++;
        }
        t+=2;
    }
    cout << ans << endl;

}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
}

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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector < string > A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector < string > B(M);
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}

	for (int i = 0; i < N - M + 1; i++) {
		for (int j = 0; j < N - M + 1; j++) {
			bool isOK = true;
			for (int x = 0; x < M; x++) {
				for (int y = 0; y < M; y++) {
					if (A[j + y][i + x] != B[y][x]) {
						isOK = false;
					}
				}
			}
			if (isOK) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
for i in range(1,26):
    for j in range(15):
        if N % (4*i + 7*j) == 0:
            print('Yes')
            exit()
for j in range(1,15):
    for i in range(26):
        if N % (4*i + 7*j) == 0:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
#include<stdio.h>

int main(){

  int K,N;
  scanf("%d %d",&N,&K);
  char S[N];

  scanf("%s",S);

  if(S[K-1]=='A'){
    S[K-1]='a';
  }else if(S[K-1]=='B'){
    S[K-1]='b';
  }else{
    S[K-1]='c';
  }

  printf("%s\n",S);

  return 0;


}


Measured memory_bytes: 128
#include <iostream>
#define ll long long
using namespace std;

ll dp[310][310];

void warshall_floyd(int n){
    for(int k=1; k<=n; ++k){
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=n; ++j){
                dp[i][j]=min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }
}

int main() {
	int N, M;
	ll L;
	cin >> N >> M >> L;
	for(int i=1; i<=N; ++i){
	    for(int j=1; j<=N; ++j) dp[i][j]=1e15;
	    dp[i][i]=0;
	}
	for(int i=0; i<M; ++i){
	    int A, B;
	    ll C;
	    cin >> A >> B >> C;
	    dp[A][B]=dp[B][A]=C;
	}
	warshall_floyd(N);
	for(int i=1; i<=N; ++i){
	    for(int j=1; j<=N; ++j){
	        if(dp[i][j]<=L) dp[i][j]=1;
	        else dp[i][j]=10000;
	    }
	    dp[i][i]=0;
	}
	warshall_floyd(N);
	int Q;
	cin >> Q;
	for(int i=0; i<Q; ++i){
	    int s, t;
	    cin >> s >> t;
	    if(dp[s][t]<=N) cout << dp[s][t]-1 << endl;
	    else cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main() {
    long N;
    long sum = 0;
    long a[3000];
    scanf("%ld\n", &N);
    for(int i = 0; i < N; i++) {
        scanf("%ld", &a[i]);
    }
    for(int i = 0; i < N ; i++) {
        sum += a[i] - 1;
    }
    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;

	bool flag = 0;

	for (int i = 0; i <= X; i++){
		if (i * 2 + (X - i) * 4 == Y) {
			cout << "Yes" << endl;
			flag = 1;
			break;
		}
	}
	if (!flag) {
		cout << "No" << endl;
	}
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a, b;
	cin >> a >> b;
	if(a%3 == b%3 && a%3!=0) puts("Impossible");
	else puts("Possible");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const string nl="\n";
const ll MOD=1000000007;

int main(){
    int n;cin>>n;
    ll h[n];
    for(int i=0;i<n;i++){
    	cin>>h[i];
    }
    int f=0;
    for(int i=n-1;i>0;i--){
    	if(h[i-1]<=h[i]) continue;
    	h[i-1]--;
    	if(h[i-1]>h[i]){
    		cout<<"No";return 0;
    	}
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn=3e5+10,mod=998244353,inf=0x3f3f3f3f;
int n,m,k,t,fac[maxn],inv[maxn];
int qpow(int x,int y)
{
    int ret=1;
    while(y)
    {
        if(y&1)
            ret=(long long)ret*x%mod;
        x=(long long)x*x%mod;
        y>>=1;
    }
    return ret;
}
int C(int x,int y)
{
    return (long long)fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    int i,j;
    fac[0]=1;
    for(i=1;i<maxn;i++)
        fac[i]=(long long)fac[i-1]*i%mod;
    inv[maxn-1]=qpow(fac[maxn-1],mod-2);
    for(i=maxn-2;i>=0;i--)
        inv[i]=(long long)inv[i+1]*(i+1)%mod;
    long long k;
    int a,b;
    scanf("%d%d%d%lld",&n,&a,&b,&k);
    int ret=0;
    for(i=0;i<=n && (long long)a*i <= k;i++)
    {
        long long cnt=(k-(long long)a*i)/b;
        if(cnt>n || cnt*b!= k- (long long)a*i)continue;
        ret+=(long long)C(n,i)*C(n,cnt)%mod;
        ret%=mod;
    }
    printf("%d\n",ret);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, cnt=0;
  cin >> N;
  vector<int> p(N);
  vector<int> q;
  REP(i,N) {
    cin >> p[i];
    if(p[i]!=i+1) cnt++;
  }
  if(cnt==0 || cnt==2) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

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

//从小到大枚举点集大小i，再枚举点集里的所有点x_{ij} 
//对于 r - l >= i的区间 则显然会被包含在区间一次 
//考虑 对于 r - l + 1 < i 的点 则其显然至多 在枚举某个 x_{i,j}的时候被计算一次贡献
//这样点 x_{i,j}的数量是 mlogm级别的 暴力枚举即可 
 
//需要支持的操作有区间加法 单点求值 维护一棵bit即可
 
const int maxn = 300005;

namespace BIT{
	int c[maxn], siz;
	
	inline int lowbit(int x){
		return x & (-x);
	}
	
	void update(int x, int d){
		for(; x <= siz; x += lowbit(x))
			c[x] += d;
	}
	
	int query(int x){
		int res = 0;
		for(; x; x ^= lowbit(x))
			res += c[x];
		return res;
	}
}

struct segment_Tp{
	int l, r, len;
	
	bool operator < (const segment_Tp &s0) const {
		return len < s0.len;
	}
}que[maxn];

int n, m;

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
		scanf("%d%d", &que[i].l, &que[i].r), que[i].len = que[i].r - que[i].l;
	sort(que + 1, que + 1 + n);
	BIT::siz = m;
	
	for(int ans_cur, p = 1, i = 1; i <= m; i++){
		while(p <= n && que[p].len < i)
			BIT::update(que[p].l, 1), BIT::update(que[p].r + 1, -1), ++p;
		ans_cur = n - p + 1;
		for(int j = 0; j <= m; j += i)
			ans_cur += BIT::query(j);
		printf("%d\n", ans_cur);
	}
	
	return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

/*
n
 */
ll n;

int main(){
  cin >> n;

  int ans = (int)floor(log10(n))+1;
  FOR_IN(a,1,sqrt(n)+1){
    if(!(n%a))
      ans = min(ans, (int)floor(log10(n/a))+1);
  }

  cout << ans << endl;

  return 0;
}


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

# abc128_c

def main():
    # Input
    n, m = [int(s) for s in input().split()]
    reports = [[int(s) for s in input().split()] for _ in range(m)]
    ps = [int(s) for s in input().split()]
    # Get ans
    def get_switch_lists():
        for i in range(2**n):
            yield [(i//2**k)%2 for k in range(n)]
    def get_odd(switch_list, repo):
        return sum(switch_list[r-1] for r in repo[1:]) % 2
    ans = 0
    for switch_list in get_switch_lists():
        qs = [get_odd(switch_list, repo) for repo in reports]
        if all(p==q for p, q in zip(ps, qs)):
            ans += 1
    # Output
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l+r)/2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

#define EPS 1e-6

#define T double
typedef complex<T> pt;
#define x real()
#define y imag()
T dot(pt v, pt w) {return (conj(v)*w).x;}
T cross(pt v, pt w) {return (conj(v)*w).y;}
T orient(pt a, pt b, pt c) {return cross(b-a,c-a);}
T dist(pt a, pt b) {return abs(a-b);}

int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int b[n] = {};
	b[0] = 0;
	b[1] = abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		b[i] = min(b[i-1] + abs(a[i-1]-a[i]), b[i-2] + abs(a[i-2]-a[i]));
	}
	cout<<b[n-1]<<endl;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
B = []

for i in range(N):
  B.append(A[i] - (i+1))
C = sorted(B)
ans = 0
bns = 0

if N % 2 == 1:
  a = C[(N-1)//2]
  for i in range(N):
    ans += abs(A[i]-(a+i+1))
  print(ans)
else:
  a = C[N//2]
  b = C[N//2-1]
  for i in range(N):
    ans += abs(A[i]-(a+i+1))
    bns += abs(A[i]-(b+i+1))
  print(min(ans, bns))
  
 

Measured memory_bytes: 25748
# import bisect
# # import heapq
# # from copy import deepcopy
# # from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math
# a,b,c = map(int, input().split())

# p = list(map(int, input().split()))
n = int(input())
count = 0
a = [[0] * 10 for i in range(10)]
# print(a)
# print(b)
for i in range(n +1):
    head = int(str(i)[0])
    tail = int(str(i)[-1])
    # if i == 18:
    #     print(head,tail)
    a[head][tail] += 1


for i in range(n+1):
    if i % 10 == 0:
        continue

    head = int(str(i)[0])
    tail = int(str(i)[-1])
    count += a[tail][head]

print(count)


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

int main() {
    int n;
    int b[110];
    cin >> n;
    for(int i = 0; i < n - 1; ++i) cin >> b[i];
    int a[110];
    
    for(int i = 0; i < n; ++i) a[i+1] = min(b[i], b[i+1]);
    a[0] = b[0];
    a[n-1] = b[n-2];
    
    int total = 0;
    for(int i = 0; i < n; ++i) total += a[i];
    
    cout << total << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    char s[4];
    scanf("%s",s);
    if ((s[0] != s[1]) || (s[1] != s[2]))
    {
        printf("Yes\n");
        return 0;
    } else
    {
        printf("No\n");
        return 0;
    }
    
    
    return 0;  
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>

using namespace std;

char str[1023];

int main()
{
    int n,m=0;
    cin>>n>>m;
    m-=m;
    while(n--)
    {
        cin>>str;
        puts(str),puts(str);
    }
    return m;
}

Measured memory_bytes: 256
def cmb(n, r, p):
    A = 1
    B = 1
    r = min(r, n - r)
    for i in range(r):
        A = A * (n-i) % p
        B = B * (i+1) % p
    return A * pow(B, p-2, p) % p

n, a, b = map(int, input().split())
p = 10**9 + 7
A = pow(2, n, p) - 1 - cmb(n, a, p) - cmb(n, b, p)
A = A%p
print(A)

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

int main(void){
  int X, Y, a, b;
  cin >> X >> Y;

  a = (Y - 2 * X) % 2;
  b = (4 * X - Y) % 2;

  if(a == 0 && (Y - 2 * X) >= 0 ){
    if(b == 0 && (4 * X - Y) >= 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
vector<ll> groupvalue;
vector<ll> dp;
int n;
ll solve(int left){
    if(dp[left]!=-1){
        return dp[left];
    }
    dp[left]=groupvalue[left];
    for(int s=left;s;s=(s-1)&left){
        if(s==left){
            continue;
        }
        dp[left]=max(dp[left],solve(left^s) + solve(s));
    }
    return dp[left];
}
ll solve(){
    cin>>n;
    int value[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>value[i][j];
        }
    }
    groupvalue.resize((1<<n),0);
    dp.resize((1<<n),-1);
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                for(int k=j+1;k<n;k++){
                     if(i&(1<<k)){
                         groupvalue[i]+=value[j][k];
                     }
                }            
            }
        }
    }
    return solve((1<<n) -1);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> B.at(i);
  }
  for(int i = 0; i < N-1; i++){
    cin >> C.at(i);
  }
  
  int sum = 0;
  for(int i = 0; i < N; i++){
    sum += B.at(A.at(i)-1);
    if( i > 0 ){
      if( A.at(i) == (A.at(i-1)+1) ) sum += C.at(A.at(i)-2);
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  int i,n,m,h,j,k;
  char a[200],T;

  while(1){
  scanf("%s",a);
  if(a[0]=='-') break;

  m=strlen(a);

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&h);
    for(k=0;k<h;k++){
    for(j=0;j<m-1;j++){
      T=a[j];
      a[j]=a[j+1];
      a[j+1]=T;
    }
    }
  }
  for(i=0;i<m;i++){
    printf("%c",a[i]);
  }

  printf("\n");
  }
  return 0;
}

Measured memory_bytes: 568
from math import factorial as f
n = int(input())
def sc(s, t, l):
  if t == 0:
    return 0
  i = s[0]
  for j in range(i+1, n+1):
    l[j] += 1
  return f(t-1)*(i-1-l[i]) + sc(s[1:], t-1, l)
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
pc = sc(P, n, [0 for _ in range(n+1)])
qc = sc(Q, n, [0 for _ in range(n+1)])
print(abs(qc-pc))

Measured memory_bytes: 3064
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int h,n,a[1001],b[1001],dp[20001],ans=INF;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>h>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=1;i<=h+10000;++i)
	{
		dp[i]=INF;
		for(int j=1;j<=n;++j)
		{
			if(i-a[j]<0)
			{
				continue;
			}
			dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
		}
	}
	for(int i=h;i<=h+10000;++i)
	{
		ans=min(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

set<string> s;

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

	for (int i = 0; i < n; i++) {
		int a[3];
		string str = "";
		cin >> a[0] >> a[1] >> a[2];
		sort(a,a+3);
		str += to_string(a[0]);
		str += to_string(a[1]);
		str += to_string(a[2]);
		s.insert(str);
	}
	cout << n - s.size() << endl;
	return	0;
}

Measured memory_bytes: 3304
n = int(input())
lst = [int(x) for x in input().split()]
hasError = False

for i in lst:
  if i % 2 == 0:
    if i % 3 != 0 and i % 5 != 0:
      hasError = True
      break

if hasError:
  print('DENIED')
else:
  print('APPROVED')

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

int main() {
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>> t(n);
  for (int i = 0;i < n;i++){
    cin >> t[i].first.first >> t[i].first.second;
    t[i].second = i + 1;
    t[i].first.second *= -1;
  }
  
  sort(t.begin(),t.end());
  
  for (int i = 0;i < n;i++){
    cout << t[i].second << endl;
  }
}

Measured memory_bytes: 3520
MOD = 10 ** 9 + 7

S = [0] + list(input())
n = len(S) - 1

yet = [0] * (n+1)
a = [0] * (n+1)
ab = [0] * (n+1)
abc = [0] * (n+1)
#i番目まで見終わった後の考えられる手数

abc[n] = 1

for i in range(1,n+1):
    if S[n-i+1] == "A":
        yet[n-i] = (yet[n-i+1] + a[n-i+1]) % MOD
        a[n-i] = a[n-i+1]
        ab[n-i] = ab[n-i+1]
        abc[n-i] = abc[n-i+1]
    elif S[n-i+1] == "B":
        yet[n-i] = yet[n-i+1]
        a[n-i] = (ab[n-i+1] + a[n-i+1]) % MOD
        ab[n-i] = ab[n-i+1]
        abc[n-i] = abc[n-i+1]
    elif S[n-i+1] == "C":
        yet[n-i] = yet[n-i+1]
        a[n-i] = a[n-i+1]
        ab[n-i] = (ab[n-i+1] + abc[n-i+1]) % MOD
        abc[n-i] = abc[n-i+1]
    else:
        yet[n-i] = (yet[n-i+1] * 3 + a[n-i+1]) % MOD
        a[n-i] = (a[n-i+1] * 3 + ab[n-i+1]) % MOD
        ab[n-i] = (ab[n-i+1] * 3 + abc[n-i+1]) % MOD
        abc[n-i] = (abc[n-i+1] * 3) % MOD

print(yet[0])

Measured memory_bytes: 19536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define int long long int
#define ull unsigned long long
#define PI 3.14159265
#define SIZE 200010
#define MOD 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define tc int tcs;cin>>tcs;while(tcs--)
#define set_bit __builtin_popcount
#define MSET(table,i) memset(table, i, sizeof(table))
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ){stringstream ss; ss<< number; return ss.str();}
int power(int x,int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}



int32_t main()
{
    fast;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if( k <= a+b )
    {
        cout<<min(k,a);
    }
    else
    {
        cout<< a - (k - a -b);
    }
    
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT = std::numeric_limits<int>::max();
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL = std::numeric_limits<long long>::max();

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


///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(max(b*d, a*c), max(b*c, a*d)) << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    double tmp;
    cin >> tmp;

    return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int h,w;
	cin>>h>>w;
	int cnt[26] = {};
	rep(i,h*w){
		char c;
		cin>>c;
		cnt[c-'a']++;
	}
	int x=0,y=0,z=0;
	rep(i,26){
		z += cnt[i]/4;
		cnt[i] %=4;
		y += cnt[i]/2;
		cnt[i] %= 2;
		x += cnt[i];
	}
	int a,b,c;
	if (h % 2 == 0)swap(h,w);
	if (h%2==1){
		if (w%2==1){
			a=1;
			b=(h+w-1)/2;
			c=(h*w-(h+w-1))/4;
		}
		else{
			a=0;
			b=w/2;
			c = (h*w -w)/4;
		}
	}
	else{
		a=b=0;
		c=h*w/4;
	}
	if (x<=a && y<=b){
		cout << "Yes"<<endl;
	}
	else{
		cout << "No"<<endl;
	}



	return 0;
}

Measured memory_bytes: 256
import sys

input=sys.stdin.readline

N,M=map(int,input().split())
eat=[]
for i in range(M):
    x,y=map(int,input().split())
    eat.append((x,y))

eat=eat[::-1]

turkey=[]
for i in range(1,N+1):
    tempval=set([i])
    tempid=set([])
    for j in range(M):
        x,y=eat[j]
        if x in tempval and y in tempval:
            break
        elif x in tempval:
            tempval.add(y)
            tempid.add(j)
        elif y in tempval:
            tempval.add(x)
            tempid.add(j)
    else:
        turkey.append([tempval,tempid])

ans=0
n=len(turkey)
#print(turkey)
for i in range(1,n):
    for j in range(i):
        aval,aid=turkey[i]
        bval,bid=turkey[j]
        checkval=True
        checkid=True
        for val in bval:
            checkval=checkval&(val not in aval)
        for id in bid:
            checkid=checkid&(id not in aid)
        if checkid and checkval:
            ans+=1
            #print(i,j)

print(ans)

Measured memory_bytes: 79480
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	char a[101][101];
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=m+2;i++)
	{
		cout<<"#";
	}
	cout<<endl;
	for(int i=1;i<=n;i++)
	{
		cout<<"#";
		for(int j=1;j<=m;j++)
		{
			cout<<a[i][j];
		}
		cout<<"#"<<endl;	
	}
	for(int i=1;i<=m+2;i++)
	{
		cout<<"#";
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int ans=0, mode=0;
  ll prev=a[0];
  for(int i=1;i<n;i++){
    if(mode==0){
      if(a[i]>prev){
        mode=1;
      }else if(a[i]<prev){
        mode=2;
      }
    }else if(mode==1){
      if(a[i]<prev){
        ans++;
        mode=0;
      }
    }else{
      if(a[i]>prev){
        ans++;
        mode=0;
      }
    }
    prev=a[i];
  }
  cout<<ans+1<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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 REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

template<class T> inline int sgn(T n) { if (n > 0) return 1; else if (n < 0) return -1; else return 0; }

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

int n, m;
const int MAX = 10;
vi to[MAX];

int dfs(int cnt, int v, vi checked) {
  if (cnt == n-1) {
    return 1;
  }

  checked[v] = true;

  int ret = 0;
  for (auto x : to[v]) {
    if (!checked[x]) {
      ret += dfs(cnt+1, x, checked);
    }
  }
  return ret;
}

int main () {
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  vi checked(MAX,false);
  cout << dfs(0,0,checked) << endl;
  return 0;
}

Measured memory_bytes: 256