akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void){
  int m,n,i,f[1001],a[1001],c,t;
  char s[15];
  while(1){
    scanf("%d %d",&m,&n);
    if(m+n==0)break;
    for(i=1;i<=m;i++)
      f[i]=1;
    c=0;
    t=m;
    for(i=1;i<=n;i++){
      scanf("%s",s);
      c++;
      while(f[c]==0){
	if(c==m)
	  c=0;
	c++;
      }
      if(t>1){
	if(i%15==0){
	  if(strcmp(s,"FizzBuzz")!=0){
	    f[c]=0;
	    t--;
	  }
	}
	else if(i%3==0){
	  if(strcmp(s,"Fizz")!=0){
	    f[c]=0;
	    t--;
	  }
	}
	else if(i%5==0){
	  if(strcmp(s,"Buzz")!=0){
	    f[c]=0;
	    t--;
	  }
	}
	else{
	  if(atoi(s)!=i){
	    f[c]=0;
	    t--;
	  }
	}
      }
      if(c==m)
	c=0;
    }
    c=0;
    for(i=1;i<=m;i++){
      if(f[i])
	a[c++]=i;
    }
    for(i=0;i<c-1;i++)
      printf("%d ",a[i]);
    printf("%d\n",a[i]);
  }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
#define V vector<int>
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)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;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, n - 2) {
		V tmp(3);
		int tmp2 = a[i + 1];
		tmp[0] = a[i], tmp[1] = a[i + 1], tmp[2] = a[i + 2];
		sort(tmp.begin(), tmp.end());
		if (tmp2 == tmp[1]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
a = 'abcdefghijklmnopqrstuvwxyz'

s = list(s)
a = list(a)

for i in range(0,len(s)):
  if(s[i] in a):
    k = a.index(s[i])
    del a[k]

if(len(a) == 0):
  print("None")
else:
  print(a[0])

Measured memory_bytes: 49392
import Data.List (inits, tails)


contSubSeqs :: String -> [String]
contSubSeqs = concatMap inits . tails


isACGTStr :: String -> Bool
isACGTStr = all (\c -> c == 'A' || c == 'C' || c == 'G' || c == 'T')


lenOfLongestACGTSTr :: String -> Int
lenOfLongestACGTSTr = maximum . fmap length . filter isACGTStr . contSubSeqs

main :: IO ()
main = do
    s <- getLine
    print $ lenOfLongestACGTSTr s

Measured memory_bytes: 508
n = gets.chomp.to_i
nums = gets.chomp.split(" ").map(&:to_i)
flag = true

(0...n).each do |i|
  if nums[i].even?
    if nums[i] % 3 == 0 || nums[i] % 5 == 0
      flag = true
    else
      flag = false
      break
    end
  end
end

if flag
  puts 'APPROVED'
else
  puts 'DENIED'
end

Measured memory_bytes: 3836
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0001

#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int d[10] = { 0 };
	for (int i = 0; i < 10;i++) cin >> d[i];
	sort(d, d + 10);
	reverse(d, d + 10);
	cout << d[0] << endl << d[1] << endl << d[2] << endl;
}

Measured memory_bytes: 3148
import itertools
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        d = list(map(int, input().split()))

        ans = 0
        for comb in itertools.combinations(d, 2):
            ans += comb[0] * comb[1]

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


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

di = len(str(n))
ans = sum([int(w)for w in str(n)])

for i in range(di):
    digits = [int(w)for w in str(n)]
    if digits[i] == 0:
        continue
    t = sum(digits[0:i])

    t += digits[i]-1
    t += 9 * (di - i - 1)
    ans = max(ans, t)

print(ans)


Measured memory_bytes: 9120
#include <stdio.h>
using namespace std;

int main()
{
    int N, x;
    int even = 0;
    int odd4 = 2;
    int odd2 = 0;
    bool flag_odd = false;
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i) {
        scanf("%d", &x);
        if (x % 2 == 1) {
            ++even;
        }
        if (x % 2 == 0 && x % 4 != 0 && flag_odd == false) {
            ++even;
            flag_odd = true;
        }
        if (x % 4 == 0) {
            ++odd4;
        }
    }
    if (odd4 > even) {
        printf("Yes");
    } else {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
 
struct intree{
  int parent;
	int left;
	int right;
};
 
 
int main(void){
  	int n,i,j,k,id,left,child,depth,key;
	struct intree list[100000];
 
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    list[i].parent=-1;
    list[i].left=-1;
  	list[i].right=-1;
  }  
   
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
      for(j=0;j<k;j++){
  		scanf("%d",&child);
      	if(j==0){
      		list[id].left=child;
      		list[child].parent=id;
      	}
      	else{
      		list[left].right=child;
      		list[child].parent=id;
      	}
  	left=child;
      }
  }
      	
	 for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",list[i].parent);
    key=i;
	 	depth=0;
	 	while(list[key].parent!=-1){
	 		key=list[key].parent;
	 		depth++;
	 	}
	 	printf("depth = %d, ",depth);  
    
	 	if(list[i].parent==-1) printf("root, ");
    else if(list[i].left==-1 && list[i].parent!=-1) printf ("leaf, ");
    else printf("internal node, ");
    printf("[");
	 	
	 	if(list[i].left!=-1){
	 		key=list[i].left;
	 		printf("%d",list[i].left);
	 		while(list[key].right!=-1){
	 			printf(", %d",list[key].right);
	 			key=list[key].right;
	 		}
	 	}
	 	printf("]\n");
	 	
	 }
  return 0;
}

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

