akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

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

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

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



signed main(){

    int N; cin >> N;
    int ans = 0;
    REP(i, N + 1) if(i % 3 && i % 5) ans += i;
    Out(ans);

    return 0;
}


Measured memory_bytes: 3640
def solve(h):
    res = 0
    a = 1
    while h > 0:
        res += a
        h //= 2
        a *= 2
    return res

assert solve(2) == 3
assert solve(4) == 7
assert solve(1000000000000) == 1099511627775
h = int(input())
print(solve(h))



Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
using ll = long long;
 
 
int main() {
  ll A;
  double B;

  double ans;
  cin >> A >> B;
  int C = B*100;
  //cout << (double)A << B << endl;
  
  ans = A * C / 100;
 
  //cout << fixed << setprecision(1);
  cout << (ll)ans << endl;
 
  return 0;
 
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int modulo(1e9 + 7);
int main() {
	int n;
	cin >> n;
	int ans(1);
	for(int i(2); i <= n; i++) {
		bool f(true);
		for(int j(2); j < i; j++) {
			if(i % j == 0) {
				f = false;
				break;
			}
		}
		if(f) {
			int cnt(0);
			int x(n);
			for(;;) {
				x /= i;
				if(!x) 
					break;
				cnt += x;
			}
			ans = (long long)ans * (cnt + 1) % modulo;
			
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  cout << min(c,b/a) << endl;
}

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

int main()
{
    char s[4];

    cin >> s;

    char a,b;

    a = s[0];
    int anum=0;
    for (int i = 0; i < 4; i++)
    {
        if(s[i]==a){
            anum++;
        }
    }
    for (int i = 0; i < 4; i++)
    {
        if (s[i] != a)
        {
            b=s[i];
            break;
        }
    }
    int bnum = 0;
    for (int i = 0; i < 4; i++)
    {
        if (s[i] == b)
        {
            bnum++;
        }
    }

    if(anum==2 && bnum==2)
    {
        cout << "Yes";
    }else
    {
        cout << "No";
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#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 ALL(v) v.begin(), v.end()
 
template <class T> bool chmin(T &v, const T &v2){if(v > v2){v = v2; return true;} else return false;}

using namespace std;
 
auto main() -> int
{
  int H, N; cin >> H >> N;
  vector<int> dp(100000, 1e9); 
  dp[0] = 0;
  
  while(N--){
  	int damage, mp;
  	cin >> damage >> mp;
    REP(i, H)  chmin(dp[i+damage], dp[i] + mp);
  }
  
  REPR(i, dp.size()-2) chmin(dp[i], dp[i + 1]);
  cout << dp[H] << endl;
}

Measured memory_bytes: 640
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main() {
  int N; cin >> N;
  double ans = 0;

  for (int i = 1; i <= N; i++) {
    double d; cin >> d;
    ans += 1 / d;
  }
  cout << fixed << setprecision(9) << 1 / ans << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val l = readLine()!!.split(" ").map { it.toInt() }
    val k = l[0]
    val n = l[1]
    val a = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var max = k + a[0] - a[n-1]
    for (i in 0 until n-1) {
        max = Math.max(a[i+1]-a[i], max)
    }
    println(k-max)
}


Measured memory_bytes: 80876
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	g = zeros(Int,n,n)
	for i in 1:n
		g[i,:] = parseMap(split(chomp(readline()), ""))
	end
	d = n*ones(Int,n,n)
	for i in 1:n
		d[i,i] = 0
		for j in 1:n
			if g[i,j] == 1
				d[i,j] = 1
			end
		end
	end
	for k in 1:n
		for i in 1:n
			for j in 1:n
				d[i,j] = min(d[i,j], d[i,k]+d[k,j])
			end
		end
	end
	f = 0
	for i in 1:n
		for j in 1:n
			for k in 1:n
				if d[i,j]==d[i,k] && d[j,k]==1
					f = 1
					break
				end
			end
		end
	end
	if f == 1
		println(-1)
	else
		println(maximum(d)+1)
	end
end

main()

Measured memory_bytes: 178696
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, D = MAP()
print(-(-N//(2*D+1)))

Measured memory_bytes: 5136
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    while(true){
     cin>>x;
     cin>>y;
     if(x==0&&y==0){
        break;
     }
     if(x<y){
        cout<<x<<" "<<y<<endl;
     }
     else{
          cout<<y<<" "<<x<<endl;
      }
      
    }
 }


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w,h;cin>>w>>h;
    ll p[w],q[h];rep(i,w){cin>>p[i];}
    rep(i,h){cin>>q[i];}
    vector<pair<ll,ll>> cost;
    rep(i,w){cost.push_back(make_pair(p[i],1));}
    rep(i,h){cost.push_back(make_pair(q[i],0));}
    sort(begin(cost), end(cost));
    ll cntw=w+1,cnth=h+1;
    ll req = (w+1)*(h+1)-1;
    ll res = 0;
    rep(i,cost.size()){
        if(req==0){break;}
        if(cost.at(i).second==1){
            if(cnth>0&&cnth<=req){ 
                res += cost.at(i).first*cnth;
                req -= cnth;
                cntw--;
            }
        }else{
            if(cntw>0&&cntw<=req){
                res += cost.at(i).first*cntw;
                req -= cntw;
                cnth--;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 8048
#include <bits/stdc++.h>
using namespace std;
char C[1010][1010];
int A[1010][1010]; 
int dx[4] = {1,0,-1,0}; 
int dy[4] = {0,1,0,-1}; 
int H, W, Ch, Cw, Dh, Dw; 
bool seen[1010][1010]; 
void dfs(int x, int y, int d){
	A[x][y] = d; seen[x][y] = true; 
	for(int t = 0; t < 4; t++){
		int nx = x + dx[t]; 
		int ny = y + dy[t]; 
		if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue; 
		if(C[nx][ny] == '#' || seen[nx][ny]) continue; 
		dfs(nx, ny, d); 
	}
}
int main(){
	cin >> H >> W; 
	cin >> Ch >> Cw >> Dh >> Dw; 
	Ch--; Cw--; Dh--; Dw--; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> C[i][j]; 
		}
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(seen[i][j] || C[i][j] == '#') continue; 
			dfs(i, j, 10000 * i + j + 1); 
		}
	}
	deque<pair<int, int>> que; 
	que.push_front(make_pair(Ch, Cw)); 
	int D[1010][1010] = {}; 
	int inf = 1145141919; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			D[i][j] = inf; 
		}
	}
	D[Ch][Cw] = 0; 
	while(que.size()){
		pair<int, int> p = que.front(); que.pop_front(); 
		int x = p.first; int y = p.second; 
		for(int t = 0; t < 4; t++){
			int nx = x + dx[t]; 
			int ny = y + dy[t]; 
			if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue; 
			if(C[nx][ny] == '#' || D[nx][ny] <= D[x][y]) continue; 
			D[nx][ny] = D[x][y]; 
			que.push_front(make_pair(nx, ny));
		}
		for(int i = -2; i <= 2; i++){
			for(int j = -2; j <= 2; j++){
				int nx = x + i; int ny = y + j; 
				if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue; 
				if(C[nx][ny] == '#' || D[nx][ny] < inf || A[nx][ny] == A[x][y]) continue; 
				D[nx][ny] = D[x][y] + 1; 
				que.push_back(make_pair(nx, ny));
			}
		}
	}
	if(D[Dh][Dw] == inf) cout << -1 << "\n"; 
	else cout << D[Dh][Dw] << "\n"; 
	/*for(int i = 0; i < H; i++){
	    for(int j = 0; j < W; j++){
	        cout << D[i][j] << " "; 
	    }
	    cout << "\n"; 
	}*/
}

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

int main(void){
  
  int N;
  cin >> N;
  int data[N];
  for(int i=0;i<N;i++) cin >> data[i];
  sort(data,data+N);
  cout << data[N-1] - data[0] << endl;
}


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

namespace _0051
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; ++i)
            {
                string str = Console.ReadLine();
                List<string> num = new List<string>();
                for (int j = 0; j < str.Length; ++j)
                {
                    num.Add(str.Substring(j, 1));
                }
                num.Sort();
                int numMin = int.Parse(string.Join("",num));
                num.Reverse();
                int numMax = int.Parse(string.Join("", num));
                Console.WriteLine(numMax-numMin);
            }
        }
    }
}



