akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from collections import deque

def read_graph(v, e):
    A = [ [float('inf')]*v for _ in range(v) ]
    for i in range(v):
        A[i][i] = 0
    for _ in range(e):
        line = list(stdin.readline().strip().split())
        i = line[0]
        j = line[1]
        k = line[2]
        A[int(i)][int(j)] = int(k)
    return A

def worshall_floyd(A, v):
    for k in range(v):
        for i in range(v):
            if A[i][k] == float('inf'):
                continue
            for j in range(v):
                if A[k][j] == float('inf'):
                    continue
                A[i][j] = min(A[i][j], A[i][k] + A[k][j])
    return A

def print_ans(A, v):
    NEGATIVE = False
    for i in range(v):
        if A[i][i] < 0:
            NEGATIVE = True
    if NEGATIVE:
        print('NEGATIVE CYCLE')
    else:
        for i in A:
            print(*[str(k).upper() for k in i], sep=' ')

v, e = [int(i) for i in input().split()]
A = read_graph(v, e)
A = worshall_floyd(A, v)
print_ans(A, v)



Measured memory_bytes: 6700
n, k = map(int, input().split())
s = [int(s) for s in list(input())]
count = 0
tmp = 1
c = []

for i in s:
    if i == tmp:
        count += 1
    else:
        c.append(count)
        tmp = i
        count = 1

c.append(count)
if s[-1] == 0:
    c.append(0)

if len(c) <= 2*k+1:
    ans = sum(c)
else:
    ans = total = sum(c[:2*k+1])
    for i in range(0, len(c)-2*k-2, 2):
        total = total + c[i+2*k+1] + c[i+2*k+2] - c[i] - c[i+1]
        ans = max(ans, total)

print(ans)


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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
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; } }

