akhauriyash/Code-Regression huggingface dataset:
N=int(input())
l=[0]*(10**4+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            num=pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i
            if num<=10**4:
                l[num]=l[num]+1
for i in range(1,N+1):
    print(l[i])


Measured memory_bytes: 69508
import numpy as np
s = input()
n = int(s)

digit = len(s)

all_combinations = []

for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    for i6 in ("3", "5", "7"):
                        for i7 in ("3", "5", "7"):
                            for i8 in ("3", "5", "7"):
                                for i9 in ("3", "5", "7"):
                                    all_combinations.append(i1+i2+i3+i4+i5+i6+i7+i8+i9)

for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    for i6 in ("3", "5", "7"):
                        for i7 in ("3", "5", "7"):
                            for i8 in ("3", "5", "7"):
                                all_combinations.append(i1+i2+i3+i4+i5+i6+i7+i8)

for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    for i6 in ("3", "5", "7"):
                        for i7 in ("3", "5", "7"):
                            all_combinations.append(i1+i2+i3+i4+i5+i6+i7)

for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    for i6 in ("3", "5", "7"):
                        all_combinations.append(i1+i2+i3+i4+i5+i6)

for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                for i5 in ("3", "5", "7"):
                    all_combinations.append(i1+i2+i3+i4+i5)

for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            for i4 in ("3", "5", "7"):
                all_combinations.append(i1+i2+i3+i4)

for i1 in ("3", "5", "7"):
    for i2 in ("3", "5", "7"):
        for i3 in ("3", "5", "7"):
            all_combinations.append(i1+i2+i3)

selected_num = []
for i in all_combinations:
    if not ('7' in i):
        continue
    if not ('5' in i):
        continue
    if not ('3' in i):
        continue

    selected_num.append(int(i))

selected_num_array = np.array(selected_num)

print(np.sum(selected_num_array <= n))

Measured memory_bytes: 23540
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],b[1000005];
typedef long long LL;
inline LL Gcd(LL x,LL y)
{
	return y==0?x:Gcd(y,x%y);
}
int main()
{
	LL x,y;
	scanf("%lld%lld",&x,&y);
	LL d=Gcd(x,y);
	int tot=0;
	for(int i=2;1ll*i*i<=d;i++)
		if(d%i==0)
		{
			tot++;
			while(d%i==0)
				d/=i;
		}
	if(d!=1)
	tot++;
	printf("%lld",tot+1);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <queue>

#define r first
#define c second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;
using pii = pair<int, int>;

typedef long long llint;

const int MAXN = 810;
const int DR[] = {-1, 1, 0, 0};
const int DC[] = {0, 0, 1, -1};
const int INF = 1e9;

int h, w, k, sol = INF;
char a[MAXN][MAXN];
queue<pii> q;
int dist[MAXN][MAXN], dist2[MAXN][MAXN];

bool in(int r, int c) {
  return r >= 0 && c >= 0 && r < h && c < w;
}

void solve(int sr, int sc) {
  memset(dist, -1, sizeof(dist));
  memset(dist2, -1, sizeof(dist2));

  REP(r, h) REP(c, w)
    if (r == 0 || c == 0 || r == h - 1 || c == w - 1) {
      dist[r][c] = 0;
      q.push({r, c});
    }
  
  while (!q.empty()) {
    pii x = q.front();
    q.pop();

    REP(i, 4) {
      int nr = x.r + DR[i];
      int nc = x.c + DC[i];
      
      if (!in(nr,nc)) continue;
      if (dist[nr][nc] == -1) {
	dist[nr][nc] = dist[x.r][x.c] + 1;
	q.push({nr, nc});
      }
    }
  }
  
  q.push({sr, sc});
  dist2[sr][sc] = 0;

  while (!q.empty()) {
    pii x = q.front();
    q.pop();
    
    if (dist2[x.r][x.c] > k) break;
    sol = min(sol, 1 + (dist[x.r][x.c] + k - 1) / k);

    REP(i, 4) {
      int nr = x.r + DR[i];
      int nc = x.c + DC[i];
      
      if (!in(nr,nc) || a[nr][nc] == '#') continue;
      if (dist2[nr][nc] == -1) {
	dist2[nr][nc] = dist2[x.r][x.c] + 1;
	q.push({nr, nc});
      }
    }
  }
}


int main(void) {
  scanf("%d %d %d",&h,&w,&k);
  REP(i, h) scanf("%s",a[i]);

  REP(r, h) REP(c, w)
    if (a[r][c] == 'S')
      solve(r,c);

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


Measured memory_bytes: 6016
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) // present in container?
#define vpresent(c,x) (find(all(c),x) != (c).end()) // present in vector?
#define endl '\n'
using namespace std;

int luca(int n){
    vector<int> lucas(n + 1);
    lucas[0] = 2;
    lucas[1] = 1;
    for(int i = 2; i <= n ; ++i){
        lucas[i] = lucas[i - 1] + lucas[i - 2]; 
    }
    return lucas[n];
}

int n; 

void solve(){
    cin >> n;
    cout << luca(n) << endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    
    if a[0] %2 ==0:
        print(a[0])
    else:
        print(a[0]*2)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

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


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] a = new int[n+1];
    int[] b = new int[n+1];
    for(int i=1;i<=n;i++){
        a[i]=sc.nextInt();
    }
    int total=0;
    for(int i=n;i>0;i--){
        int pal=0;
        for(int j=2*i;j<=n;j+=i){
            pal+=b[j];
        }
        b[i]=(pal+a[i])%2;
        total+=b[i];
    }
    System.out.println(total);
    int j=1;
    for(int i=0;i<total;i++){
        while(b[j]==0){
            j++;
        }
        System.out.print(j+" ");
        j++;
    }
  }
}



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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int t,n,i,k,ans=1;
	cin>>n>>k;
	for (i=0;i<n;i++){
		cin>>t;
	}
	n-=k;
	if (n%(k-1)==0){
		ans+=n/(k-1);
	}
	else {
		ans+=n/(k-1)+1;
	}
	cout<<ans;
	return 0;
}

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