Measured memory_bytes: 16788
import itertools


def main():
    n = int(input())
    p = [int(i) for i in input().split()]
    q = [int(i) for i in input().split()]

    a = 0
    for i, p_per in enumerate(sorted(itertools.permutations(range(1, n+1))), start=1):
        if list(p_per) == p:
            a = i

    b = 0
    for j, q_per in enumerate(sorted(itertools.permutations(range(1, n+1))), start=1):
        if list(q_per) == q:
            b = j

    print(abs(a - b))


if __name__ == "__main__":
    main()

Measured memory_bytes: 8052
<?php
fscanf(STDIN, "%d", $data);
$result = "No";
for ($i = 1; $i < 10; $i++)
{
  for ($j = 1; $j < 10; $j++)
  {
    if($i * $j == $data) {
      $result = "Yes";
      break;
    } 
  }
}

echo $result;
  
?>

Measured memory_bytes: 3576
import java.util.Scanner;
class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
   	int k;
    k = scan.nextInt();
   	String s;
    s = scan.next();
    int num = s.length();
    if (k>=num)
      System.out.println(s);
    else{
      String str= s.substring(0,k);
      System.out.println(str+"...");
    }
  }         
}

Measured memory_bytes: 38648
def main():
    a,b = map(int,input().split())
    print(100,100)
    white = [["."]*50 for _ in range(100)]
    black = [["#"]*50 for _ in range(100)]
    a1,b1 = a-1,b-1
    x,y = 0,0
    for i in range(b1//25):
        for j in range(25):
            white[i*2][j*2] = "#"
        x = i+1
    for i in range(b1%25):
        white[x*2][i*2] = "#"
    for i in range(a1//25):
        for j in range(25):
            black[i*2][49-j*2] = "."
        y = i+1
    for i in range(a1%25):
        black[y*2][49-i*2] = "."
    for i,j in zip(white,black):
        print("".join(i) + "".join(j))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38320
def InsertionSort(data):
    show(data)
    for i in range(1, len(data)):
        temp = data[i]
        for j in reversed(range(0, i)):
            if data[j] > temp:
                data[j+1] = data[j]
            else:
                data[j+1] = temp
                break
            if j == 0:
                data[0] = temp
        show(data)
    return data

def Input():
    input()
    data = [int(e) for e in input().split()]
    return data

def show(data):
    string = str(data[0])
    for i in range(1, len(data)):
        string = string + " " + str(data[i])
    print(string)

InsertionSort(Input())


Measured memory_bytes: 5604
def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

n = iip()
al = iip()
#al = [2**60 - 114514 - i for i in range(1000)]

mod = 10**9 + 7
num1 = [0 for i in range(60)]

for a in al:
    b = bin(a)[2:].zfill(60)
    #print(b)
    for i in range(60):
        if b[i] == "1":
            num1[i] += 1

result = 0
for i, a in enumerate(num1):
    a1 = 2**(59-i) % mod
    a2 = (a * (n-a)) % mod
    result += a1*a2 % mod
    result = result % mod


#print(num1)
print(result)

Measured memory_bytes: 125624
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,p;
  cin>>n>>p;
  ll ans=1;
  int odd=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    odd+=a%2;
    ans*=2;
  }
  if(odd==0){
    if(p==0){
      cout<<ans<<endl;
    }
    else{
      cout<<0<<endl;
    }
  }
  else{
    cout<<ans/2<<endl;
  }
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<char>c(n);
    for (int i = 0; i < n; ++i) {
        cin >>c[i];
    }
    vector<ll>col;
    char k='W';
    ll now=0;
    for (int i = 0; i < n; ++i) {
        if(c[i]==k)now++;
        else {
            col.push_back(now);
            if(k=='R')k='W';
            else k='R';
            now=1;
        }
    }
    if(now!=0)col.push_back(now);
    if(col.size()%2==1)col.push_back(0);
//    for(auto e:col){
//        cout <<e<<endl;
//    }
// col ok
    vector<ll>w;
    for (int i = 0; i < col.size(); ++i) {
        if(i%2==0)w.push_back(col[i]);
    }
//    for(auto ww:w)cout <<ww<<" ";
//    cout <<endl;
    vector<ll>r;
    reverse(all(col));
    for (int i = 0; i < col.size(); ++i) {
        if(i%2==0)r.push_back(col[i]);
    }
    reverse(all(col));
    vector<ll>rsum(r.size()+1,0);
    for (int i = 0; i < r.size(); ++i) {
        rsum[i+1]=rsum[i]+r[i];
    }
    vector<ll>wsum(w.size()+1,0);
    for (int i = 0; i < w.size(); ++i) {
        wsum[i+1]=wsum[i]+w[i];
    }
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ll s=upper_bound(all(rsum),i)-rsum.begin();
        ll t=upper_bound(all(wsum),i)-wsum.begin();
        if(rsum[s]>i)s--;
        if(wsum[t]>i)t--;
        if(s+t>=r.size()){
            ans=i;
            break;
        }
    }
    cout <<ans <<endl;
}


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

