akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
using namespace std;
int main(void){
	
	int n,i,minnum=10000,mina;
	double ave=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
		ave+=a[i];
	}
	for(i=0;i<n;i++){
//		cout<<minnum<<" "<<abs(ave-a[i]*n)<<" "<<a[i]<<endl;
		if(minnum>abs(ave-a[i]*n)){
			mina=i;
			minnum=abs(ave-a[i]*n);
		}
	}
	cout<<mina<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int a[20][20];
std::vector<int> dp(66666,-LINF);
std::vector<int> w(66666,0);
int f(int k){
  //cout<<k<<endl;
  if(dp[k]!=-LINF)return dp[k];
  int res=w[k];
  int sub=k;
  sub=(sub-1)&k;
  //cout<<sub<<endl;
  while(sub!=0){
    int a=sub,b=k-a;
    //cout<<LINF<<endl;
    res=max(res,f(a)+f(b));
    //cout<<INF<<endl;
    sub=(sub-1)&k;
  }
  return dp[k]=res;
}
//main
signed main(){
  int N;cin>>N;
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>a[i][j];
  for(int i=0;i<=pow(2,N)-1;i++){
    for(int j=0;j<N;j++){
      for(int k=j+1;k<N;k++){
        if(((i>>j)&1)&((i>>k)&1))w[i]+=a[j][k];
      }
    }
  }
  cout<<f(pow(2,N)-1)<<endl;
}


Measured memory_bytes: 1280
s = input()
t = input()

sl = len(s)
tl = len(t)
ans = tl
for i in range(sl-tl+1):
  cnt = 0
  for j in range(tl):
    if s[i+j] != t[j]:
      cnt += 1
  ans = min(ans, cnt)
print(ans)

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

int z(int x){
	if(x<0)x=-x;
	return x;
}