int main(){
    pair<pair<string, int>, int> p[120];
    int n, a;
    string s;
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        cin >> s >> a;
        p[i] = make_pair(make_pair(s, -a), i);
    }
    sort(p, p+n);
    for(int i=0; i<n; i++) printf("%d\n", p[i].second+1);
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  bool ok = false;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(N==i*j){
        ok = true;
      }
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int n, m;
set<int> X;
priority_queue<int> q;

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int temp;
        cin >> temp;
        X.insert(temp);
    }

    auto it = X.begin();
    for (int i = 0; i < m - 1; ++i)
    {
        auto n_it = it;
        int tmp = *++it - *n_it;
        q.push(tmp);
    }

    for (int i = 0; i < n - 1; ++i)
    {
        if (q.empty())
        {
            break;
        }
        q.pop();
    }

    int sum = 0;
    while (!q.empty())
    {
        int tmp = q.top();
        sum += tmp;
        q.pop();
    }

    cout << sum << endl;
}

Measured memory_bytes: 5628
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == -1){
				break;
			}
			
			System.out.println(Integer.toString(n, 4));
		}
		
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N[4];
    for (int& n : N) cin >> n;
    sort(begin(N), end(N));
    cout << ((N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

long long MOD = 1000000007;
int main(){
    long long n,m;
    cin >> n >> m;
    long long x = 0;
    long long answer = 0;
    long long buf;
    long long last;
    for(long long i = 0; i < n; i++){
        cin >> buf;
        if(i > 0){
            long long comb = i * (n-i);
            comb %= MOD;
            long long length = buf - last;
            long long addBuf = (length * comb) % MOD;
            x = (x + addBuf) % MOD;
        }
        last = buf;
    }
    for(long long i=0;i<m;i++){
        cin >> buf;
        if(i>0){
            long long comb = i * (m-i);
            comb %= MOD;
            long long length = buf - last;
            long long addBuf = (length * comb) % MOD;
            addBuf *= x;
            addBuf %= MOD;
            answer = (answer + addBuf) % MOD;
        }
        last = buf;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

using vint = vector<int>;
using pint = pair<int, int>;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

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; }
template<typename T> inline void debug(T a) { cout << "[ "; for (const auto e : a) { cout << e << ", "; } cout << "]" << endl; }

int ceil(int a, int b) { return (a + (b - 1)) / b; }

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// }}}

const int NIL = -1;

vector<int> factorial(100010, NIL);

int fact(int n) {
	if (factorial[n] != NIL) return factorial[n];
	else return factorial[n] = factorial[n-1] * n;
}

int combination2(int n) {
	return n * (n-1) / 2;
}

signed main() {
	factorial[0] = 1;
	factorial[1] = 1;

	int n;
	cin >> n;

	set<string> s;
	map<string, int> m;

	rep (i, n) {
		string tmp;
		cin >> tmp;
		sort(ALL(tmp));
		s.insert(tmp);
		m[tmp]++;
	}

	int ans = 0;

	for (const auto e : s) {
		if (m[e] > 1) ans += combination2(m[e]);
	}

	cout << ans << endl;
}



Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	
	double pi=acos(-1);
	
	double hoge=2*pi/12*h+pi/6/60*m;
	double piyo=2*pi/60*m;
	
	double dif=abs(hoge-piyo);
	if(dif>pi) dif=2*pi-dif;
	debug(dif);
	
	double ans=sqrt(a*a+b*b-2*a*b*cos(dif));
	
	printf("%.18f\n",ans);
}


Measured memory_bytes: 4252
# ABC 128, C

def f(X, Y):
    return(len(X.intersection(Y)) % 2)

n, m = [int(el) for el in input().split(' ')]


T = []
for i in range(m):
    S = set()
    tmp = [int(el) for el in input().split(' ')]
    for j in range(1, len(tmp)):
        S.add(tmp[j])
    T.append(S)
P = [int(el) for el in input().split(' ')]



total = 0
for i in range(2**n):
    pattern = set()
    for j in range(n):
        if ((i >> j) & 1):
            pattern.add(j+1)
    
    if all([P[k] == f(T[k], pattern) for k in range(m)]):
        total += 1
print(total)









Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    int n;
    cin >> n;
    priority_queue<ll, vector<ll>, greater<ll> > pque1;
    priority_queue<ll> pque2;
    ll total1 = 0, total2 = 0;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        total1 += a;
        pque1.push(a);
    }
    ll sum1[n + 1] = {}, sum2[n + 1] = {};
    ll mid[n];
    sum1[0] = total1;
    for (int i = 0; i < n; i++) {
        cin >> mid[i];
        sum1[i + 1] = sum1[i] + mid[i];
        pque1.push(mid[i]);
        sum1[i + 1] -= pque1.top();
        pque1.pop();
    }
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        total2 += a;
        pque2.push(a);
    }
    sum2[0] = total2;
    for (int i = 0; i < n; i++) {
        sum2[i + 1] = sum2[i] + mid[n - 1 - i];
        pque2.push(mid[n - 1 - i]);
        sum2[i + 1] -= pque2.top();
        pque2.pop();
    }
    ll ans = total1 - total2;
    for (int i = 0; i < n + 1; i++) {
        ans = max(ans, sum1[i] - sum2[n - i]);
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 4852
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int D, Q, x[131072], ls, rs, es; vector<int> seg[262144];
int query(int a, int b, int x1, int x2, int k, int l, int r) {
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return lower_bound(seg[k].begin(), seg[k].end(), x2) - lower_bound(seg[k].begin(), seg[k].end(), x1);
	int lc = query(a, b, x1, x2, 2 * k, l, (l + r) / 2);
	int rc = query(a, b, x1, x2, 2 * k + 1, (l + r) / 2, r);
	return lc + rc;
}
int main() {
	scanf("%d", &D);
	for (int i = 0; i < D; i++) {
		scanf("%d", &x[i]);
		int t = i + 131072;
		while (t > 0) {
			seg[t].push_back(x[i]);
			t >>= 1;
		}
	}
	for (int i = 1; i < 262144; i++) {
		if (seg[i].size() > 1) {
			sort(seg[i].begin(), seg[i].end());
		}
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d%d", &ls, &rs, &es);
		int a = min(x[ls - 1], x[rs - 1]);
		int b = max(x[ls - 1], x[rs - 1]);
		printf("%d\n", rs - ls + 1 - query(ls - 1, rs, a - es, b + es + 1, 1, 0, 131072));
	}
	return 0;
}

Measured memory_bytes: 21212
N = int(input())
xy = [[int(i) for i in input().split()] for _ in range(N)]

pq = []
for i in range(N) :        
    for j in range(i+1, N) :
        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]
        pq.append((p, q))
        
