akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
h = l()
ans = 0
start = 0
Flag = 0
for i in range(N-1):
    if h[i] > h[i+1]:
        Flag = 1
    if h[i] < h[i+1] and Flag == 1:
        kukan = h[start:i+1]
        ans -= h[i]
        ans += max(kukan)
        start = i+1
        Flag = 0
kukan = h[start:N]
ans += max(kukan)
print(ans)

Measured memory_bytes: 5052
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int N, x;
    ll X;
    cin >> N >> X;
    
    int min = 10000, cnt = 0;
    for (int i = 0; i < N; i++) {
        cin >> x;
        X -= x;
        if (x < min) {
            min = x;
        }
    }
    cnt = N;
    cnt += (X / min);
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Triangles solver = new Triangles();
        solver.solve(1, in, out);
        out.close();
    }

    static class Triangles {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] array = new int[n];

            for (int i = 0; i < n; i++) {
                array[i] = in.nextInt();
            }
            Arrays.sort(array);

            long result = 0;
            for (int i = 0; i < array.length; i++) {
                int a = array[i];
                for (int j = i + 1; j < array.length; j++) {
                    int b = array[j];
                    int k = i;
                    while (k < array.length && array[k] < a + b) {
                        k++;
                    }
                    result += k - (j + 1);
                }
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 40044
In = list(map(int, input().split()))
K = In[0]
A = In[1]
B = In[2]

if A >= B:
    print(1 + K)
elif A + 1 == B:
    print(1 + K)
elif A + 2 == B:
    print(1 + K)
else:
    n = A - 1 #A枚たまるまでのパンパン回数
    if (K - n) % 2 == 0:
        print(A + (B - A) * (K - n) // 2)
    else:
        num = 1 + A + (B - A) * (K - n - 1) // 2
        print(num)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

long long n,m,i,j,K,S1,S2,ggg,T,type1;
long long ans;
char str[105],t1,tn,c1,c2;
long long f[105][30][30];

int main()
{
	//freopen("read.in","r",stdin);
	scanf("%s",str+1);
	scanf("%lld",&K);
	type1=1;
	while (str[n+1]!=0)
	{
		n++;
		if (str[n]!=str[1]) type1=0;
	}
	if (type1)
	{
		printf("%lld",(K*n)/2);
		return 0;
	}
	if (n==1)
	{
		printf("%lld",K/2);
		return 0;
	}
	ans=10000000000000000;
	memset(f,10,sizeof(f));
	for (t1='a';t1<='z';t1++)
	{
		if (t1!=str[1])
		f[1][t1-'a'+1][t1-'a'+1]=1;
		else
		f[1][t1-'a'+1][t1-'a'+1]=0;
		for (i=2;i<=n;i++)
		{
			for (c1='a';c1<='z';c1++)
			{
				for (c2='a';c2<='z';c2++)
				{
					if (c1==c2) continue;
					if (f[i-1][c1-'a'+1][t1-'a'+1]>=n) continue;
					if (c2==str[i])
					{
						f[i][c2-'a'+1][t1-'a'+1]=min(f[i][c2-'a'+1][t1-'a'+1],f[i-1][c1-'a'+1][t1-'a'+1]);
					}
					else
					{
						f[i][c2-'a'+1][t1-'a'+1]=min(f[i][c2-'a'+1][t1-'a'+1],f[i-1][c1-'a'+1][t1-'a'+1]+1);
					}
				}
			}
		}
	}
	for (t1='a';t1<='z';t1++)
	{
		for (tn='a';tn<='z';tn++)
		{
			if (f[n][tn-'a'+1][t1-'a'+1]>=n) continue;
			if (t1==tn)
			{
				T=f[n][tn-'a'+1][t1-'a'+1]*K+(K-1);
			}
			else
			{
				T=f[n][tn-'a'+1][t1-'a'+1]*K;
			}
			ans=min(ans,T);
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 896
#include <iostream>
#include <stdlib.h>
using namespace std;
int com(const void *a, const void *b)
{
	return *(int*)b-*(int*)a;
}

int main()
{
	int H[11]={0},*p=H;
	while(cin>>*p++)
	qsort(H,11,sizeof(int),com);
	cout<<H[0]<<endl;
	cout<<H[1]<<endl;
	cout<<H[2]<<endl;
	return 0;
}

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

const string YES = "YES";
const string NO = "NO";

void solve(std::string A, std::string B, std::string C) {
  if (A.back() == B.front() and B.back() == C.front()) {
      cout << YES;
  } else {
      cout << NO;
  }
  cout << endl;
}

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

  std::string A;
  std::cin >> A;
  std::string B;
  std::cin >> B;
  std::string C;
  std::cin >> C;
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char str[100100];

int main(){
    int n;
    scanf("%d%s", &n, str);
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (str[i] != str[i + 1]) cnt++;
    }
    printf("%d\n", cnt + 1);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#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 <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	int n,h;
	cin >> n >> h;
	vector<ll> a(n);
	vector<ll> b(n);
	ll a_max = 0;
	ll b_sum = 0;
	int ans = 0;
	rep(i, n) 
	{
		cin >> a[i] >> b[i]; 
		a_max = max(a_max, a[i]); 
	}
	rep(i,n) if(b[i]>a_max)b_sum += b[i];
	sort(ALL(b), greater<ll>());
	while (b_sum < h)
	{
		h -= a_max;
		ans++;
	}
	int i = 0;
	while (h > 0)
	{
		h -= b[i];
		ans++;
		i++;
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 1792
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int a,b,c;cin >> a >> b >> c;
    int ans=c-(a-b);
    if(ans<0)ans=0;
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 256
S=input()
L=len(S)

judge = 0

for i in range((L-1)//2):
    if S[i] != S[L-1-i]:
        judge = judge + 1
        
for i in range((L-1)//2):
    if S[i] != S[((L-1)//2)-1-i]:
        judge = judge + 1
    
if judge == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
H, W = [int(_) for _ in input().split()]
l = []
del_list_H = []
del_list_W = []
for i in range(H):
    l.append(list(input()))

for i in range(H):
    t = 0
    for j in range(W):
        if l[i][j] == '.':
            t += 1
    if t == W:
        del_list_H.append(i)

counter = len(del_list_H)
for i in range(counter):
    del l[del_list_H[i]]
    del_list_H = [x-1 for x in del_list_H]
    H -= 1

for i in range(W):
    t = 0
    for j in range(H):
        if l[j][i] == '.':
            t += 1
    if t == H:
        del_list_W.append(i)

counter = len(del_list_W)
for i in range(counter):
    for j in range(H):
        del l[j][del_list_W[i]]
    del_list_W = [x-1 for x in del_list_W]
    W -= 1


for i in range(len(l)):
    text = ''
    for j in range(len(l[i])):
        text += l[i][j]
    print(text)


Measured memory_bytes: 3192
x = int(input())
if x == 2:
    print(2)
    exit()
if x%2 == 0:
    x += 1
flag = True
while flag:
    flag = False
    for i in range(2, int(x**0.5)+2):
        if x % i == 0:
            flag = True
            break
    ans = x
    x += 2
print(ans)

Measured memory_bytes: 3188
//////////////////////////
//////////////////////////
////Please give me AC!////
////Please give me AC!////
//////////////////////////
//////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll A;
  string B;
  cin>>A>>B;
  ll c=(B.at(0)-'0')*100+(B.at(2)-'0')*10+B.at(3)-'0';
  cout<<A*c/100<<endl;
}

Measured memory_bytes: 3612
// Problem : C - Maximal Value
// Contest : AtCoder - AtCoder Beginner Contest 140
// URL : https://atcoder.jp/contests/abc140/tasks/abc140_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	vi v(N-1);
	F0R(x,N-1)
	{
		cin>>v[x];
	}
	ll sum=v.back();
	FORd(x,N-1,1)
	{
		sum+=min(v[x],v[x-1]);
	}
	sum+=v[0];
	cout<<sum<<endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    for(int i=0; i<=1000; i++) {
      int eight = (int)(i*0.08);
      int ten = (int)(i*0.1);
      if(eight == a && ten == b) {
        System.out.println(i);
        return;
      }
    }
    System.out.println(-1);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll mod = 1e9+7;
using P = pair<ll,ll>;
const int MAX = 1e6+1;
 
ll Pow(ll x, ll n){
  if(n == 0) return 1;
  if(n % 2 == 0) return Pow(x*x % mod, n/2);
  else return x * Pow(x,n-1) % mod;
}

void extgcd(ll a, ll b, ll &x, ll &y) {
  if(b == 0) {
    x = 1;
    y = 0;
    return;
  }
  extgcd(b, a%b, y, x);
  y -= a/b*x;
  return; 
}

ll mod_inverse(ll a, ll m) {
  ll x, y;
  extgcd(a,m,x,y);
  return (m + x % m) % m;
}
 
int main(){
  int n;
  cin >> n;
  ll a[n], c[n];
  rep(i,n) {
    cin >> a[i];
    c[i] = a[i];
  }
  vector<ll> m(MAX,0);
  rep(i,n) {
    for(ll l = 2; l*l <= a[i]; l++) {
      ll num = 0;
      while(c[i] % l == 0) {
        c[i] /= l;
        num++;
      }
      m[l] = max(num,m[l]);
    }
    if(c[i] > 1) {
      m[c[i]] = max(m[c[i]],(ll)1);
    }
  }
  ll l = 1;
  for(ll i = 2; i < MAX; i++) (l *= pow(i,m[i])) %= mod;
  ll ans = 0;
  rep(i,n) (ans += l*mod_inverse(a[i],mod)) %= mod;  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8320
#include <cstdio>
int main()
{
	int N = 0, S = 0, W = 0, E = 0;
	char c;
	while ((c = getchar()) != EOF)
	{
		switch(c)
		{
			case 'N': ++N; break;
			case 'S': ++S; break;
			case 'W': ++W; break;
			case 'E': ++E; break;
		}
	}
	if(N && S) N = S = 0;
	if(W && E) W = E = 0;
	puts((N||S||W||E)?"No":"Yes");
}

Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

int n, ans, A[MAXN];

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    ans = A[0];

    for (int i = 1; i < n; i++) {
        ans = gcd(ans, A[i]);
    }

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

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int x, y;
	
	while(1){
	    scanf("%d %d", &x, &y);
	    
	    if(x == 0 && y == 0) break;
	    
	    if(x > y){
	        printf("%d %d\n", y, x);
	        
	    }else{
	        printf("%d %d\n", x, y);
	    }
	}
	return 0;
}



Measured memory_bytes: 2016
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
  ll a;
  string b;
  cin >>a>>b;
  ll tmp1,tmp2,tmp3;
  tmp1=(ll)(b.at(0)-'0')*100;
  tmp2=(ll)(b.at(2)-'0')*10;
  tmp3=(ll)(b.at(3)-'0');
  ll b100=tmp1+tmp2+tmp3;
  ll ans=a*b100/100;
  cout <<ans<<endl;
}


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

using namespace std;

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

	long long n, k;
	cin >> n >> k;

	vector<long long> v(n), a(n);
	for(long long i = 0; i < n; i++){
		cin >> v[i];
	}

	a[0] = 0;
	a[1] = abs(v[1]-v[0]);

	for(long long i = 2; i < n; i++){
		a[i] = 1000000000;
		for(long long j = 1; j <= min(i, k); j++){
			a[i] = min(a[i], abs(v[i]-v[i-j])+a[i-j]);
		}
	}

	cout << a[n-1]; 

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    ll a, offset, unko1, b, c, unko2, unko3;
    cin >> a >> offset >> unko1 >> b >> c >> unko2 >> unko3;
    ll ans = offset;
    ll ma = 0;
    for (int i = 0; i < 2; i++) {//1,1,1
        for (int j = 0; j < 1; j++) {//1,2,0
            for (int k = 0; k < 1; k++) {//1,0,2
                int na = a-i-j-k;
                int nb = b-i-2*j;
                int nc = c-i-2*k;
                if (na < 0 || nb < 0 || nc < 0) continue;
                ll buf = (i+j+k)*3;
                buf += na/2*2;
                buf += nb/2*2;
                buf += nc/2*2;
                ma = max(ma, buf);
            }
        }
    }
    cout << ans+ma << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define SENTINEL 1000000000

int count=0,A[500000];

void Merge(int left, int mid, int right){
  int n1 = mid-left;
  int n2 = right-mid;
  int L[n1],R[n2];
  int i,j,k;
  for (i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for (i=0;i<=n2-1;i++){
    R[i]=A[mid+i];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  /*
  printf("L[");
  for (i=0;i<=n1;i++){
    if (i!=0){
      printf(" ");
    }
    printf("%d",L[i]);
  }
  printf("]\n");
  printf("R[");
  for (i=0;i<=n2;i++){
    if (i!=0){
      printf(" ");
    }
    printf("%d",R[i]);
  }
  printf("]\n");
  */
  for (k=left;k<=right-1;k++){
    count++;
    if (L[i]<=R[j]){
      A[k]=L[i];
      i++;
    } else {
      A[k]=R[j];
      j++;
    }
  }
}

void MergeSort(int left, int right){
  int mid;
  if (left+1<right){
    mid = (left+right)/2;
    MergeSort(left,mid);
    MergeSort(mid,right);
    Merge(left,mid,right);
  }
}

int main(){
  int i,n;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  MergeSort(0,n);
  for (i=0;i<n;i++){
    if(i!=0){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	string s, t;
	cin >> s >> t;
	int ss = s.size();
	int tt = t.size();
	
	int ans = INF;
	rep(i, ss - tt + 1) {
		int cnt = tt;
		rep(j, tt) if (s[i + j] == t[j])cnt--;
		ans = min(ans, cnt);
	}
	cout << ans << endl;

}

Measured memory_bytes: 3596
n = int(input())
a = [int(input()) for _ in range(n)]
d = [{x: 0 for x in a} for _ in range(2)]
b = sorted(a)
for i in range(n):
    if i % 2:
        d[0][a[i]] += 1
        d[1][b[i]] += 1
t1 = 0
t2 = 0
for v1, v2 in zip(d[0].values(), d[1].values()):
    if v1 > v2:
        t1 += v1 - v2
print(t1)

Measured memory_bytes: 25492
#include<bits/stdc++.h>
using namespace std;
int mod;
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=1ll*res*b%mod;
		b=1ll*b*b%mod; n>>=1;
	}
	return res;
}
int f[2][105][105],pw[105][10005],C[105][105];
void init(int n){
	for(int i=0;i<=n;++i){
		pw[i][0]=1;
		for(int j=1;j<=n*n;++j)
			pw[i][j]=1ll*pw[i][j-1]*i%mod;
	}
	C[0][0]=1;
	for(int i=1;i<=n;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
}
void add(int &x,int y){
	x=(x+y)%mod;
}
signed main(){
	int n,m,K;
	cin>>n>>m>>K>>mod;
	init(100);
	f[0][0][0]=1;int u=0;
	for(int k=1;k<=K;++k){
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				if(f[u][i][j]){
					int now=f[u][i][j],Pw=1ll*pw[k][m-j]*pw[K-k+1][j]%mod;
					for(int a=0;i+a<=n;++a)
						add(f[u^1][i+a][j],1ll*now*C[n-i][a]%mod),now=1ll*now*Pw%mod;	
				}
		u^=1;
		memset(f[u^1],0,sizeof(f[u^1]));
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				if(f[u][i][j]){
					int now=f[u][i][j],Pw=1ll*pw[k][n-i]*pw[K-k+1][i]%mod;
					for(int b=0;j+b<=m;++b)
						add(f[u^1][i][j+b],1ll*now*C[m-j][b]%mod),now=1ll*now*Pw%mod;
				}
		u^=1;
		memset(f[u^1],0,sizeof(f[u^1]));
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				if(f[u][i][j]){
					int tmp,now=f[u][i][j],Pw=1ll*pw[k][m-j]*pw[K-k][j]%mod;
					for(int a=0;i+a<=n;++a)
						tmp=1ll*now*C[n-i][a]%mod,
						add(f[u^1][i+a][j],(a&1?mod-tmp:tmp)),
						now=1ll*now*Pw%mod;							
				}
		u^=1;
		memset(f[u^1],0,sizeof(f[u^1]));
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				if(f[u][i][j]){
					int tmp,now=f[u][i][j],Pw=1ll*pw[k][n-i]*pw[K-k][i]%mod;
					for(int b=0;j+b<=m;++b)
						tmp=1ll*now*C[m-j][b]%mod,
						add(f[u^1][i][j+b],(b&1)?mod-tmp:tmp),
						now=1ll*now*Pw%mod;
				}	
		u^=1;
		memset(f[u^1],0,sizeof(f[u^1]));
	}
	cout<<f[u][n][m];
	return 0;
}


Measured memory_bytes: 7624
#include <iostream>
#include <math.h>
using namespace std;

int main(void)
{
    long long x; cin >> x;
    long long a, b, a_5, b_5;
    for (a = 1; a < 1000; a++)
    {
        a_5 = pow(a, 5);
        if (a_5 > x)
        {
            for (b = 0; b < 1000; b++)
            {
                b_5 = pow(b, 5);
                if (a_5 - b_5 == x)
                {
                    cout << a << " " << b << endl;
                    return 0;
                }
            }
        }
        else
        {
            for (b = 0; b < 1000; b++)
            {
                b_5 = - pow(b, 5);
                if (a_5 - b_5 == x)
                {
                    cout << a << " " << -b << endl;
                    return 0;
                }
            }
        }
    }
}

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

int main() {
	int n = 0;
	string s(4,'z');
	cin >> s;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') {
			n++;
		}
		else if(s[i]=='-'){
			n--;
		}
	}
	cout << n << endl;


	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

Ans = 0

for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            if 500*l + 100*m + 50*n == X:
                Ans += 1
                continue

print(Ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>ac(n, 0), acsum(n + 1,0);
	for (int i = 0; i < n-1; i++) {
		if (s.substr(i, 2) == "AC") {
			ac[i]++;
			i++;
		}
	}
	rep(i, n)acsum[i + 1] = acsum[i] + ac[i];
	int l, r;
	rep(i, q) {
		cin >> l >> r;
		cout << acsum[r-1] - acsum[l-1] << endl;
	}
	return 0;
}



Measured memory_bytes: 4308
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,input().split())
query = list(map(int,input().split()))[1:]
#print(query)
ans = 0
cnt = [0]*len(query)
if n == 1: 
    print(len(query))
    exit(0)
for j in range(n-1):
    a_j  = list(map(int,input().split()))[1:]
    for i in range(len(query)):
        if query[i] in a_j: cnt[i] += 1
        if cnt[i] == n-1: ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0), b(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  long long int count = 0;
  for (int i = 0; i < n; ++i) {
    if(a[i] < b[i])
    {
      count += (long long int)(floor((b[i] - a[i]) * 0.5));
    }else{
      count -= a[i] - b[i];
    }
  }
  if(count >= 0)
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    var (a, b, c) = readInputLine().split(" ").map { it.toInt() }

    var ans = 0
    
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        val newA = b / 2 + c / 2
        val newB = a / 2 + c / 2
        val newC = a / 2 + b / 2
        
        a = newA
        b = newB
        c = newC
        
        ans++
        
        if (ans == 100000000) {
            println(-1)
            return
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 38112
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    sort(arr,arr+n);

    long double ans=((arr[0]+arr[1])*1.0)/2;
    for(int i=2;i<n;i++){
        ans=((ans+arr[i])*1.0)/2;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector< ii > vii;
typedef long long LL;
const int maxn = 2005;
int par[maxn];
int dist[maxn];
int n, k;
vector<int> adj[maxn];
void dfs(int u, int p)
{
	par[u] = p;
	for(auto v : adj[u])
	{
		if(v == p) continue;
		dfs(v, u);
	}
}
int solve(int u1, int u2)
{
	fill(dist, dist+n+1, 1e9);
	queue<int> Q;
	Q.push(u1); Q.push(u2);
	dist[u1] = dist[u2] = 0;
	while(!Q.empty())
	{
		int u = Q.front(); Q.pop();
		for(auto v : adj[u])
		{
			if(dist[v]> dist[u]+1)
			{
				dist[v] = dist[u]+1;
				Q.push(v);
			}
		}
	}
	int cnt = 0;
	for(int i = 1; i<= n; i++)
	{
		if(dist[i]> k/2) cnt++;
	}
	return cnt;
}
int main()
{
	scanf("%d %d", &n, &k);
	for(int i = 0; i< n-1; i++)
	{
		int a, b; scanf("%d %d", &a, &b);
		adj[a].pb(b);
		adj[b].pb(a);
	}
	dfs(1, 0);
	int res = 1e9;
	if(k%2 == 0) res = min(res, solve(1, 0));
	for(int i = 2; i<= n; i++)
	{
		if(k%2 == 0) res = min(res, solve(i, 0));
		else res = min(res, solve(i, par[i]));
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 1;
		for(int i=0; i < n; i++){
			long num = sc.nextInt();
			System.out.println("Case " + count++ +":");
			for(int j=0; j < 10; j++){
				if(num == 0){
					num = 1;
				}
				else{
					num = num * num;
				}
				num = num / 100;
				num = num % 10000;
				System.out.println(num);
			}
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 11000
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    int N, K;
    io >> N >> K;
    vi A(N);
    for (int i = 0; i < N; i++)
        io >> A[i];

    for (int i = 0; i < N - K; i++)
    {
        io << YesNo(A[i] < A[i+K]) << BR;
    }
}

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

int main(){
  int N;cin>>N;
  int dp[110000];
  for(int i=0;i<110000;i++)  dp[i]=1000000000;
  int h[N];
  for(int i=0;i<N;i++) cin>>h[i];
  
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  //cout<<dp[0]<<endl<<dp[1]<<endl;
  
  for(int i=2;i<N;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    //cout<<dp[i]<<endl;
  }
  
  cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
typedef long long int ll;
char a[11];
ll as(int b, ll c, ll d){
	if(a[b]=='\0') return c+d;
	else return as(b+1, c*10+a[b]-'0',d)+as(b+1,a[b]-'0',d+c);
}
int main(){
	scanf("%s",a);
	printf("%lld",as(1,a[0]-'0',0));
	return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(2000005);


//nPk
 mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}




//組み合わせの数nCrを計算
   int calcNumOfCombination(int n, int r){
       int num = 1;
       for(int i = 1; i <= r; i++){
           num = num * (n - i + 1) / i;
       }
       return num;
   }
   mint g(int r, int c) {
     return comb(r+c+2, r+1) - 1;
   }
int main() {
  ios::sync_with_stdio(false);
	cin.tie(0);
  int r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;
  r1--;c1--;
  mint n=comb(6,3);
//  cout<<n.x;

  mint g1=comb(r1+c1+2,r1+1);


  mint g2=comb(r2+c2+2,r2+1);

  mint g3=comb(r2+c1+2,r2+1);
  mint g4=comb(r1+c2+2,r1+1);
  mint ans=g2;
//  cout<<ans;
  ans-=g3;
  ans-=g4;
  ans+=g1;
//  ans+=1;
  cout<<ans.x;


}


Measured memory_bytes: 31488
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

	int n;
	cin >> n;

	vector<int>a(n);
	for (auto &x : a)
		cin >> x;

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

	cout << a[n - 1] - a[0] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {sws;

    int n;
    cin >> n;
    int abc[100005][3];
    fo(i, n) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

    int dp[100005][3];
    fo(i, 3) dp[0][i] = abc[0][i];

    for ( int i = 1; i < n; i++ ) {
        fo(j, 3) {
            dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + abc[i][j];
        }
    }

    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;

    return 0;
}

Measured memory_bytes: 5964
x=input()
A=x.split()
S=[]
L=[]
for i in A:
    s=A.count(i)
    S.append(s)
    l=len(i)
    L.append(l)
M=max(S)
m=max(L)
Y=S.index(M)
y=L.index(m)
print(A[Y],A[y])


Measured memory_bytes: 5560
// C++ program to compute LCM of array elements modulo M 
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 

typedef long long ll; 
const ll mod = 1000000007; 

ll prime[MAX]; 
unordered_map<ll, ll> max_map; 

// Function to return a^n 
ll power(ll a, ll n) 
{ 
	if (n == 0) 
		return 1; 
	ll p = power(a, n / 2) % mod; 
	p = (p * p) % mod; 
	if (n & 1) 
		p = (p * a) % mod; 
	return p; 
} 

// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
	prime[0] = prime[1] = 1; 
	for (ll i = 2; i < MAX; i++) { 
		if (prime[i] == 0) { 
			for (ll j = i * 2; j < MAX; j += i) { 
				if (prime[j] == 0) { 
					prime[j] = i; 
				} 
			} 
			prime[i] = i; 
		} 
	} 
} 

// Function to return the LCM modulo M 
ll lcmModuloM(const ll* ar, ll n) 
{ 

	for (ll i = 0; i < n; i++) { 
		ll num = ar[i]; 
		unordered_map<ll, ll> temp; 

		// Temp stores mapping of prime factor to 
		// its power for the current element 
		while (num > 1) { 

			// Factor is the smallest prime factor of num 
			ll factor = prime[num]; 

			// Increase count of factor in temp 
			temp[factor]++; 

			// Reduce num by its prime factor 
			num /= factor; 
		} 

		for (auto it : temp) { 

			// Store the highest power of every prime 
			// found till now in a new map max_map 
			max_map[it.first] = max(max_map[it.first], it.second); 
		} 
	} 

	ll ans = 1; 

	for (auto it : max_map) { 

		// LCM is product of primes to their highest powers modulo M 
		ans = (ans * power(it.F, it.S)) % mod; 
	} 

	return ans; 
} 

// Driver code 
int main() 
{ 
	sieve(); 
	ll n;
	cin >> n;
	ll *arr = new ll[n];
	for(ll i=0 ; i<n ; i++)
		cin >>arr[i];

	ll lAns = lcmModuloM(arr , n);
	ll ans = 0;
	for(int i=0 ; i<n ; i++)
	{
	    ans = (ans + (lAns * power(arr[i],mod-2))%mod)%mod;
	}
	
	cout << ans;
	return 0; 
} 


Measured memory_bytes: 78848
//
// Created on 2020/09/26.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    int k;
    cin>>k;
    for (int i = 0; i < k; ++i) {
        cout<<"ACL";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3584
fn solve(s: &str) -> bool{
    let n = s.len();

    let s = s.chars().collect::<Vec<char>>();

    for i in 0..n {
        if i % 2 == 0 && s[i] == 'L' {
            return false;
        }
        if i % 2 == 1 && s[i] == 'R'{
            return false;
        }
    }

    return true;
}


fn main(){
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.pop();


    let ans = solve(&s);
    match ans {
        true => println!("Yes"),
        false => println!("No")
    }
}


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

typedef long long ll;

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

    int n;
    cin>>n;
    int ans = 0;
    int a = 1, b=9;
    while (1){
        if (n>=a){
            if (n>b) ans += (b-a+1);
            else ans += (n-a+1);
        }
        else break;
        a = a*100;
        b = b*100 + 99;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, K;
set<int> st;

int dfs(int lev, int s) {
    if (s >= N) return s;
    int res = 1LL << 30;
    if (lev == 5) return res;
    for (int d : st) res = min(res, dfs(lev + 1, s * 10 + d));
    return res;
}

void _main() {
    cin >> N >> K;
    REP (i, 10) st.insert(i);
    REP (i, K) {
        int D;
        cin >> D;
        st.erase(D);
    }
    cout << dfs(0, 0) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main(void) {
  int index = 0;
  string S, ANS = "keyence";
  cin >> S;

  if (S.find(ANS) != string::npos) {
    goto yes;
  }
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == ANS[index])
      index++;
    else
      break;
  }
  if (S.substr(S.length() - (ANS.length() - index)) == ANS.substr(index)) {
    goto yes;
  }

  cout << "NO" << endl;
  return 0;
yes:
  cout << "YES" << endl;
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  vector<int> a;
  rep(i, n)
  {
    int tmp;
    cin >> tmp;
    
    a.push_back(tmp);
  }
  
  bool result = true;
  rep(i, n)
  {
    if (0 == a[i] % 2)
    {
      if((0 == a[i] % 3) || (0 == a[i] % 5))
      {
        result == true;
      }
      else
      {
        result = false;
      }
    }
  }
  
  if (result)
  {
    printf("APPROVED");
  }
  else
  {
    printf("DENIED");
  }
    
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count = 0
b = []
c = [] 

for i in range(len(a)):
    if a[i]!=i+1:
        count = count + 1
        b.append(i+1)
        c.append(a[i])
        
if count == 0:
    print('YES')
elif count == 2 and b[0] == c[1] and c[0] == b[1]:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
def main():
    n, factor = getInputs()

    points = []
    for i in range(n):
        points.append([0] * 3)

    # points[day][pile]
    for pile in range(3):
        points[0][pile] = factor[0][pile]

    for day in range(1, n):
        points[day][0] = max(points[day - 1][1], points[day - 1][2]) + factor[day][0]
        points[day][1] = max(points[day - 1][0], points[day - 1][2]) + factor[day][1]
        points[day][2] = max(points[day - 1][0], points[day - 1][1]) + factor[day][2]

    print(max(points[-1]))

def getInputs():
    n = int(input())

    factor = []
    for i in range(n):
        factor.append(tuple(map(lambda x: int(x), input().split())))

    return n, factor

main()


Measured memory_bytes: 105980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    cout << (3 * a + p) / 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int card[4][14]={0};
    char c;
    int n,a,i,j=0;
    
    scanf("%d",&n);
    for(i=0;i<n*2;i++){
        //printf("%d",i);
        scanf("%c %d",&c,&a);
        if(c =='S'){
            card[0][a]=a;
        }else if(c == 'H'){
            card[1][a]=a;
        }else if(c == 'C'){
            card[2][a]=a;
        }else if(c == 'D'){
            card[3][a]=a;
        }
    }
    for(i=0; i<4; i++){
        for(j=1; j<14; j++){
            if(i==0){
                if(card[0][j] == 0){
                    printf("S %d\n",j);
                }
            }else if(i==1){
                if(card[1][j] == 0){
                    printf("H %d\n",j);
                }
            }else if(i==2){
                if(card[2][j] == 0){
                    printf("C %d\n",j);
                }
            }else if(i==3){
                if(card[3][j] == 0){
                    printf("D %d\n",j);
                }
            }
            
        }
        
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>



int main()
{
	std::string s;

	std::cin >> s;

	if (std::find(s.begin(), s.end(), '9') != s.end()) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}

	





	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int M, x;

  cin >> M;

  if(1 <= M && M <= 23){
      x = 48 - M;
  }
  else{
      cout << "Input Error" <<endl;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;



int32_t main(){
    vaibhavv06;
	string s,t; cin>>s>>t;
	cout<<t+s<<endl;
}

Measured memory_bytes: 764
from sys import stdin

X = [ 0 for i in range(100) ]
d = [ 0 for i in range(100) ]
G = [[ 0 for i in range(100) ] for i in range(100)]
queue = [ 0 for i in range(100) ]

t = 0
head = 0
tail = 0

def BFS(i) :
	global head
	for j in range(n) :
		if G[i][j] == 1 and d[j] == -1 :
			d[j] = d[i] + 1
			queue[head] = j
			head += 1

def tailQ() :
	global tail
	tail += 1
	return queue[tail-1]


n = int(input())
for i in range(n) :
	X[i] = stdin.readline().strip().split()


for i in range(n) :
	for j in range(int(X[i][1])) :
		G[int(X[i][0])-1][int(X[i][j+2])-1] = 1
	if i != 0 : d[i] = -1

BFS(0)
while head-tail != 0 : 
	BFS(tailQ())

for i in range(n) : print(i+1,d[i])
 

Measured memory_bytes: 6768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,m,tree[300005];
struct node{int l,r,len;}q[300005];
bool cmp(node t1,node t2){return t1.len<t2.len;}
int lowbit(int x){return x&-x;}
void add(int x,int y){for (int i=x;i<=m;i+=lowbit(i))tree[i]+=y;}
int query(int x){int s=0;for (int i=x;i>0;i-=lowbit(i))s+=tree[i];return s;}
int main()
{
   scanf("%d%d",&n,&m);
   for (int i=1;i<=n;i++)
      scanf("%d%d",&q[i].l,&q[i].r),q[i].len=q[i].r-q[i].l+1;
   sort(q+1,q+n+1,cmp);
   for (int i=1,k=1;i<=m;i++)
   {
      for (;(k<=n && q[k].len<i);k++)
         add(q[k].l,1),add(q[k].r+1,-1);
      int ans=n-k+1; 
      for (int j=i;j<=m;j+=i) ans+=query(j);
      printf("%d\n",ans);
   }
   return 0; 
}

Measured memory_bytes: 4992
// CODE © by 𝕌𝕥𝕜𝕒𝕣𝕤𝕙 𝔾𝕒𝕣𝕘
// Copying or sharing of this code without permission of the Author is strictly prohibited!!!
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Speed ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define endl "\n"
int power(int x, int n, int mod) {int res = 1; x %= mod; while (n) {if (n & 1)res = (res * x) % mod; x = (x * x) % mod; n >>= 1;} return res;}
int dp[3001][3001];
int f(int arr[], int si, int ei, int ch, int t) {
	if (dp[si][ei] != INT_MIN)return dp[si][ei];
	if (ch == 0) {
		// if (ei == 0)return arr[ei];
		// if (si == t - 1)return arr[si];
		if (si == ei)return arr[si];
		int a1, a2;
		if (dp[si + 1][ei] == INT_MIN)dp[si + 1][ei] = f(arr, si + 1, ei, 1, t);
		if (dp[si][ei - 1] == INT_MIN)dp[si][ei - 1] = f(arr, si, ei - 1, 1, t);
		a1 = arr[si] + dp[si + 1][ei];
		a2 = arr[ei] + dp[si][ei - 1];
		// cout << "ans by removing " << arr[si] << " is " << a1 << endl;
		// cout << "ans by removing " << arr[ei] << " is " << a2 << endl;
		return max(a1, a2);
	}
	if (ch == 1) {
		// if (si == t - 1)return (-1 * arr[si]);
		// if (ei == 0)return (-1 * arr[ei]);
		int a1, a2;
		if (si == ei)return (-1 * arr[si]);
		if (dp[si + 1][ei] == INT_MIN)dp[si + 1][ei] = f(arr, si + 1, ei, 0, t);
		if (dp[si][ei - 1] == INT_MIN)dp[si][ei - 1] = f(arr, si, ei - 1, 0, t);
		a1 = -1*arr[si] + dp[si + 1][ei];
		a2 = -1*arr[ei] + dp[si][ei - 1];
		return min(a1, a2);
	}
}
signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif
	int a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, t = 0, n = 0, q = 0;
	for(int i=0;i<=3000;i++)for(int j=0;j<=3000;j++)dp[i][j]=INT_MIN;
	cin >> n;
	int arr[n];
	for (i = 0; i < n; i++) {cin >> arr[i]; }
	// for(int i=0;i<n;i++)cout<<arr[i]<<" ";
	cout << f(arr, 0, n - 1, 0, n);
}

Measured memory_bytes: 74264
import kotlin.math.abs

fun main(args: Array<String>){

    val (a,b,h,m) = readLine()!!.split(" ").map { it.toInt() }

    val mm = Math.PI * 2 / 60.0 * m
    val hh = Math.PI * 2 * h / 12.0 + Math.PI * 2 / 12.0 * m / 60.0

    val c2 = a * a + b * b -2 * a * b * Math.cos(abs(mm - hh))
    print(Math.sqrt(abs(c2)))
}



Measured memory_bytes: 36588