akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int n,i,j=0,m=0,a[1000] = {},k;

  while(1){

    scanf("%d",&n);
    if(n == 0)break;
    
    for(i = 0;i < (n/4);i++){
      scanf("%d",&m);
      a[j] += m;
    }
    j++;

  }
  for(k = 0;k < j;k++){
    printf("%d\n",a[k]);
  }
  return 0;
}

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

N = int(input())
A = list(map(int, input().split()))

S = 0
T = 0

for i in range(N):
    S += A[i] **2
    T += A[i]
    S %= MOD
    T %= MOD

print((T**2 - S) * pow(2, MOD - 2, MOD) % MOD)

Measured memory_bytes: 94256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    var d = mutableSetOf<Int>()

    repeat(n) {
        d.add(nextInt())
    }

    println(d.size)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 34208
float a,b,c,d,p=57.296;main(){for(;~scanf("%f%f%f%f",&a,&b,&c,&d);)a+1&&printf("%.f\n",6378.1*acos(sin(a/=p)*sin(c/=p)+cos(a)*cos(c)*cos(b/p-d/p)));}

Measured memory_bytes: 0
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}

const ll m=1e9+7;

int main()
{
    int n;
    cin>>n;
    vector<ll>a(n),pref(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        pref[i]=sum;

    }
    ll ans=0;
for(int i=0;i<n-1;i++){
    ll p=a[i];
    ll q = pref[n-1]-pref[i];
    ll z= ((p%m)*(q%m))%m;
    ans=((ans%m)+(z%m))%m;
}
cout<<ans<<endl;
    return 0;
}


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

ll n;
string s;

void work(){
	ll res=0;
	cin>>n;
	cin>>s;
	for(ll i=0,j=n-1;i<j;i++){
		if(s[i]=='W'){
			for(;s[j]!='R'&&j>i;)
				j--;
			if(i<j)	swap(s[j],s[i]), res++;
		}
	}
	cout<<res<<endl;
	return ;
}