pq = list(set(pq))

ret = N
for p, q in pq :
    tmp = 0
    visited = [0] * N
    for i in range(N) :
        if visited[i] :
            continue
            
        visited[i] = 1
        
        queue = [i]
        while queue :
            que = queue.pop()
            for j in range(N) :
                if visited[j] :
                    continue
                    
                dx = xy[j][0] - xy[que][0]
                dy = xy[j][1] - xy[que][1]
                if (dx == p and dy == q) or (dx == -p and dy == -q) :
                    queue.append(j)
                    visited[j] = 1
    
        tmp += 1
        
    ret = min(tmp, ret)
    
print(ret)

Measured memory_bytes: 43356
n = int(input())
x = [[0]*3 for i in range(n)]
for i in range(n):
    a,b = map(int,input().split())	
    x[i] = [a+b,a,b]
x.sort()
C = [[0]*3 for i in range(n)]
for i in range(n):
    C[i]=x[n-1-i]
x = C

A = 0
T = 0
for i in range(n):
    if i%2 == 0:
        A+=x[i][1]
    else:
        T+=x[i][2]
print(A-T)

Measured memory_bytes: 32936
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    for (ll i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    sort(ALL(a));
    for (ll i = 0; i < m; i++)
    {
        n -= a[i];
    }
    if (n < 0)
    {
        cout << -1 << endl;
    }
    else{
        cout << n << endl;
    }
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define all(c) (c).begin(), (c).end()
#define rep( i, a, n) for( ll i=a; i<n; i++)
#define pb push_back 

int main () {
  int n;
  cin >> n;
  int arr[n];
  rep (i, 0, n ) cin >> arr[i];

  int flag = 0;
  rep ( i, 0, n ) {
    if ( arr[i] % 2 == 0) {
      if ( arr[i] % 5 != 0 and arr[i] % 3 != 0){
        flag = 1;
        break;
      }
    }
  }

  if  (flag ) {
    cout << "DENIED" << endl;
  }
  else {
    cout << "APPROVED" << endl;
  }
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;

int main()
{
	scanf("%d",&N);
	vector<int> A(N);
	FOR(i,0,N){
		scanf("%d",&A [i]);
	}

	int ans = 1,curr = -1;
	FOR(i,1,N){
		if(A [i] > A [i - 1]){
			if(curr == 0){
				ans++;
				curr = -1;
			}
			else{
				curr = 1;
			}
		}
		if(A [i] < A [i - 1]){
			if(curr == 1){
				ans++;
				curr = -1;
			}
			else{
				curr = 0;
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 640
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)

for _ in range(m):
	tmp_min = heapq.heappop(a)
	heapq.heappush(a, (-1)*(-tmp_min//2))

print(-sum(a))

Measured memory_bytes: 14252
#! /usr/bin/env python3

# from fractions import gcd
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

hoge = N - sum(A)
if hoge >= 0:
    print(hoge)
else:
    print(-1)

Measured memory_bytes: 10104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;

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

    vector<string> st;

    for(int i = 0; i< s.size(); i++){
        for(int l = 1; l<=5; l++){
                st.push_back(s.substr(i, l));
        }
    }
    sort(st.begin(), st.end());
    st.erase(unique(st.begin(), st.end()));
    cout << st[K-1] << endl;
}

Measured memory_bytes: 1660
#include <cstdio>
using namespace std;
typedef unsigned long long ull;
const int N=610;
const int B=13333;
int n;
int a[N][N];
ull bas[N];
ull f[N][N],g[N][N]; // row col
inline int max(int x,int y){
	return x>y?x:y;
}
void readData(){
	scanf("%d",&n);
	static char str[N];
	for(int i=1;i<=n;i++){
		scanf("%s",str+1);
		for(int j=1;j<=n;j++){
			a[i][j]=(str[j]-'a'+1);
			a[n+i][j]=a[i][n+j]=a[n+i][n+j]=a[i][j];
		}
	}
}
void initHash(){
	bas[0]=1;
	for(int i=1;i<=2*n;i++) bas[i]=bas[i-1]*B;
	for(int i=1;i<=2*n;i++){
		for(int j=1;j<=2*n;j++){
			f[i][j]=f[i][j-1]+bas[j-1]*a[i][j];
			g[j][i]=g[j-1][i]+bas[j-1]*a[j][i];
		}
	}
}
bool judge(int x,int y,int d){
	int up=max(x,y);
	return (f[x][y]-f[x][y-d])*bas[up-y]==(g[x][y]-g[x-d][y])*bas[up-x];
}
bool check(int x,int y){
	for(int i=0;i<n;i++)
		if(!judge(x+i,y+i,i+1))
			return false;
	return true;
}
void solve(){
	int ans=0;
	for(int x=1;x<=n;x++)
		for(int y=1;y<=n;y++)
			ans+=check(x,y);
	printf("%d\n",ans);
}
int main(){
	readData();
	initHash();
	solve();
	return 0;
}


Measured memory_bytes: 7424
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var dic = new Dictionary<int, long>();
            foreach (var i in Enumerable.Range(0, N))
            {
                if (dic.ContainsKey(A[i]))
                {
                    dic[A[i]]++;
                }
                else
                {
                    dic[A[i]] = 1;
                }
            }

            var all = 0L;
            foreach (var pair in dic)
            {
                var count = pair.Value;
                all += (count * (count - 1)) / 2;
            }

            foreach (var k in Enumerable.Range(0, N))
            {
                var count = dic[A[k]] - 1;
                Console.WriteLine(all - count);
            }
        }
    }
}


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

int main(){

   int n ;
   int nmax = 0;
   int submax = 0;
   int innum = 0;
   cin >> n;
   vector<int> a;
   vector<bool> index(n);
   rep(i,n){
      int temp;
      cin >> temp;
      a.push_back(temp);
      nmax = max(nmax,temp);
   }
   rep(i,n){
      if(a[i] == nmax){
         index[i] = true;
         innum++;
         a[i] = 0;
      }
   }
   sort(a.begin(),a.end());
   // rep(i,n){
   //    cout << a[i] << endl;
   // }
   submax = a[a.size()-1];
   // cout << submax << endl;
   rep(i,n){
      if(innum == 1 && index[i])cout << submax << endl;
      else cout << nmax << endl;
   }
}

Measured memory_bytes: 2552
import itertools

n = int(input())
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))
p_list = tuple(p_list)
q_list = tuple(q_list)
n_list = list(range(1, n+1))

a_list = list(itertools.permutations(n_list))
a = a_list.index(p_list)
b = a_list.index(q_list)

print(abs(a-b))


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

using namespace std;


int main()
{
	double n, k;
	cin >> n >> k;
	double p=0;
	for (int i = 1; i <= n; i++) {
		double s = i, x=1;
		while (s < k) {
			s *= 2;
			x *= 0.5;
		}
		p += (x / n);
	}
	cout << fixed << setprecision(9) << p << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e12


int main(){
	int v,e;
	cin>>v>>e;
	vector<vector<ll> > g(v,vector<ll>(v,inf) );
	for(int i=0;i<e;i++){
		int s,t,w;
		cin>>s>>t>>w;
		g[s][t] = w;
	}
	for(int i=0;i<v;i++)g[i][i] = 0;
	for(int k=0;k<v;k++){
		for(int i=0;i<v;i++){
			for(int j=0;j<v;j++){
			    if(g[i][k] == inf || g[k][j] == inf)continue;
			    g[i][j] = min(g[i][j],g[i][k] + g[k][j] );
			}
		}
	}
	bool negative_cycle = false;
	for(int i=0;i<v;i++) if(g[i][i] != 0) negative_cycle = true;
	if(negative_cycle){
		cout<<"NEGATIVE CYCLE"<<endl;
	}else
	for(int i=0;i<v;i++){
		for(int j=0;j<v;j++){
			if(j!=0)cout<<" ";
			if(g[i][j] == inf)cout<<"INF";
			else cout<<g[i][j];
		}
		cout<<endl;
	}


	return 0;
}



Measured memory_bytes: 3228
#![allow(unused_imports)]

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;
use std::collections::HashMap;
use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut a=a;
    for i in 0..a.len() {
        a[i] -= i as i64 + 1;
    }
    a.sort();
    let b = {
        if a.len() % 2 == 0 {
            ((a[a.len()/ 2] + a[a.len() / 2 - 1]) / 2) as i64
        } else {
            a[a.len()/ 2]
        }
    };
    let m = {
        a.iter().fold(10000, |min, item| if i64::abs(min-b) < i64::abs((*item)-b) {min} else {*item})
    };
    let ans = a.into_iter().fold(0, |sum, item| sum + i64::abs(item - m));
    println!("{}", ans);
}

Measured memory_bytes: 8444
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;

ll modSum(ll A, ll B, ll C) {
	return (A + B) % C;
}
ll modMul(ll A, ll B, ll C) {
	return (A * B) % C;
}

int main() {
	scanf("%lld %lld", &N, &M);
	string S = "";
	cin >> S;
	ll rem = 0;
	ll val = 1;
	ll ans = 0;
	ll ans2 = 0;
	ll ans5 = 0;
	ll ans10 = 0;
	unordered_map<ll, ll> mp;
	mp[0]++;
	if(M == 2 || M == 5 || M == 10) {
		fi(i, 0, S.size(), 1) {
			if((S[i] - '0') % 2 == 0) {
				ans2 += i + 1;
			}
			if((S[i] - '0') % 5 == 0) {
				ans5 += i + 1;
			}
			if((S[i] - '0') % 10 == 0) {
				ans10 += i + 1;
			}
		}
	}
	if(M == 2) {
		cout << ans2 << "\n";
		quit;
	}
	if(M == 5) {
		cout << ans5 << "\n";
		quit;
	}
	if(M == 10) {
		cout << ans10 << "\n";
		quit;
	}
	for(int i = S.size() - 1; i >= 0; i--) {
		rem = (modSum(rem, modMul(val, (S[i] - '0'), M), M));
		ans += mp[rem];
		mp[rem]++;
		val = modMul(10, val, M);
	}
	cout << ans << "\n";

	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 900
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
bool is_integer( double x ){
  return floor(x)==x;
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll x2 = 0;
  rep(i,n){
    if (i%2) x2 -= a[i];
    else x2 += a[i];
  }
  vector<int> ans(n);
  ans[0] = x2/2;
  rep(i,n-1){
    ans[i+1] = a[i]-ans[i];
  }
  rep(i,n) ans[i] *=2;
  rep(i,n) printf("%d%c",ans[i], i==n-1?'\n':' ');
  
  return 0;
}


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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

signed main() {
    int N, M;
    cin >> N >> M;

    vector< pair<int, int>> con;
    vector<int> en(N, 0);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        con.pb(make_pair(a, b));

        if (b == N-1) {
            en[a] = 1;
        }
    }

    sort(ALL(con));

    bool ok = false;
    REP(i, M) {
        if (con[i].first != 0) break;

        if (en[con[i].second] == 1) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int N, T; cin >> N >> T;
    vector<ll> t(N);
    rep(i,N) cin >> t[i];

    ll now = 0;
    ll ans = 0;
    rep(i,N){
        if (now > t[i]){
            ans += t[i]+T-now;
            now = t[i]+T;
        }
        else{
            now = t[i]+T;
            ans += T;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
s = gets.chomp.split("")
t = gets.chomp
for i in 0..s.length-1
  for j in 0..s.length-2
    s[j], s[j+1] = s[j+1], s[j]
  end
  if s.join == t
    puts "Yes"
    exit
  end
end
puts "No"

Measured memory_bytes: 1788
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int P;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1e5+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void Add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int f[N],c[N],ans[N],st[N],Pre[N],suf[N],top,n;
void dfs1(int u,int fa){
	f[u]=1;
	go(u)if(v!=fa)dfs1(v,u),f[u]=mul(f[u],f[v]+1);
	top=0;go(u)if(v!=fa)st[++top]=v;
	Pre[0]=1;fp(i,1,top)Pre[i]=mul(Pre[i-1],f[st[i]]+1);
	suf[top+1]=1;fd(i,top,1)suf[i]=mul(suf[i+1],f[st[i]]+1);
	fp(i,1,top)c[st[i]]=mul(Pre[i-1],suf[i+1]);
}
void dfs2(int u,int fa,int res){
	ans[u]=mul(res+1,f[u]);
	go(u)if(v!=fa)dfs2(v,u,mul(res+1,c[v]));
}
int main(){
	scanf("%d%d",&n,&P);
	for(R int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),Add(u,v),Add(v,u);
	dfs1(1,0),dfs2(1,0,0);
	fp(i,1,n)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 7680
import sys
input = sys.stdin.readline


N = int(input())

ans = [0] * 10001

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            ret = x * x + y * y + z * z + x * y + y * z + z * x
            if ret < 10001:
                ans[ret] += 1

for i in range(1, N + 1):
    print(ans[i])

Measured memory_bytes: 74812
#include<iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main() {

	ll();
	 
	string s;
	bool t = true;
	cin >> s;
	for (int i = 97; i <= 122; i++)
	{
		t = true;
		for (int j = 0; j < s.length(); j++)
		{
			
			if (char(i) == s[j])
			{
				t = false;
				continue;
				
			}
		}
		if (t == true){
			cout << char(i) << endl;
			return 0;
		}
		
	}
	if (t==false)
	{
		cout << "None" << endl;
		return 0;
	}

}

Measured memory_bytes: 3748
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int H, W;

ll f(int y, int x) {
	if (y < 0 || x < 0) return -1;
	if (y + 2 >= H || x + 2 >= W) return -1;
	return (ll)y * W + x;
}

int main() {
	cin >> H >> W;
	map<ll, int> mp;
	int N; cin >> N;
	while (N--) {
		int y, x; scanf("%d%d", &y, &x);
		y--; x--;
		for (int dy = 0; dy < 3; dy++)
			for (int dx = 0; dx < 3; dx++)
				mp[f(y - dy, x - dx)]++;
	}
	vector<ll> ans(10);
	ans[0] = (ll)(H - 2) * (W - 2);
	for (ll_i z: mp)
		if (z.first != -1) {
			ans[z.second]++;
			ans[0]--;
		}
	for (int j = 0; j <= 9; j++)
		cout << ans[j] << endl;
}


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

int main() {
	int n;
	cin >> n;
	int *d = new int[n];
	for (int a = 0; a < n; ++a) {
		cin >> d[a];
	}
	int put;
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j>i; j--) {
			if (d[j] < d[j - 1]) {
				put = d[j];
				d[j] = d[j - 1];
				d[j - 1] = put;
			}
		}
	}
	int judge = d[0];
	int count = 1;
	int sum = 0;
	for (int k = 0; k < n; ++k) {
		if (judge!=d[k]) {
			judge = d[k];
			count++;
		}
		sum += d[k];
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
 
using namespace std;
 
//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
 
//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
 
//repetition
//------------------------------------------
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
 
//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;
 
// output vector
// ------------------------------------------
namespace std {
    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
        for(auto it=v.begin(); it!=v.end(); ++it){
            os << *it << (it+1==v.end() ? "" : ",");
        }
        return os;
    }
}
 
//clear memory
#define clr(a) memset((a), 0 ,sizeof(a))
 
int main(){
    int n;
    ull a;
     
    cin >> n;
     
    rep(i,n){
        cin >> a;
        cout << "Case " << i+1 << ":"<<  endl;
        rep(j,10){
            a=pow(a,2);
            a/=100;
            a%=10000;
            cout << a << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1168
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll res = min(a, k);
	if (a + b < k)
	{
		res -= k - (a + b);
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 3672
S = input()
T = input()
s = len(S)
t = len(T)

count = 0
max = 0

for i in range(s-t+1):
  for j in range(t):
    if S[i+j] == T[j]:
      count += 1
  if count > max:
    max = count
    count = 0
  else:
    count = 0

print(t-max)

Measured memory_bytes: 8924
import sys
import itertools


x = int(input())
for b in itertools.count():
    for a in itertools.count(b):
        a5b5 = a**5 + b**5
        if a5b5 == x:
            print(a, -b)
            sys.exit(0)
        a5b5 = a**5 - b**5
        if a5b5 == x:
            print(a, b)
            sys.exit(0)
        if x < a5b5:
            break

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec s(N); cin >> s;

    int ans = 0;
    //t=A-B
    FOR(t, 1, N){
       int x = t, y = N - 1 - t;
       int tmp = 0;
       while(t < y && !((N - 1) % t == 0 && x >= y)){
           tmp += s[x] + s[y];
           Max(ans, tmp);
           x += t; y -= t;
       }
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 1024
/*
 * ARC093_D.cpp
 *
 *  Created on: May 18, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

char grid[100][100];

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

	int A, B;
	cin >> A >> B;
	REP(i, 100) {
		grid[i][0] = '#';
		grid[i][99] = '.';
		FOR(j, 1, 98) {
			if(i%2==0) {
				grid[i][j] = '.';
			}
			else {
				grid[i][j] = '#';
			}
		}
	}

	for(int i=0; ; i+=2) {
		for(int j=2; j<=98; j+=2) {
			if(A  <= 1) break;
			grid[i][j] = '#';
			A--;
		}
		if(A <= 1) break;
	}
	for(int i=51; ; i+=2) {
			for(int j=97; j>=1; j-=2) {
				if(B  <= 1) break;
				grid[i][j] = '.';
				B--;
			}
			if(B <= 1) break;
		}

	cout << 100 << " " << 100 << endl;
	REP(i, 100) {
		REP(j, 100) {
			cout << grid[i][j];
		}
		cout << "\n";
	}
	cout << flush;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b;
   cin>>a>>b;
   k=0;
   for(i=0;i<3;i++)
   {
       if(a[i]==b[i])
       {
           k++;
       }
   }

   cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
aabaaa
aa

output:
0
3
4
"""

import sys


class NaiveStringSearch(object):
    __slots__ = ('target', 'pattern')

    def __init__(self, in_data):
        """"""
        self.target, self.pattern = map(lambda x: x.strip(), _input)

    def brute_force(self):
        m, n = len(self.pattern), len(self.target)
        for i in range(n - m + 1):
            for j in range(m):
                if self.target[i + j] != self.pattern[j]:
                    break
                if j == m - 1:
                    print(i)
        return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    case = NaiveStringSearch(in_data=_input)
    case.brute_force()

Measured memory_bytes: 7544
N = int(input())
A = list(map(int, input().split()))

flag = True
for a in A:
    if a % 2 == 0:
        if (a % 3 == 0) or (a % 5 == 0):
            continue
        else:
            flag = False
            break

if flag:
    print("APPROVED")
else:
    print("DENIED")


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

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;

ll
gcd(ll c, ll d)
{
  return d ? gcd(d, c % d) : c;
}

int
main() 
{
  int n, q; cin >> n >> q;
  string s; cin >> s;
  vector<vector<int>> arr(q);
  rep(i, 0, q){
    int l, r; cin >> l >> r;
    arr[i].push_back(l);
    arr[i].push_back(r);
  }

  vector<int> acum(n + 1, 0);

  rep(i, 1, n){
    if(s[i - 1] == 'A' && s[i] == 'C'){
      acum[i] = acum[i - 1] + 1;
    } else {
      acum[i] = acum[i - 1];
    }
  }

  rep(i, 0, q){
    int l = arr[i][0];
    int r = arr[i][1];
    cout << acum[r - 1] - acum[l - 1] << endl;
  }





}



Measured memory_bytes: 6784
#include <iostream>
using namespace std;
int main(void){
    long long n, ans = 0;
    cin >> n;
    if(n%2 == 1) ans = 0;
    else{
        for(long long x = 10; x <= n; x *= 5){
            ans += n/x;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,s[50001],t[50001],e[50001];
  cin>>n>>m;
  int i=0;
  while(cin>>s[i]>>t[i]>>e[i],s[i])s[i]--,t[i]--,i++;
  int l;
  cin>>l;
  for(int j=0;j<l;j++){
    int b[10000];
    for(int k=0;k<m;k++){
      cin>>b[k];
    }
    int ans[10000]={};
    for(int k=0;k<i;k++)
      ans[s[k]]+=e[k]*b[t[k]];
    for(int k=0;k<n;k++){
      if(k)cout<<" ";
      cout<<ans[k];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3616
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String S = sc.next();
        final int M = sc.nextInt();
        // final int A = sc.nextInt();
        // final int B = sc.nextInt();
        // final int C = sc.nextInt();

        // System.out.println();
        System.out.println(24 + (24 - M));

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21076