akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N;
    cin >> N;
    cout << (int)pow(N, 0.5) * (int)pow(N, 0.5) << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

string n;

int main()
{
    cin >> n;
    if(n[0]==n[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		String[] info = new String[n];
		
		for (int i = 0; i < n; i++) {
			String city = sc.next();
			int rank = sc.nextInt();
			info[i] = city + "_" + (10100 - rank) + "_" + (i+1);
		}
		Arrays.sort(info);
		for (int i = 0; i < n; i++) {
			String[] strs = info[i].split("_");
			System.out.println(strs[2]);
		}
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll x[n],p[n];
  for(ll i=0;i<n;i++){
    cin >>x[i];
    p[i]=x[i];
  }
  sort(p,p+n);
  for(ll i=0;i<n;i++){
    if(x[i]<=p[n/2-1]) cout <<p[n/2]<<endl;
    else cout <<p[n/2-1]<<endl;
  }
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long X; cin >> X; 
	long long A[1010] = {}; 
	for(long long i = 0; i <= 1000; i++){
		long long p = i - 500; 
		A[i] = p*p*p*p*p; 
	}
	for(int i = 0; i <= 1000; i++){
		for(int j = 0; j <= 1000; j++){
			if(A[i] - A[j] == X){
				cout << i - 500 << " " << j - 500 << endl; 
				return 0; 
			}
		}
	}
}

Measured memory_bytes: 3644
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

n,m = imap()
a = [[int(elm=="#") for elm in list(input())] for i in range(n)]
b = [[int(elm=="#") for elm in list(input())] for i in range(m)]
a,b = np.array(a),np.array(b)
#print(a)
#print(b)

flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        tmp = a[i:i+m, j:j+m]
        if (tmp == b).all(): flag = 1; break

ans = "Yes" if flag else "No"
print(ans)


Measured memory_bytes: 37720
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
// #define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int dp[(int) 1e4 + 5];
int a[(int) 1e3 + 5];
const int INF = 1e9;
int b[(int) 1e3 + 5];
void solve() {
	int h, n;
	cin >> h >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
	}
	dp[0] = 0;
	for (int i = 1; i <= h; ++i) {
		dp[i] = INF;
	}
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= n; ++j) {
			dp[i] = min(dp[i], dp[max(0, i - a[j])] + b[j]);
		}
	}
	cout << dp[h];
}   

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
	int res_price = 0;
	int a_price, b_price, ab_price, x, y;
	std::cin >> a_price >> b_price >> ab_price >> x >> y;
	
	if((a_price + b_price) > (ab_price * 2)) {
		res_price = (ab_price * 2) * std::min(x, y);
		int alpha_num = std::max(x, y) - std::min(x, y);	
		if (x > y) {
			if ((a_price * alpha_num) > (ab_price * 2 * alpha_num))
				res_price += (ab_price * 2 * alpha_num);
			else
				res_price += a_price * alpha_num;
		}
		else if (y > x) {
			if ((b_price * alpha_num) > (ab_price * 2 * alpha_num))
				res_price += (ab_price * 2 * alpha_num);
			else			
				res_price += b_price * alpha_num;
		}
	}
	else {
		res_price = a_price * x + b_price * y;
	}
	
	printf("%d", res_price);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c;