int twoMul(int num, int count) {
    int ans = num;
    for(int i = 0;i < count;i++) {
        ans *= 2;
    }
    return ans;
}
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int a, b, c;
   int k;
   cin >> a >> b >> c >> k;
   if(a>b) {
       if(a>c) {
           cout << twoMul(a, k) + b +c << endl;
       } else {
           cout << a+b+twoMul(c, k) << endl;
       }
   } else {
       if(b>c) {
           cout << a+twoMul(b, k)+c << endl;
       } else {
           cout << a+ b + twoMul(c, k) << endl;
       }
   }
}



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

const int N = 2005;

int arr[N][N];
int suff[N][N][2];
vector<int> hist;

int getMaxArea()
{
    stack<int> s;
    int max_area = 0,tp,area_with_top,i = 0,n = hist.size();
    while (i < n)
    {
        if (s.empty() || hist[s.top()] <= hist[i])
            s.push(i++);
        else
        {
            tp = s.top();  
            s.pop();  
            area_with_top = hist[tp] * (s.empty() ? i + 1 : i - s.top());
            if (max_area < area_with_top)
                max_area = area_with_top;
        }
    }
    while (s.empty() == false)
    {
        tp = s.top();
        s.pop();
        area_with_top = hist[tp] * (s.empty() ? i + 1 : i - s.top());
        if (max_area < area_with_top)
            max_area = area_with_top;
    }
    return max_area;
}

int main(){
	int i, j, n, m, ans = -1;
	string s;
	scanf("%d %d", &n, &m);
	for(i = 1; i <= n; i++){
		cin >> s;
		for(j = 1; j <= m; j++)
			arr[i][j] = (s[j - 1] == '.');
	}
	for(j = 1; j <= m; j++){
		for(i = 1; i <= n; i++){
			if(j == 1){
				suff[i][j][0] = i;
				suff[i][j][1] = i;
				continue;
			}
			suff[i][j][0] = (suff[i - 1][j][0] + 1) * (arr[i][j] == arr[i][j - 1]);
			suff[i][j][1] = (suff[i - 1][j][1] + 1) * (arr[i][j] != arr[i][j - 1]);
		}
	}
    for(i = 1; i <= n; i++){
    	hist.clear();
    	for(j = 2; j <= m; j++)
    		hist.push_back(suff[i][j][arr[i][j] != arr[i][j - 1]]);
    	ans = max(ans, getMaxArea());
    }
    ans = max(ans, max(n, m));
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 47360
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
    int n;
	int a[11000],b[11000],c[11000],d[11000];
	int t[11000],k[11000];
	cin>>n;
	for(int i=0;i<(n*(n-1))/2;i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		t[i]=0;
	}
	for(int i=0;i<(n*(n-1))/2;i++){
		if(c[i]>d[i])
			t[a[i]]+=3;
		if(c[i]<d[i])
			t[b[i]]+=3;
		if(c[i]==d[i]){
			t[a[i]]++;
			t[b[i]]++;
		}
	}
	int j=1;
	int h=0;
	for(int g=n*3;g>=0;g--){
		for(int i=1;i<n+1;i++){
			if(g==t[i]){
				k[i]=j;
				h++;
			}
		}
		j+=h;
		h=0;
    }
	for(int i=1;i<n+1;i++){
		cout<<k[i]<<endl;
	}
    return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28, lg = 41;
long long a[maxn], ans;
int main(){
	int n;
	long long m;
	long long x = 0;
	cin >> n >> m;
	for(int i = 0; i < n; i++)	
		cin >> a[i];
	for(int i = lg; i >= 0; i--){
		int ones = 0, zeros = 0;
		for(int j = 0; j < n; j++)
			if(a[j] & ((long long)1 << i))
				ones ++;
			else
				zeros ++;
		
		if(ones < zeros && (x + ((long long) 1 << i)) <= m){
			x += ((long long)1 << i);
		}
	}
	for(int i = 0; i < n; i++)
		ans += (a[i] ^ x);
	cout << ans;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] defargs) {
        Scanner scanner = new Scanner(System.in);
        int integer = scanner.nextInt();
        int integer1 = scanner.nextInt();
        if (integer < integer1){
            System.out.println("a < b");
            } else if(integer > integer1){
                System.out.println("a > b");
            }else{
                System.out.println("a == b");
            }
    }
}