int main(void) {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    int ans = 1e9;
    ans = min(ans, abs(a2-a1)+abs(a3-a2));
    ans = min(ans, abs(a3-a1)+abs(a2-a3));
    ans = min(ans, abs(a1-a2)+abs(a3-a1));
    ans = min(ans, abs(a3-a2)+abs(a1-a3));
    ans = min(ans, abs(a1-a3)+abs(a2-a1));
    ans = min(ans, abs(a2-a3)+abs(a1-a2));

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a = [int(input()) for _ in range(5)]
max_i = 9
flag_0 = 0
ans = 0
for i in range(5):
    if a[i] % 10 != 0:
        flag_0 = 1
        max_i = min(max_i,a[i]%10)
        ans += (a[i]//10)*10 + 10
    else: ans += a[i]
if flag_0:
    ans -= 10 - max_i
print(ans)


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

int main() {
  string s;
  cin>>s;
  int a[26]={};
  bool out=true;
  for(int i=0;i<s.size();i++)
    a[s[i]-'a']++;
  for(int i=0;i<26;i++)
    if(a[i]==0){
      cout<<char(i+'a');
      out=false ;
      break;
    }
      
  if(out)
    cout<<"None";
  
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    string s;
    cin >> s;
    int32 q;
    cin >> q;
    while(q--){
        int32 k;
        cin >> k;
        int64 res = 0;
        int32 d = 0, m = 0, c = 0;
        int64 comb = 0;
        REP(i,n){
            if(i - k >= 0){
                if(s[i-k] == 'D'){
                    d--;
                    comb -= m;
                }else if(s[i-k] == 'M'){
                    m--;
                }else if(s[i-k] == 'C'){
                    c--;
                }
            }
            if(s[i] == 'D'){
                d++;
            }else if(s[i] == 'M'){
                m++;
                comb += d;
            }else if(s[i] == 'C'){
                c++;
                res += comb;
            }
            // cout << d << " " << m << " " << c << " " << comb << endl;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1948
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def f(x,y,i):
        p = [a[x],a[i-1]-a[x],b[y],b[-i-1]-b[y]]
        if 0 in p:
            return float("inf")
        return max(p)-min(p)

    n = I()
    a = LI()
    b = [a[i] for i in range(n)]
    for i in range(n-1):
        a[i+1] += a[i]
    for i in range(n-1)[::-1]:
        b[i] += b[i+1]
    b.sort()
    ans = float("inf")
    for i in range(2,n-1):
        l = a[i-1]
        r = b[-1-i]
        li = bisect.bisect_left(a,l/2)
        ri = bisect.bisect_left(b,r/2)
        for x in range(max(li-1,0),min(li+2,i-1)):
            for y in range(max(ri-1,0),min(ri+2,n-i-1)):
                ans = min(f(x,y,i),ans)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 84484
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = new long[n];
            string[] lines = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(lines[i]);
            }

            long ans1 = 0;
            long ans2 = 0;
            int sign = 1;
            long sum = 0;
            for (int i = 0; i < n; i++)
            {
                sum += a[i];
                if (sign > 0)
                {
                    if (sum >= 0)
                    {
                        ans1 += 1 + sum;
                        sum = -1;
                    }
                }
                else
                {
                    if (sum <= 0)
                    {
                        ans1 += 1  -sum;
                        sum = 1;
                    }
                }
                sign *= -1;
            }

            sign = -1;
            sum = 0;
            for (int i = 0; i < n; i++)
            {
                sum += a[i];
                if (sign > 0)
                {
                    if (sum >= 0)
                    {
                        ans2 += 1 + sum;
                        sum = -1;
                    }
                }
                else
                {
                    if (sum <= 0)
                    {
                        ans2 += 1 - sum;
                        sum = 1;
                    }
                }
                sign *= -1;
            }

            Console.WriteLine(Math.Min(ans1, ans2));
        }
    }
}


Measured memory_bytes: 29280
/* SANDEEP YADAv*/
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
lld gcd(lld a,lld b){ if(a<b) { a=a+b; b=a-b; a=a-b;}while(b!=0){lld r=a%b; a=b; b=r;} return a;}
long long power(long long a, long long b, long long m) {a %= m;long long res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
void judge()
{
      #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif
}

int main()
{
    fastio;
    // judge();

    string s;
    cin>>s;
    lld n=s.size();

    int flag=0;
    for(int i=0;i<n;i++)
        if(s[i]!=s[n-i-1])
            flag=1;

        for(int i=0;i<(n-1)/2;i++)
            if(s[i]!=s[(n-1)/2-i-1])
            flag=1;
        for(int i=(n+3)/2;i<n;i++)
            if(s[i]!=s[(n-i-1)])
            flag=1;
        if(!flag)
            cout<<"Yes";
        else
            cout<<"No";

    return 0;
}

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

int main(){
  string S[2];
  cin>>S[0]>>S[1];
  map<char,char> mp[2];
  for(int j=0;j<2;j++){
    for(int i=0;i<S[j].size();i++){
      if(mp[j].count(S[j][i])){
        if(mp[j][S[j][i]] != S[1-j][i]){
          cout<<"No"<<endl;
          return 0;
        }
      }
      else{
        mp[j][S[j][i]] = S[1-j][i];
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int x;
    cin >> x;
    REP(i, 1, x +1) {
        if(x % i != 0) continue;
        if(i <= 9 && x /i <= 9) {
            cout << "Yes" << endl;
            return 0; 
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

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

    while(!s.empty()){
        if(s.length() >= 6 && s.substr(s.length()-6) == "eraser"){
            s.erase(s.begin()+s.length()-6,s.end());
            continue;
        }else if(s.length() >= 7 && s.substr(s.length()-7) == "dreamer"){
            s.erase(s.begin()+s.length()-7,s.end());
            continue;
        }else if(s.length() >= 5 && s.substr(s.length()-5) == "dream"){
            s.erase(s.begin()+s.length()-5,s.end());
            continue;
        }else if(s.length() >= 5 && s.substr(s.length()-5) == "erase"){
            s.erase(s.begin()+s.length()-5,s.end());
            continue;
        }
        std::cout << "NO" << std::endl;
        return 0;
    }
    std::cout << "YES" << std::endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int A, B; cin >> A >> B;
	if((A+B)<10) cout << A+B << endl;
	else cout << "error" << endl;


	return 0;

}


Measured memory_bytes: 256
use std::collections::BinaryHeap;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (n, m) = parse!(it, 2);
    let mut items: Vec<(usize, usize)> = (0..n).map(|_| parse!(it, 2)).collect();
    items.sort();
    items.reverse();
    let mut q = BinaryHeap::new();
    let mut ret = 0;
    for i in 0..m {
        while items.len() > 0 {
            let last = items[items.len() - 1];
            if last.0 <= i + 1 {
                q.push(last.1);
                items.pop();
            } else {
                break;
            }
        }
        if let Some(v) = q.pop() {
            ret += v;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 10492
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
n,k=map(int,input().split())
if k%2==1:
    num=n//k
    print(num**3)
else:
    num=n//k
    num2=(n-k//2)//k+1
    print(num**3+num2**3)

Measured memory_bytes: 64936
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

int main() {
	ll n; cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		a[i] = x;
	}
	sort(a.begin(), a.end());
	ll min = INF, r;
	for (int i = 0; i < n - 1; ++i) {
		if (abs((double)(a[i] - (double)(a[n - 1] / 2.0))) < min) {
			min = abs((double)(a[i] - (double)(a[n - 1] / 2.0)));
			r = a[i];
		}
	}
	cout << a[n - 1] << " " << r << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,a[100002],b[100002],c[100002];
long long fA[100002],fB[100002],fC[100002];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	for(int i=1;i<=n;i++){
		fA[i]=max(fB[i-1],fC[i-1])+a[i];
		fB[i]=max(fA[i-1],fC[i-1])+b[i];
		fC[i]=max(fB[i-1],fA[i-1])+c[i];
	}
	cout<<max(max(fA[n],fB[n]),fC[n]);
}

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

int main()
{
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	char last = '0';
	for( int i = 0; i < N; i++ ) {
		if( S[i] != last ) {
			ans++;
			last = S[i];
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 512
import sys
import string
input = sys.stdin.readline
from collections import defaultdict
N = int(input())
T = [input()[::-1].strip() for i in range(N)]

#N = 100
#M = 10000
#import random
#import string
#T = [''.join(random.choices(string.ascii_lowercase, k=random.randint(M,M))) for i in range(N)]

class TrieTree:
    class Node:
        def __init__(self):
            #self.clue = defaultdict(int)
            self.clue = [0]*26
            self.ch = defaultdict(TrieTree.Node)
            self.cnt = 0
            self.end = False

    def __init__(self):
        self.root = self.Node()

    def register(self,word):
        node = self.root
        for w in word:
            node.cnt += 1
            node = node.ch[w]
        node.cnt += 1
        node.end = True
    
    def prefix(self, word):
        node = self.root
        for w in word:
            if w not in node.ch:
                return False
            else:
                node = node.ch[w]
        return node

tt = TrieTree()
for word in T:
    tt.register(word)

route = []

st = [tt.root]
while st:
    node = st.pop()
    route.append(node)
    st.extend(node.ch.values())

f = lambda c : ord(c)-97
for node in route[::-1]:
    for c,nnode in node.ch.items():
        for i,v in enumerate(nnode.clue):
            node.clue[i] += v
        node.clue[f(c)] += nnode.cnt - nnode.clue[f(c)]

ans = 0
for word in T:
    pre = word[:-1]
    last = word[-1]
    node = tt.prefix(pre)
    if not node:
        continue
    ans += node.clue[f(last)] - 1
    
print(ans)


Measured memory_bytes: 923892
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
	ll n,x,t;
	cin>>n>>x>>t;
	ll count = 0;
	while(1)
	{
		if(n<=0)
		{
			break;
		}
		else
		{
			n=n-x;
			count+=t;
		}
	}
	cout<<count<<endl;
	
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

long long GCD(long long a, long long b) {                                                                                                                                                             
     if (b == 0) return a;
     else return GCD(b, a % b);
}
 
long long LCM(long long a, long long b) {
     long long g = GCD(a, b);
     return a / g * b;
}

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    ll lcm = 1;
    rep(i,n) lcm = LCM(lcm,a[i]);

    bool ok = true;
    rep(i,n) if ((lcm/a[i]) % 2 == 0) ok = false;
    if (!ok) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = m / (lcm/2);
    ans = (ans + 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <deque>
struct dot{int x,y,step;};std::deque<dot> q;
int h,w,ch,cw,dh,dw;char s[1003][1003];bool vis[1003][1003];
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
int main(){
    scanf("%d%d%d%d%d%d",&h,&w,&ch,&cw,&dh,&dw);
    for(int i=1;i<=h;i++) scanf("%s",s[i]+1);
    q.push_back((dot){ch,cw,0});
    while(!q.empty()){
        dot t=q.front();q.pop_front();
        //printf("%d %d %d\n",t.x,t.y,t.step);
        if(t.x==dh&&t.y==dw) return printf("%d\n",t.step),0;
        vis[t.x][t.y]=1;
        for(int i=0;i<4;i++){
            int tx=t.x+dx[i],ty=t.y+dy[i];
            if(tx>=1&&tx<=h&&ty>=1&&ty<=w&&!vis[tx][ty]&&s[tx][ty]=='.')
                q.push_front((dot){tx,ty,t.step});
        }
        for(int tx=t.x-2;tx<=t.x+2;tx++)
            for(int ty=t.y-2;ty<=t.y+2;ty++)
                if(tx>=1&&tx<=h&&ty>=1&&ty<=w&&!vis[tx][ty]&&s[tx][ty]=='.')
                    q.push_back((dot){tx,ty,t.step+1});
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 11996
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n;
	long long int sum = 1000;
	cin >> n;
	vector<int> num(n);
	for (int i = 0; i < n; i++)
		cin >> num[i];
	for (int i = 0; i < n - 1; i++)
		if (num[i] < num[i + 1])
			sum = (sum / num[i]) * num[i + 1] + (sum - num[i] * (sum / num[i]));
	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 3628
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, d: usize, x: [[i32; d];n]};
    let x: Vec<Vec<i32>> = x;
    let mut count = 0;

    for i in 0..n - 1 {
        for j in i + 1..n {
            let mut result: usize = 0;
            for k in 0..d {
                result += (x[i][k] - x[j][k]).pow(2) as usize;
            }
            let x = (result as f64).sqrt() as usize;
            if x * x == result {
                count += 1;
            }
        }
    }

    println!("{}", count)
}


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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		Arrays.sort(a);

		int ans = 0;
		Set<Integer> set = new HashSet<>();
		label:
		for (int i = 0; i < n; i++) {
			if (i < n - 1 && a[i] == a[i + 1]) {
				set.add(a[i]);
				continue;
			}
			List<Integer> list = divList(a[i]);
			for (Integer e : list) {
				if (set.contains(e)) {
					continue label;
				}
			}
			set.add(a[i]);
			ans++;
		}
		System.out.println(ans);
	}

	static List<Integer> divList(int n) {
		List<Integer> list = new ArrayList<>();
		int end = (int) Math.sqrt(n);
		for (int i = 1; i <= end; i++) {
			if (n % i == 0) {
				list.add(i);
			}
		}
		int i = end * end == n ? list.size() - 2 : list.size() - 1;
		for ( ; i >= 0; i--) {
			list.add(n / list.get(i));
		}
		return list;
	}
}


Measured memory_bytes: 74932
#include<stdio.h>
 
int n,key,j;
int a[1005];
 
int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    printf("%d",a[0]);
    for(int k=1; k<n; k++)
        printf(" %d",a[k]);
    printf("\n");
    for(int i=1; i<n; i++)
    {
        key=a[i];
        j=i-1;
        while(j>=0&&a[j]>key)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=key;
        printf("%d",a[0]);
        for(int k=1; k<n; k++)
            printf(" %d",a[k]);
        printf("\n");
    }
    return 0;
}


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

int main(){
  long long A,B,K;
  cin>>A>>B;
  K=abs(A-B);
  if(K%2==0){
    if(A<B){
      cout<<B-K/2<<endl;
    }
    else{
    cout<<A-K/2<<endl;
    }
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 1e9;

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;
}

int main() {
    // input
    int n;
    cin >> n;
    int x[n];
    rep(i, n) {
        cin >> x[i];
    }
    // solve
    ll min_p = INF;
    for (int p = 1; p <= 100; p++) {
        ll sum = 0;
        rep(i, n) {
            sum += (x[i]-p)*(x[i]-p);
        }
        chmin(min_p, sum);
    }
    // output
    cout << min_p << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,m,dp[100009],e[100009],ans;
vector<int>G[100009];
queue<int>q;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	while(m--) {
		int x,y;
		cin>>x>>y;
		e[y]++;
		G[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
		if(!e[i])
			q.push(i);
	while(q.size()) {
		int hd=q.front();
		q.pop();
		for(int i=0;i<G[hd].size();i++) {
			e[G[hd][i]]--;
			dp[G[hd][i]]=max(dp[G[hd][i]],dp[hd]+1);
			if(!e[G[hd][i]]) q.push(G[hd][i]);
		}
	}
	for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
import os
import sys
from io import BytesIO, IOBase


def solution(s, k):
    n = len(s)
    if n <= k:
        write(s)
    else:
        write(s[:k] + "...")


def main():
    k = r_int()
    s = input()
    solution(s, k)


# fast-io region

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

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

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

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

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


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


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end='\n'):
    for x in args[:-1]:
        sys.stdout.write(str(x) + ' ')
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


if __name__ == "__main__":
    main()


Measured memory_bytes: 62672
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

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

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e3 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const ll MOD2 = 1e9 + 7;
const ll MOD3 = 1e9 + 9;

ll n , m , dp[MAXN][MAXN];
string s[MAXN];

int main() {
    fast_io;

    cin >> n >> m;
    for(ll i = 1 ; i <= n ; i++)    cin >> s[i];

    dp[0][1] = 1;
    for(ll i = 1 ; i <= n ; i++)
    {
        for(ll j = 1 ; j <= m ; j++)
        {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            if(s[i][j - 1] == '#')  dp[i][j] = 0;
        }
    }
    cout << dp[n][m] << endl;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 9216
N = int(input())

ans = []
current_sum = 0
for i in range(1, N+1):
    ans.append(i)
    current_sum += i
    if current_sum >= N:
        break

diff = current_sum - N
if diff > 0:
    ans.remove(diff)
for _ans in ans:
    print(_ans)

Measured memory_bytes: 3572
import java.io.*;
import java.util.*;

class Main{
	public void run(){
		HashSet<Integer> set = new HashSet<>();
		set.add(ni());
		set.add(ni());
		set.add(ni());
		out.println(set.size());
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 8148
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
long long gcd(long long a,long long b){
    a=a%b;
    if(a==0)return b;
    else if(a==1)return 1;
    else return gcd(b,a);
}
long long lcm(long long a,long long b){
return a>b ? a*b/gcd(a,b) : a*b/gcd(b,a);
}
int main(){
    long long a,b;
    scanf("%lld %lld",&a,&b);
    printf("%lld",lcm(a,b));
    return 0;
}

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

int main()
{
  long long n,w;
  cin >> n >> w;
  long long wei[n+1], val[n+1], dp[n+1][w+1]={}; 
  for(long long i=1; i<=n; i++) cin >> wei[i] >> val[i];
  for(long long i=1; i<=n; i++)
  {
    for(long long j=1; j<=w; j++)
    {
      if(j>=wei[i]) dp[i][j] = max(dp[i-1][j], dp[i-1][j-wei[i]] + val[i]);
      else dp[i][j] = dp[i-1][j];
    }
  }
  cout << dp[n][w];
  return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int k(int k)
{
	int n=0;
	while(k>0)
	{
		n+=k%10;
		k/=10;
	}
	return n;
}
int main()
{
	int n,a,b,ans=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;++i)
	{
		if(k(i)>=a&&k(i)<=b)ans+=i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)



int main()
{
    string S, T;
    cin >> S;
    cin >> T;
    if (1 <= S.length() && S.length() <= 10) {
        if (T.length() == S.length() + 1) {
            if (S == T.substr(0, T.length()-1)) {
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    } else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
#include<stdio.h>

int main() {

	int a[10000], b=1, c=1;

	scanf("%d", &a[1]);
	if(a[1] != 0)
	{
		for (b = 2; a[b - 1] != 0; b++, c++)
		{
			scanf("%d", &a[b]);
		}

		for (b = 1; b < c; b++)
		{
			printf("Case %d: %d\n", b, a[b]);
		}
	}
	return 0;
}

Measured memory_bytes: 1744
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    vec<int> m(5);
    int o = -1;
    for(int q=0; q<5; q++){
        cin>>m[q];
        if(!m[q]) o = q;
    }
    cout<<o+1;
}

Measured memory_bytes: 3652
while True:
    N, X = map(int, input().split())
    if N == 0:
        break
    res = 0
    for i in range(1, N-1):
        for j in range(i+1, N):
            for k in range(j+1, N+1):
                if i + j + k == X:
                    res += 1
    print(res)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define roop0(n) for(long long i = 0;i < n;i++)
#define roop1(n) for(long long i = 1;i < n;i++)
#define rep(i,a,b) for(long long i = a; i < b; i++)
#define print(a) for(auto x : a) cout << x << " "; cout << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using namespace std;
typedef long long ll;
using vi   = vector<int>;
using vll  = vector<ll>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvs  = vector<vector<string>>;

int main () {
  int n; cin >> n;
  ll A[n]; roop0(n) cin >> A[i];
    
  ll money = 1000;
  ll kabu = 0;
  for (int i = 0;i < n - 1;i++) {
    money += A[i] * kabu;
    kabu = 0;
    if (A[i] < A[i + 1]) // 今日が安いから買う
    {     
      
      ll buyable = money / A[i];
      money -= buyable * A[i];
      kabu += buyable;
    }
  }
  if (kabu > 0) money += kabu * A[n - 1];
  cout << money << endl;
  
  return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int n,k;cin>>n>>k;
  string s;cin>>s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }if(s[k-1]=='B'){
    s[k-1]='b';
  }if(s[k-1]=='C'){
    s[k-1]='c';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_166_AC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            if (s == "ABC")
            {
                s = "ARC";
            }
            else
            {
                s = "ABC";
            }



            string result = s;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25660
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def lcm(a, b):
    n = fractions.gcd(a, b)
    return a * b // n

def main():
    N = I()
    curT, curA = 1, 1
    for i in range(N):
        newT, newA = LI()
        # if newT >= curT and newA >= curA:
        #     curT, curA = newT, newA
        #     continue
        r1 = (curT-1)//newT + 1
        r2 = (curA-1)//newA + 1
        curT = newT * max(r1, r2)
        curA = newA * max(r1, r2)
    print(curT + curA)
main()



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

priority_queue<unsigned long long int> a;
unsigned long long int n, m, x, ans = 0;

int main()
{
	cin >> n >> m;
	for (size_t i = 0; i < n; i++)
	{
		cin >> x;
		a.push(x);
	}
	for (size_t i = 0; i < m; i++)
	{
		x = a.top();
		a.pop();
		x >>= 1;
		a.push(x);
	}
	while (!a.empty())
	{
		ans += a.top();
		a.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
import numpy as np
import sys
sys.setrecursionlimit(100000)


def main():
    n, m, x = map(int, input().split())
    cl = [None]*n
    al = [None]*n
    for i in range(n):
        cl[i], *al[i] = map(int, input().split())
    
    def dfs(i, cost, A):
        if i == n-1:
            global ans
            if all([a >= x for a in A]) and cost < ans:
                ans = cost
            return
        i += 1
        dfs(i, cost, A[:])
        dfs(i, cost+cl[i], A[:]+al[i])
    
    dfs(-1, 0, np.array([0]*m))
    
    if ans == 10**7:
        print(-1)
    else:
        print(ans)
        

if __name__ == "__main__":
    ans = 10**7
    main()

Measured memory_bytes: 27184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int n;
  cin >> n;
  if(n % 10 == 3) {
    cout << "bon";
  } else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
    cout << "pon";
  } else {
    cout << "hon";
  }
}

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

int main()
{
	int a;
	cin>>a;
	int b,c,d;
	while(a>0){
		b=a%10;
		a/=10;
		c=a%10;
		a/=10;
		d=a%10;
		a/=10;
	}
	if(b==7||c==7||d==7){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int digit_num(long long a){
  int res = 0;
  while(a > 0){
    a /= 10;
    res++;
  }
  return res;
}

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

  long long n;
  cin >> n;

  long long digit_a = 1, digit_b = digit_num(n), res = digit_b;;
  for(long long i = 2; i * i <= n; i++){
    if(n % i == 0){
      n /= i;
      digit_a = digit_num(i), digit_b = digit_num(n);
      res = min(res, max(digit_a, digit_b));
      n *= i;
    }
  }

  cout << res << "\n";

  return 0;
  
}


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

int main (void) {
    int n, i;
    scanf("%d", &n);
    long long a[n];
    for ( i=0; i<n; i++ )
        scanf("%lld", &a[i]);

    long long rain_m[n];  /* rain amount of each mountain */
    rain_m[0] = 0;
    for ( i=0; i<n; i++ )
        rain_m[0] += (i%2)?-a[i]:a[i];
    for ( i=1; i<n; i++ )
        rain_m[i] = 2*(a[i-1]-rain_m[i-1]/2);

    for ( i=0; i<n; i++ )
        printf("%lld ", rain_m[i]);
    printf("\n");
    return EXIT_SUCCESS;
}


Measured memory_bytes: 2816
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(m)]

class UnionFind(object):

    def __init__(self, N):
        self.N = N
        self.parent = list(range(self.N))
        self.rank = [0] * self.N
        self.size = [1] * self.N

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            x, y = y, x

        self.size[x] += self.size[y]
        self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def count(self, x):
        return self.size[self.find(x)]

uni = UnionFind(n)
ans = []
kota = n*(n-1)/2
ans.append(kota)
for i in range(m-1,0,-1):
    x,y = a[i]
    x-=1;y-=1
    xs = uni.count(x)
    ys = uni.count(y)
    if uni.find(x) == uni.find(y):
      ans.append(kota)
      continue
    uni.union(x,y)
    kota -= ys*xs
    ans.append(kota)
for i in ans[::-1]:
  print(int(i))

Measured memory_bytes: 38060
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll inf = (1 << 29);
template<typename T>
T GCD(T a, T b) {
	while (max(a, b) % min(a, b)) {
		if (a > b)a = a % b;
		else b = b % a;
	}
	return min(a, b);
}
template<typename T>
T LCM(T a, T b) {
	return a / GCD(a, b)*b;
}
bool prime(ll a) {
	for (int i = 2; i <= sqrt(a); i++) {
		if (!(a%i))return false;
	}
	return true;
}
int main() {
	int n;
	int ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i+=2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (!(i%j))cnt++;
		}
		if (cnt == 8)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)

int main() {
    // your code goes here
    ll n,s=0;
    cin >> n;
    rep(i,1,n){
        if(i%3!=0&&i%5!=0) s+=i;
    }
    cout << s << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
	int N;
	int A[11];
	int cnt1=0;
	cin>>N;
	while(1){
		
		if(cnt1==N){
			break;
		}
		cnt1++;
		for(int i=1;i<=10;i++){
			cin>>A[i];
		}
		int B=A[1];
		int Z[11];
		for(int i=1;i<=10;i++){
			Z[i]=0;
		}
		int C=0;
		int cnt2=0;
		int su=0;
		for(int i=2;i<=10;i++){
			if((B+1==A[i])/*||((su==1)&&(B<A[i]))*/){
				B=A[i];
				cnt2++;
				//cout<<"1"<<A[i]<<endl;
			}
			else if((C+1==A[i])/*||((su==1)&&(B<A[i]))*/){
				C=A[i];
				cnt2++;
				Z[i]=C;
				su=0;
//cout<<"2"<<A[i]<<endl;
			}
			else if(B<A[i]){
				B=A[i];
				//Z[i]=C;
				//su=0;
				cnt2++;
//cout<<"3"<<A[i]<<endl;
			}
			else if(C<A[i]){
				C=A[i];
				Z[i]=C;
				su=0;
				cnt2++;
//cout<<"4"<<A[i]<<endl;
			}
			//CにB＋1がはいっていたらsu=1にすること
			for(int q=1;q<=10;q++){
				if(B+1==Z[q]){
					su=1;
				}
			}
			
		}
		if(cnt2==9){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;	
}

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

int main() {
  int n, r;
  cin >> n >> r;
  if(n>9) cout << r << endl;
  else cout << r+100*(10-n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

long long ruijou(int n, int k){
    if(k==0) return 1;
    int x=k/2;
    long long t=ruijou(n,x);
    
    if(k%2==1) return n*t*t;
    else return t*t;
}

ll N,K;
vec d;

ll solve(ll k, vec D){
    ll ret=0;
    ll n=D.size();
    if(D.size()<k) return 0;
    if(k==1){
        ret=D.at(0);
        ret+=(D.size()-1)*9;
        return ret;
    }

    else{
        if(n>k) {
            ret=1;
            rep(i,k) ret*=(n-1-i);
            rep(i,k) ret/=(i+1);
            rep(i,k) ret*=9;
        }

        vec a,b;
        rep(i,n-1) a.pb(9);
        ret+=(D.at(0)-1)*solve(k-1,a);
        ll x=1;
        while(D.at(x)==0) {x++; if(x==n) break;}
        if(x!=n){
            for(ll i=x; i<n;i++) b.pb(D.at(i));
        }
        ret+=solve(k-1,b);
        return ret;
    }
}


int main(){
    string S; cin>>S;
    N=S.size();
    cin>>K;
    ll ans=1;
    
    rep(i,N) d.pb(S.at(i)-'0');
    
    cout<<solve(K,d)<<endl;
}

Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

//vl f(N);


int main()
{ 

IOS;

ll n;cin>>n;

vpll x(n);

FOR(i,n){
  cin>>x[i].ff;
  x[i].ss=i+1;
}

sort(all(x));

FOR(i,n){
  cout<<x[i].ss<<" ";
}

return 0;
 
}


Measured memory_bytes: 4628