int main(){
	//work();
//freopen("C:\\Users\\lenovo\\Desktop\\in.txt","r",stdin);
	work();
	return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec A(N); readvec(A);

    if(N == 1){
        cout << "YES";
        return 0;
    }

    int s = 0;
    REP(i, N) s += A[i];
    int t = N * (N + 1) / 2;
    if(s % t != 0){
        cout << "NO";
        return 0;
    }

    s /= t;

    int s2 = 0;
    REP(i, N){
        int dif = A[i] - A[(i + N - 1) % N];
        if((s - dif) % N != 0 || s < dif){
            cout << "NO";
            return 0;
        }
        s2 += (s - dif) / N;
    }
    
    if(s2 == s){
        cout << "YES";
    }else{
        cout << "NO";
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1152
N = int(input())
A = list(map(int,input().split()))
ans = [1 for i in range(N)]
for i,a in enumerate(A):
    i = N-i-1
    if i != 0:
        partsum = 0
        if i <= N//2-1:
            for j in range(N//(i+1)):
                k = j+1
                k *= (i+1)

                partsum += ans[k-1]

            if partsum % 2 != A[i]:
                ans[i] = 0
            
        else:
            if A[i] == 0:
                ans[i] = 0
    else:
        if sum(ans)%2 == A[i]:
            bans = []
            for bi, b in enumerate(ans):
                if b == 1:
                    bans.append(bi+1)
            print(len(bans))
            if len(bans) != 0:
                print(*bans)
        else:
            ans[i] = 0
            bans = []
            for bi, b in enumerate(ans):
                if b == 1:
                    bans.append(bi+1)
            print(len(bans))
            if len(bans) != 0:
                print(*bans)

Measured memory_bytes: 14148
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<set>
using namespace std;

const int maxn = 4200000;
int n;
int arr[maxn];

int main()
{
	while(cin >> n)
	{
		int rev = (n%2);
		if(rev == 0)
		{
			int pt = n/2;
			int step = 0;
			int r = 1;
			for(int i = 0;i<n;i++)
			{
				int x;
				scanf("%d",&x);
				arr[pt] = x;
				step ++;
				r = -r;
				pt += r*step;
			}
		}
		else 
		{
			int pt = n/2;
			int step = 0;
			int r = -1;
			for(int i = 0;i<n;i++)
			{
				int x;
				scanf("%d",&x);
				arr[pt] = x;
				step ++;
				r = -r;
				pt += r*step;
			}
		}
		for(int i = 0;i<n;i++)
		{
			if(i == 0) printf("%d",arr[i]);
			else printf(" %d",arr[i]);
		}
		cout<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, ll> P;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

const ll INF = 1e10;

int V, E;

vector<vector<ll>> dist(110, vector<ll>(110, INF));

int main() {
	cin >> V >> E;

	rep(v, V) dist[v][v] = 0;

	rep(i, E) {
		int s, t; ll d; cin >> s >> t >> d;
		dist[s][t] = d;
	}

	rep(k, V) {
		rep(i, V) {
			rep(j, V) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	bool flag = false;
	rep(v, V) if (dist[v][v] < 0) flag = true;

	if (flag) {
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}

	rep(i, V) {
		rep(j, V) {
			if (dist[i][j] >= INF / 2) cout << "INF";
			else cout << dist[i][j];
			if (j != V - 1) cout << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
const ll MOD = 1000000007;

int main() {
    int n,m;
    cin >> n >> m;
    int x,y;
    int red[n];
    int ball[n];
    rep(i,n) {
        red[i] = 0;
        ball[i] = 1;
    }
    red[0] = 1;
    rep(i,m) {
        cin >> x >> y;
        ball[x-1]--;
        ball[y-1]++;
        if(red[x-1] == 1&& ball[x-1] == 0){
            red[x-1] = 0;
            red[y-1] = 1;
        }else if (red[x-1] == 1&&ball[x-1] > 0) {
            red[y-1] = 1;
        }
    }
    int ans = 0;
    rep(i,n) {
        if(red[i] == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


#define PT pair<ll, int>
int N, M, S, T;
vector<PT> E[100001];
ll D[100001];
ll dp1[100001], dp2[100001];
ll mod = 1e9 + 7;

ll search1(int A) {
	if (dp1[A] != -1) return dp1[A];
	ll ret = 0;
	for (auto p : E[A]) {
		if (D[p.second] == D[A] + p.first) {
			ret = (ret + search1(p.second)) % mod;
		}
	}
	dp1[A] = ret;
	return ret;
}

ll search2(int A) {
	if (dp2[A] != -1) return dp2[A];
	ll ret = 0;
	for (auto p : E[A]) {
		if (D[p.second] == D[A] - p.first) {
			ret = (ret + search2(p.second)) % mod;
		}
	}
	dp2[A] = ret;
	return ret;
}

ll hanbun;
ll kotae = 0;
void calc(int A) {
	if (D[A] == hanbun) {
		ll kari = search1(A) * search2(A) % mod;
		kotae = (kotae + kari * kari) % mod;
	}
	else if(D[A] < hanbun) {
		for (auto p : E[A]) {
			if (D[A] + p.first > hanbun && D[A] + p.first == D[p.second]) {
				ll kari = search1(p.second) * search2(A) % mod;
				kotae = (kotae + kari * kari) % mod;
			}
		}
	}
}

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


	cin >> N >> M >> S >> T;

	rep(i, M) {
		int u, v, d;
		cin >> u >> v >> d;
		E[u].pb(mp(2 * d, v));
		E[v].pb(mp(2 * d, u));
	}

	rep1(i, N) D[i] = 1e18;
	D[S] = 0;

	priority_queue<PT, vector<PT>, greater<PT>> que;
	que.push(mp(0, S));
	while (que.size()) {
		PT p = que.top();
		que.pop();
		int i = p.second;
		if (D[i] != p.first) continue;
		for (PT p2 : E[i]) {
			int j = p2.second;
			ll d = D[i] + p2.first;
			if (D[j] > d) {
				D[j] = d;
				que.push(mp(d, j));
			}
		}
	}
	
	hanbun = D[T] / 2;

	rep1(i, N) dp1[i] = -1;
	dp1[T] = 1;
	rep1(i, N) dp2[i] = -1;
	dp2[S] = 1;
	rep1(i, N) calc(i);

	co((search1(S) * search1(S) % mod - kotae + mod) % mod);

	Would you please return 0;
}


Measured memory_bytes: 17916
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    double d;
    cin >> d;
    double ans=2*pi*d;
    printf("%.12lf",ans);
    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool f = 0;

    rep(i, n-1){
        for(int j = i; j < n; j++){
            if (s.substr(0, i) + s.substr(j, n-j) == "keyence") f = 1;
        }
    }

    if (f) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  if(A>=13){
    cout << B << endl;
  }
  else if(A>=6 && A<=12){
    cout << B/2 << endl;
  }
  else if(A<=5){
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

S=one_str()

if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		if (s[i] == t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
		
	return 0;
}


Measured memory_bytes: 256
import os
import heapq
import sys
import math
import bisect
import operator
from collections import defaultdict
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]


# def bubbleSort(arr,b):
#     n = len(arr)
#     for i in range(n):
#         for j in range(0, n - i - 1):
#             if arr[j] > arr[j + 1] and b[j]!=b[j+1]:
#                 arr[j], arr[j + 1] = arr[j + 1], arr[j]
#                 b[j],b[j+1]=b[j+1],b[j]
def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    #for _ in range(int(input())):
    n=int(input())
    arr=inar()
    mn=arr[0]
    mx=arr[0]
    take=1000
    for i in range(1,n):
        if arr[i]<mx:
            got=take//mn
            rem=take%mn
            take=got*mx
            take+=rem
            mx=arr[i]
            mn=arr[i]
        else:
            mx=max(arr[i],mx)
    got = take // mn
    rem = take % mn
    take = got * mx
    take += rem
    print(take)














BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 67336
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
 

template<typename T>
struct WeightedUnionFind
{
    std::vector<int> par, sz;
    std::vector<T> pot;
    WeightedUnionFind(int N = 0) : par(N), sz(N, 1), pot(N) {
        std::iota(par.begin(), par.end(), 0);
    }
    int find(int x) {
        if (par[x] != x) {
            int r = find(par[x]);
            pot[x] = pot[x] + pot[par[x]], par[x] = r;
        }
        return par[x];
    }
    bool unite(int s, int t, T rel_diff) {
        // Relate s and t by t = s + rel_diff
        // Return false iff contradiction happens.
        rel_diff = rel_diff + weight(s) + (-weight(t));
        if ((s = find(s)) == (t = find(t))) return rel_diff == 0;
        if (sz[s] < sz[t]) std::swap(s, t), rel_diff = -rel_diff; 
        par[t] = s, sz[s] += sz[t], pot[t] = rel_diff;
        return true;
    }
    T weight(int x) { find(x); return pot[x]; }
    T diff(int s, int t) { return weight(t) + (-weight(s)); }
    int count(int x) { return sz[find(x)]; }
    bool same(int s, int t) { return find(s) == find(t); }
};


int main()
{
    int N, M;
    cin >> N >> M;
    WeightedUnionFind<lint> uf(N + 1);
    while (M--) {
        int l, r, d;
        cin >> l >> r >> d;
        if (!uf.unite(l, r, d)) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
main(){
  int n,x,t,ans=0;
  cin>>n;
  set<int>s[3];
  for(int i=0;i<3;i++){
    cin>>x;
    for(int j=0;j<x;j++){
      cin>>t;
      s[i].insert(t);
    }
  }
  for(int i=1;i<=n;i++){
    int a[3]={};
    for(int j=0;j<3;j++){
      if(s[j].count(i))a[j]++;
    }
    if(a[2]&&!a[0]||a[2]&&a[1])ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3112
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define eb emplace_back

typedef long long ll;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    REP(i,n){
        int x;cin >> x;
        if(x%2==0){
            if(!(x%3==0||x%5==0)){
                cout << "DENIED" << '\n';
                return 0;
            }
        }
    }
    cout << "APPROVED" << '\n';
    return 0;
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

h,w = map(int, input().split())
a = [input() for _ in range(h)]

y = [False] * h
x = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            y[i] = True
            x[j] = True

for i in range(h):
    if y[i]:
        for j in range(w):
            if x[j]:
                print(a[i][j],end="")
        print("")





Measured memory_bytes: 9140
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};

main {
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    auto a = vectors(h, w, 0LL);
    cin >> a;
    int si, sj;
    rep(i, h) rep(j, w) if (a[i][j] == 2) si = i, sj = j;
    function<int(int, int, int)> dfs = [&](int i, int j, int c) {
      if (c == 10) return INF;
      int mini = INF;
      rep(k, 4) {
        int ni = i + di[k], nj = j + dj[k];
        if (ni < 0 || nj < 0 || ni >= h || nj >= w || a[ni][nj] == 1) continue;
        while (0 <= ni && ni < h && 0 <= nj && nj < w) {
          if (a[ni][nj] == 3) {
            cmin(mini, c + 1);
            break;
          }
          if (a[ni][nj] == 1) {
            a[ni][nj] = 0;
            cmin(mini, dfs(ni - di[k], nj - dj[k], c + 1));
            a[ni][nj] = 1;
            break;
          }
          ni += di[k], nj += dj[k];
        }
      }
      return mini;
    };
    int ans = dfs(si, sj, 0);
    cout << (ans == INF ? -1 : ans) << endl;
  }
}



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

int main() {
  int e,z;
  cin >> e >> z;
  z = z - e + 1;
  for(int i = 0; i < e * 2 - 1; i++){
    if(i == e * 2 -2){
      cout << z + i << endl;
      return 0;
    }
    else{
    cout << z + i << " ";  
    }
  }
  return 0;
}

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

namespace Structure_and_Class
{
    class Dice_IV
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var dices = new Dice4[n];
            for (int i = 0; i < n; i++)
                dices[i] = new Dice4(Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray());

            for (int i = 0; i < n-1; i++)
                for (int j = i + 1; j < n; j++)
                    if (dices[i].IsEqual(dices[j]))
                    {
                        Console.WriteLine("No");
                        return;
                    }
            Console.WriteLine("Yes");
        }
    }

    public class Dice4
    {
        public int[] label = new int[6];

        public Dice4(int[] label)
        {
            this.label = label;
        }

        public bool IsEqual(Dice4 diceB)
        {
            if (RotaetCheck(diceB)) return true;
            diceB.Move('N');
            if (RotaetCheck(diceB)) return true;
            diceB.Move('N');
            if (RotaetCheck(diceB)) return true;
            diceB.Move('E');
            if (RotaetCheck(diceB)) return true;
            diceB.Move('N');
            if (RotaetCheck(diceB)) return true;
            diceB.Move('N');
            if (RotaetCheck(diceB)) return true;

            return false;
        }

        private bool RotaetCheck(Dice4 diceB)
        {
            for (int i = 0; i < 4; i++)
            {
                diceB.Rotate();
                if (label.SequenceEqual(diceB.label)) return true;
            }
            return false;
        }

        public void Move(char c)
        {
            int[] res = new int[6];
            switch (c)
            {
                case 'E':
                    res[0] = label[3];
                    res[1] = label[1];
                    res[2] = label[0];
                    res[3] = label[5];
                    res[4] = label[4];
                    res[5] = label[2];
                    label = res;
                    break;
                case 'N':
                    res[0] = label[1];
                    res[1] = label[5];
                    res[2] = label[2];
                    res[3] = label[3];
                    res[4] = label[0];
                    res[5] = label[4];
                    label = res;
                    break;
                case 'S':
                    Move('N');
                    Move('N');
                    Move('N');
                    break;
                case 'W':
                    Move('E');
                    Move('E');
                    Move('E');
                    break;
            }
        }

        public void Rotate()
        {
            int[] res = new int[6];
            res[0] = label[0];
            res[1] = label[3];
            res[2] = label[1];
            res[3] = label[4];
            res[4] = label[2];
            res[5] = label[5];
            label = res;
        }
    }
}

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

int main (){
  int N;
  cin >>N;
  vector<int64_t> vec;
  vec.push_back(2);
  vec.push_back(1);

  if (N<2){
    cout << vec.at(N) << endl;
  }
  else {
    for (int i=2;i<N+1;i++){
      int64_t a=vec.at(i-1)+vec.at(i-2);
      vec.push_back(a);
      
    }
    cout << vec.at(N) << endl;
  }
}
  
            
  

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<long long> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    long long buf = a.at(0);
    for (int i=1; i<n; i++) {
        buf = buf ^ a.at(i);
    }
    if (buf == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  ll a;
  string b;
  cin >> a >> b;
  string c;
  rep(i, sz(b)) {
    if (b[i] == '.') continue;
    c += b[i];
  }
  cout << a * stoll(c) / 100 << endl;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
    int r, c;
    int num[101][101] = {};
    int i, j;
    
    scanf("%d%d", &r, &c);
    
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            scanf("%d", &num[i][j]);
            num[i][c]+=num[i][j];
        }
    }
    for(i=0; i<r; i++){
        for(j=0; j<c+1; j++){
           num[r][j]+=num[i][j]; 
        }
    }
    
    for(i=0; i<=r; i++){
        for(j=0; j<=c; j++){
            printf("%d", num[i][j]);
            if(j<c){
                printf(" ");
            }
            else{
                printf("\n");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#pragma comment(linker,"/STACK:102400000,102400000")
#define inf 0x3f3f3f3f
#define maxm 100000
typedef long long ll;
using namespace std;
int main()
{
    int v[maxm],w[maxm];
    int f[maxm];
    int N,W;
    cin>>N>>W;
    for(int i = 1;i <= N; i++)
        scanf("%d%d",&v[i],&w[i]);
    for(int i = 1;i <= N; i++)
    {
        for(int j = W;j>=w[i]; j--)
        {
            f[j] = max(f[j],f[j-w[i]]+v[i]);
        }
    }
    printf("%d\n",f[W]);
}



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


int main() {
    string a, b,c;
    cin >> a >> b>>c;
    int d = a.size() - 1, e = b.size() - 1, f = c.size() - 1;
    if (a[d] == b[0] && b[e] == c[0])cout << "YES" << endl;
    else cout << "NO" << endl;
  
 
    
    return 0;
}

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

int main(){
  int n;
  while(cin>>n){
    if(n==0) break;
    int a[n+1];
    for(int i=0; i<n; i++) cin >> a[i];
    int Max = a[0];

    for(int i=0; i<n; i++){
      int sum=0;
      for(int j=i; j<n; j++){
	sum+=a[j];
	if(Max < sum) Max = sum;
      }
    }
    cout << Max << endl;
  }
  return 0;
}

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

int main(){
    int n; cin >> n;
    map<int,int> d;
    rep(i,n){
        int tmp; cin >> tmp;
        d[tmp]++;
    }
    int m; cin >> m;
    map<int,int> t;
    rep(i,m){
        int tmp; cin >> tmp;
        t[tmp]++;
    }

    for(auto a:t){
        //cout << a.first << " " << a.second << " ";
        if(d[a.first] - a.second < 0){
            put("NO");
            return 0;
        }
    }
    //cout << endl;
    put("YES");
}

Measured memory_bytes: 18944
#include<iostream>
#include<cstdio>
#define MAX 2000000+5
using namespace std;
int heap[MAX];
int num;
void maxheapify(int i){
	int largest;
	int left=i*2;int right=i*2+1;
	if(left<=num&&heap[left]>heap[i]){
		largest=left;
	}else{
		largest=i;
	}
	if(right<=num&&heap[largest]<heap[right]){
		largest=right;
	}
	if(largest!=i){
		swap(heap[largest],heap[i]);
		maxheapify(largest);
	}
	return;
}
void insert(int i){
num++;
heap[num]=i;
int t=num;
while(t>1&&heap[t/2]<heap[t]){
	swap(heap[t],heap[t/2]);
	t=t/2;
}
return;
}
void extract(){
	cout<<heap[1]<<endl;
	heap[1]=heap[num];num--;
	maxheapify(1);
	return;
}
int main(){
	char s[10];
	num=0;
	while(scanf("%s",&s)){
		if(s[0]=='i') {
			int i;scanf("%d",&i);insert(i);
		}else if(s[0]=='e'&&s[1]=='x'){
			extract();
		}else break;
			
		}
	}



Measured memory_bytes: 6956
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int n, k;
ll a[101], dp[101][100001];

int main() {
    cin >> n >> k;
    for(int i=1;i<=n;++i) cin >> a[i];
    
    dp[0][0] = 1LL;
    for(int i=1;i<=n;++i) {
        for(int j=1;j<=k;++j) {
            dp[i-1][j] += dp[i-1][j-1];
            dp[i-1][j] %= MOD;
        }
        dp[i][0] = 1LL;
        for(int j=1;j<=k;++j) {
            if(j <= a[i]) {
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = (dp[i-1][j] - dp[i-1][j-a[i]-1] + MOD) % MOD;
            }
            // cerr << dp[i][j] << " ";
        }
        // cerr << endl;
    }

    cout << dp[n][k] << endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d[i];
  }
  int ma=0,counter=0;
  sort(d.begin(),d.end());
  for(int i=0;i<N;i++){
    if(ma<d[i]){
      ma=d[i];
      counter++;
    }
  }
  cout<<counter<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min(a,b,c,d,e)
t = 4
if n % m ==0:
    t += n//m
else:
    t += n//m + 1
print(t)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int y500c = sc.nextInt();
		int y100c = sc.nextInt();
		int y50c = sc.nextInt();
		// 文字列の入力
		int x = sc.nextInt();

		int count=0;
		for(int i=0;i<=y500c;i++) {
			for(int j=0;j<=y100c;j++) {
				for(int k=0;k<=y50c;k++) {
					if(500*i + 100*j + 50*k == x)count++;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21076
K = int(input())
Is = [input() for i in range(K)]
Ns = [input() for i in range(K)]
atk_I = 0
atk_N = 0
#"mamoru", "tameru", "kougekida"
#"Isono-kun", "Nakajima-kun", "Hikiwake-kun"
for i, n in zip(Is, Ns):
	i_n = [i, n]
	if (i_n.count("mamoru") == 2):
		pass
	elif (i_n.count("mamoru") == 1):
		if (i_n.count("tameru") == 1):
			exec("atk_{} += 1".format('I' if i[0] == "t" else 'N'))
			if (atk_I > 5):
				atk_I = 5
			elif (atk_N > 5):
				atk_N = 5
		else:
			if (i[0] == "k"):
				if (atk_I == 5):
					print("Isono-kun")
					exit()
				elif (atk_I == 0):
					print("Nakajima-kun")
					exit()
				else:
					atk_I = 0
			elif (n[0] == "k"):
				if (atk_N == 5):
					print("Nakajima-kun")
					exit()
				elif (atk_N == 0):
					print("Isono-kun")
					exit()
				else:
					atk_N = 0
	else:
		if (i_n.count("kougekida") == 2):
			if (atk_I > atk_N):
				print("Isono-kun")
				exit()
			elif (atk_I == atk_N):
				atk_I = 0
				atk_N = 0
			else:
				print("Nakajima-kun")
				exit()
		elif (i_n.count("kougekida") == 1):
			if (i[0] == "k"):
				if (atk_I == 0):
					print("Nakajima-kun")
					exit()
				else:
					print("Isono-kun")
					exit()
			else:
				if (atk_N == 0):
					print("Isono-kun")
					exit()
				else:
					print("Nakajima-kun")
					exit()
		else:
			atk_I += 1 if atk_I != 5 else 0
			atk_N += 1 if atk_N != 5 else 0
else:
	print("Hikiwake-kun")


Measured memory_bytes: 5628
import bisect
A, B, Q = list(map(int, input().split()))
S, T, X = [], [], []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
for _ in range(Q):
    X.append(int(input()))
INF = 10 ** 12
S = [-INF] + S + [INF]
T = [-INF] + T + [INF]

for x in X:
    ans = INF
    sr = bisect.bisect_right(S, x)
    tr = bisect.bisect_right(T, x)
    for s in S[sr-1: sr+1]:
        for t in T[tr-1: tr+1]:
            ans = min(ans, abs(s-x) + abs(s-t), abs(t-x) + abs(s-t))
    print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (auto& i : vec) cin >> i;

    double l = 0., r = 1.0;
    for (int c = 0; c < 100; c++) {
        double m = (l + r) / 2.0;
        set<int> s;
        s.insert(1);

        for (int i = 0; i < N; i++) {
            int lo_n = ceil((1.0 - m) * (double)vec[i]);
            int up_n = (1.0 + m) * vec[i];

            set<int> ns;
            for (auto j : s) {
                int v = up_n / j;
                int u = ceil((double)lo_n / j);
                for (; u <= v; u++) if (u != 0) ns.insert(j * u);
            }

            s = ns;
        }

        if (s.size() > 0) r = m;
        else l = m;
    }

    printf("%.10f\n", l);

    return 0;
}

Measured memory_bytes: 10688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  int x,n;
  cin >> x >> n;
  vector<int> non;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    non.push_back(tmp);
  }
  int i=-100;
  int delmin=1000;
  int ans=-1;
  while(i<102){
    auto res=find(non.begin(),non.end(),i);
    if(res==non.end()){
      int delta=abs(i-x);
      if(delta<=delmin){
        if(delta!=delmin)ans=i;
        delmin=delta;
      }else{
        break;
      }
    }
    i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
package main

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

var stdin []string

func main() {
    scanner := bufio.NewScanner(os.Stdin)

    var tmp string

    for scanner.Scan() {
        tmp = scanner.Text()

        if tmp == "" {
            break
        } else {
            stdin = append(stdin, scanner.Text())
        }
    }

    var N int
    arr := strings.Split(stdin[0], " ")
    N, _ = strconv.Atoi(arr[0])
    //L, _ = strconv.Atoi(arr[1])

    strs := make([]string, N) // 数が分かっているのでmakeで生成

    for i := 1; i <= N; i++ {
        strs[i - 1] = stdin[i]
    }

    sort.Strings(strs)

    for j := 0; j < N; j++ {
        fmt.Print(strs[j])
    }
    fmt.Println()
}

Measured memory_bytes: 640
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, n, a) for(int i = a; i < n; ++i)

int main(void) {
  int n, i, j, ans = 0;
  scanf("%d", &n);
  int a[n];
  rep(i, n) scanf("%d", &a[i]);
  int flag = 1;
  while(flag) {
    flag = 0;
    for(j = n - 1; j > 0; --j) {
      if(a[j] < a[j - 1]) {
        int t;
        t = a[j], a[j] = a[j - 1], a[j - 1] = t;
        flag = 1;
        ++ans;
       }
    }
  }
  rep(i, n) {
    if(i) printf(" %d", a[i]);
    else printf("%d", a[i]);
  }
  printf("\n%d\n", ans);
  return 0;
}


Measured memory_bytes: 2672
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		String line2 = sc.nextLine();

		int count = Integer.parseInt(line1);

		String[] num = line2.split(" ");

		int n = Integer.parseInt(num[0]);
		int m = Integer.parseInt(num[0]);

		long result = 0;

		for (int i = 0; i < count; i++) {

			if (m > Integer.parseInt(num[i])) {
				m = Integer.parseInt(num[i]);
			}
			if (n < Integer.parseInt(num[i])) {
				n = Integer.parseInt(num[i]);
			}

			result += Integer.parseInt(num[i]);
		}
		System.out.println(m + " " + n + " " + result);
	}
}



Measured memory_bytes: 31316
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
#define MAX 1000

static const int N = 1000;

int main()
{
    int n, m[N+1][N+1], p[N+1];

    cin >> n;
    rep(i, n){
        cin >> p[i] >> p[i+1];
    }

    for(int i = 1; i <= n; ++i) m[i][i] = 0;
    for(int l = 2; l <= n; ++l){
        for(int i = 1; i <= n-1; ++i){
            int j =  i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j-1; ++k){
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


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

int main(){
  long long n, i, right=0, left=0, count=0, zero=0;
  cin >> n;
  vector<long long> a(n+1);
  vector<long long> b(n);

  for(i=0; i<n+1; i++) cin >> a[i];
  for(i=0; i<n; i++) cin >> b[i];

    for(i=0; i<n; i++){
      if(i==0){
        count += min(a[i], b[i]);
        right = max(b[i]-a[i],  zero);
      }else{
        count += min(a[i], right);
        a[i] = max(a[i] - right, zero);
        count += min(a[i], b[i]);
        right = max(b[i]-a[i],  zero);
      }
    }

    count += min(right, a[i]);


  cout << count << endl;
  return 0;
}


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

using namespace std;

int main() {
	string s, t; cin >> s >> t;
	s += s;
	for (int i = 0; i < s.size()-t.size()+1; ++i) {
		if ( s.substr(i, t.size()) == t ) {
			cout << "Yes" << endl;
			exit(0);
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 100005
  #define INF 1000000000000
  #define eps 1e-6
  #define int long long

int32_t main()
{


    int n,k;
    cin >>n >> k;


    int ans = n*(n-1)/2 - k;

    if(ans < n - 1)
    {
      cout << -1;
      return 0;
    }

    cout << ans << endl;

    for(int i = 1; i <= n; i++)
    {
      for(int j = i + 1; j <= n; j++)
      {
        cout << i << " " << j << endl;
        ans--;
        if(ans == 0)return 0;
      }
    }



    return 0;
}

Measured memory_bytes: 256
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define ppa     pair<pair<int,int>,int>
#define pap     pair<int,pair<int,int>>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define qqq 400005

int power(int a,int b){
    if(b==0)return 1;
    int k=power(a,b/2);
    k*=k;k%=M;
    if(b&1)return (a*k)%M;
    return k;
}
void Weapons19(){
    int n,k;cin>>n>>k;
    v1d dp(k+1);
    int ans=0;
    for(int i=k;i>0;i--){
        int p=k/i;
        p=power(p,n);
        int w=0;
        for(int j=i*2;j<=k;j+=i){
            w+=dp[j];
            w%=M;
        }
        p=p-w+M;p%=M;
        dp[i]=p;
        ans+=i*p;ans%=M;
    }
    cout<<ans;
























}

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);


    Weapons19();
    
}


Measured memory_bytes: 3964
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<vector>
using std::vector;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define reg register
typedef long long ll;
inline int read(){
    reg int x=0,f=1;reg char ch=getchar();
    for(;!isdigit(ch);f=ch=='-'?-1:1,ch=getchar());
    for(;isdigit(ch);x=x*10+(ch^48),ch=getchar());
    return x*f;
}
const int mod=1e9+7;
int n,c;
int a[405],b[405],f[405][405];
ll prod[405][405];
inline ll qpow(ll a,ll b){
    reg ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        a=a*a%mod;b>>=1;
    }
    return res;
}
int main(){
    n=read();c=read();
    for(reg int i=1;i<=n;i++)a[i]=read();
    for(reg int i=1;i<=n;i++){
        b[i]=read();prod[i][0]=b[i]-a[i]+1;
        for(reg int j=1;j<=c;j++)
            for(reg int k=a[i];k<=b[i];k++)prod[i][j]=(prod[i][j]+qpow(k,j))%mod;
    }
    f[0][0]=1;
    for(reg int i=1;i<=n;i++)
        for(reg int j=0;j<=c;j++)
            for(reg int k=0;k<=j;k++)
                f[i][j]=(f[i][j]+1ll*f[i-1][j-k]*prod[i][k]%mod)%mod;
    printf("%d\n",f[n][c]);
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll m,k;

void init(){
	cin>>m>>k;
}

int main(void){
	init();
	if(m==0){
		if(k==0){
			cout<<"0 0"<<endl;
		}else{
			cout<<-1<<endl;
		}
	}else if(m==1){
		if(k==0){
			cout<<"0 0 1 1"<<endl;
		}else{
			cout<<-1<<endl;
		}
	}else{
		if(k<(1<<m)){
			rep(i,1<<m){
				if(i!=k){
					cout<<i<<" ";
				}
			}
			cout<<k<<" ";
			irep(i,1<<m){
				if(i!=k){
					cout<<i<<" ";
				}
			}
			cout<<k<<endl;
		}else{
			cout<<-1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1792