Measured memory_bytes: 26412
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> dat(n);
  for (int i = 0; i < n; i++) scanf("%d", &dat[i]);
  long long total = accumulate(dat.begin(), dat.end(), 0ll);
  long long sum = 0;
  long long ans = LLONG_MAX;
  for (int i = 0; i + 1 < n; i++) {
    sum += dat[i];
    long long other = total - sum;
    ans = min(ans, llabs(other - sum));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int N;
string S;

vector<int> R,G,B;

ll cal(const vector<int>& a, const vector<int>& b, const vector<int>& c)
{	
	ll res = 0;
	for(int i=0;i<a.size();++i){
		int iidx = a[i];
		auto iter1 = upper_bound(b.begin(),b.end(),iidx);
		if(iter1 == b.end()) break;
		for(int j=iter1-b.begin();j<b.size();++j){
			int jidx = b[j];
			const int d = jidx - iidx;
			auto iter2 = upper_bound(c.begin(),c.end(), jidx);
			if(iter2 == c.end()) break;
			res += (c.end() - iter2);
			if(binary_search(c.begin(),c.end(),jidx+d)) res--;
		}
	}
	return res;
}

void solve()
{
	ll ans = 0;
	for(int i=0;i<N;++i){
		if(S[i]=='R') R.pb(i);
		else if(S[i]=='G') G.pb(i);
		else B.pb(i);
	}
	ans += cal(R,G,B);
	ans += cal(R,B,G);
	ans += cal(G,R,B);
	ans += cal(G,B,R);
	ans += cal(B,R,G);
	ans += cal(B,G,R);
	cout << ans << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> S;
	solve();
	return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#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)
constexpr int MOD = 1000000007;
int main()
{
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()

a = 0 if n <= 1 else n*(n-1)//2
b = 0 if m <= 1 else m*(m-1)//2

print(a+b)

Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int N,M,Q;
vector<int>hen[SIZE];
vector<int> color,dist,v;
int dp[15][SIZE];
int main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		hen[a].pb(b);hen[b].pb(a);
	}
	cin>>Q;
	for(int i=1;i<=N;i++)for(int j=0;j<=10;j++)dp[j][i]=Q;
	for(int i=0;i<Q;i++){
		int vv,c,d;
		cin>>vv>>d>>c;
		v.pb(vv);
		color.pb(c);
		dist.pb(d);
		dp[d][vv]=Q-1-i;
	}
	/*for(int i=0;i<=10;i++){
		for(int j=1;j<=N;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	for(int x=9;x>=0;x--){
		for(int i=1;i<=N;i++){
			dp[x][i]=min(dp[x][i],dp[x+1][i]);
			for(int j=0;j<hen[i].size();j++){
				int to=hen[i][j];
				dp[x][i]=min(dp[x+1][to],dp[x][i]);
			}
		}
	}
	/*for(int i=0;i<=10;i++){
		for(int j=1;j<=N;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	for(int i=1;i<=N;i++){
		if(dp[0][i]==Q)cout<<"0"<<endl;
		else cout<<color[Q-1-dp[0][i]]<<endl;
	}
}

Measured memory_bytes: 13688
#include <bits/stdc++.h>
using namespace std;
const int maxa = 30000;
const int maxn = 30000 + 10;
int n;
bool f[maxn];
int main()
{
	for(int i = 2; i <= maxa; i += 2) f[i] = 1;
	for(int i = 3; i <= maxa; i += 3) f[i] = 1;
	scanf("%d", &n);
	if(n == 3)
	{
		puts("2 5 63");
		return 0;
	}
	if(n & 1)
	{
		printf("%d ", 30000);
		--n;
	}
	for(int i = 1; n; ++i)
	{
		if(f[i]) 
		{
			printf("%d ", i);
			--n;
			if(i != maxa - i) printf("%d ", maxa - i);
			else printf("%d ", maxa);
			--n;
		}
	}
	return 0;
}

Measured memory_bytes: 3860
class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def push(queue, spell)
  size = queue.size
  index = queue.index{|entry| entry[0] >= spell} || size
  return queue[index][1] if index < size && queue[index][0] == spell

  # return nil if index > 0 && !spell.start_with?(queue[index - 1][0])
  # queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(spell)

  nodes = {}
  queue.insert(index, [spell, nodes])
  nodes
end

def calc(n, arrows, start, goal)
  ins = Array.new(n){[]}
  arrows.each do |arrow|
    ins[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    ins[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end

  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  outs = Array.new(n){[]}
  arrows.each do |arrow|
    outs[arrow.source] << arrow
  end

  limit = n * arrows.map{|arrow| arrow.label.size}.max

  queue = [['', {start => true}]]
  until queue.empty?
    spell, nodes = queue.shift
    return spell if nodes[goal]
    return nil if spell.size > limit

    nodes.each do |node, _|
      outs[node].each do |arrow|
        new_nodes = push(queue, spell + arrow.label)
        new_nodes[arrow.sink] = true if new_nodes
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  end

  puts calc(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 10500
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S,T;
cin >> S >> T;
  int str=S.size();
  int i,c;
 c=0;
 for(i=0;i<str;i++) 
 {
 char s=S.at(i);
 char t=T.at(i);
 if(s==t) c++;
 }
if(c==str) cout << "Yes" << endl;
else  cout << "No" << endl;
return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    int Kind[M];
    for(int i=0;i<M;i++) Kind[i] = 0;
    for(int i=0;i<N;i++){
        int K;
        cin >> K;
        for(int j=0;j<K;j++){
            int A;
            cin >> A;
            Kind[A-1]++;
        }
    }
    int sum=0;
    for(int i=0;i<M;i++){
        if(Kind[i] == N) sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const int N=1005;
int k;
char s[N];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	k=read(),scanf("%s",s+1);
	int len=strlen(s+1);
	if(len<=k)	printf("%s",s+1);
	else{
		for(int i=1;i<=k;i++)
			printf("%c",s[i]);
		puts("...");
	}
	return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n; cin >> n;
  while(n--) {
    int a; cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) {
        cout << "DENIED\n";
        return 0;
      }
    }
  }
  cout << "APPROVED\n";
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

struct Point{
  double x,y;
};

void koch(int,struct Point, struct Point );


int main(){
  struct Point a,b;
  int N;

  scanf("%d",&N);
  if(!(0<=N &&  N<=6))
    exit(1);

  a.x = 0.0;
  a.y = 0.0;
  b.x = 100.0;
  b.y = 0.0;

  printf("%.8f %.8f\n",a.x, a.y);
  koch(N, a, b);
  printf("%.8f %.8f\n",b.x, b.y);

  return 0;
}


void koch(int N, struct Point a, struct Point b){
  if(N == 0)
    return;

  struct Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(N-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);

  koch(N-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);

  koch(N-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);

  koch(N-1, t, b);
}



Measured memory_bytes: 2008
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

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

void solve(std::string S){
    ll N = S.length();
    string tgt = "keyence";

    if(S.substr(N-7, 7)==tgt){
        cout << YES << endl;
        return;
    }
    if(S.substr(0, 7)==tgt){
        cout << YES << endl;
        return;
    }

    for(ll i=1; i<7; i++){
        if(S.substr(0, i)==tgt.substr(0, i) && S.substr(N-(7-i), 7-i) == tgt.substr(i, 7-i)){
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;

}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
commands=[input().split() for i in range(n)]
    
List=deque()
for list_command in commands:
    if 'insert' in list_command:
        List.appendleft(list_command[1])
    elif 'delete' in list_command:
        try:
            List.remove(list_command[1])
        except:
            pass
    elif 'deleteFirst' in list_command:
        List.popleft()
    elif 'deleteLast' in list_command:
        List.pop()
  
print(*List)

Measured memory_bytes: 557404
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
int INPUT_INT() { int d; cin >> d; return d; } // ??\??????push_back(d)???array[d]???????????????1?????§?????????
											   
// ------------------- include, typedef, define END. -------------------

bool uruu(LL Y) {
	return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false);
}

int main() {
	int d, c;
	
	cin >> d >> c;
	cout << (d*c);


	puts("");
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

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

const double PI = acos(-1);
const double EPS = 1e-8;
const int INF = 1001001001;
typedef complex<double> P;

double cross(const P &a, const P &b)
{
    return imag(conj(a) * b);
}
double dot(const P &a, const P &b)
{
    return real(conj(a) * b);
}

struct L : public vector<P>
{
    L(){}
    L(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
};

int ccw(P a, P b, P c)
{
    b -= a; c -= a;
    if(cross(b, c) > 0)     return 1;   // counter clockwise
    if(cross(b, c) < 0)     return -1;  // clockwise
    if(dot(b,c) < 0)        return 2;   // c-a-b on line
    if(norm(b) < norm(c))   return -2;  // a-b-c on line
    return 0;                           // a-c-b on line
}

bool intersectSP(const L &l, const P &p)
{
    return abs(l[0]-p) + abs(l[1]-p) - abs(l[1]-l[0]) < EPS;
}

bool intersect(const L& s, const L& t)
{
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
    ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

P projection(const L &l, const P &p)
{
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}
                                
double dstcSP(const L& l, const P& p)
{
    const P r = projection(l, p);
    if(intersectSP(l, r)) return abs(r - p);
    return min(abs(l[0] - p), abs(l[1] - p));
}

double dstc(const L &s, const L &t)
{
    if(intersect(s, t)) return 0;
    return min(min(dstcSP(s, t[0]), dstcSP(s, t[1])),
               min(dstcSP(t, s[0]), dstcSP(t, s[1])));
}

const int con[][2] = { {0,2}, {0,3}, {1,3}, {1,4}, {2,4} };
typedef pair<double, int> DI;

int main()
{
    int N, M, LL;
    double x, y, a, r;
    double d[550];
    P point[550];
    L line[550];
    
    while(cin >> N >> M >> LL && N)
    {
        rep(i, N)
        {
            cin >> x >> y >> a >> r;
            rep(j, 5) {
                point[i*5+j]
                = P(x + r * cos(a*PI/180 + j*PI*2/5 + PI/2),
                    y + r * sin(a*PI/180 + j*PI*2/5 + PI/2));
            }
            rep(j, 5) {
                line[i*5+j] = L(point[i*5+con[j][0]], point[i*5+con[j][1]]);
            }
        }
        --M; --LL;
        
        priority_queue<DI, vector<DI>, greater<DI> > que;
        fill_n(d, 550, INF);
        d[M*5] = 0;
        que.push(DI(0, M*5));
        
        while(true)
        {
            DI p = que.top(); que.pop();
            int cur = p.second;
            if(cur/5 == LL) {
                cout << setprecision(15) << p.first << endl;
                break;
            }
            if(d[cur] < p.first) continue;
            rep(i, 5*N) if(i != cur) {
                if(d[i] > d[cur] + dstc(line[cur], line[i])) {
                    d[i] = d[cur] + dstc(line[cur], line[i]);
                    que.push(DI(d[i], i));
                }
            }
        }
    }
}

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

typedef long long ll;
const int MAX_N = 200000;
const ll MOD = (ll)1e+9 + 7;

int main() {
  int N, M, K;
  std::cin >> N >> M >> K;

  ll cmb = 1, sub = (ll) N * M - 2;
  for(int i = 0; i < K - 2; ++i) {
    cmb *= sub; cmb %= MOD;
    --sub;
  }

  static std::vector<ll> inv(K - 1);
  inv[1] = 1;
  for(int i = 2; i <= K - 2; ++i) {
    inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
  }
  for(int i = K - 2; i > 0; --i) {
    cmb *= inv[i];
    cmb %= MOD;
  }

  ll ans = 0;
  for(int d = 1; d < N; ++d) {
    ll sub = (ll) d;
    sub *= (ll) (N - d) * (((ll) M * M) % MOD);
    sub %= MOD;
    ans += sub;
  }
  for(int d = 1; d < M; ++d) {
    ll sub = (ll) d;
    sub *= (ll) (M - d) * (((ll) N * N) % MOD);
    sub %= MOD;
    ans += sub;
  }
  ans %= MOD;
  ans *= cmb;
  ans %= MOD;

  std::cout << ans << std::endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define abs(x) (x>0?x:-(x))

int main()
{
	int A, B;

	scanf("%d%d", &A, &B);

	if (A >= 13)
		printf("%d\n", B);
	else if (A >= 6)
		printf("%d", B / 2);
	else
		printf("0\n");
}

Measured memory_bytes: 128
#include <stdio.h>
#define N 1000001
 
int spf[N], u[N], s[17], d, i, k;
char* r = "pairwise";
 
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
main(j) {
    while (++i < N)spf[i] = i;
    for (i = 2; i * i < N; i++) {
        for (j = i * i; j < N; j += i) {
            if (spf[j] == j)
                spf[j] = i;
        }
    }
    for (scanf("%*d"); ~scanf("%d", &j); k = 0) {
        d = gcd(d, j);
        for (; j > 1; j /= i) {
            s[k++] = i = spf[j];
            if (u[i]) r = "setwise";
        }
        while(k--)u[s[k]] = 1;
    }
    printf("%s coprime\n", d > 1 ? "not" : r);
    return 0;
}


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

a = [int(i) for i in input().split()]

ans = 0

tmp = a[0]

if a[0] == 0:
    tmp = 1
    ans += 1
    
for i in range(1,n):
    #print(tmp,ans)
    if tmp > 0:
        if tmp + a[i] >= 0:
            ans += tmp + a[i] + 1
            tmp = -1
        else:
            tmp += a[i]
    else:
        if tmp + a[i] <= 0:
            ans += abs(tmp + a[i]) + 1
            tmp = 1
        else:
            tmp += a[i]

#print(ans)


ans2 = 0

if a[0] > 0:
    ans2 += a[0]+1
    tmp = -1
elif a[0] < 0:
    ans2 += -a[0]+1
    tmp = 1
else:
    tmp = -1
    ans2 += 1

    
for i in range(1,n):
    #print(tmp,ans)
    if tmp > 0:
        if tmp + a[i] >= 0:
            ans2 += tmp + a[i] + 1
            tmp = -1
        else:
            tmp += a[i]
    else:
        if tmp + a[i] <= 0:
            ans2 += abs(tmp + a[i]) + 1
            tmp = 1
        else:
            tmp += a[i]

print(min(ans,ans2))
exit()

ans2 = 0

tmp = -a[0]

ans2 += abs(a[0])*2
    
for i in range(1,n):
    #print(tmp,ans)
    if tmp > 0:
        if tmp + a[i] >= 0:
            ans2 += tmp + a[i] + 1
            tmp = -1
        else:
            tmp += a[i]
    else:
        if tmp + a[i] <= 0:
            ans2 += abs(tmp + a[i]) + 1
            tmp = 1
        else:
            tmp += a[i]

print(min(ans,ans2))

Measured memory_bytes: 14332
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{  int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(max(a-c,c-a)<=d)   cout<<"Yes";
   else if(max(a-b,b-a)<=d && max(b-c,c-b)<=d)  cout<<"Yes";
   else cout<<"No";
   return 0;    
}


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

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for(int i =1; i <= n; i++) {
    cout << "ACL";
  }
  cout << "\n";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <math.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;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int H, W; cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10,0));
    rep(i,10) rep(j,10) cin >> c[i][j];

    vector<vector<int>> A(H, vector<int>(W,0));
    rep(i,H) rep(j,W) cin >> A[i][j];

    rep(k,10){
        rep(i,10){
            rep(j,10){
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
    ll ans = 0;
    rep(i,H){
        rep(j,W){
            if (A[i][j] == -1) continue;
            ans += c[A[i][j]][1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3768
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n;
  bool ms[300005]={};
  int i,j;

  for(i=0;7*i<300005;i++)//monday saturday
    ms[7*i+1]=ms[7*i+6]=true;
  ms[1]=false;

  for(i=0;i<300005;i++)//prime search
    if(ms[i])
      for(j=2;i*j<300005;j++)
	ms[i*j]=false;
  
  while(1){
    cin>>n;
    if(n==1)break;
    cout<<n<<":";
    rep(i,n+1)
      if(ms[i] && n%i==0)
	cout<<" "<<i;
    cout<<endl;
  }

}

Measured memory_bytes: 3288
lst = [True for i in range(52)]
n = int(input())
for i in range (n):
    suit, rank = input().split()
    rankn = int(rank)
    if suit == 'S':
        lst[rankn-1] = False
    elif suit == 'H':
        lst[rankn+12] = False
    elif suit == 'C':
        lst[rankn+25] = False
    else:
        lst[rankn+38] = False
for i in range(52):
    tf = lst[i]
    if i <= 12 and tf:
        print ('S %d' % (i+1))
    elif 12 < i <= 25 and tf:
        print ('H %d' % (i-12))
    elif 25 < i <= 38 and tf:
        print ('C %d' % (i-25))
    elif tf:
        print ('D %d' % (i-38))


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

int main() {
    string s;
    cin >> s;

    if (s == "SUN") cout << 7 << endl;
    else if (s == "MON") cout << 6 << endl;
    else if (s == "TUE") cout << 5 << endl;
    else if (s == "WED") cout << 4 << endl;
    else if (s == "THU") cout << 3 << endl;
    else if (s == "FRI") cout << 2 << endl;
    else if (s == "SAT") cout << 1 << endl;
    
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

using namespace std;

void solve(string S) {
    int
            ans = 1e9;
    for (int i = 0; i + 2 <= S.size(); i++) {
        string t = S.substr(i, 3);
        stringstream ss(t);
        int w;
        ss >> w;
        ans = min(ans, abs(753 - w));
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    string S;
    cin >> S;
    solve(S);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int num[10][10];
int main(){
	n=read();
	for(register int i=1;i<=n;i++){
		int x=i,w1=x%10,w2;
		while(x>=10)x/=10;
		w2=x;
		num[w1][w2]++;
	}
	int ans=0;
	for(register int i=1;i<=n;i++){
		int x=i,w1=x%10,w2;
		while(x>=10)x/=10;
		w2=x;
		ans+=num[w2][w1];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int D[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>D[i];

    sort(D,D+N);

    int ans=D[N/2]-D[N/2-1];

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans[n];
	for (int i = 1; i <= n; i++) {
		int t;
		cin >> t;
		ans[t-1] = i; 
	}

	for (int i = 0; i < n; i++) cout << ans[i] << " ";
	cout << endl;
    return 0;
}


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

int main() {
    int A,B,ans;
    ans = 0;
    cin >> A >> B;
    for (int i=A;i<=B;i++){
        int x,y,z,w;
        x = i / 10000;
        y = (i % 10000) /1000;
        z = (i % 100) /10;
        w = i % 10;
        if (x==w && y == z){
            ans += 1;
        }

    }
    cout << ans << endl;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;
const ll INF = 10010010010010010;


int main() {
    string s,t; cin >> s >> t;
    int n = s.size(), m = t.size();
    int dp[n][26]; rep(i,n) rep(j,26) dp[i][j] = -1;
    for (int i = n-1; i >= 0; i--) {
        dp[n-1][s[i]-'a'] = i;
    }
    //rep(i,n) {rep(j,26) {printf("%d ", dp[i][j]);} printf("\n");}
    for (int i = n-2; i >= 0; i--) {
        rep(j,26) {
            dp[i][j] = dp[i+1][j];
        }
        dp[i][s[i+1]-'a'] = i+1;
    }
    //rep(i,n) {rep(j,26) {printf("%d ", dp[i][j]);} printf("\n");}
    int idx = -1;
    rep(i,n) {
        if (t[0] == s[i]) {
            idx = i;
            break;
        }
    }
    if (idx == -1) {
        cout << idx << endl;
        return 0;
    }
    ll ans = 0;
    rep(i,m-1) {
        int nx = dp[idx][t[i+1]-'a'];
        if (nx == -1) {
            cout << -1 << endl;
            return 0;
        }
        else if (nx > idx) {
            idx = nx;
        }
        else {
            idx = nx;
            ans += n;
        }
    }
    ans += idx + 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13920
#include<stdio.h>
#include<algorithm>
#include<functional>
int m,n;
int manj[10000];
int sum[10001];
int dp[501][10001];
using namespace std;
int main(void){
	scanf("%d %d",&m,&n);
	int i,j,cnt=0;
	for(i=0;i<m;i++){
		sum[i]=0;
		scanf("%d",&manj[i]);
	}
	sort(manj,manj+m,greater<int>());
	int temp=0;
	for(i=0;i<m;i++){
		temp+=manj[i];
		sum[i+1]+=temp;
	}//
	for(i=0;i<n;i++){
		for(j=0;j<10001;j++){
			dp[i][j]=-1;
		}
	}
	for(i=0;i<n;i++){
		int c,e;
		scanf("%d %d",&c,&e);
		if(dp[i][c]>=e || dp[i][c]==-1){
			dp[i][c]=e;
		}
		if(i-1>=0){
			for(j=0;j<10001;j++){
				if(dp[i][j+c]>dp[i-1][j]+e || dp[i][j+c]==-1 && dp[i-1][j]!=-1 &&j+c<=10000){
					dp[i][j+c]=dp[i-1][j]+e;
					//printf("%d\n",dp[i-1][j]);
				}
			}
		}
		for(j=10000;j>=0;j--){
			if(dp[i][j]!=-1 && dp[i][j]<=dp[i][j-1] || dp[i][j-1]==-1 && j-1>=0){
				dp[i][j-1]=dp[i][j];
			}
		}
		for(j=0;j<10001;j++){
			if(dp[i][j]>dp[i+1][j] || dp[i+1][j]==-1 && j+1<10001){
				dp[i+1][j]=dp[i][j];
			}
		}
	}
	int max=0;
	/*for(i=0;i<=15;i++){
		printf("%d=%d %d",i,sum[i],dp[n-1][i]);
		printf("\n");
		if(max<sum[i]-dp[n-1][i] && dp[n-1][i]!=-1){
			max=sum[i]-dp[n-1][i];
		}
		//printf("%d\n",max);
	}*/
	for(i=1;i<10001;i++){
		if(max<sum[i]-dp[n-1][i] && dp[n-1][i]!=-1){
			max=sum[i]-dp[n-1][i];
		}
	}
	printf("%d\n",max);
	return 0;
}

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

int main() {
  ll n; cin >> n;
  int m = 26;
  string ans = "";
  while (n) {
    n--;
    ans += 'a'+n%m;
    n /= m;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); 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 operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


int main() {
	int n;
	std::cin >> n;
	mint ans=mint(10).pow(n);
	ans-=mint(9).pow(n);
	ans-=mint(9).pow(n);
	ans+=mint(8).pow(n);
	print(ans);
}


Measured memory_bytes: 3648
def cnt_digits(x):
    if (x // 10) >0:
        return 1 + cnt_digits(x // 10)
    else:
        return 1

n = int(input())
ans = float('inf')
for A in range(1, int(n ** 0.5) + 1):
    if n % A == 0:
        ans = min(ans, max(cnt_digits(A), cnt_digits(n // A)))
print(ans)

Measured memory_bytes: 3188
<?php
  
$s = trim(fgets(STDIN));
$t = trim(fgets(STDIN));

for($i=0; $i<strlen($s); $i++){
  $sa[$i] = $s[$i];
}
for($i=0; $i<strlen($t); $i++){
  $ta[$i] = $t[$i];
}

sort($sa);
rsort($ta);

echo implode('', $sa) < implode('', $ta) ? 'Yes' : 'No';
  
?>

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

int main()
{
    bool test[3] = {false,false,false};
    int t;
    cin >> t;
    test[--t] = true;
    cin >> t;
    test[--t] = true;
    for(int i = 0; i < 3; ++i)
    {
        if(!test[i])
        {
            cout << ++i << endl;
        }
    }
}

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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(t>s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

const int INF = 1000000;

int main() {
  int N;
  vector<int> v;
  cin >> N;
  int m = INF;
  rep(i, N) {
    int temp;
    cin >> temp;
    if(m >= temp) {
      m = temp;
      v.push_back(i);
    }
  }
  cout << v.size() << endl;
  return 0;
}

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

void mkvec(vector<int>&v,int base,int limit){
	int i=base;
	while(i<=limit){
		v.emplace_back(i);
		i*=base;
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>num(1,1);
	mkvec(num,6,n),mkvec(num,9,n);
	vector<vector<int>>dp(2,vector<int>(n+1,1e9)); dp.front().front()=0;
	for(int i=0;i<num.size();++i){
		for(int j=0;j<=n;++j){
			if(j<num.at(i))dp.at((i+1)&1).at(j)=dp.at(i&1).at(j);
			else dp.at((i+1)&1).at(j)=min(dp.at(i&1).at(j),dp.at((i+1)&1).at(j-num.at(i))+1);
		}
	}
	cout<<dp.at(num.size()&1).back()<<"\n"s;
}


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

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

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

int main () {
  string s;
  cin >> s;

  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
} 

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

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

using namespace std;

typedef long long ll;

int w, h;
int c[55][55];
int ans;

void dfs(int x, int y) {
  c[y][x] = 0;
  for (int dx = -1; dx <= 1; dx++) {
    for (int dy = -1; dy <= 1; dy++) {
      if (dx == 0 && dy == 0) { continue; }
      int nx = x + dx;
      int ny = y + dy;
      if (nx < 0 || ny < 0 || nx >= w || ny >= h ) {
        continue;
      }
      if (c[ny][nx] != 1) {
        continue;
      }
      dfs(nx, ny);
    }
  }
}

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

  while ( true ) {
    cin >> w >> h;
    if (w == 0 && h == 0) { break; }

    rep(y, 30) { rep (x, 30) { c[y][x] = 0; } }

    rep(y, h) {
      rep (x, w) {
        cin >> c[y][x];
      }
    }
    ans = 0;
    rep(y, h) {
      rep(x, w) {
        if (c[y][x] == 1) {
          dfs(x, y);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3252