akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
using vec = vector<vector<vector<vector<int>>>>;

int main(){
in hp,n;
  cin>>hp>>n;
  vector<pair<in,in>> a(n);
  in x,y;
  rep(i,n){
  cin>>x>>y;
    a.at(i)= make_pair(x,y);
  }
  vector<in> dp(21000,INF);
  dp[0]=0;
  in mp,dmg;
  rep(i,hp){
    rep(j,n){
      dmg=a[j].first;
       mp=a[j].second;
       dp[i+dmg]=min(dp[i]+mp,dp[i+dmg]);
    }
  }
  in ans =INF;
  for(int i=hp;i<21000;i++){
    ans =min(ans,dp[i]);
  }
  cout<<ans;
}


Measured memory_bytes: 384
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
x = l()
p=sorted(x)
mid = len(p)//2
for i in x:
    a = bisect.bisect(p,i)
    if a <= mid:
        print(p[mid])
    else:
        print(p[mid-1])


Measured memory_bytes: 33856
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int ans =0;
    if(n-k>0){
        ans += k*x;
        ans += (n-k)*y;
    }else{
        ans = n*x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//هوالحق
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int r = 1, p = 0;
    while(r<n && x + p <= m){
        p+=x;
        cin >> x;
        r++;
    }
    cout << r + ((p+x <= m?1:0));
}


Measured memory_bytes: 256
n = int(input())
line = []
for _ in range(n):
    x, l = map(int, input().split())
    s, g = x-l, x+l
    line.append([g, s])

line.sort()
ans = 1
now_g = line[0][0]

for g, s in line[1:]:
    if now_g <= s:
        ans += 1
        now_g = g

print(ans)


Measured memory_bytes: 20480
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		int k=scanner.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scanner.nextInt();
		}
		int cnt=2;
		for(int i=2;i<n;i++) {
			cnt++;
			if(cnt%k==1) {
				i--;
			}
		}
		System.out.println((int)Math.ceil((double)cnt/k));
	}
}