ll s[100005],t[100005],x[100005];
ll s_binary(ll i){
	ll lb=-1; ll ub=a;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(s[mid]>=i){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	return ub;
}
ll t_binary(ll i){
	ll lb=-1; ll ub=b;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		if(t[mid]>=i){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	return ub;
}
int main(void){
    cin>>a>>b>>c;
    for(int i=0;i<a;i++){
		cin>>s[i];
	}
	for(int i=0;i<b;i++){
		cin>>t[i];
	}
	for(int i=0;i<c;i++){
		cin>>x[i];
		ll k=s_binary(x[i]);
		ll l=t_binary(x[i]);
		ll ans=1000000000000;
		if(k<a&&l<b){
			ll A=max(s[k]-x[i],t[l]-x[i]);
			ans=min(ans,A);
		}
		if(k>=1&&l>=1){
			ll B=max(x[i]-s[k-1],x[i]-t[l-1]);
			ans=min(ans,B);
		}
		if(k>=1&&l<b){
		    ll ccc=min(x[i]-s[k-1],t[l]-x[i]);
			ll C=x[i]-s[k-1]+t[l]-x[i]+ccc;
			ans=min(ans,C);
		}
		if(k<a&&l>=1){
		    ll d=min(s[k]-x[i],x[i]-t[l-1]);
			ll D=s[k]-x[i]+x[i]-t[l-1]+d;
			ans=min(ans,D);
		}
		cout<<ans<<endl;
	}
    
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define lim 100010
#define mod 1e9 + 7
#define INF 1e9
#define REP(i, n) for (int i = 0; i < n; i++)

ll GCD(int x, int y){
  return x%y == 0 ? y : GCD(y, x % y);
}

int main() {
  int A, B;
  scanf("%d%d", &A, &B);
  ll g = GCD(A, B);
  ll ans = A * (B / g);
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 1
mod = 998244353
if a[0] !=0:
    ans = 0

cnt = [0]*n
for i in range(n):
    cnt[a[i]] += 1
for i in range(1,n):
    ans *= cnt[a[i]-1]
    ans %= mod
print(ans)

    

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define abs(a) llabs(a)
#define rv(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

signed main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,a;
  cin>>n;

  priority_queue<int,vector<int>,greater<int> > x;

  rep(i,n){
      cin>>a;
      x.push(a);
  }

  double cnt = x.top();

  x.pop();

  while(!x.empty()){
      cnt = cnt + x.top();
      x.pop();
      cnt = cnt / 2;
  }

  cout<<cnt<<'\n';
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e3+23;

int n;
int bio[N][N];
int in[N][N];
int a[N][N];
int dp[N][N];
vector<pair<int, int>> g[N][N];

int dfs(int x, int y) {
  int &ret = dp[x][y];
  if (ret) return ret;
  bio[x][y] = 1;
  ret = 1;
  for (const auto &v: g[x][y]) {
    if (bio[v.first][v.second] == 1) {
      printf("-1");
      exit(0);
    }
    ret = max(ret, 1+dfs(v.first, v.second));
  }
  bio[x][y] = 2;
  return ret;
}

void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n-1; ++j) {
      scanf("%d", a[i]+j);
      --a[i][j];
      if (j) {
	g[min(i, a[i][j-1])][max(i, a[i][j-1])]
	  .emplace_back(min(i, a[i][j]), max(i, a[i][j]));
	++in[min(i, a[i][j])][max(i, a[i][j])];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      for (const auto &v: g[i][j]) {
	//	printf("(%d, %d) -> (%d, %d)\n", i, j, v.first, v.second);
      }
      if (in[i][j]) continue;
      if (bio[i][j]) continue;
      ans = max(ans, dfs(i, j));
    }
  }
  if (!ans) printf("-1");
  else printf("%d", ans);

}
int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 59964
import java.util.*;

public class Main {
    private static Map<Integer, Integer> memo = new HashMap<>();
    private static List<List<Integer>> graph = new ArrayList<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            graph.add(new ArrayList<>());
        }

        for (int i = 0; i < m; i++) {
            graph.get(sc.nextInt()).add(sc.nextInt());
        }

        int result = 0;
        for (int i = 1; i <= n; i++) {
            result = Math.max(result, rec(i));
        }

        System.out.println(result);
    }

    private static int rec(int n) {
        if (memo.containsKey(n)) {
            return memo.get(n);
        }
        if (graph.get(n).size() == 0) {
            memo.put(n, 0);
            return 0;
        }
        int length = 0;
        for (Integer i : graph.get(n)) {
            length = Math.max(length, rec(i) + 1);
        }
        memo.put(n, length);
        return length;
    }
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x, y;
  x = a + b;
  y = c + d;
  if (x > y) {
    cout << "Left" << endl;
  }
  else if (x == y) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n; ll k;
ll a[maxn], f[maxn];





bool good(ll x) {
  ll t = 0;
  for (int i=0; i<n; i++) {
    ll maxtime = x/f[i];
    t += max(0LL, a[i] - maxtime);
  }
  return t <= k;
}

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

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

  sort(a,a+n);
  sort(f,f+n);
  reverse(a,a+n);

  ll lo = -1;
  ll hi = 1e13;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (good(mid)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  ll ans = hi;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5888
N = int(input())
max1 = -1
max_N = -1
while(N>0):
    cnt = 0
    temp = N
    while(temp!=1):
        if temp%2!=0:
            break
        temp //= 2
        cnt += 1
    if max1 < cnt:
        max1 = cnt
        max_N = N
    N -= 1
print(max_N)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
#define PI 3.141592653589793238
int main()
{
  cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(15);
  double a,b,h,m,p=30,q,r=6,o,s,t,y;
  cin>>a>>b>>h>>m;
  p*=h;
  q=m*0.5;
  p+=q;
  r*=m;
  o=p-r;
  t=a*a+b*b;
  y=cos((o*PI)/180.000000000);
  y*=2*a*b;
  t-=y;
  t=sqrt(t);
  cout<<t;
}

Measured memory_bytes: 4292
use proconio::input;

fn main() {
    input! {
        n: usize,
        es: [(usize, usize, i64); n-1]
    };
    let mut g: Vec<Vec<_>> = vec![Vec::new(); n];
    let mut color = vec![-1; n];
    for (u, v, w) in es {
        g[u - 1].push((v - 1, w));
        g[v - 1].push((u - 1, w));
    }
    color[0] = 0;
    dfs(0, &g, &mut color);
    for c in color {
        println!("{}", c);
    }
}

fn dfs(current: usize, g: &Vec<Vec<(usize, i64)>>, colors: &mut Vec<i64>) {
    let color = colors[current];
    assert_ne!(color, -1);
    for &(next, w) in &g[current] {
        if colors[next] != -1 {
            continue;
        }
        if w % 2 == 0 {
            colors[next] = color;
        } else {
            colors[next] = (color + 1) % 2;
        }
        dfs(next, &g, colors)
    }
}


Measured memory_bytes: 18916
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,l;
    cin >> n >> l;
    long ans = 0;
    if(l>=0){
        for(int i = 1;i<n;i++){
            ans+=(l+i);
        }
        cout << ans << endl;
    }
    else{
        if(l+n-1>=0){
            for(int i = 0;i<n;i++){
                ans+=(l+i);
            }
            cout << ans << endl;
        }
        else{
            for(int i = 0;i<n-1;i++){
                ans+=(l+i);
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int g[20][20]={0},cost[1<<15]={0},dp[1<<15][15];
int main(){
	int i,j,k,n,m,a,b,c;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d%d",&a,&b,&c);
		g[a-1][b-1]=g[b-1][a-1]=c;
	}
	for(i=1;i<(1<<n);i++){
		for(j=0;j<n;j++){
			if(!(i>>j&1))
				continue;
			for(k=j+1;k<n;k++)
				if(i>>k&1)
					cost[i]+=g[j][k];
		}
	}
	for(i=0;i<(1<<n);i++)
		for(j=0;j<n;j++)
			dp[i][j]=-1000000000;
	for(i=0;i<(1<<n);i++)
		dp[i][0]=cost[i];
	for(i=0;i<(1<<n);i++){
		for(j=1;j<n;j++){
			if(!(i>>j&1))
				continue;
			for(k=0;k<n;k++)
				if(k!=j&&(i>>k&1)&&g[j][k])
					dp[i][j]=max(dp[i][j],dp[i^(1<<j)][k]+g[j][k]);
			for(k=i;k;k=(k-1)&i)
				dp[i][j]=max(dp[i][j],dp[i^k][j]+cost[k|(1<<j)]);
		}
	}
	printf("%d\n",cost[(1<<n)-1]-dp[(1<<n)-1][n-1]);
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define ld long double
#define mod 1000000007ll
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define Debug(x) cout << x << "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
//int main() {
//    ll n;
//    cin >> n;
//    ll ct = 0;
//    while(n) {
//        n /= 26;
//        ++ct;
//        if(n < 26)
//            break;
//    }
//    string ans = "";
//    for(int i = 0; i < ct; ++i)
//        ans += 'a';
//    ans += char(n - 1 + 97);
//    cout << ans;
//
//}
int main() {
    ll n;
    cin >> n;
    vl a(n);
    ll ans = 0;
    for(auto &num: a) {
        cin >> num;
        ans ^= num;
    }
    for(auto num: a) {
        cout << (ans ^ num) << " ";
    }
}


Measured memory_bytes: 4816
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
map<long long,int>p;
int n;
long long a[220000];
int main(){
	int ans;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),p[a[i]]++;
	sort(a+1,a+1+n);
	for(int i=n;i>=1;i--){
		if(p[a[i]]==0)continue;
		p[a[i]]--;
		for(int j=1;j<=a[i]*2;j<<=1){
			if(j>a[i]){
				if(p[j-a[i]]){
					p[j-a[i]]--;
					ans++;
				}
				break;
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 26752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100100
#define LL long long
using namespace std;
LL h[maxn];
int main() {
	int n;
	while(cin >> n) {
		LL a, b;
		cin >> a >> b;
		for(int i = 1; i <= n; i++) {
			cin >> h[i];
		}
		LL l = 1, r = 1e+9;
		LL ans = r;
		while(l <= r) {
			LL mid = (l + r) / 2;
			LL sum = 0;
			for(int i = 1; i <= n; i++) {
				if(h[i] <= mid * b) continue;
				if((h[i] - mid * b) % (a - b) == 0) {
					sum = sum + (h[i] - mid * b) / (a - b);
				}
				else {
					sum = sum + (h[i] - mid * b) / (a - b) + 1;
				}
			}
			if(sum <= mid) {
				ans = min(mid, ans);
				r = mid - 1;
			}
			else {
				l = mid + 1;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
} 

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())

output = 0
divisors = make_divisors(N)
for div in divisors:
    if N/div < (div - 1):
        output += div - 1

print(output)

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fe(i,a,b) for(int i=(a);i<=(b);i++)
#define fne(i,a,b) for(int i=(a);i<(b);i++)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%lld",&x)
#define mst(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define pb push_back
#define lowbit(x) x&-x
#define lc rt<<1
#define rc rt<<1|1
#define ls lc,l,m
#define rs rc,m+1,r
#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;
#define dbg2(x,y) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl;
#define dbg3(x,y,z) cout<<' '<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl;
const int INF =0x3f3f3f3f;
const int mod = 1e9+7;
const double eps=1e-8;
const int N = 2e5+5;
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
ll dp[N];
int h[N];
int main(){
//	freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	//freopen("BZW.txt","r",stdin);
	int n,k;
	read2(n,k);
	fe(i,1,n)read(h[i]);
	mst(dp,0x3f);
    dp[1] = 0;
    fe(i,1,n){
		fe(j,1,k){
			if(i-j<1)break;
			dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
    }
    printf("%lld\n",dp[n]);




	return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        System.out.println(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]?"YES":"NO");
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 500010;

int main(){
    char trump;
    string s[4][13];
    string str = "23456789TJQKA";
    auto mx = [&](string a, string b, char suit){
        if(a[1] == trump && b[1] != trump) return a;
        else if(a[1] != trump && b[1] == trump) return b;
        else if(a[1] == trump && b[1] == trump) return str.find(a[0]) > str.find(b[0]) ? a : b;
        else{
            if(a[1] == suit && b[1] != suit) return a;
            else if(a[1] != suit && b[1] == suit) return b;
            else return str.find(a[0]) > str.find(b[0]) ? a : b;
        }
    };
    while(cin >> trump && trump != '#'){
        rep(i, 4)rep(j, 13) cin >> s[i][j];
        int leader = 3, ew = 0, ns = 0;
        rep(i, 13){
            char suit = s[leader][i][1];
            pair<string, int> p = {s[leader][i], leader};
            rep(j, 4)if(mx(p.fi, s[j][i], suit) != p.fi){
                p = {s[j][i], j};
            }
            p.se == 0 || p.se == 2 ? ++ns : ++ew;
            leader = p.se;
        }
        printf("%s ", ns > ew ? "NS" : "EW");
        printf("%d\n", max(ns, ew) - 6);
    }
}


Measured memory_bytes: 3292
x = int(input())

if x >= 1800:
    ans = 1
elif x >= 1600:
    ans = 2
elif x >= 1400:
    ans = 3
elif x >= 1200:
    ans = 4
elif x >= 1000:
    ans = 5
elif x >= 800:
    ans = 6
elif x >= 600:
    ans = 7
elif x >= 400:
    ans = 8

print(ans)


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

using namespace std;

void out(vector<int> bit) {
    reverse(begin(bit), end(bit));
    bool start = false;
    for (int i = 0; i < bit.size(); i++) {
        if (start) cout << bit[i];
        else {
            if (bit[i]) {
                cout << bit[i];
                start = true;
            }
        }
    }
    cout << endl;
}

long long rev(vector<int> bit) {
    long long ret = 0;
    for (int i = 0; i < bit.size(); i++) {
        if (bit[i]) {
            if (i % 2 == 0) ret += (1LL << i);
            else ret += (1LL << i) * -1;
        }
    }
    return ret;
}

int main() {
    long long N;
    cin >> N;
    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }
    string ans = "";
    bool isNegative = N < 0;
    N = llabs(N);
    vector<int> bit;
    while (N) {
        bit.emplace_back(N % 2);
        N /= 2;
    }
    while (bit.size() < 64) {
        bit.emplace_back(0);
    }
    //out(bit);
    for (int i = 0; i < bit.size(); i++) {
        if (bit[i] == 1) {
            if (i % 2 == (isNegative ? 0 : 1)) {
                // minus
                bit[i + 1]++;
            } else {
                // plus
            }
        } else if (bit[i] == 2) {
            if (i % 2 == (isNegative ? 0 : 1)) {
                // minus
                bit[i] = 0;
                bit[i + 1]++;
            } else {
                // plus
                bit[i] = 0;
                bit[i + 1]++;
            }
        }
    }
    out(bit);
    auto foo = rev(bit);
    //cout << foo << endl;
}


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

template<class Iter>
inline bool next_permutation2(Iter first, Iter k, Iter last)
{
  if (first == k)
    return false;
  if (k == last)
    return next_permutation(first, last);
  Iter i = k;
  --i;
  if (*i < *k) {
    std::rotate(i, k, last);
    return true;
  }
  while (i != first) {
    Iter j = i;
    ++j;
    std::rotate(i, j, last);
    --i, --j;
    for (; j != last; ++j) {
      if (*i < *j)
        break;
    }
    if (j != last) {
      std::iter_swap(i, j);
      return true;
    }
  }
  std::rotate(first, ++Iter(first), last);
  return false;
}

struct nvec : public vector<int>
{
  int base;
  nvec(int len, int base) : vector<int>(len), base(base) {}
  nvec& operator=(ll in)
  {
    for (int i = 0; i < size(); i++) {
      if (in == 0)
        break;
      at(i) = in % base;
      in /= base;
    }
    return *this;
  };
  operator ll() const noexcept
  {
    ll out, b;
    out = 0;
    b = 1;
    for (int i = 0; i < size(); i++) {
      if (at(i))
        out += at(i) * b;
      b *= base;
    }
    return out;
  };
  nvec& operator++()
  {
    for (int i = 0; i < size(); i++) {
      at(i)++;
      if (at(i) < base)
        break;
      at(i) = 0;
    }
    return *this;
  };
  nvec& operator--()
  {
    for (int i = 0; i < size(); i++) {
      if (0 < at(i)) {
        at(i)--;
        break;
      }
      at(i) = base - 1;
    }
    return *this;
  };
  nvec& operator++(int dummy) { return operator++(); }; // 後置(a++)のoverload
  nvec& operator--(int dummy) { return operator--(); }; // 後置(a--)のoverload
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N;
  cin >> N;
  vector<int> v(9);
  vector<int> x(9);
  x[0] = 1;
  for (int i = 1; i < 9; i++) {
    x[i] = x[i - 1] * 10;
  }
  nvec nv(10, 4);
  int ans = 0;
  do {
    int num = 0;
    int flag = 0;
    int zero = 0;
    for (int i = 8; 0 <= i; i--) {
      switch(nv[i]) {
      case 0:
        num += (7 * x[i]);
        flag |= 1;
        break;
      case 1:
        num += (5 * x[i]);
        flag |= 2;
        break;
      case 2:
        num += (3 * x[i]);
        flag |= 4;
        break;
      case 3:
        if (flag != 0) {
          zero = 1;
        }
        break;
      }
    }
    nv++;
    if (flag == 7 && zero == 0) {
      if (num <= N) {
        dump(num);
        ans++;
      }
    }
  } while (nv[9] == 0);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
baraN = list(str(N))

honlist = ["2", "4", "5", "7", "9"]
ponlist = ["0", "1", "6", "8"]
bonlist = ["3"]

if baraN[-1] in honlist:
    print("hon")
elif baraN[-1] in ponlist:
    print("pon")
elif baraN[-1] in bonlist:
    print("bon")


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

using namespace std;

int main()
{
	char b;
	cin >> b;

	if (b == 'A') {
		cout << "T" << endl;
	}
	else if (b == 'T') {
		cout << "A" << endl;
	}
	else if (b == 'G') {
		cout << "C" << endl;
	}
	else if (b == 'C') {
		cout << "G" << endl;
	}
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    long long n,m;
    cin>>n>>m;
    pair<long long,long long>p[n];
    for(int i=0;i<n;i++){
        long long a,b;
        cin>>a>>b;
        p[i]={a,b};
    }
    sort(p,p+n);
    long long ans=0;
    for(int i=0;i<n;i++){
        if(m>=p[i].second){
            ans+=p[i].first*p[i].second;
            m-=p[i].second;
        }else{
            ans+=p[i].first*m;
            m=0;
        }
        if(m<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

void Main()
{
    string S, T;
    cin >> S >> T;

    int cnt = 0;
    REP(i, S.length())
    {
        if (S.at(i) != T.at(i))
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
#define pb push_back
#define mp make_pair
#define endl "\n"
// #define mem(x) memset(x, -1, sizeof(x))
const int MOD = 1e9+7;

template <typename T>
void print(T AA[], int nn){for(int ii=0; ii<nn; ii+=1){cout<<AA[ii]<<" ";}cout<<endl;}
template <typename T> inline void print(T nn){ cout << nn << endl;}
/* ----------------------------------------------------------------------------------- */

const int N = 3005;
int n, vis[N][N];
double cache[N][N], A[N];

double fn(int i, int heads){
    if(i==n) return (heads*2>=n);
    if(vis[i][heads]==1) return cache[i][heads];
    vis[i][heads] = 1;
    double ans = A[i]*fn(i+1, heads+1) + (1-A[i])*fn(i+1, heads);
    cache[i][heads] = ans;
    return ans;
}


int32_t main(){

    IOS

    memset(vis, 0, sizeof(vis));
    cin >> n;
    for(int i=0; i<n; i+=1) cin >> A[i];
    cout <<fixed << setprecision(12) << fn(0, 0) << endl;

    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, d[300][300], f[300][300];

int main() {
	cin >> n;
	inc(i, n) {
	inc(j, n) {
		cin >> d[i][j];
	}
	}
	
	bool x = true;
	inc(i, n) {
	inc(j, n) {
		inc(k, n) {
			if(k == i || k == j) { continue; }
			if(d[i][j] >  d[i][k] + d[k][j]) { x = false; }
			if(d[i][j] == d[i][k] + d[k][j]) { f[i][j] = 1; }
		}
	}
	}
	
	LL ans = 0;
	inc(i, n) {
	inc(j, i) {
		if(f[i][j] == 0) { ans += d[i][j]; }
	}
	}
	
	if(! x) { ans = -1; }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    string S; cin >> S;
    vector<int> sum(3);
    rep(i,S.size()){
        sum[S[i]-'a']++;
    }
    int Sum = sum[0] + sum[1] + sum[2];
    int d = Sum/3;
    int r = Sum%3;
    bool ok = true;
    sort(sum.begin(),sum.end());
    if(sum[0] != d) ok = false;
    if(r >= 1){
        if(sum[2] != d+1) ok = false;
    }
    cout << (ok ? "YES" : "NO") << endl;
   
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
 
static const int INF = 0x3f3f3f3f;
 
int main() {
        int n;
        scanf("%d", &n);
        string s, t;
        cin >> s >> t;
        if (s == t) return !puts("0");
        if (s[0] != t[0]) return !puts("-1");
        vector<int> a, b;
        b.push_back(0);
        for (int i = 1; i < n; i ++) if (t[i] != t[i - 1]) b.push_back(i);
        int p = n - 1;
        int bp = b.size() - 1;
        while (p > 0) {
                while (t[b[bp]] != s[p]) p --;
                if (p == 0) break;
                a.push_back(p);
                bp --;
                p = min(p, b[bp]);
        }
        a.push_back(0);
        if (a.size() != b.size()) return !puts("-1");
        reverse(a.begin(), a.end());
        int lb = -1, ub = INF;
        while (ub - lb > 1) {
                int s = (lb + ub) / 2;
                bool ok = true;
                for (int i = 0; i < b.size(); i ++) {
                        if (i + s < a.size()) ok &= a[i + s] - s >= b[i];
                }
                if (ok) ub = s;
                else lb = s;
        }
        printf("%d\n", ub + 1);
        return 0;
}


Measured memory_bytes: 14332
#include<stdio.h>
typedef long long int lli;
int main() {
  char s[3];
  scanf("%s", &s);
  int ans=0;

  for(int i=0;i<3;i++){
      if(s[i]=='R')
        ans++;
      if(s[i]=='S' && i==1)
        break;
  }
  if(s[0]=='S' && s[1]=='S' && s[2]=='R')
    ans=1;

  printf("%d", ans);
}



Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <vector>       // ヘッダファイルインクルード
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    int N;
    int Y;
    cin >> N>>Y;
    int a[3]={0};
    for (int i = 0; i < Y/1000+1; ++i) {
       for (int j = 0; j < Y/5000+1; ++j) {
         int s = N-i-j;
         if(s>=0){
           if (10000*s+5000*j+1000*i==Y){
           a[0]=i;
           a[1]=j;
           a[2]=s;
           break;}}
    
    }
    }
    if(a[0]==0&&a[1]==0&&a[2]==0){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;}
  else{cout<<a[2]<<" "<<a[1]<<" "<<a[0]<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, s, N) for(ll i{N - 1}; i > s - 1; i--)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll N;
  cin >> N;
  vector<ll> V(N);
  for(auto&& i : V){
    cin >> i;
  }
  for(auto&& i : V){
    ll j;
    cin >> j;
    i -= j;
  }
  sort(V.rbegin(), V.rend());
  while(V.back() < 0){
    V.pop_back();
  }
  cout << accumulate(V.begin(), V.end(), 0LL) << rt;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

int N,M,x,y;
int dp[100010];
vector<vector<int> > G;

ll dfs(int v){
    if(dp[v]!=-1) return dp[v];
    ll ret = 0;
    for(int nv : G[v]){
        ret = max(ret,dfs(nv)+1);
    }
    return dp[v] = ret;
}

int main(){
    cin >> N >> M;
    G.resize(N);
    for(int i=0; i < M; ++i){
        cin >> x >> y;
        G[--x].push_back(--y);
    }
    for(int i=0;i<N;++i) dp[i] = -1;
    ll ans = 0;
    for(int i=0;i<N;++i){
        ans = max(ans,dfs(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
using namespace std;
#include<string>
#define ll long long
#define pb push_back

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
//const ll N=1e5+5;


// int divi(ll num) {
// 	if (num % 2 == 0) {
// 		num /= 2;
// 		return divi(num);
// 	}
// 	else
// 		return num;
// }

void solve() {
	string s, t;
	cin >> s;
	cin >> t;
	ll p = 0;
	fr(i, 0, s.size()) {
		if (s[i] != t[i])
			p++;
	}
	cout << p;
}



int main() {
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif


	ll t = 1;
	//cin >> t;
	while (t--) {
		solve();
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3884
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#define INF (1 << 28)

using namespace std;

int mp[10];
int c[10][10];

void update(vector<int> num) {
	int ind = 0;
	for (int i = 0; i < 10; ++i) {
		if (num[i] == 1) {
			ind = i;
		}
	}

	int res = 0;
	for (int i = ind; i > 0; --i) {
		res += c[num[i-1]][num[i]];
		if (res > mp[num[i-1]]) {
			return;
		}
		mp[num[i-1]] = res;
	}
	return;
}

int main(void) {
	int H,W;
	cin >> H >> W;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> c[i][j];
		}
	}
	vector<int> num(10);
	iota(num.begin(),num.end(),0);
	for (int i = 0; i < 10; ++i) {
		mp[i] = INF;
	}
	update(num);
	mp[1] = 0;
	while (next_permutation(num.begin(),num.end())) {
		if (num[0] != 1) {
			update(num);
		}
	}

	int res = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int temp;
			cin >> temp;
			if (temp >= 0) {
				res += mp[temp];
			}
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x%2==0 &&(x%3!=0 && x%5!=0)){
			cout<<"DENIED";
			return 0;
		}
	}
	cout<<"APPROVED";
	return 0;
}

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

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,i,sum=0,j;
    cin>>n;
    if(n&1)
        {
            cout<<0<<endl;
            return 0;
        }
    for(j=5; n/j>=1; j*=5)
    {
      sum+=(n/j)/2;

    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define  BLACK 1
#define  WHITE -1
#define  GRAY 0
#define  N 1000
#define INFTY 1<<21
/*辺がない状態として非常に大きな値に設定しておくと都合がいい*/

int array[N][N];
int number;



void find(void){

  int color[N];
  int d[N];
  int p[N];
  
  int sum=0;
  int i,k;
  int m,u;
  
  /*初期化*/
  for(i=0;i<number;i++){
    d[i]=INFTY;
    color[i]=WHITE;
    
  }


  d[0]=0;
  p[0]=-1;
  
  


  while(1){


    m=INFTY;
    
    for(i=0;i<number;i++){
      if(m>d[i] && color[i] != BLACK){
       
	m=d[i];
	u=i;
      }
    }

    
    if(m==INFTY){break;}

    color[u]=BLACK;



    for(k=0;k<number;k++){
      if(color[k]!=BLACK  && array[u][k] != INFTY){
	if(d[k]>array[u][k]){
	  d[k]=array[u][k];
	  p[k]=u;
	  color[k]=GRAY;
	}
      }
    }
  }


  for(i=0;i<number;i++){
    if(p[i]!=-1){
      // printf("%d ",array[i][p[i]]);
      sum+=array[i][p[i]];}
  }
  


  printf("%d\n",sum);
}



int main(){
  scanf("%d",&number);

  int i,j;
  int n;

  
  for(i=0;i<number;i++){
    for(j=0;j<number;j++){
      
      scanf("%d",&n);

      
      
      /* if(n==-1){array[i][j]=INFTY;}
      else{array[i][j]=n;}
      */
 
      array[i][j]=(n ==-1) ? INFTY:n;
      // array[i][j]=n;


    }
    }


  find();

  /*  
      for(i=0;i<number;i++){
	for(j=0;j<number;j++){
	  //	  printf("%d ",array[i][j]);
	}
	printf("\n");
      }
         
  */
  
  return 0;
}



Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define T 6005
#define N 105
#define M 55
using namespace std;
int n,m,l,p[N],t[N],v[N];
double dp[N][2][T],sum[N][T];
 
int main(){
  cin>>n>>m>>l;
  for(int i=0;i<n;i++)
    cin>>p[i]>>t[i]>>v[i];
  for(int i=0;i<n;i++){
    dp[i][0][0]=1;
    for(int j=0;j<m;j++){
      for(int k=0;k<T;k++){
	if(!dp[i][j%2][k])continue;
	dp[i][(j+1)%2][k]+=dp[i][j%2][k]*(100.0-p[i])/100.0;
	dp[i][(j+1)%2][k+t[i]]+=dp[i][j%2][k]*p[i]/100.0;
      }
      for(int k=0;k<T;k++)dp[i][j%2][k]=0;
    }
  }
  for(int i=0;i<n;i++)
    for(int j=T-2;j>=0;j--)
      sum[i][j]=sum[i][j+1]+dp[i][m%2][j];
  for(int i=0;i<n;i++){
    double ans=0;
    if(v[i])
      for(int j=0;j<T;j++){
	if(!dp[i][m%2][j])continue;
	double x=dp[i][m%2][j];
	double s=j+1.0*l/v[i];
	for(int k=0;k<n;k++){
	  if(i==k||!v[k])continue;
	  int idx=(int)(s-1.0*l/v[k]);
	  if(s-1.0*l/v[k]<0)idx=0;
	  else idx++;
	  if(T<=idx){
	    x=0;
	    break;
	  }
	  x*=sum[k][idx];
	}
	ans+=x;
      }
    printf("%.8f\n",ans);
  }
  return 0;
}

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


int main() {

  int A;
  cin >> A;

  string ans = "NO";
  if(A==3||A==5||A==7){
    ans = "YES";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string.h>
using namespace std;
 
int main() {
	// your code goes here
	string str;
	getline(cin,str);
	int arr[26];
	memset(arr,0,sizeof arr);
	for(int i=0;i<str.length();i++){
		arr[str[i]-'a']++;
	}
	bool found = false;
	for(int i=0;i<26;i++){
		if(arr[i]==0){
			found = true;
			char c = i+'a';
			cout<<c<<endl;
break;
		}
	}
	if(found==false){
		cout<<"None"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int a,b; cin>>a>>b;
  cout << 6 -a-b << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		while(true) {
			long b=sc.nextLong();
			if(b==0) {
				System.exit(0);
			}
			else {
				long root=root(2*b);
				for(long i=root; i>=1; i--) {
					//(n-k+1)<(n+k)で小さい方の約数探索
					if((2*b)%i==0) {
						//n-k+1が発見された
						long npk=(2*b)/i;		//(N+K)
						long n=(npk+i-1)/2;
						long k=-i+n;
						if((n*(n+1)/2)-(k*(k+1)/2)==b) {
							pl(k+1+" "+(n-k));
							break;
						}
					}
				}
			}
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static long root(long a) {

		int ketasu=0;
		long tmp=a;
		while(tmp>0) {
			ketasu++;
			tmp/=10;
		}
		int constant=(ketasu+1)/2;	//よく使うので定数化
		if(ketasu>=1) {
			long[] suuji=new long[constant];
			tmp=a;
			for(int i=0; i<constant; i++) {
				suuji[constant-1-i]=a%100L;
				a/=100L;
			}
			long ans=0;
			long kai=0;
			long mae=0;
			if(constant<=1) {
				for(long i=10L; i>=0L; i--) {
					if(suuji[0]>=i*i) {
						return i;
					}
				}
			}
			else {
				for(long i=0L; i<((long)constant); i++) {
					mae+=kai*2;
					for(long j=9L; j>=0L; j--) {
						if((mae*10L+j)*j<=suuji[(int)i]) {
							ans=ans*10+j;
							mae*=10;
							kai=j;
							if(i+1<((long)constant)) {
								suuji[(int)i+1]+=(suuji[(int)i]-(mae+j)*j)*100;
							}
							break;
						}
					}
				}
			}
			return ans;
		}
		else {
			return 0;
		}
	}
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	map<int, string> mp;
	mp[2] = "hon";
	mp[4] = "hon";
	mp[5] = "hon";
	mp[7] = "hon";
	mp[9] = "hon";
	
	mp[0] = "pon";
	mp[1] = "pon";
	mp[6] = "pon";
	mp[8] = "pon";
	
	mp[3] = "bon";
	
	IN(int, n);
	OUT(mp[n % 10]);
}


Measured memory_bytes: 3600