int main(){
	int d,n,a[200],b[200],c[200],t[200],dp[200][200];
	scanf("%d%d",&d,&n);
	for(int i=0;i<d;i++)scanf("%d",&t[i]);
	for(int i=0;i<n;i++)scanf("%d%d%d",&a[i],&b[i],&c[i]);
	for(int i=0;i<200;i++)for(int j=0;j<200;j++)dp[i][j]=-1;
	for(int j=0;j<n;j++)if(a[j]<=t[0]&&t[0]<=b[j])dp[0][j]=0;
	for(int i=1;i<d;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				int e=-1;
				if(dp[i-1][k]!=-1&&a[j]<=t[i]&&t[i]<=b[j])e=dp[i-1][k]+z(c[k]-c[j]);
				if(e>dp[i][j])dp[i][j]=e;
			}
		}
	}
	int ans=0;
	for(int j=0;j<n;j++){
		if(dp[d-1][j]>ans)ans=dp[d-1][j];
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1332
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
struct edge{
	int to,cost;
	edge(){}
	edge(int to,int cost):to(to),cost(cost){}
};
int N;
vector<edge> g[100100];
int col[100100];
bool used[100100];
void dfs(int v,int p,int c){
	col[v]=c;
	used[v]=true;
	for(int i=0;i<g[v].size();i++){
		edge e = g[v][i];
		int u = e.to;
		int cost = e.cost;
		if(u==p)continue;
		if(used[u])continue;
		if(cost%2==0)dfs(u,v,c);
		else dfs(u,v,1-c);
	}
}
int main(){
	cin >> N;
	for(int i=0;i<N-1;i++){
		int u,v,w;
		cin >> u >> v >> w;
		u--;v--;
		g[u].pb(edge(v,w));
		g[v].pb(edge(u,w));
	}
	dfs(0,-1,0);
	for(int i=0;i<N;i++)cout << col[i] << endl;
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>

typedef unsigned long long ull;

int main()
{
    std::cout.sync_with_stdio(false);

    int a,b;
    std::cin >> a >> b;
    int count = 0;
    int val = 1;
    while (val < b)
    {
        count++;
        val += a - 1;
    }
    std::cout << count;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	ll n,k;
	cin>>n>>k;
	n=n%k;
	cout<<min(n,k-n)<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int x[N], d[N], ans[N];
int main() {
	int n, l, t;
	scanf("%d%d%d", &n, &l, &t);
	vector<int> L, R;
	for (int i = 0; i < n; ++ i) {
		scanf("%d%d", &x[i], &d[i]);
		(d[i] == 1 ? R : L).push_back(x[i]);
		(d[i] == 1 ? R : L).push_back(x[i] - l);
		(d[i] == 1 ? R : L).push_back(x[i] + l);
	}
	sort(L.begin(), L.end());
	sort(R.begin(), R.end());
	if (L.empty()) {
		for (int i = 0; i < n; ++ i) printf("%lld ", 1LL * (x[i] + t) % l); puts("");
		return 0;
	}
	if (R.empty()) {
		for (int i = 0; i < n; ++ i) printf("%lld ", (1LL * (x[i] - t) % l + l) % l); puts("");
		return 0;
	}
	int base = (2 * t) / l;
	for (int i = 0; i < n; ++ i) {
		if (d[i] == 1) {
			int rt = 2 * t - base * l;
			int cnt = upper_bound(L.begin(), L.end(), x[i] + rt) - lower_bound(L.begin(), L.end(), x[i]);
			cnt += 1LL * base * L.size() / 3 % n;
			ans[(i + cnt) % n] = (x[i] + t) % l;
		}
		else {
			int rt = 2 * t - base * l;
			int cnt = upper_bound(R.begin(), R.end(), x[i]) - lower_bound(R.begin(), R.end(), x[i] - rt);
			cnt += 1LL * base * R.size() / 3 % n;
			ans[((i - cnt) % n + n) % n] = ((x[i] - t) % l + l) % l;
		}
	}
	for (int i = 0; i < n; ++ i) printf("%d ", ans[i]); puts("");
}


Measured memory_bytes: 3820
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}


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

struct RMQ {
	using type = int;
	static type id() { return INT_MAX; }
	static type op(type l, type r) { return min(l, r); }
};

template <typename M>
class avl_tree {
	using T = typename M::type;
	struct node {
		T val, all;
		node *ch[2];
		int dep, size;
		node(T v, node* l = nullptr, node* r = nullptr)
			: val(v), all(v), ch{ l, r }, dep(1), size(1) {}
	};
	int depth(node *t) const { return t ? t->dep : 0; }
	int count(node *t) const { return t ? t->size : 0; }
	T que(node *t) const { return t ? t->all : M::id(); }
	node *update(node *t) {
		t->dep = max(depth(t->ch[0]), depth(t->ch[1])) + 1;
		t->size = count(t->ch[0]) + 1 + count(t->ch[1]);
		t->all = M::op(que(t->ch[0]), M::op(t->val, que(t->ch[1])));
		return t;
	}
	node *rotate(node *t, int b) {
		node *s = t->ch[1 - b];
		t->ch[1 - b] = s->ch[b];
		s->ch[b] = t;
		update(t);
		return update(s);
	}
	node *fix(node *t) {
		if (!t) return t;
		int d = depth(t->ch[0]) - depth(t->ch[1]), b = (d < 0);
		if (abs(d) != 2) return t;
		if (depth(t->ch[b]->ch[1 - b]) > depth(t->ch[b]->ch[b])) {
			t->ch[b] = rotate(t->ch[b], b);
		}
		return rotate(t, 1 - b);
	}
	node *insert(node *t, int k, T v) {
		if (!t) return new node(v);
		int c = count(t->ch[0]), b = (k > c);
		t->ch[b] = insert(t->ch[b], k - (b ? (c + 1) : 0), v);
		return fix(update(t));
	}
	node *erase(node *t) {
		if (!t) return t;
		if (!t->ch[0] && !t->ch[1]) return nullptr;
		if (!t->ch[0] || !t->ch[1]) return t->ch[t->ch[0] == nullptr];
		return fix(update(new node(find(t->ch[1], 0)->val, t->ch[0], erase(t->ch[1], 0))));
	}
	node *erase(node *t, int k) {
		if (!t) return t;
		int c = count(t->ch[0]);
		if (k == c) return fix(erase(t));
		int b = (k > c);
		t->ch[b] = erase(t->ch[b], k - (b ? c + 1 : 0));
		return fix(update(t));
	}
	node *find(node *t, int k) const {
		if (!t) return t;
		int c = count(t->ch[0]);
		return k < c ? find(t->ch[0], k) : k == c ? t : find(t->ch[1], k - (c + 1));
	}
	T find(node *t, int l, int r) const {
		if (!t || r <= 0 || t->size <= l) return M::id();
		if (l <= 0 && t->size <= r) return t->all;
		int c = count(t->ch[0]);
		return M::op(find(t->ch[0], l, r), M::op((l <= c && c < r ? t->val : M::id()), find(t->ch[1], l - (c + 1), r - (c + 1))));
	}
	node *root;
public:

	avl_tree() : root(nullptr) {}
	int size() const {
		return count(root);
	}
	void insert(int k, T b) {
		root = insert(root, k, b);
	}
	void erase(int k) {
		root = erase(root, k);
	}
	T find(int k) const {
		return find(root, k)->val;
	}
	T find(int l, int r) const {
		return find(root, l, r);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	avl_tree<RMQ> tree;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		tree.insert(i, a);
	}
	while (q--) {
		int x, y, z;
		cin >> x >> y >> z;
		if (x == 0) {
			int val = tree.find(z);
			tree.erase(z);
			tree.insert(y, val);
		}
		else if (x == 1) {
			printf("%d\n", tree.find(y, z + 1));
		}
		else {
			tree.erase(y);
			tree.insert(y, z);
		}
	}
	return 0;
}



Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

const int N=1e6+1;
ll f[N];

ll mpow(ll x, ll y){ 
    ll res = 1;
    x = x % mod;
    while (y > 0) { 
        if (y & 1) res = (res * x) % mod; 
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
  
ll modInv(ll n){ 
    return mpow(n,mod-2); 
} 
  
ll C(ll n, ll r){
    if (r == 0) return 1; 
    assert(n>=r);
    return (f[n]*modInv(f[r])%mod*modInv(f[n-r])%mod)%mod; 
} 

void fact(){
    f[0]=1;
    for(int i=1;i<N;i++){
        f[i]=(f[i-1]*i)%mod; 
    }
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    fact();
    ll n;
    cin>>n;
    if(n==1){
        cout<<0;
        return 0;
    }
    ll tot=mpow(10,n);
    ll sub=((2*mpow(9,n))%mod-mpow(8,n)+mod)%mod;
    ll ans=tot-sub;
    //ll ans=(c*mpow(10,n-2))%mod;
    ans+=mod;
    ans%=mod;
    cout<<ans;


 
 
    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 11580
using System;
using System.Linq;

namespace id_1608cs
{
    public class Scores
    {
        int[] _scores;
        public Scores(int[] givenScores)
        {
            _scores = givenScores;
        }
        public int MinimumDifference()
        {
            int result = int.MaxValue;
            for (int i = 0; i < _scores.Length - 1; i++)
            {
                for (int j = i + 1; j < _scores.Length; j++)
                {
                    result = Math.Min(result, Math.Abs(_scores[i] - _scores[j]));
                }
            }
            return result;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var n = int.Parse(Console.ReadLine());
                if (n == 0) return;
                var score = new Scores(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
                Console.WriteLine(score.MinimumDifference());
            }
        }
    }
}



Measured memory_bytes: 18276
#include <iostream>
#include <bits/stdc++.h>
#define LEN 100010
using namespace std;

typedef struct _P {
    char name[100];
    int t;
} P;

P Q[LEN];

int head=0, tail=0;

void enqueue (P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue () {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int main(){
    int n, q, t=0, dt;
    P p;
    cin >> n >> q;
    for (int i=0; i < n; i++) cin >> Q[i].name >> Q[i].t;
    tail = n;
    while (head != tail) {
        p = dequeue();
        dt = min(q, p.t);
        t += dt;
        p.t -= dt;
        if (p.t > 0) enqueue(p);
        else cout << p.name << " " << t << endl;
    }
    return 0;
} 


Measured memory_bytes: 13236
//21-03-2K20

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305
int main()
{
    fastio;
    int n;
   
    cin>>n;
    cout<<pow(n,3)<<"\n";    //:D
   
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,f[300005],ans[300005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    rep(i,0,n)
    {
        ll a;
        cin>>a;
        f[a]++;
    }
    vl v,s;
    rep(i,1,n+1)
        v.pb(f[i]);
    sort(all(v));
    s=v;
    rep(i,1,sz(s))
        s[i]+=s[i-1];
    rep(i,1,n+1)
    {
        ll p=ub(all(v),i)-v.begin(),sm=0;
        if(p)
            sm=s[p-1];
        sm+=(n-p)*i;
        f[i]=sm/i;
    }
    set<ll>st;
    rep(i,1,n+1)
        st.insert(i);
    sep(i,n,1)
    {
        while(sz(st) and *st.begin()<=f[i])
        {
            ans[*st.begin()]=i;
            st.erase(st.begin());
        }
    }
    rep(i,1,n+1)
        cout<<ans[i]<<"\n";

}


Measured memory_bytes: 25452
inf = int(9e18)


def recursive(i, total, cost, C, A, X):
    if i == len(A):
        return inf
    ncost = recursive(i+1, total, cost, C, A, X)

    ok = True
    for j in (range(len(total))):
        total[j] += A[i][j]
        if (total[j] < X):
            ok = False
    if ok:
        dcost = cost + C[i]
    else:
        dcost = recursive(i+1, total, cost + C[i], C, A, X)
    for j in (range(len(total))):
        total[j] -= A[i][j]

    return (min(ncost, dcost))


def main():
    nmx = [int(_x) for _x in input().split()]
    n = nmx[0]
    m = nmx[1]
    x = nmx[2]
    c = []
    a = []
    for i in range(n):
        ca = [int(_x) for _x in input().split()]
        c.append(ca[0])
        a.append(ca[1:])
    total = [0] * m

    result = recursive(0, total, 0, c, a, x)

    if result == inf:
        print(-1)
    else:
        print(result)


main()


Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define M 1000000007
#define INF 999999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
using namespace std;
 typedef  long long  int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;

ll arr[200005];
int main()
{
// freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,sum=0;
 cin>>n;
 for(int i=0;i<n;i++)
  cin>>arr[i],sum+=arr[i];
ll s1 = arr[0];
ll s2= sum-arr[0];
ll diff = abs(s2-s1);

for(int i=1;i<n-1;i++)
{
    s1+=arr[i];
    s2-=arr[i];
    diff = min(diff,abs(s2-s1));
}

cout<<diff<<endl;
return 0;
}



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

int main () {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a,a+n);
  int b = 0;
  for (int i = 0; i < n-1; i++) {
    b += a[i];
  }
  if (a[n-1] < b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, L): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = (L..(L + N)).sum::<i64>() - (L..(L + N)).min_by_key(|&i| i.abs()).unwrap();

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

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

#define rep(T, i, a, b) for (T (i)=(a); (i) < (b); (i)++)
#define repe(T, i, a, b) for (T (i)=(a); (i) <= (b); (i)++)
#define MOD(n, M) ((((n) % (M)) + (M)) % (M))
#define PB push_back
#define F first
#define S second
#define PI acos(-1)
#define PRNT(arr) for (auto i : (arr)) cout << i << " "; cout << endl;
#define eps 1e-11
#define len(x) x.size()
#define FIN freopen("input.txt", "r", stdin);
#define FOUT freopen("output.txt", "w", stdout);
#define NL "\n"

using namespace std;

typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;



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

    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible\n";
    else cout << "Impossible\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
//using ll = long long int;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c <= 21) {
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>

using namespace std;
#define mod 1000000007
#define ll long long 


ll dp[100009];
int n, m;

vector<int> g[100009];

ll solve(int i) {
	if(dp[i] != -1)
		return dp[i];
	
	ll ans = 1;
	for(int j = 0; j < g[i].size(); j++) {
		int u = g[i][j];
		ans = max(ans, 1 + solve(u));
	}

	return dp[i] = ans;
}


int main() {
  	cin>>n>>m;
  	int x, y;
  	for(int i = 0; i < m; i++) {
  		cin>>x>>y;
  		g[x].push_back(y);
  	}

  	memset(dp, -1, sizeof(dp));
  	ll ma = INT_MIN;
  	for(int i = 1; i <= n; i++) {
  		ma = max(ma, solve(i));
  	}
  	cout<<ma - 1<<endl;
}

Measured memory_bytes: 8576
use std::io::*;
use std::str::FromStr;

fn main() {
    let a: usize = read();
    let p: usize = read();
    
    let kakera = p + a * 3;
    println!("{}", kakera / 2);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, L;
    cin >> N >> L;
    int ans = 10000000;
    int sum = 0;
    vector<int> v(N);
    rep(i, N) {
        v.at(i) = L + i;
        sum += v.at(i);
    }

    rep(i, N) {
        int x = sum - v.at(i);
        if(abs(x - sum) < abs(ans - sum)) {
            ans = x;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
bool visited[1001][1001][1001];
//------------------------------------------------------------------------------
void _main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);
    rep(i, 0, X) cin >> A[i];
    rep(i, 0, Y) cin >> B[i];
    rep(i, 0, Z) cin >> C[i];
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());

    vector<ll> ans;

    rep(x, 0, X) rep(y, 0, Y) rep(z, 0, Z)
    {
        if ((x + 1) * (y + 1) * (z + 1) <= K) ans.push_back(A[x] + B[y] + C[z]);
        else break;
    }

    sort(ans.rbegin(), ans.rend());

    rep(k, 0, K)
    {
        cout << ans[k] << endl;
    }
}


Measured memory_bytes: 1404
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

ll a[100001] = {};
int main() {
	ll n; cin >> n;
	rep(i, 0, n) {
		ll A; cin >> A;
		a[A]++;
		if (a[A] % 3 == 0) {
			a[A] = 1;
		}
	}
	ll f = 0;
	ll s = 0;
	rep(i, 0, 100001) {
		if (a[i] == 1)f++;
		else if (a[i] == 2)s++;
	}

	if (!(s & 1)) {
		f += s;
	}
	else {
		f += s - 1;
	}

	cout << f << endl;

	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    int x[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    int ans = 0, a = 0, b = k;
    for (int i = 0; i < n; i++) {
        ans += 2 * (min(abs(x[i] - b), x[i] - a));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <limits>
#include <cmath>

using namespace std;

int main(){
 double x,y,a,b,c,d,e,f;
 while(cin>>a>>b>>c>>d>>e>>f){
  x=(c*e-f*b)/(a*e-d*b);
  y=(a*f-d*c)/(a*e-d*b);
  if(abs(x)<=(0.0+numeric_limits<double>::epsilon())) x = +0.00000000;
  if(abs(y)<=(0.0+numeric_limits<double>::epsilon())) y = +0.00000000;
  cout << fixed << setprecision(3) << x << " " << y << endl;
 }
 return 0;
}

Measured memory_bytes: 1280
N = int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
yakusulist = make_divisors(N)
center1 = yakusulist[(len(yakusulist)-1)//2]
center2 = yakusulist[(len(yakusulist))//2]
print(center1+center2-2)

Measured memory_bytes: 63952
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();

    if n % 2 == 0 {
        println!("{}", n * (n - 2) / 2);
    } else {
        println!("{}", (n - 1) * (n - 1) / 2);
    }

    for i in 1..n + 1 {
        let k;
        if n % 2 == 0 {
            k = n + 1 - i;
        } else {
            k = n - i;
        }

        for j in i + 1..n + 1 {
            if j == k {
                continue;
            }
            println!("{} {}", i, j);
        }
    }
}


Measured memory_bytes: 4352
n = int(input())
a = [int(x) for x in input().split()]
index = [0]*n
for i in range(n):
    index[a[i]-1] = i+2


class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if i == 0:
            print("Oops! BIT is an 1-indexed tree.")
            exit()
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


ans = 0
s = BIT(n+2)
s.add(1, -1)
s.add(n+2, 1)
for i in range(n):
    s.add(index[i], 1)

    left = s.sum(index[i]) - 1
    bottom = 1
    top = index[i]
    while top - bottom > 1:
        middle = (top+bottom)//2
        if s.sum(middle) >= left:
            top = middle
        else:
            bottom = middle
    if left == -1:
        left = 1
    else:
        left = top

    right = s.sum(index[i])+1
    bottom = index[i]
    top = n+2
    while top - bottom > 1:
        middle = (top+bottom)//2
        if s.sum(middle) >= right:
            top = middle
        else:
            bottom = middle
    right = top

    ans += (i+1)*(index[i]-left)*(right-index[i])

print(ans)


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

int main() {
    string s,ss,sss;
    int n,m,l;
    cin>>s;
	cin>>n;

	for (int i = 0; i < n; ++i) {
		cin>>ss>>m>>l;
		if(ss=="replace"){
			cin>>sss;
			s.replace(m,l-m+1,sss);
		}else if(ss=="reverse"){
			string temp=s.substr(m,l-m+1);
			for (int j = 0; j < temp.size(); ++j) {
				s[j+m]=temp[temp.size()-j-1];
			}
		}else if(ss=="print"){
			cout<<s.substr(m,l-m+1)<<endl;
		}
	}
}

Measured memory_bytes: 3220
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),X=in(),A=in();
        int min_val=1e9,min_index;
        REP(i,N){
            int H=in();
            int t=abs(1000*X-6*H-1000*A);
            if(min_val>t){
                min_val=t;
                min_index=i+1;
            }
        }

	cout << min_index << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAXN=2e5+5;
int a[MAXN];


int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=1;i<=n;++i)   
        {
            cin>>a[i];
        }
        if(n&1)
        {
            cout<<a[n];
            for(int i=n-2;i>=1;i-=2)
                cout<<" "<<a[i];
            for(int i=2;i<=n-1;i+=2)
                cout<<" "<<a[i];
            cout<<endl;
        }else
        {
            cout<<a[n];
            for(int i=n-2;i>=2;i-=2)
                cout<<" "<<a[i];
            for(int i=1;i<=n-1;i+=2)
                cout<<" "<<a[i];
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2944
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> a(N),b(N),c(N),d(N);
    rep(i,N) cin >> a[i] >> b[i];
    rep(i,N) cin >> c[i] >> d[i];

    BipartiteMatching BM(2*N);
    rep(i,N) {
        rep(j,N) {
            if (a[i] < c[j] && b[i] < d[j]) {
                BM.add_edge(i,N+j);
            }
        }
    }

    cout << BM.bipartite_matching() << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if(n%k==0){
            System.out.println("0");
        }else{
            System.out.println("1");
        }
    }
}


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

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double wid = x/(a*a);
    double hei;
    hei = 2*wid*a/b;
    const double PI = acos(-1);
    double ans;
    if(hei <= a){
        ans = atan(b/hei)*180.0/PI;
    }else{
        double up = 2*wid - b;
        ans = atan((b-up)/a)*180.0/PI;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	s := make(map[string]int, n)
	for i := 0; i < n; i++ {
		var tmp string
		fmt.Scan(&tmp)
		s[tmp]++
	}

	name := make([]string, 0)
	v := 0

	for index, value := range s {
		if value > v {
			name = make([]string, 1)
			name[0] = index
			v = value
		} else if value == v {
			name = append(name, index)
		}
	}

	sort.Sort(sort.StringSlice(name))
	for i := 0; i < len(name); i++ {
		fmt.Println(name[i])
	}
}


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

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
    int N;
    IN(N);
    int max = 0;
    vector<int> H(N);
    REP(i, N) IN(H[i]);
    REP(i, N) {
        if(max < H[i]) max = H[i];
        if(max > H[i] + 1) {
            OUT("No");
            return 0;
        }
    }
    OUT("Yes");
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,c=0,d=0,m,k,t;
	cin>>n>>m>>k;
	d = m+k;
	if(m>=n)
    {
        cout<<n;
    }
    else if(m==0)
    {
        cout<<0;
    }
    else
    {
        c = n/d;
        t = n%d;
        if(t==0)
        {
	    cout<<(m*c);
        }
        else if(t<=m)
        {
            cout<<(m*c)+t;
        }
        else{
            cout<<(m*c)+m;
        }
    }
}


Measured memory_bytes: 256
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

public class Main{    
    static int[] parent;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int[] nums = new int[4];
        for (int i = 0; i < 4; i++) {
            nums[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
        }
        
        int[] pm = new int[3];
        for (int i = 0; i < 8; i++) {
            int tmp = nums[0];
            String binary = make_bi_nari(3, i);
            for (int j = 0; j < 3; j++) {
                pm[j] = Integer.parseInt(String.valueOf(binary.charAt(j)));
                if (pm[j] == 0) {
                    tmp-=nums[j+1];
                }else{
                    tmp+=nums[j+1];
                }
            }
            if (tmp == 7) {
                for (int j = 0; j < 3; j++) {
                    System.out.print(nums[j]);
                    if (pm[j] == 0) {
                        System.out.print("-");
                    }else{
                        System.out.print("+");
                    }
                }
                System.out.println(nums[3]+"=7");
                return;
            }
        }

        sc.close();
    }

    public static String make_bi_nari(int nbit, int num_to_binary) {
        String res = Integer.toBinaryString(num_to_binary);
        while(res.length() < nbit){
            res = "0" + res;
        }
        return res;
    }

}




Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  
  ll A, B, C;
  cin >> A >> B >> C;

  
  
  ll ans = 0;
  while(1){
    if((A%2)||(B%2)||(C%2)) break;
    if(A == B && B == C) {cout << -1 << endl; return 0;}
    ans ++;
    ll a = A/2;
    ll b = B/2;
    ll c = C/2;

    A = b+c;
    B = a+c;
    C = a+b;
    cerr << a << " " << b << " " << c << ":";
    cerr << A << " " << B << " " << C << endl;
  }
  cout << ans << endl;
  

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu|10];
fuko cnt;
int main(){
int n=read(),m=read(),i;
for (;m--;) cnt[read()]++,cnt[read()]++;
for (i=1;i<=n;++i) if (cnt[i]&1) return puts("NO"),0;
puts("YES");
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int pri;
	int cou;
	int kouka[6] = {500, 100, 50, 10, 5, 1};
	int i;
		
	while (1){
		scanf("%d", &pri);
		
		if (pri == 0){
			break;
		}
		
		pri = 1000 - pri;
		cou = 0;
		i = 0;
		while (i != 6){
			if (pri - kouka[i] >= 0){
				pri -= kouka[i];
				cou++;
			}
			else {
				i++;
			}
		}
		printf("%d\n", cou);
	}
	
	return (0);
}

Measured memory_bytes: 600
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = Counter(A)
    sum_ = sum([v*(v-1)/2 for v in count.values()])

    for i in range(len(A)):
        took_count = count[A[i]]
        sub = took_count - 1
        print(int(sum_ - sub))

if __name__ == '__main__':
    main()

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

int main(){
  long long a,b;
  cin >> a >> b;
  if(a>0) cout << "Positive" << endl;
  else if(a<=0 && b>=0) cout << "Zero" << endl;
  else{
    if((abs(a-b)+1)%2==0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N;
	string A, B, C;
	cin >> N;
	cin >> A >> B >> C;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		set<char>S;
		S.insert(A[i]);
		S.insert(B[i]);
		S.insert(C[i]);
		ans += (S.size() - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  double i ,max ,min ,tmp;
  scanf ( "%lf" ,&tmp );
  max = tmp;
  min = tmp;
  while (  scanf ( "%lf" ,&tmp ) != EOF ){

    if ( tmp < min ){   /*　　山の最大の高さ   */
      min = tmp;
    }

    else if ( tmp > max ){   /*　　山の最小の高さ　　*/
      max = tmp;
    }

  }

  i = max - min;

  printf  ( "%.1lf\n" ,i );
  return 0;
}

Measured memory_bytes: 652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[100001];
		
		long sum=0;
		int in;
		for(int i=0; i<n; i++) {
			in = sc.nextInt();
			a[in]++;
			sum += in;
		}
		
		int q = sc.nextInt();
		
		int b;
		int c;
		for(int i=0; i<q; i++) {
			b = sc.nextInt();
			c = sc.nextInt();
			sum = sum+ (c-b) * a[b];
			a[c] += a[b];
			a[b] = 0;
			System.out.println(sum);
		}
	}

}


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

int main() {
  int N; cin >> N;
  vector<int> cards(N);
  for (int i=0; i<N; i++) cin >> cards[i];
  sort(cards.begin(), cards.end(), greater<int>());
  int A=0, B=0;
  for (int i=0; i<N; i+=2) {
    A += cards[i];
  }
  for (int i=1; i<N; i+=2) {
    B += cards[i];
  }
  cout << A-B << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n := readInt()
	var arr []int
	for i := 0; i < n; i++ {
		arr = append(arr, readInt())
	}
	for i := 0; i < n; i++ {
		if arr[i]%2 == 0 {
			if arr[i]%3 != 0 && arr[i]%5 != 0 {
				fmt.Println("DENIED")
				os.Exit(0)
			}
		}
	}
	fmt.Println("APPROVED")
}


Measured memory_bytes: 640
/*
 * atcoder/abc149_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, K;
int S[3] = {0};
string T;
vector<int> A;
int score(int me, int you) {
  if (me == 0 and you == 1) return S[0];
  if (me == 1 and you == 2) return S[1];
  if (me == 2 and you == 0) return S[2];
  return 0;
}

ll dp[100001][3] = {0};
void print() {
  for (int me=0; me<3; me++) {
    for (int n=0; n<N; n++) {
      cout << dp[n][me] << "\t";
    }
    cout << endl;
  }
}
void solve() {
  cin >> N >> K >> S[0] >> S[1] >> S[2] >> T;
  for (auto&&c: T) {
    if (c == 'r') A.push_back(0);
    if (c == 's') A.push_back(1);
    if (c == 'p') A.push_back(2);
  }

  for (int n=0; n<N; n++) {
    int you = A[n];
    for (int me=0; me<3; me++) {
      if (n<K) { dp[n][me] = score(me, you); continue; }
      for (int prev_me=0; prev_me<3; prev_me++) {
        if (me == prev_me) continue;
        chmax(dp[n][me], dp[n-K][prev_me] + score(me, you));
      }
    }
  }

  // print();

  ll total = 0;
  for (int k=0; k<K; k++) {
    int n = N-1-k;
    total += max(dp[n][0], max(dp[n][1], dp[n][2]));
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
int dp[100001] = {0}, visited[100001] = {0};
vector<int>adj[100001];
void dfs(int x)
{
	visited[x] = 1;
	for(int j = 0; j < adj[x].size(); j++)
	{
		if(!visited[adj[x][j]])
			dfs(adj[x][j]);
	}
	for(int j = 0; j < adj[x].size(); j++)
		dp[x] = max(dp[x], dp[adj[x][j]] + 1);
}
int main()
{
	int N, M, a, b;
	cin >> N >> M;
	int i, j;
	for(i = 0; i < M; i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
	}
	for(i = 1; i <= N; i++)
	{
		if(!visited[i])
			dfs(i);
	}
	sort(dp, dp + N + 1);
	cout << dp[N];
	return 0;
}

Measured memory_bytes: 8576
while True:
  hw = [int(x) for x in input().split()]
  h, w = hw[0], hw[1]

  if h == 0 and w == 0:
    break
  for hh in range(h):
    for ww in range(w):
      if hh == 0 or hh == h - 1 or ww == 0 or ww == w - 1:
        print('#', end = '')
      else:
        print('.', end = '')
    print('')
  print('')

Measured memory_bytes: 9096
n = int(input())
hoge = []
for i in range(n):
    a, b = list(map(int, input().split()))
    hoge.append([a, b, a+b])
hoge.sort(key=lambda x: x[2], reverse=True)
ans = 0
for ind, l in enumerate(hoge):
    if ind%2 == 0:
        ans += l[0]
    else:
        ans -= l[1]
print(ans)


Measured memory_bytes: 24872
#author : dokueki

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n = int(sys.stdin.readline())
    s = input()
    R, G, B = set(), set(), set()
    # tot = len(r) * len(g) * len(b)
    for i in range(n):
        if s[i] == "R":
            R.add(i + 1)
        if s[i] == "G":
            G.add(i + 1)
        if s[i] == "B":
            B.add(i + 1)
    tot = len(R)*len(G)*len(B)
    for r in R:
        for g in G:
            l = g - r
            if g + l in B:
                tot -= 1
            if r - l in B:
                tot -= 1
            if l % 2 == 0 and l // 2 + r in B:
                tot -= 1
    print(tot)

    # print(tot)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 73892
#include<bits/stdc++.h>
using namespace std;
int bucket[10]={0};
int n,k;
int minnum=0xffffff;
void dfs(int num)
{
	if(num>=n)
	{
		if(num<minnum)
			minnum=num;
		return;
	}
	for(int i=0;i<=9;i++)
	{
		if(!bucket[i]) dfs(num*10+i);
	}
}
int main()
{

	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		int num;cin>>num;
		bucket[num]=1;
	}
	for(int i=1;i<=9;i++)
	{
		if(bucket[i]!=1)dfs(i);
	}
	cout<<minnum;
 	return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    INF = 10 ^ 5
    N = parseInt(readline())
    H = parseMap(split(readline()))
    dp = fill(INF,N)
    dp[1] = 0
    for i in 2:N
        if i > 2
            o = dp[i-1] + abs(H[i-1] - H[i])
            t = dp[i-2] + abs(H[i-2] - H[i])
            dp[i] = min(o,t)
        else
            dp[i] = dp[i-1] + abs(H[i-1] - H[i])
        end
    end
    println(dp[N])
end

main()

Measured memory_bytes: 117472
#include"iostream"
#include"algorithm"
#include"string"

using namespace std;
typedef long long int llint;
string S;
int Q;

int main() {
	cin >> S;
	cin >> Q;
	
	string front, back;
	bool re = false;
	for (int i = 0; i < Q; i++) {
		int T;
		cin >> T;

		if (T == 1) {
			re = !re;
		}
		else {
			int T;
			string C;
			cin >> T;
			cin >> C;
			if (T == 1) {
				if (re) {
					back += C;
				}
				else {
					front += C;
				}
			}
			else {
				if (re) {
					front += C;
				}
				else {
					back += C;
				}
			}
		}
		/*cout << front << endl;
		cout << S << endl;
		cout << back << endl;*/
	}
	if (!re) {
		reverse(front.begin(), front.end());
		cout << front << S << back << endl;
	}
	else {
		reverse(back.begin(), back.end());
		reverse(S.begin(), S.end());
		cout << back << S << front << endl;
	}

}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ; 
ll _abs (ll x ) { return (x>0?x:-x); }

const int N = 105 , MW = 1e5+2; 
int n , W , v[N] , w[N] ; 
ll dp[N][MW] ; // max value at index i with weight
int main(){
    fastio; 
    cin>>n>>W; 
    for(int i = 0 ; i < n ;i++ ){
        cin>>w[i]>>v[i] ; 
    }
    
    for(int i = 1 ; i <= n ; i++ ){
        for(int j = 0 ; j <= W ; j++ ){
            ll& r = dp[i][j] ; 
            r = max(r,dp[i-1][j]); 
            if( j - w[i-1] >= 0)r=max(r,dp[i-1][j-w[i-1]]+v[i-1]); 
          //  cout<<i<<" "<<j<<" "<<r<<endl; 
        }
    }
    cout<<dp[n][W]; 
}

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

typedef long long ll;


int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int a[] = {A*10+B+C,A+B*10+C,A+B+C*10};
  cout << max(a[0],max(a[1],a[2])) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int main(){
    int n, m, Q;
    cin >> n >> m >> Q;
    vector<vector<ll>> LR(n + 1);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        LR[a].push_back(b);
    }
    rep(i, n + 1){
        sort(ALL(LR[i]));
        LR[i].push_back(INF);
    }

    rep(i, Q){
        int p, q;
        cin >> p >> q;
        ll sum = 0;
        REP(j, p, q){
            sum += (upper_bound(ALL(LR[j]), q) - LR[j].begin());
            //if(*lower_bound(ALL(LR[j]), q) == q)sum++;
        }
        cout << sum << endl;
    }
    
}

Measured memory_bytes: 3456