using namespace std;

#define ll long long

int main()
{
	int K, N;
	cin >> K >> N;
	vector < ll > A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	vector < ll > dist(N);
	for (int i = 0; i < N - 1; i++) {
		dist[i] = A[i + 1] - A[i];
	}

	dist[N - 1] = K - A[N - 1] + A[0];

	sort(dist.begin(), dist.end());
	dist.pop_back();

	ll sum = accumulate(dist.begin(), dist.end(), 0LL);

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    long long int n,ans=0;
    cin>>n;
    vector<long long int>a(200000);
    vector<long long int>b(200000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),greater<>());
    for(int i=0;i<n;i++){
        ans+=a[i];
    }

    for(int i=0;i<n+1;i++){
        if(ans%10!=0){
            break;
        }
        else if(i<n&&a[n-i-1]%10!=0){
            ans-=a[n-1-i];
        }
        if(i==n&&ans%10==0){
            ans=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //long longをllで表せる
 
int main() {
  ll n,m;
  cin >> n;
  m=n;
  string na;
  
  for (int i = 0; i<n; i++) {
    m=m-1;
    if(m%26==0){na.push_back('a');}
    if(m%26==1){na.push_back('b');}
    if(m%26==2){na.push_back('c');}
    if(m%26==3){na.push_back('d');}
    if(m%26==4){na.push_back('e');}
    if(m%26==5){na.push_back('f');}
    if(m%26==6){na.push_back('g');}
    if(m%26==7){na.push_back('h');}
    if(m%26==8){na.push_back('i');}
    if(m%26==9){na.push_back('j');}
    if(m%26==10){na.push_back('k');}
    if(m%26==11){na.push_back('l');}
    if(m%26==12){na.push_back('m');}
    if(m%26==13){na.push_back('n');}
    if(m%26==14){na.push_back('o');}
    if(m%26==15){na.push_back('p');}
    if(m%26==16){na.push_back('q');}
    if(m%26==17){na.push_back('r');}
    if(m%26==18){na.push_back('s');}
    if(m%26==19){na.push_back('t');}
    if(m%26==20){na.push_back('u');}
    if(m%26==21){na.push_back('v');}
    if(m%26==22){na.push_back('w');}
    if(m%26==23){na.push_back('x');}
    if(m%26==24){na.push_back('y');}
    if(m%26==25){na.push_back('z');}
    
    if(m<26){break;}
    m=m/26;}  
  reverse(na.begin(), na.end() );
cout << na <<endl;  
}

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

using namespace std;

int main() {
	long n, p;
	cin >> n >> p;
	map<long, int> s;
	for (int i = 2; i <= p / i; i++) {
		if (p%i) continue;
		s[i]++;
		p /= i--;
	}
	if (p > 1) s[p]++;
	long r = 1;
	for (auto i : s)
		r *= pow(i.first, i.second / n);
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define MAX 111111
#define endl '\n'
#define boost ios_base::sync_with_stdio(0);cin.tie(0)
#define INF LONG_MAX

int32_t main()
{
    boost;

	string str;
	cin>>str;
	int l=0,r=str.size()-1,ans=0;        

	while(l<r)
	{
		if(str[l]!=str[r])
			ans++;
		l++;
		r--;
	}
	cout<<ans<<endl;
}


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

using namespace std;
int n, c;
const long long INF = 1e18L + 5;

int main() {
    scanf("%d %d", &n, &c);
    vector<int> w(n), v(n);
    int total_value = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &w[i], &v[i]);
        total_value += v[i];
    }

    // dp[i][j] := minimum total "weight" with the first i items to make total value j
    vector<long long> dp(total_value + 1, INF);
    dp[0] = 0;

    // O(NV)
    for (int i = 1; i <= n; ++i) {
        vector<long long> cur(total_value + 1, 0);
        for (int j = 0; j <= total_value; ++j) {
            if (j >= v[i - 1]) cur[j] = min(dp[j], dp[j - v[i - 1]] + w[i - 1]);
            else cur[j] = dp[j];
        }
        dp = cur;
    }

    long long ans = 0;
    for (int i = total_value; i >= 0; i--) {
        if (dp[i] <= c) {
            ans = i;
            break;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

int main()
{
	string s = "keyence";
	string sr;
	cin>>sr;
	for(int i=0;i<sr.length();i++){
		for(int j=0;j<sr.length();j++){
			string ss = sr;
			ss.erase(i,j);;
				if(ss==s){
					cout<<"YES";
					return 0;
				}
		}
	}
	cout<<"NO";
} 


Measured memory_bytes: 256
n = gets.to_i
p = gets.chomp.split.map(&:to_i)

res = 0
n.times do |i|
  next if i + 1 != p[i]
  if i < n - 1 && i + 2 == p[i + 1]
    p[i], p[i + 1] = p[i + 1], p[i]
  elsif i > 0 && i == p[i - 1]
    p[i], p[i - 1] = p[i - 1], p[i]
  end
  res += 1
end
puts res

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


int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B){if(A!=C){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  }
  else if(A==C){if(A!=B){cout<<"Yes"<<endl;}}
  else if(C==B){if(A!=C){cout<<"Yes"<<endl;}}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n;
 scanf("%d", &n);
 if(n%10==3){
   printf("bon");
 }else if(n%10==0||n%10==1||n%10==6||n%10==8){
   printf("pon");
 }else{
   printf("hon");
 }
  return 0;
}


Measured memory_bytes: 1708
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
#define double long long
using namespace std;
signed main() {
    int N, X;
    cin >> N >> X;
    int A = 0;
    int i;

    vector<int>L(N);

    for (i = 0; i < N; i++) {
        cin >> L.at(i);
        A += L.at(i);
        if (A > X) {
            break;
        }
        
    }
    cout << i + 1 << endl;
}


Measured memory_bytes: 3532
import fractions


k = int(input())

def gcd(p, q):
    if p % q == 0: return q
    return gcd(q, p % q)

res = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            res += gcd(gcd(a, b), c)
print(res)



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

int main() {
    int n; cin >> n;
    vector<int> t(n);
    for (auto& e : t) cin >> e;
    int m; cin >> m;
    
    int p, x;
    for (int i = 0; i < m; i++) {
        cin >> p >> x;
        int sum = 0;
        for (int j = 0; j < n; j++) {
            if (j == p-1) sum += x;
            else sum += t[j];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include<math.h>
typedef long long int ll;
using namespace std;
ll a,n,ii,ans=1000000000000000000,ans1;
ll max1,max2,min1,min2;
ll s[300000]; 
ll findMaximal1(ll s,ll t);
ll findMaximal2(ll s,ll t);
ll unimodalFunc1(ll x);
ll unimodalFunc2(ll x);

int main(){
    ll k;
    ll k1,k2;
    ll b,t;
    cin>>n;
    s[0]=0;
    for(int i=0;i<n;i++){
        cin>>k;
        s[i+1]=s[i]+k;
    }
    for(ii=2;ii<n-1;ii++){
    findMaximal1(1,ii);
    findMaximal2(ii+1,n);
    ans1=fmaxl(max1,max2)-fminl(min1,min2);
    if(ans>ans1)ans=ans1;
    }

    cout<<ans<<endl;
}

//[from, to)におけるunimodalFuncのargmax(もし複数ある場合は一番若い番号)を返す
ll findMaximal1(ll from, ll to) {
	// d[i] = a[i] - a[i-1]とする。
	// このとき、d[i] > 0 <=> a[i] > a[i-1]なので、
	// d[i] > 0なる最大のi in (from, to)を見つけると、a[i]が最大値
    ll s1=from,t1=to;
	for (;to - from > 1;) {
		ll mid = (from + to) / 2;
		(unimodalFunc1(mid) - unimodalFunc1(mid - 1) < 0 ? from : to) = mid;
	}

    max1=fmaxl(s[ii]-s[from],s[from]-s[0]);
    min1=fminl(s[ii]-s[from],s[from]-s[0]);
	return from;
}

ll unimodalFunc1(ll x){
    ll a1=s[ii]-s[x],a2=s[x]-s[0];
    return fmaxl(a1,a2)-fminl(a1,a2);
}

ll findMaximal2(ll from, ll to) {
	// d[i] = a[i] - a[i-1]とする。
	// このとき、d[i] > 0 <=> a[i] > a[i-1]なので、
	// d[i] > 0なる最大のi in (from, to)を見つけると、a[i]が最大値
	for (;to - from > 1;) {
		ll mid = (from + to) / 2;
		(unimodalFunc2(mid) - unimodalFunc2(mid - 1) < 0 ? from : to) = mid;
	}

    max2=fmaxl(s[n]-s[from],s[from]-s[ii]);
    min2=fminl(s[n]-s[from],s[from]-s[ii]);
	return from;
}

ll unimodalFunc2(ll x){
    ll a1=s[n]-s[x],a2=s[x]-s[ii];
    return fmaxl(a1,a2)-fminl(a1,a2);
}

Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vi v(86400);
    rep(i, n) {
      int h, m, d;
      char gomi;
      cin >> h >> gomi >> m >> gomi >> d;
      int l = h * 3600 + m * 60 + d;
      cin >> h >> gomi >> m >> gomi >> d;
      int r = h * 3600 + m * 60 + d;
      v[l]++;
      v[r]--;
    }
    loop(i, 1, 86400) v[i] += v[i - 1];
    int c = 0;
    rep(i, 86400) cmax(c, v[i]);
    cout << c << endl;
  }
}

Measured memory_bytes: 3652
nmc = input().split()
lstb = input().split()
a = []
for n in range(int(nmc[0])):
    a.append(input().split())
total = 0
count = 0
for n in range(int(nmc[0])):
    for m in range(int(nmc[1])):
        total += (int(lstb[m]) * int(a[n][m]))
    if total + int(nmc[2]) > 0:
        count += 1
    total = 0
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n;
  while(cin >> n, n!=0){
    vector<int> s;
    int input = 0;
    for(int i=0; i<n; i++){
      cin >> input;
      s.push_back(input);
    }
    sort(s.begin(), s.end());
    int sum = 0;
    for(int i=1;i<n-1;i++){
      sum += s[i];
    }
    cout << floor(sum/(n-2)) << endl;
    s.clear();
  }
  return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <utility>
#include <climits>
#include <string>

typedef long long ll;

using namespace std;

void solve(){
    string s, p;
    cin >> s >> p;

    for(int i = 0; i < s.length(); i++){
        string str;
        if(i < s.length()-p.length()){
            str = s.substr(i, p.length());
        }else{
            str = s.substr(i, p.length());
            str += s.substr(0, p.length()-str.length());
        }
        if(str == p){
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long n,a,b,ans=0;
	cin>>n;
	cin>>a;
	n--;
	while(n--)
	{
	cin>>b;
	if(b<a)
	ans+=a-b;
	else	
	a=b;	
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    char s[1024];
    int q;
    int i;
 
    scanf("%s", s);
    scanf("%d", &q);
    while (q--){
        char query[16];
        int a, b;
 
        scanf("%s %d %d", query, &a, &b);
        if (!strcmp(query, "print")){
            for (i = a; i <= b; ++i) putchar(s[i]);
            puts("");
        }
        else if (!strcmp(query, "reverse")){
            for (i = 0; i <= (b - a) / 2; ++i){
                char tmp = s[a + i];
                s[a + i] = s[b - i];
                s[b - i] = tmp;
            }
        }
        else {
            char p[1024];
 
            scanf("%s", p);
            strncpy(s + a, p, b - a + 1);
        }
    }
 
    return 0;
}

Measured memory_bytes: 600
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def check(str0, left, right):

    if right - left <= 1:
        print(left)
        now_str = input()
        if now_str == 'Vacant':
            sys.exit()
        print(right)
        now_str = input()
        if now_str == 'Vacant':
            sys.exit()

    half = (left + right) // 2

    print(half)
    half_str = input()
    if half_str == 'Vacant':
        sys.exit()

    if (half_str == str0 and half % 2) or (half_str != str0 and half % 2 == 0):
        check(str0, left, half)
    else:
        check(str0, half, right)


def main():
    num = int(input())

    print(0)
    str0 = input()
    if str0 == 'Vacant':
        sys.exit()

    check(str0, 0, num)




if __name__ == '__main__':
    main()


Measured memory_bytes: 39104
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll n;
vector <ll> dp;
vector <ll> h;

ll calc( ll i )
{
	if( dp[i] != -1)
	{
		return dp[i];
	}
	if( i == 2 )
	{
		ll temp = abs( h[i] - h[i-1] ) + calc( i -1 ) ;
		dp[2] = temp;
		return temp;
	}
	if(i <= 1)
	{
		dp[1] = 0;
		return 0;
	}
	dp[i] = 0;
	dp[i] = min( abs( h[i] - h[i-1]) + calc( i -1 ) , abs( h[i] - h[i-2] ) + calc( i- 2) );
	return dp[i];
}

int main() 
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=0;i<=n;i++)
	{
		dp.push_back(-1);
		h.push_back(0);
	}
	for(int i=1;i<=n;i++)
	{
		ll input;
		cin>>input;
		h[i] = input;
	}
	ll ans = calc(n);
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 4332
using static System.Math;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(getAns(n, a));
    }
    static int getAns(int n, int[] a)
    {
        var amax = a.Max();
        var amin = a.Min();
        var ans = int.MaxValue;
        for (int i = amin; i <= amax; i++)
        {
            var t = 0;
            for (int j = 0; j < n; j++)
                t += (a[j] - i) * (a[j] - i);
            ans = Min(ans, t);
        }
        return ans;
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >>n;
    char c;
    string ans = "Three";
    F0R(i,n) {
      cin >> c;
      if(c == 'Y') ans = "Four";
    }
    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
const double pi=acos(-1); 
int main()
{
	int s,w;
	sc(s);sc(w);
	if(w>=s)pf("unsafe\n");
	else pf("safe\n");
}


Measured memory_bytes: 3772
main = do
    (a:b:k:_)<-map read.words<$>getLine::IO [Int]
    putStrLn $ unwords $ map show $ tak a b k
tak a b k
    | k==0 = [a,b]
    | otherwise = ao (a`div`2) (b+a`div`2) (k-1)
ao a b k
    | k==0 = [a,b]
    | otherwise = tak (a+b`div`2) (b`div`2) (k-1)


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


int main(){
  char G[4][4];
  int frago,fragx,i,j;
  char n;
  
  while(scanf("%c",&n)!=EOF){

    frago = fragx = 0; 

    for(i=0; i<3; i++){
      for(j=0; j<3; j++){
	if(i==0 && j==0) continue;
	scanf("%c",&G[i][j]);
      }
    }
    getchar();
    G[0][0] = n;


    for(j=0; j<3; j++){
      if(G[0][j] =='o' && G[1][j] == 'o' && G[2][j] == 'o') frago = 1;
      if(G[0][j] =='x' && G[1][j] == 'x' && G[2][j] == 'x') fragx = 1;
      
      if(G[j][0] =='o' && G[j][1] == 'o' && G[j][2] == 'o') frago = 1;
      if(G[j][0] =='x' && G[j][1] == 'x' && G[j][2] == 'x') fragx = 1;
    }



    if(G[0][0] =='o'&& G[1][1]=='o'&& G[2][2]=='o') frago = 1;
    if(G[0][0] =='x'&& G[1][1]=='x'&& G[2][2]=='x') fragx=1;

    if(G[0][2]=='o' && G[1][1]=='o' && G[2][0]=='o') frago=1;
    if(G[0][2]=='x' && G[1][1]=='x' && G[2][0]=='x') fragx=1;

    if(frago == 0 && fragx == 0) cout << 'd' << endl;
    else if(frago == 1 && fragx == 0) cout << 'o' << endl;
    else if(frago == 0 && fragx == 1) cout << 'x' << endl;
  }



  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String args[]){
		for(int i=1;i<=9;i++)
			for(int j=1;j<=9;j++)
				System.out.printf("%dx%d=%d\n",i,j,i*j);
	}
}

Measured memory_bytes: 26384
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	ll h,m,H,M,t;
	cin>>h>>m>>H>>M>>t;
	ll a=h*60+m;
	ll b=H*60+M;
	cout<<max(0ll,b-a-t) NL;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<set>
#define ll long long

using namespace std;

ll count(ll n,ll a,ll b) {
    ll min_v=(n-1)*a+b;
    ll max_v=(n-1)*b+a;
    return (max_v-min_v+1);
}

int main() {
    long long n,a,b;
    cin>>n>>a>>b;
    if (n==1) {
        if(a!=b)
            cout<<"0";
        else
            cout<<"1";
    } else {
        if(a>b)
            cout<<"0";
        else if(a==b)
            cout<<"1";
        else {
            cout<<count(n,a,b);
        }
    }
    return 0;
}


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

 
int main() {
  
  string board[50];
  int h,w;
  int dx[]={-1,-1,-1,0,0,1,1,1};
  int dy[]={-1,0,1,-1,1,-1,0,1};
  cin>>h>>w;
  
 
  
  for(int i=0;i<h;i++)
  {
     cin>>board[i];
  }
  
  
  for(int i=0;i<h;i++)
  {
  for(int j=0;j<w;j++)
    {
       if(board[i][j]=='.')
       {
          int sum=0;
          for(int k=0;k<8;k++)
          {
             int x = i+dx[k];
             int y = j+dy[k];
           
            if(x>=0 && x<h && y>=0 && y<w&& board[x][y]=='#')
              sum++;
                         
          }
         board[i][j]=char(sum+'0');
       }
    }
  }
 
     for(int i=0;i<h;i++)
     {
       cout<<board[i]<<endl;
     }
  
  return 0;
}

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

using namespace std;

using int64 = long long;

int H, W, D;
string C = "RYGB";

int get_color(int x, int y) {
  x += 1000000;
  y += 1000000;
  x %= 2 * D;
  y %= 2 * D;
  x = x < D;
  y = y < D;
  return (x << 1) | y;
}

int main() {
  cin >> H >> W >> D;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cout << C[get_color(i + j, i - j)];
    }
    cout << endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

bool check(ll x, ll y, ll r, ll c){
	int count = 0;
	if(x == 0) count++;
	if(x == r) count++;
	if(y == 0) count++;
	if(y == c) count++;
	if(count >= 1) return true;
	else return false;
}

ll value(ll x, ll y, ll r, ll c){
	ll ret = 0;
	if(x == 0){
		ret += y;
	}else if(x == r){
		ret = r + c + (c-y);
	}else if(y == 0){
		ret = c + r + c + (r-x);
	}else{
		ret = c + x;
	}
	return ret;
}

struct point{ll d; int id;};

int main(void){
	ll r,c,n;
	cin>>r>>c>>n;
	vector<point> P;
	ll x1,y1,x2,y2;
	rep(i,n){
		cin>>x1>>y1>>x2>>y2;
		if(check(x1,y1,r,c) && check(x2,y2,r,c)){
			P.push_back(point{value(x1,y1,r,c), i});
			P.push_back(point{value(x2,y2,r,c), i});
		}else{
			continue;
		}
	}
	sort(all(P), [](const point& a, const point& b){return a.d < b.d;});

	if(P.size() == 0){
		cout<<"YES"<<endl;
	}

	stack<int> st;
	st.push(-1);
	rep(i,P.size()){
		if(st.top() == P[i].id){
			st.pop();
		}else{
			st.push(P[i].id);
		}
	}
	if(st.size() == 1){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

	return 0;
}


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

long gcd(long a, long b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int N;
	cin >> N;
	vector<long> A(N);
	for (auto& i : A) cin >> i;
	/*//sort(A.begin(), A.end());
	long ans = LONG_MAX;
	for (int i = 1; i < N; ++i) {
		for (int j = 0; j < N - 1; ++j) {
			ans = min(A[j] - A[i] % A[j], ans);
		}
	}
	cout << ans;*/
	for (int i = 1; i < N; ++i) {
		A[i] = gcd(A[i - 1], A[i]);
	}
	cout << A[N - 1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* 約数列挙 */vector<ll> divisor(ll n) {vector<ll> ret;for(ll i = 1; i * i <= n; i++) {if(n % i == 0) {ret.push_back(i);if(i * i != n) ret.push_back(n / i);}}sort(begin(ret), end(ret));return (ret);}/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  ll ans{};
  rep(i, 1, N+1){
    if(divisor(i).size() == 8 && i%2 == 1) ans++;
  }
  cout << ans << rt;
}

Measured memory_bytes: 256
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int main()
{
   ll n;
   cin>>n;
   ll a[n];
   ll s[2000009]={0};
   for(int i=0;i<n;i++){
   cin>>a[i];
   }
   sort(a,a+n);
   for(int i=0;i<n-1;i++){
       if(a[i]==a[i+1])s[a[i]]=1;
   }
   
   ll m = a[n-1];
   int count =0;
   for(ll i=0;i<n-1;i++){
       if(!s[a[i]])count++;
       if(a[i]!=a[i+1]){
       for(ll j=1;j*a[i]<=m;j++)
       s[j*a[i]]=1;
   }}
   if(s[m]==0)count++;
   cout<<count;
     return 0;
}





Measured memory_bytes: 20760
using System;
using System.Collections.Generic;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var a = int.Parse(_[1]);
            var b = int.Parse(_[2]);

            var total = 0;
            for(var i = 1; i <= n; i++){
                var s = i.ToString().ToCharArray().Select(x => int.Parse(x.ToString())).Sum();
                if(s >= a && s <= b){
                    total += i;
                }
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <iostream>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
ll a[maxn],f[maxn];
bool cmp(ll x,ll y){return x>y;}
ll n,k;
bool check(ll x){
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(a[i]*f[i]>x){
			sum+=a[i]-x/f[i];
		}
	}
	return sum<=k;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>f[i];
	}
	sort(f+1, f+n+1,cmp);
	sort(a+1, a+n+1);
	ll l=0,r=1e12,mid;
	while (l<=r) {
		mid=(l+r)>>1;
		if(check(mid)){
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	cout<<l<<endl;
}


Measured memory_bytes: 3328