Measured memory_bytes: 50284
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n; scan(n);
    auto b = readints;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans += b[i];
        }
        else if (i == n - 1) {
            ans += b[i - 1];
        }
        else {
            ans += min(b[i - 1], b[i]);
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
N = int(input())
pre_w = input()
his = [pre_w]
for i in range(N-1):
    w = input()
    if pre_w[-1] != w[0]:
        print("No")
        break
    elif w in his:
        print("No")
        break
    his.append(w)
    pre_w = w
    if i == N-2:
        print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vi a(n), f(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, n)
    {
        cin >> f[i];
    }
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll l = -1;
    ll r = 1e12;
    while (l + 1 < r)
    {
        ll mid = (l + r) / 2;
        bool ok = [&] {
            ll s = 0;
            rep(i, n)
            {
                s += max(a[i] - mid / f[i], 0ll);
            }
            return s <= k;
        }();
        if (ok)
            r = mid;
        else
            l = mid;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#define ll long long
#define MOD 1000000007

using namespace std;

ll s(ll x)
{
    ll ans=1,i=1;
    while(i<=x)
    {
        ans=(ans*i)%MOD;
        i++;
    }
    return ans;
}

int main()
{
    ll n,m;
    while(cin>>n>>m)
    {
        if(abs(n-m)>1)
        {
            printf("0\n");
            continue;
        }
        if(abs(n-m)==1)
        {
            ll sum=s(n)*s(m)%MOD;
            cout<<sum<<endl;
        }
        else
        {
            ll sum=s(n)*s(n)*2%MOD;
            cout<<sum<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    string s;
    cin>>s;
    stack<int> p[10];
    vector<bool> can(1000,false);
    vector<bool> used(10,false);
    REP(i,N) p[s[i]-'0'].push(i);
    REP(i,N){
        if(used[s[i]-'0']) continue;
        rep(j,i+1,N) REP(k,10) if(!p[k].empty()){
            if(p[k].top()>j) can[(s[i]-'0')*100+(s[j]-'0')*10+k]=true;
        }
        used[s[i]-'0']=true;
    }
    int ans=0;
    REP(i,1000) if(can[i]) ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, k; std::cin >> n >> k;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    int sum = std::accumulate(a.begin(), a.end(), 0);
    std::vector<int> b;
    auto check = [&](int m) -> bool {
        b.clear();
        for (int i = 0; i < n; i++) b.push_back(a[i] % m);
        std::sort(b.rbegin(), b.rend());
        int c = std::accumulate(b.begin(), b.end(), 0) / m;
        return std::accumulate(b.begin() + c, b.end(), 0) <= k;
    };
    int ans = 0;
    for (int i = 1; i*i <= sum; i++) {
        if (sum%i != 0) continue;
        if (check(i)) ans = std::max(ans, i);
        if (check(sum / i)) ans = std::max(ans, sum / i);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
using System;


namespace ITP1_1C
{
    class Program
    {
        static void Main()
        {

            int a, b, c, d;

            string[] str = Console.ReadLine().Split(' ');

            a = int.Parse(str[0]);
            b = int.Parse(str[1]);

            c = a * b;
            d = 2 * a + 2 * b;

            Console.WriteLine("{0} {1}" ,c, d);

            

        }
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/10/04  Problem: Nagoya_univ_contest_17_b  / Link:   ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	FOR(i, 0, N) {
		int l, r; cin >> l >> r;
		ans += (r - l + 1);
	}
	
	cout << ans << "\n";

	return 0;
}

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

int main()
{
     ll n,s,b;
     scanf("%lld%lld%lld",&n,&s,&b);
     if(s>b||(n==1&&s!=b))
          printf("0\n");
     else
          printf("%lld\n",((n-2)*(b-s)+1));

     return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
bool dp_x[4010][17000], dp_y[4010][17000];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int x, y; cin >> x >> y;
  int idx;
  for (idx = 0; idx < s.length(); ++idx) {
    if (s[idx] == 'T') break;
    --x;
  }
  ++idx;
  vector<int> xx, yy;
  int now = 0, tate = 1;
  FOR(i, idx, s.length()) {
    if (s[i] == 'T') {
      if (tate) yy.emplace_back(now);
      else xx.emplace_back(now);
      tate ^= 1;
      now = 0;
    } else ++now;
  }
  if (tate) yy.emplace_back(now);
  else xx.emplace_back(now);
  sort(ALL(xx));
  sort(ALL(yy));
  int x_sz = xx.size(), y_sz = yy.size();
  dp_x[0][8500] = true;
  int range = 0;
  REP(i, x_sz) {
    int ub = 8500 + range, lb = 8500 - range;
    FOR(j, lb, ub+1) if (dp_x[i][j]) {
      dp_x[i+1][j+xx[i]] = dp_x[i+1][j-xx[i]] = true;
    }
    range += xx[i];
  }
  if (!dp_x[x_sz][8500+x]) {
    cout << "No\n";
    return 0;
  }
  dp_y[0][8500] = true;
  range = 0;
  REP(i, y_sz) {
    int ub = 8500 + range, lb = 8500 - range;
    FOR(j, lb, ub+1) if (dp_y[i][j]) {
      dp_y[i+1][j+yy[i]] = dp_y[i+1][j-yy[i]] = true;
    }
    range += yy[i];
  }
  if (!dp_y[y_sz][8500+y]) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 129792
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

const ll INF = (1ll << 60);

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    while (n != 0)
    {
        int v[n][n + 1];
        rep(i, n) rep(j, n + 1) cin >> v[i][j];
        ll dp[1 << n];
        rep(i, 1 << n) dp[i] = INF;
        dp[0] = 0;
        rep(i, 1 << n)
        {
            rep(j, n)
            {
                if (i & (1 << j))
                    continue;
                rep(k, n + 1)
                {
                    if (k > 0 && (i & (1 << (k - 1))) == 0)
                        continue;

                    //   cerr << (i | (1 << j)) << endl;
                    dp[i | (1 << j)] = min(dp[i | (1 << j)], dp[i] + v[j][k]);
                }
            }
        }
        cout << dp[(1 << n) - 1] << endl;
        cin >> n;
    }
    return 0;
}



Measured memory_bytes: 3592
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
		}
		long base = Math.abs(A[0]) + Math.abs(A[N - 1]);
		for (int i = 0; i + 1 < N; ++i) {
			base += Math.abs(A[i + 1] - A[i]);
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(base - Math.abs(A[0]) - Math.abs(A[1] - A[0]) + Math.abs(A[1]));
		for (int i = 1; i < N - 1; ++i) {
			pw.println(base - Math.abs(A[i - 1] - A[i]) - Math.abs(A[i + 1] - A[i]) + Math.abs(A[i + 1] - A[i - 1]));
		}
		pw.println(base - Math.abs(A[N - 1]) - Math.abs(A[N - 2] - A[N - 1]) + Math.abs(A[N - 2]));
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 33512
L1=["2","4","5","7","9"]
L2=["0","1","6","8"]
n=input()
if(n[-1] in L1):
    print("hon")
elif(n[-1] in L2):
    print("pon")
elif(n[-1]=='3'):
    print("bon")
del L1
del L2

Measured memory_bytes: 9036
from collections import Counter
N = int(input())
need = int(N // 2)
x = 0
y = 0
num = list(map(int,input().split()))
x = len(list(filter(lambda x: x%4 == 0,num)))
y = len(list(filter(lambda x: (x%4 != 0) and (x%2==0),num)))
if (x + (y // 2)) >= need:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 14628
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int D = scan.nextInt();

		int count = 0;

		while (true) {
			if ((count % 2) == 0) {
				C -= B;
				if (C <= 0) {
					System.out.println("Yes");
					break;
				}
			} else {
				A -= D;
				if (A <= 0) {
					System.out.println("No");
					break;
				}
			}
			count++;
		}
	}
}

Measured memory_bytes: 35796
N,M=map(int,input().split())
p=[]
s=[]
for i in range(M):
  p0,S0=map(str,input().split())
  p0=int(p0)-1
  p+=[p0]
  s+=[S0]
awlist=[0 for i in range(N)]
walist=[0 for i in range(N)]
wacount=0
account=0
for i in range(M):
  if s[i]=='WA' and awlist[p[i]]==0:
    walist[p[i]]+=1
  elif s[i]=='AC' and awlist[p[i]]==0:
    account+=1
    awlist[p[i]]=1
    wacount+=walist[p[i]]
Answer=[account,wacount]
print(*Answer)

Measured memory_bytes: 14936
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, D: int, A: "List[List[int]]", Q: int, L: "List[int]", R: "List[int]"):
    K = {}
    for i in range(H):
        for j in range(W):
            K[A[i][j]] = (i, j)
    B = [[0 for _ in range(W)] for _ in range(H)]
    for i in range(D+1, H*W+1):
        j = i % D
        ti, tj = K[i]
        si, sj = K[i-D]
        B[ti][tj] = B[si][sj] + abs(ti-si) + abs(tj-sj)
    for q in range(Q):
        ri, rj = K[R[q]]
        li, lj = K[L[q]]
        s = B[ri][rj] - B[li][lj]
        print(s)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    Q = int(next(tokens))  # type: int
    L = [int()] * (Q)  # type: "List[int]"
    R = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    solve(H, W, D, A, Q, L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31320
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            if (S == "ABC")
            {
                WriteLine("ARC");
            }
            else
            {
                WriteLine("ABC");
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int read(){
	int a = 0; char c = getchar(); while(!isdigit(c)) c = getchar();
	while(isdigit(c)){a = a * 10 + c - 48; c = getchar();} return a;
}

const int _ = 5e5 + 7;
struct Edge{int end , upEd , w;}Ed[_ << 1];
int head[_] , cntEd , N , M , col[_] , num[3] , cnt;
void addEd(int a , int b , int c){Ed[++cntEd] = (Edge){b , head[a] , c}; head[a] = cntEd;}

bool dfs(int x , int c){
	++num[col[x] = c]; bool flg = 1;
	for(int i = head[x] ; i ; ++cnt , i = Ed[i].upEd)
		if(~col[Ed[i].end]) flg &= (c + Ed[i].w - col[Ed[i].end]) % 3 == 0;
		else flg &= dfs(Ed[i].end , (c + Ed[i].w) % 3);
	return flg;
}

int main(){
	N = read(); M = read(); memset(col , -1 , sizeof(col));
	for(int i = 1 ; i <= M ; ++i){int p = read() , q = read(); addEd(p , q , 1); addEd(q , p , 2);}
	long long sum = 0;
	for(int i = 1 ; i <= N ; ++i)
		if(col[i] == -1){
			num[0] = num[1] = num[2] = cnt = 0; bool flg = dfs(i , 0);
			if(!flg) sum += 1ll * (num[0] + num[1] + num[2]) * (num[0] + num[1] + num[2]);
			else if(!num[1] || !num[2]) sum += cnt >> 1;
			else sum += 1ll * num[0] * num[1] + 1ll * num[0] * num[2] + 1ll * num[1] * num[2];
		}
	cout << sum; return 0;
}


Measured memory_bytes: 13056
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

map <ll,int> prime_factor(ll mynum){//素因数分解
  map<ll,int> res;
  for(ll i = 2; i*i <= mynum; i++){
    while(mynum % i == 0){
      ++res[i];
      mynum /= i;
    }
  }
  if(mynum != 1){
    res[mynum] = 1;
  }
  return res;
}


int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N;
  cin >> N;
  map <int,int> P;
  for (int i = 1; i <= N; i++) {
    auto pr = prime_factor(i);
    for (auto x : pr) {
      P[x.fir] += x.sec;
    }
  }
  ll ans = 1;
  numa(x,P){
    ans *= x.sec + 1;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
    int64_t n,k;
    cin >> n >> k;

    vector<int> v(n);
    rep(i, n){
        int a;
        cin >> a;
        v[i] = a;
    }

    int64_t sel = 0;
    rep(i, n){
        for(int j=i; j<n; j++){
            if(v[i] > v[j]){
                sel++;
            }
        }
    }

    int64_t rgt = 0;
    rep(i, n){
        rep(j, n){
            if(v[i] < v[j]){
                rgt++;
            }
        }
    }

    int64_t ans = 0;
    ans += sel * k;
    ans %= 1000000007;
    int64_t anstmp;
    anstmp = (k*(k-1))/2;
    anstmp %= 1000000007;
    ans += rgt * anstmp;
    ans %= 1000000007;

    cout << ans;
}

Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
int main(){
	
	string s;
	
	cin>>s;
	
	if(s[0]==s[s.size()-1])
		cout<<s[0]<<endl;
	else
		cout<<'o'<<endl;
	
	
	
	

	
}

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

int main()
{
    while(1)
    {
        long long n;
        cin>>n;if(!n)return 0;
        long long a=n;
        int k=-1;
        for(;a>0;++k){
            a/=8;
        }
        for(;k>=0;--k){
            int ans=n/pow(8,k);
            if(ans==4)cout<<5;
            else if(ans>4)cout<<ans+2;
            else cout<<ans;
            n=n%(long long)pow(8,k);
        }
        cout<<endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 28);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

ll N,K;

ll search(
	const vector<vector<int>>& edges,
	const int bef,
	const int now
){
	ll child = (int)edges[now].size() - (bef==-1?0:1);
	ll res = 1;
	ll base = K - 1 - (bef==-1?0:1);
	REP(i,child){
		(res*=base)%=MOD;
		base--;
	}
	for(auto next:edges[now]){
		if(next==bef)continue;
		(res *= search(edges, now, next))%=MOD;
	}
	return res;
}

int main()
{
	cin>>N>>K;
	vector<vector<int>> edges(N);
	REP(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	cout<<(search(edges, -1, 0)*K)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int main(){
    int X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    lli p[A],q[B],r[C];
    for(int i = 0; i<A; i++)cin>>p[i];
    for(int i = 0; i<B; i++)cin>>q[i];
    for(int i = 0; i<C; i++)cin>>r[i];
    sort(p,p+A);
    sort(q,q+B);
    sort(r,r+C);
    reverse(p,p+A);
    reverse(q,q+B);
    reverse(r,r+C);
    lli total[X+Y+C];
    int x = 0,y = 0, z = 0;
    for(int i = 0; i<X; i++)total[i] = p[i];
    for(int i = 0; i<Y; i++)total[X+i] = q[i];
    for(int i = 0; i<C; i++)total[X+Y+i] = r[i];
    sort(total,total+X+Y+C);
    reverse(total,total+X+Y+C);
    lli sum = 0;
    for(int i = 0; i<X+Y; i++){
        sum+= total[i];
    }
    cout<<sum;



}

Measured memory_bytes: 4736
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

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

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

ll dp[1010][1010], comb[1010][1010], fact[1010], ifact[1010];

//二分累乗法 xのe乗
ll binpow(ll x, ll e) {
  ll a = 1, p = x;
  while(e > 0) {
    if(e%2 == 0) {p = (p*p) % MOD; e /= 2;}
    else {a = (a*p) % MOD; e--;}
  }
  return a % MOD;
}

void pascalTriangle(int n) {
  REP(i, n) {
    comb[i][0] = 1;
    comb[i][i] = 1;
    FOR(j, 1, i) comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD;
  }
}

void initFact(int n) {
  fact[0] = fact[1] = 1;
  ifact[1] = 1;
  FOR(i, 2, n) {
    fact[i] = (fact[i-1] * i) % MOD;
    ifact[i] = binpow(fact[i], MOD-2);
  }
}

ll P(ll n, int r) {
  return fact[n]*binpow(fact[n-r], MOD-2)%MOD;
}

signed main(void)
{
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  fact[0] = 1;
  for(int i = 1; i <= n; i++) {
    fact[i] = (fact[i-1] * i) % MOD;
  }

  dp[a-1][0] = 1;
  for(int i = a; i <= b; i++) {
    for(int j = 0; j <= n; j++) dp[i][j] = dp[i-1][j];
    for(int k = c; k <= d; k++) {
      for(int j = i * k; j <= n; j++) {
	      dp[i][j] = (dp[i][j] + (dp[i-1][j-i*k] * P(j,i*k) % MOD) * binpow(binpow(fact[i],k) * fact[k] % MOD, MOD-2) % MOD) % MOD;
      }
    }
  }
  cout << dp[b][n] << endl;
  return 0;
}


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


int main(){
  int N;
  cin >> N;
  
  if(N%2==0)
    cout << N/2 << endl;
  else
    cout << N/2+1 <<endl;
}

Measured memory_bytes: 3616
import math

n = int(input())

x = list(map(int,input().split()))
y = list(map(int,input().split()))

dist = []
for i in range(n):
  dist.append(abs(x[i]-y[i]))

d1 = float(sum(dist))
d2 = 0.0
d3 = 0.0
for i in range(n):
  d2 += dist[i]**2
  d3 += dist[i]**3
d2 = float(math.sqrt(d2))
d3 = float(d3**(1.0/3.0))
d_inf = float(max(dist))

print("{:.6f}".format(d1))
print("{:.6f}".format(d2))
print("{:.6f}".format(d3))
print("{:.6f}".format(d_inf))


Measured memory_bytes: 5704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int A = GetInt();
		int B = GetInt();
		for(int i = 1; i <= 1000; i++)
		{
			if(Floor(i * 0.08) == A && Floor(i * 0.1) == B)
			{
				WriteLine(i);
				return;
			}
		}
		WriteLine(-1);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

const ll INF = pow(10, 9) + 7;

int main() {
  int n,m;
  cin >> n >> m;
  vector<P> a(m);
  vector<int> c(n,-1),wa(n);
  int ss=0;
  int cnt = 0;
  int seikai=0;
  rep(i,m){
    cin >> a[i].first >> a[i].second;
    a[i].first--;
  }
  rep(i,m){
    if(c[a[i].first] != -1) continue;
    if(a[i].second== "AC") {
      c[a[i].first] = 1;
      seikai++;
      ss += wa[a[i].first];
    }
    if(a[i].second== "WA") {
      wa[a[i].first]++;
    }
  }
  cout << seikai << " " << ss;
}

Measured memory_bytes: 7296
#include <stdio.h>
int main(){
        int cup[3]={1,0,0};
        int i=0;
        char p,q;
        while(scanf("%c,%c",&p,&q)!=EOF){
        i= cup[p-'A'];
        cup[p-'A']=cup[q-'A'];
        cup[q-'A']=i;
        scanf("%c",&p);
        }
        for(i=0;i<3;i++){
                if(cup[i]){
                        printf("%c\n",i+'A');
                }
        }
return 0;
}

Measured memory_bytes: 544
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MAX int(2* 1e5 + 5)


int main(){
    llong ruijou[20];
    ruijou[0] = 1;
    FOR(i,1,20) ruijou[i] = ruijou[i-1] * 4;

    int n;
    cin >> n;
    llong A[MAX];
    REP(i,n) scanf("%lld",&A[i]);
    llong dp[MAX][20];
    REP(i,16) dp[n-1][i] = i;
    REPR(i,n-2){
        int cnt = 0;
        if(A[i] <= A[i + 1]){
            while(A[i] * ruijou[cnt] <= A[i+1]) cnt ++;
            cnt --;
            cnt *= -1;
        }
        else{
            while(A[i] > A[i+1] *ruijou[cnt]) cnt ++;
        }

        REP(j,16){
            int tmp = max(0,cnt + j);
            if(tmp >15){
                dp[i][j] = j + dp[i+1][15] + (tmp - 15)* (n - (i + 1));  
            }
            else{
                dp[i][j] = j + dp[i+1][tmp];
            }
        }

    }



    llong hudp[MAX][20];
    REP(i,16) hudp[0][i] = i;
    FOR(i,1,n){
        int cnt = 0;
        if(A[i] <= A[i - 1]){
            while(A[i] * ruijou[cnt] <= A[i-1]) cnt ++;
            cnt --;
            cnt *= -1;
        }
        else{
            while(A[i] > A[i-1] *ruijou[cnt]) cnt ++;
        }



        REP(j,16){
            int tmp = max(0,cnt + j);
            if(tmp >15){
                hudp[i][j] = j + hudp[i-1][15] + (tmp - 15)* i;  
            }
            else{
                hudp[i][j] = hudp[i-1][tmp] + j;
            }
        }

    }
/*
    REP(i,n) cout << dp[i][0] << endl;
    cout << endl;

    REP(i,n) cout << hudp[i][0] << endl;
    cout << endl;
*/
    
    llong ans = min(2 * dp[0][0] , 2 * hudp[n-1][0] + n);
    FOR(i,1,n){
        ans = min( ans,  2 * dp[i][0] + 2 * hudp[i-1][0] + i);
    }

    cout << ans << endl;

}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  int N;
  long long ans=0;
  cin >> N;
  vector<long long> a(N+1);
  vector<long long> b(N);
  REP(i,N+1)
    cin >> a[i];
  REP(i,N)
	cin >> b[i];
  
  REP(i,N) {
    if (a[i] <= b[i]) {
      ans += a[i];
      b[i] -= a[i];
      a[i] = 0;
      if (b[i] > 0) {
        if (a[i+1] <= b[i]) {
          ans += a[i+1];
          b[i] -= a[i+1];
          a[i+1] = 0;
        } else {
          ans += b[i];
          a[i+1] -= b[i];
        }
      }
    } else {
      ans += b[i];
      a[i] -= b[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
n, m = map(int, input().split())

table = [0] * (n + 2)
table[0] = 1
for i in range(m):
    a = int(input())
    table[a] = -2

for i in range(1, n + 1):
    if table[i-1] == -2 and table[i-2] == -2:
        print(0)
        exit()


    if table[i] != -2:
        if table[i-1] != -2:
            table[i] += table[i-1]
        if table[i-2] != -2:
            table[i] += table[i-2]

        table[i] %= (10**9+7)

print(table[n])


Measured memory_bytes: 6964
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;
int main(void){
    int N;
    long long result = 0;
    scanf("%d", &N);
    vector<int> A(N+1);
    vector<int> B(N);
    for(int i = 0; i < N+1; i++)
        scanf("%d", &A[i]);

    for(int i = 0; i < N; i++)
        scanf("%d", &B[i]);


    for(int i = N-1; i >= 0; i--){
        result += min(A[i+1], B[i]);
        if(A[i+1] < B[i])
            B[i] -= A[i+1];
        else
            continue;

        result += min(A[i], B[i]);
        if(A[i] < B[i])
            A[i] = 0;
        else
            A[i] -= B[i];
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char s[100];
stack<char>ans;
void print(){
	if(ans.empty())return;
	char c=ans.top();
	ans.pop();
	print();
	putchar(c);
}
int main(){
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++){
		if(s[i]=='B'&&!ans.empty())ans.pop();
		else if(s[i]=='0'||s[i]=='1')ans.push(s[i]);
	}
	print();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 200005;
int mx = -1e9 , mn = 1e9 ;
double arr[N] , arr2[N];
double dd[N];

int main()
{

    int a , b , c , d;
    cin >> a >> b >>  c >> d ;
    cout << (a-c)*(b-d) << endl;




    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;

class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<ll> A(N); cin >> A;
        vector<vector<ll>> bitwisesum(60, vector<ll>(N + 1));
        rep(i, N) {
            rep(bit, 60) bitwisesum[bit][i + 1] = bitwisesum[bit][i] + ((A[i] & (1ll << bit)) ? 1 : 0);
        }
        // debug(bitwisesum);
        ll ans = 0;
        rep(i, N) {
            ll sum = 0;
            rep(bit, 60) {
                int num = bitwisesum[bit][N] - bitwisesum[bit][i + 1];
                if(A[i] & (1ll << bit)) num = N - i - 1 - num;
                sum = (sum + (((1ll << bit) % MOD) * num) % MOD) % MOD;
            }
            ans = (ans + sum) % MOD;
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 145580
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end(), std::greater<>());

    std::string ans = "Yes";
    int n = std::min(s.size(), t.size());
    int cnt = 0;
    for(int i = 0;i < n;i++){
        if(s[i] < t[i]){
            break;
        }else if(s[i] > t[i]){
            ans = "No";
            break;
        }else{
            ++cnt;
        }
    }
    if(cnt == n && n == t.size()){
        ans = "No";
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
from math import sqrt


def divisors(n: int) -> list:
    sq = int(sqrt(n))
    l, m, r = [], [], []
    if sq * sq == n:
        m = [sq]
    else:
        sq += 1

    for i in range(1, sq):
        if n % i == 0:
            l.append(i)
            r = [n // i] + r

    return l + m + r


def one_hundred_and_five(N: int) -> int:
    count = 0
    for n in range(105, N + 1, 2):
        if len(divisors(n)) == 8:
            count += 1
    return count


if __name__ == "__main__":
    N = int(input())
    ans = one_hundred_and_five(N)
    print(ans)


Measured memory_bytes: 3064
fn main() {
    let mut s : Vec<char> = mylib::get_str().chars().collect();
    s.sort();
    let mut r = true;
    for i in 0..s.len()-1 {
        if s[i] == s[i+1] {
            r = false;
            break;
        }
    }
    println!("{}", if r { "yes" } else { "no" })
}

mod mylib {
    // IO
    pub fn get_str() -> String {
        use std::io;
        let mut input = String::new();
        io::stdin().read_line(&mut input);
        input.as_str().trim().to_string()
    }
}


Measured memory_bytes: 4352
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

pii a[N];
int a_cpy[N];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].second;
		a_cpy[i] = a[i].second;
	}
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].first;
	}
	sort(a + 1, a + 1 + n);
	sort(a_cpy + 1, a_cpy + 1 + n);
	for (int i = 1; i <= n; ++i) {
		if (a_cpy[i] > a[i].first) {
			cout << "No\n";
			return 0;
		}
	}
	for (int i = 1; i < n; ++i) {
		if (a_cpy[i + 1] <= a[i].first) {
			cout << "Yes\n";
			return 0;
		}
	}
	map<int, int> idx;
	for (int i = 1; i <= n; ++i) {
		idx[a[i].second] = i;
	}
	for (int i = 1; i <= n; ++i) {
		a_cpy[i] = idx[a_cpy[i]];
	}
	int start = 1, seen = 1;
	while (a_cpy[start] != 1) {
		start = a_cpy[start];
		++seen;
	}
	if (seen == n) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
}

Measured memory_bytes: 6144
#include<stdio.h>

int main(void){
  
  int n, x, t, r;
  
  scanf("%d",&n);
  scanf("%d",&x);
  scanf("%d",&t);
  
  r = n/x;
  
  if(n%x == 0){
    t = t * r;
  }else{
    t = t * (r+1);
  }
  
  printf("%d",t);
  
  return 0;
}

Measured memory_bytes: 1720
object Main extends App {

  val input = Console.in.readLine.split(" ")
    
  val stk = (List[Int]() /: input) { (stk, sym) => sym match {
      case "+" => stk(1) + stk(0) :: (stk drop 2)
      case "-" => stk(1) - stk(0) :: (stk drop 2)
      case "*" => stk(1) * stk(0) :: (stk drop 2)
      case num => num.toInt :: stk
    }
  }
  println(stk.head)
}



Measured memory_bytes: 43836
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int N, M;
ll xx[1000], yy[1000], zz[1000];

struct th{
    ll x;
    ll y;
    ll z;
};

ll a[1000];
ll dp[1010][1010];
ll si[3];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> xx[i] >> yy[i] >> zz[i];
    }

    ll res = 0;
    for(int k = 0; k < 8; k++){
        si[0] = 1 - (k % 2) * 2;
        si[1] = 1 - ((k>>1) % 2) * 2;
        si[2] = 1 - ((k>>2) % 2) * 2;
        for(int i = 0; i < N; i++){
            a[i] = si[0]*xx[i] + si[1]*yy[i] + si[2]*zz[i];
        }
        sort(a, a+N);
        ll su = 0LL;
        for(int i = N-1; i >= N-M; i--){
            su += a[i];
        }
        res = max(res, su);
    }
    cout << res << endl;
    return 0;

    for (int i = 0; i <= N; i++){
        dp[0][i] = 0;
    }

    for(int i = 0; i <= M; i++){
        dp[i][0] = 0;
    }

    for(int k = 0; k < 8; k++){
        si[0] = 1 - (k % 2) * 2;
        si[1] = 1 - ((k>>1) % 2) * 2;
        si[2] = 1 - ((k>>2) % 2) * 2;

        for(int j = 1; j <= N; j++) {
            for (int i = 1; i <= min(M, j); i++) {
                ll stay = dp[i][j-1];
                ll pick = dp[i-1][j-1] + si[0]*(xx[j-1]) + si[1]*(yy[j-1]) + si[2]*(zz[j-1]);
                if(stay > pick){
                    dp[i][j] = stay;
                }
                else{
                    dp[i][j] = pick;
                }
            }
        }
        if(res < dp[M][N]){
            res = dp[M][N];
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
range = xrange
input = raw_input
 
def main():
  n = int(input())
  A = [int(x) for x in input().split()]
  B = [int(x) for x in input().split()]
 
  DP = [0]*(n+1)
  DP[n] = n
  for j in range(3):
      sell = A[j]
      extra = B[j] - sell
      if extra > 0:
          for i in reversed(range(sell,len(DP))):
              DP[i - sell] = max(DP[i - sell], DP[i] + extra)
  n = max(DP)
  A,B = B,A
 
  DP = [0]*(n+1)
  DP[n] = n
  for j in range(3):
      sell = A[j]
      extra = B[j] - sell
      if extra > 0:
          for i in reversed(range(sell,len(DP))):
              DP[i - sell] = max(DP[i - sell], DP[i] + extra) 
  print(max(DP))
 
main()

Measured memory_bytes: 227820
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define F first
#define S second

int n, m;

void solve(){
    cin >> n >> m;

    int f = m, s = m-1;
    int loc = 0;
    for(int i = f; i > 0; i-=2){
        cout << loc+1 << " " << loc+i+1 << '\n';
        ++loc;
    }
    loc = f+1;
    for(int i = s; i > 0; i-=2){
        cout << loc+1 << " " << loc+i+1 << '\n';
        ++loc;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<ll> a(x),b(y),c(z),d,e,f,sum;
  rep(i,x) cin>>a[i];
  rep(i,y) cin>>b[i];
  rep(i,z) cin>>c[i];
  rep(i,x)rep(j,y) d.push_back(a[i]+b[j]);
  sort(begin(c),end(c),greater<ll>());
  sort(begin(d),end(d),greater<ll>());
  rep(i,min(z,k)) e.push_back(c[i]);
  rep(i,min(x*y,k)) f.push_back(d[i]);
  rep(i,e.size())rep(j,f.size()) sum.push_back(e[i]+f[j]);
  sort(begin(sum),end(sum),greater<ll>());
  rep(i,k) cout<<sum[i]<<endl;
}

Measured memory_bytes: 43400
import sys
#from collections import defaultdict, deque, Counter
#from bisect import bisect_left
#import heapq
#import math
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
L,R = map(int, stdin.readline().rstrip().split())
#S = [list(stdin.buffer.readline().decode().rstrip()) for _ in range(h)]

if R-L > 2019:
    print(0)
    exit()

ans = 2018
for i in range(L,R):
    for j in range(L+1,R+1):
        ans = min(ans, (i*j)%2019)

print(ans)


Measured memory_bytes: 3064