akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <queue>

#define mp std::make_pair
#define fi first
#define se second
typedef long long LL;
typedef std::pair<int, int> pii;
const int MN = 200005;

int N, A[MN], B[MN];
std::priority_queue<pii> pq;
LL Ans;

inline int nx(const int &x) { return x % N + 1; }
inline int ls(const int &x) { return (x - 2 + N) % N + 1; }

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	for (int i = 1; i <= N; ++i) scanf("%d", &B[i]);
	for (int i = 1; i <= N; ++i) {
		if (B[i] < A[i]) return puts("-1"), 0;
		if (B[i] > A[i]) pq.push(mp(B[i], i));
	}
	while (!pq.empty()) {
		pii p = pq.top(); pq.pop();
		int i = p.se, v = p.fi;
		int x = B[ls(i)] + B[nx(i)], t = (v - A[i]) / x;
		if (!t) return puts("-1"), 0;
		Ans += t;
		B[i] -= t * x;
		if (B[i] > A[i]) pq.push(mp(B[i], i));
//		for (int i = 1; i <= N; ++i) printf("%d%c", B[i], " \n"[i == N]);
	}
	printf("%lld\n", Ans);
	return 0;
}

/*
6
1 1 1 1 1 1
1 1 9 5 1 1

*/


Measured memory_bytes: 3956
n = int(input())
h = list(map(int, input().split()))

def f():
    global h
    for i in range(n - 1, 0, -1):
        diff = h[i - 1] - h[i]
        
        if diff >= 2:
            return 'No'
        elif diff == 1:
            h[i - 1] = h[i - 1] - 1
    
    return 'Yes'

print(f())

Measured memory_bytes: 14252
N=int(input())
H = [int(i) for i in input().split()]
ans = 0
check = [0 for _ in range(N)]

for i in range(N):
    for j in range(i):
        if H[j] <= H[i]:
                check[i] = int(check[i]) + 1
    if check[i] == i:
        ans +=1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define X first
#define Y second
#define rep(i,a,n) for (long long i = a; i < n; i++)
#define ms(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int MAXN = 2e5 + 10;
const int INF = 0x3fffffff;

struct Reader {
    static const int MX = 1e6;
    bool fail;
    char buf[MX], *p1, *p2;

    inline char nc() {
        if (p1 == p2) {
            p2 = (p1 = buf) + fread(buf, 1, MX, stdin);
            if (p1 == p2) return 0;
        }
        return *p1++;
    }

    template<class T> inline void read(T &x) {
        fail = true;
        char c = nc();
        bool b = 0;
        for (; c && !isdigit(c); c = nc()) if (c == '-') b = 1;
        if (c) fail = false;
        for (x = 0; isdigit(c); x = x * 10 + c - '0', c = nc());
        if (b) x = -x;
    }

    template<class T> inline Reader & operator >> (T &x) {
        if (!fail) read(x);
        return *this;
    }

    operator void*() {
        return fail ? 0 : (Reader*)this;
    }
} rd;

int n;

void solve() {
    rd >> n;
    int l, r;
    int ans = 0;
    while (n--) {
        rd >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

int main() {
#ifdef LOCAL
    freopen("case.in", "r", stdin);
#endif

    int T, cas = 0;
//    rd >> T;
//    while (T--) {
//        printf("Case #%d: ", ++cas);
        solve();
//    }
    return 0;
}


Measured memory_bytes: 256
N,X = map(int,input().split())
L = list(map(int,input().split()))

D = [0]
k = 0
for i in range(0,N):
  d = k+L[i]
  D.append(d)
  k = d
#print(D)

cnt = 0
for i in range(0,N+1):
  if D[i] <= X:
    cnt += 1
  else:
    break
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
int main(){
    string S;
    cin >> S;
    stack<char> moji;
    ll s = S.size();
    rep(i,s){
        if(S[i] == '0')moji.push('0');
        else if(S[i] == '1')moji.push('1');
        else if(S[i] == 'B' && moji.size())moji.pop();
    }
    ll n = moji.size();
    vector<char> ans(n);
    for(ll i = n - 1;i >= 0;i--){
        ans[i] = moji.top();
        moji.pop();
    }
    rep(i,n)cout << ans[i];
    cout << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import math

n = int(input())
points = []
combi_num = 1
for i in range(n):
    p = list(map(int, input().split()))
    points.append(p)
    combi_num *= i
#print(points)

total = 0
for i in range(n):
    for j in range(n):
        if i != j:
            k = math.sqrt((points[i][0]-points[j][0])*(points[i][0]-points[j][0]) + (points[i][1]-points[j][1])*(points[i][1]-points[j][1]))
            total += k
print(total/n)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
using namespace std;
#define MAX 25
#define MOD 1000000000
#define NINF -1000000000000000000
vector<int> Graph[MAX];
bool visit[MAX];
int sum[MAX];
bool makeGraph(int n)
{
    int arr[n+1];
    int sum[n+1];
    int i=0;
    arr[i]=0;
    sum[i]=0;
    int j;
    for(i=1,j=(n/2)*2;i<=n;i++,j--)
    {
        sum[i]=0;
        if(i<j)
        {
            arr[i]=j;
        }
        else
        {
            arr[i]=0;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(arr[i]==j) continue;
            sum[i]+=j;
            sum[j]+=i;
        }
    }
    for(i=2;i<=n;i++)
    {
        if(sum[i]!=sum[i-1]) return false;
    }
    printf("%d\n",n*(n-1)/2-(n/2));
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(arr[i]==j) continue;
            printf("%d %d\n",i,j);
        }
    }
    return true;
}
int main()
{
    int n;
    scanf("%d",&n);
    bool ans=makeGraph(n);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
int a[N];
int main() {
    int n,t;
    scanf("%d%d",&n,&t);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
 
    int maxx=-INF,temp=-INF;
    for(int i=n;i>=1;i--){
        temp=max(temp,a[i]);//最大的价格
        maxx=max(maxx,temp-a[i]);//最大的贸易差
    }
    
    temp=-INF;
    int res=0;
    for(int i=n;i>=1;i--){
        temp=max(temp,a[i]);
        if(maxx==temp-a[i])
            res++;
    }
    printf("%d\n",res);
 
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    N, K = mi()
    A = lmi()
    cnt = 0
    for i in range(N):
        if A[i] >= K:
            cnt += 1
    print(cnt)
    return


if __name__ == '__main__':
    main()


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;


ll f(ll b, ll n) {
    if (n < b) return n;
    return f(b, n / b) + n % b;
}

int main() {
    ll n, s;
    cin >> n >> s;

    if (n == s) {
        cout << n + 1 << endl;
        ret();
    }

    for (ll b = 2; b * b <= n; b++) {
        if (f(b, n) == s) {
            cout << b << endl;
            ret();
        }
    }


    ll ans = INF;
    for (ll p = 1; p * p < n; p++) {
        ll b = (n - s) / p + 1;
        if (b < 2) continue;
        if (f(b, n) == s) {
            cmin(ans, b);
        }
    }

    cout << (ans == INF ? -1 : ans) << endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
char b;
int main() {
  cin >> b;
  switch (b) {
    case 'A':
      cout << "T" << endl;
      break;
    case 'G':
      cout << "C" << endl;
      break;
    case 'C':
      cout << "G" << endl;
      break;
    case 'T':
      cout << "A" << endl;
      break;
  }
  return 0;
}

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

int main() {
int h,w,a,b; cin>>h>>w>>a>>b;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j+1<=a){
        if(i+1<=b)cout<<0;
        else cout<<1;
      }
      else {
        if(i+1<=b)cout<<1;
        else cout<<0;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <array>

class Baseball{
private:
    int m_runner = 0;
    int m_out = 0;
    int m_point = 0;

public:
    void isHit(){
        if(m_runner < 3){
            ++m_runner;
            //if fill all base    
        } else {
            ++m_point;
        }
    }
    void isHomerun(){
        //add point and reset runner
        m_point += m_runner + 1;
        m_runner = 0;
    }
    void setOut(){
        ++m_out;
    }
    int getOut(){
        return m_out;
    }
    int getPoint(){
        return m_point;
    }

    void resetInning(){
        m_runner = 0;
        m_out = 0;
        m_point = 0;
    }
};

int main(){
    int n;
    std::string event;

    std::cin >> n;
    Baseball baseball;
    for(int i = 0; i < n; ++i){
        //until out count = 3
        while(baseball.getOut() < 3) {
            //input event
            std::cin >> event;
            if (event == "HIT") {
                baseball.isHit();
            } else if (event == "OUT") {
                baseball.setOut();
            } else if (event == "HOMERUN"){
                baseball.isHomerun();
            }
        }
        std::cout << baseball.getPoint() << std::endl;
        baseball.resetInning();
    }
}

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

int main()
{
    int A, B;
    cin >> A >> B;

    string S;
    cin >> S;

    string ans = "Yes";
    for (int i = 0; i < S.size(); i++)
    {
        if (i == A)
        {
            if (S[i] != '-')
            {
                ans = "No";
            }
        }
        else
        {
            if (S[i] < '0' || '9' < S[i])
            {
                ans = "No";
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int ap[101];
int main(){
	fastio;
	int x,n;
	cin>>x>>n;
	rb(i,1,n){
		int ai;
		cin>>ai;
		ap[ai]=1;
	}
	int l=x,r=x;
	while(1){
		if(!ap[l]){
			cout<<l<<endl;
			return 0;
		}
		if(!ap[r]){
			cout<<r<<endl;
			return 0;
		}
		l--;
		r++;
	}
	return 0;
}


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

N = int(input())
left = 0
right = N
print(left, flush=True)
left_seat = input()
if left_seat == 'Vacant':
    exit()


while right - left > 1:
    mid = (left + right) // 2
    print(mid, flush=True)
    mid_seat = input()
    if mid_seat == 'Vacant':
        exit()
    if mid_seat == left_seat:
        if (mid - left) % 2 == 0:
            left = mid
        else:
            right = mid
    else:
        if (mid - left) % 2 == 1:
            left = mid
            left_seat = mid_seat
        else:
            right = mid


Measured memory_bytes: 3660
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <array>
#include <initializer_list>
#include <random>
#include <regex>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;


int main()
{
    int n, m, k;
    scanf("%d%d%d",&n,&m,&k);

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            int cnt = i * m + j * n - i * j * 2;
            if (cnt == k) return !printf("Yes\n");
        }
    }
    printf("No\n");
}


Measured memory_bytes: 384
import string

punc = string.punctuation
s = input()
count = 0
line = input()
while line != 'END_OF_TEXT':
    line = line.lower()
    for p in punc:
        line.replace(p, ' ')
    words = line.split()
    for w in words:
        if w == s:
            count += 1
    line = input()
print(count)


Measured memory_bytes: 6684
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, m, idx, len, dp[3005][3005];
char lcs[3005];
string s, t;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> s >> t;

    n = s.size(); m = t.size();
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (!i || !j) dp[i][j] = 0;
            else if (s[i-1] == t[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    idx = len = dp[n][m];
    while (n && m) {
        if (s[n-1] == t[m-1]) {
            lcs[--idx] = s[n-1];
            n--; m--;
        }
        else if (dp[n-1][m] > dp[n][m-1]) n--;
        else m--;
    }

    for (int i = 0; i < len; i++)
        cout << lcs[i];
    cout << '\n';
    
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main(void) {
    int N, dt, dx, dy,dxy;
    bool flag=false;
    cin>>N;
    int t[N],x[N],y[N];
    for(int i=0;i<N;i++){
      cin>>t[i]>>x[i]>>y[i];
      if(t[i]<(int)abs(x[i]+y[i])){
            cout<<"No"<<endl;
            return 0;
      }
    }

    for(int i=0;i<N-1;i++){
    dt =  t[i+1] - t[i];
    dx =  x[i+1] - x[i];
    dy =  y[i+1] - y[i];
    dxy = (int)abs(dx+dy);
    if((dt<dxy)|| ((dt%2)!=(dxy%2))){
      cout<<"No"<<endl;
      return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);

    if (A + B >= C) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long r = sc.nextLong();
        long d = sc.nextLong();
        long x = sc.nextLong();
        for(int i=0; i<10; i++){
            x = r * x - d;
            System.out.println(x);
        }
    }


    private static class FastScanner {
        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 static 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());
        }
    }

}


Measured memory_bytes: 22612
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

int d[4] = {25, 24, 23, 22}, D;
string W[4] = {"Christmas", "Christmas Eve", "Christmas Eve Eve", "Christmas Eve Eve Eve"};

int main(){

    cin >> D;
    if (D == d[0]){
        cout << W[0];
    } else if (D == d[1]){
        cout << W[1];
    } else if (D == d[2]){
        cout << W[2];
    } else if (D == d[3]){
        cout << W[3];
    }


    return 0;
}

Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
X, Y, H = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

H = np.array(H)
X = np.array(X)
Y = np.array(Y)
base_i = np.where(H > 0)[0][0]

ans = []
for cx in range(101):
    for cy in range(101):
        ch = abs(X[base_i] - cx) + abs(Y[base_i] - cy) + H[base_i]
        ok = True
        for x, y, h in zip(X, Y, H):
            if h > 0 and ch != abs(x - cx) + abs(y - cy) + h:
                ok = False
                break
            if h == 0 and ch > abs(x - cx) + abs(y - cy):
                ok = False
                break
        if ok:
            ans = cx, cy, ch
print(*ans)


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

typedef ll Weight;
struct Edge {
	int from, to;
	Weight weight;
	Edge(int src, int dst) :
		from(src), to(dst), weight(0) { }

	Edge(int src, int dst, Weight weight) :
		from(src), to(dst), weight(weight) { }
};
bool operator < (const Edge& e, const Edge& f) {
	return e.weight != f.weight ? e.weight > f.weight :
	e.from != f.from ? e.from < f.from : e.to < f.to;
}

struct UndirectionalCompare {
	bool operator() (const Edge& e, const Edge& f) const {
		if (min(e.from, e.to) != min(f.from, f.to))
			return min(e.from, e.to) < min(f.from, f.to);
		return max(e.from, e.to) < max(f.from, f.to);
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
typedef set<Edge, UndirectionalCompare> Edgeset;

struct tree_height {
	Weight visit(const Graph& g, Graph& T, int i, int j) {
		if (T[i][j].weight >= 0) return T[i][j].weight;
		T[i][j].weight = g[i][j].weight;
		int u = T[i][j].to;
		rep(k ,  T[u].size()) {
			if (T[u][k].to == i) continue;
			T[i][j].weight = max(T[i][j].weight, visit(g, T, u, k) + g[i][j].weight);
		}
		return T[i][j].weight;
	}
	vector<Weight> height(const Graph& g) {
		const int n = g.size();
		Graph T(g); // memoise on tree
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < T[i].size(); ++j)
				T[i][j].weight = -1;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < T[i].size(); ++j)
				if (T[i][j].weight < 0)
					T[i][j].weight = visit(g, T, i, j);

		vector<Weight> ht(n); // gather results
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < T[i].size(); ++j)
				ht[i] = max(ht[i], T[i][j].weight);
		return ht;
	}
};

int main(void)
{
	int v;
	cin >> v;
	Graph g(v);
	int e = v - 1;
	rep(i, e) {
		int s, t, w;
		cin >> s >> t >> w;
		g[s].push_back({ s,t,w });
		g[t].push_back({ t,s,w });
	}

	tree_height d;
	auto r = d.height(g);
	for (auto rr : r) {
		cout << rr << endl;
	}
	return 0;
}



Measured memory_bytes: 4684
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(1,n):
    ans = ans * t[i] // gcd(ans , t[i])
    
print(ans)

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

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

    int n;
    cin >> n;
    ll a[n], copy[n];
    rep(i,n){
        cin >> a[i];
        copy[i] = a[i];
    }
    
    sort(copy, copy+n, greater<int>());
    
    rep(i,n){
        ll ans;
        
        if(a[i] == copy[0]){
            ans = copy[1];
        }else{
            ans = copy[0];
        }
        
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4736
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N], b[N], ans;
    
inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   for (int i = 1; i <= n; i ++) cin >> b[i];
   for (int B = 29; B >= 0; B --) {
      int cur = 0;
      for (int i = 1; i <= n; i ++) {
         int pos = lb (a + 1, a + n + 1, (1 << (B + 1)) + (1 << B) - b[i]) - a; 
         int pos2 = lb (a + 1, a + n + 1, (1 << (B + 1)) - b[i]) - a;
         if (pos < pos2) pos2 = pos - 1;
         int pos1 = lb (a + 1, a + n + 1, (1 << B) - b[i]) - a;
         if (pos1 <= pos2) cur += pos2 - pos1;
         cur += n - pos + 1;
         cur &= 1;
      }
      if (cur & 1) ans ^= (1 << B);
      for (int i = 1; i <= n; i ++) {
         if (a[i] & (1 << B))
            a[i] -= (1 << B);
         if (b[i] & (1 << B))
            b[i] -= (1 << B);
      }
      sort (a + 1, a + n + 1);
   }
   cout << ans;
}               
 
signed main () {                                       
  //#ifdef QWERTY
  //    freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#define MAX 21
 
int N, M, C;
int B[MAX] = {};
int adj_matrix[MAX][MAX] = {};
int num = 0;
int main(){
    cin >> N >> M >> C;
    for (int i = 0; i < M; i++){
        int element;
        cin >> element;
        B[i] = element;
     }
    for (int i = 0; i < N; i++){
        int left = 0;
        for (int j= 0; j < M; j++){
            int element;
            cin >> element;
            adj_matrix[i][j] = element;
            left += element * B[j];
        }
        left += C;
        if (left > 0){
            num += 1;
        }
    }
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<ll, ll>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;
#pragma endregion

const int N = 100005;

pls give {
    AC;
    string s;
    cin >> s;
    if (s[4] == s[5] and s[2] == s[3]) cout << "Yes" << nl;
    else cout << "No" << nl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double ans;
  if(n&1){
    int k=(n+1)/2;
    ans=double(k)/n;
  }
  else{
    int k=n/2;
    ans=double(k)/n;
  }
  cout<<fixed<<setprecision(9)<<ans;
  return 0;
}
    

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];

            Set<Integer> s = new HashSet<>();
            for (int i = 0; i < n; i++) {
                s.add(in.nextInt());
            }
            out.println(s.size());
            return;

            // int[] dp  = new int[n];
            //
            // for (int i = 0; i < n; i++) {
            //     a[i] = in.nextInt();
            // }
            //
            // for (int i = 0; i < n; ++i) {
            //     dp[i] = 1;
            //     for (int j = 0; j < i; ++j)
            //         if (a[j] > a[i])
            //             dp[i] = Math.max(dp[i], 1 + dp[j]);
            // }
            //
            // int ans = dp[0];
            // for (int i = 0; i < n; ++i)
            //     ans = Math.max(ans, dp[i]);
            //
            // out.println(ans);
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;

const ll N = 2e5 + 9;
// const ll m = 1e9 + 7;
const ll INF = 1e14;
const ll mod =1e9+7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    freopen("error.txt", "w", stderr); 
    #endif      
    int T = 1;
    // cin>>t;
    while(T--){
        ll n;cin>>n;
        ll a[n];
        for(int i = 0;i<n;i++){
            cin>>a[i];
        }
        map<ll,ll> ct1,ct2;
        for(int i = 0;i<n;i+=2){
            ct1[a[i]]++;
        }
        for(int i = 1;i<n;i+=2){
            ct2[a[i]]++;
        }
        std::vector<pii> v1,v2;
        v1.pb({0,0});
        v2.pb({0,0});
        for(auto i:ct1){
            v1.pb({i.y,i.x});
        }
        for(auto i:ct2){
            v2.pb({i.y,i.x});
        }
        sort(v1.begin(),v1.end());
        sort(v2.begin(), v2.end());
        reverse(v1.begin(),v1.end());
        reverse(v2.begin(),v2.end());

        ll ans;
        if(v1[0].y == v2[0].y){
            ans = n - max(v1[0].x+v2[1].x,v1[1].x+v2[0].x);
            
        }
        // cout<<m2<<" "<<m1<<'\n';
        else ans = n-v1[0].x-v2[0].x;
        cout<<ans<<'\n';


    }
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[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'};

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

int main(){
    ll n; cin >> n;
    string s; cin >> s;
    int count = 0;
    REP(i, 0, s.size()){
        if(s[i] == 'R'){
            count++;
        }
    }
    int k = 0;
    REP(i, 0, count){
        if(s[i] == 'W'){
            k++;
        }
    }
    cout << k << endl;
}

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


int main(){
    string S;
    vector<ll> Num(26,0);
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        Num[abs(S[i] - 'a')] ++;
    }
    
    for(int i = 0; i < 26; i++){
        if(Num[i] == 0){
            cout << char('a' + i) << endl;
            return 0;
        }
    }

    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, k; cin >> h >> w >> k;
  vector<string> S(h); rep(i, h) cin >> S[i];
  int ans = 0;
  rep(i, 1<<h) rep(j, 1<<w) {
    int cnt = 0;
    rep(k, h) rep(l, w) if(S[k][l]=='#'&&(i>>k)&1&&(j>>l)&1) cnt++;
    if(cnt == k) ans++;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<deque>
#include<utility>
#include<map>
#include<set>
using namespace std;

int visit[1000000],dis[1000000];
vector<int> v[1000000];

int dfs(int p){
    int res1=1,res2=0;
    visit[p]=1;
    for(int i=0;i<v[p].size();i++){
        if(visit[v[p][i]]==1&&dis[v[p][i]]){
            res2=dis[v[p][i]]+1;
            if(res2==0){
                dis[p]=-1;
                return -1;
            }
            res1=max(res1,res2);
        }
        else if(visit[v[p][i]]==1&&!dis[v[p][i]]){
            dis[p]=-1;
            return -1;
        }
        else{
            res2=dfs(v[p][i])+1;
            if(res2==0){
                dis[p]=-1;
                return -1;
            }
            res1=max(res2,res1);
        }
    }
    dis[p]=res1;
    return res1;
}

int main(){
    int n,a[1000],ans=0,flag,f[1001]={};
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-1;j++){
            scanf("%d",&a[j]);
            if(j){
                v[max(i-1,a[j]-1)*n+min(i,a[j])-1].push_back(max(i-1,a[j-1]-1)*n+min(i,a[j-1])-1);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(visit[i*n+j]==0){
                dis[i*n+j]=dfs(i*n+j);
            }
            if(dis[i*n+j]==-1){
                printf("-1\n");
                return 0;
            }
            ans=max(ans,dis[i*n+j]);
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 47232
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, M;
    cin >> N >> M;
    int L = 1, R = N;
    for(int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        L = max(L, l);
        R = min(R, r);
    }
    cout << max(R - L, -1) + 1 << endl;
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5+5;
ll n,m,num,L,R;
vector<ll> l,r;
int flag[N];

int solve() {
  L = *max_element(ALL(l));
  R = *min_element(ALL(r));
  
  return R - L < 0 ? 0 : R - L + 1;
}

int main () {
  ios::sync_with_stdio(false);cin.tie(nullptr);
  cin >> n >> m;
  l.reserve(m);
  r.reserve(m);
  rep(i,m) {
    cin >> L >> R;
    l.push_back(L);
    r.push_back(R);
  }
  L = 1;R = n;
  
  
  cout << solve() << endl;
}


Measured memory_bytes: 1792
function MainC(input) {
	input = input.split("\n");
	var n = input[0];
	var s = input[1];
	var result = 0;
  
  var whiteStones = 0;
	for(var i = 0; i < n; i++){
		if(s[i] == "."){
			whiteStones += 1;
		}
	}
    
  var changeStones = whiteStones;
	var minChange = changeStones;
	for(var i = 0; i < n; i++){
		if(s[i] == "#"){
			changeStones += 1;
		}else{
			changeStones -= 1;
		}
		if(minChange > changeStones) minChange = changeStones;		
	}
	console.log('%d',minChange);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
MainC(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11596
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
 
using namespace std;
 
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
 
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}
#define int long long
#define left left228
#define right right228
#define prev prev228
#define mp make_pair
#define all(v) v.begin(), v.end()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define x first
#define y second

const int N = 2003;
const int INF = 1e18 + 228;

int a[N];
int mn[N][N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        mn[i][0] = a[i];
        for (int k = 1; k <= n; ++k) {
            mn[i][k] = min(mn[i][k - 1], a[(i + k - 1) % n + 1]);
        }
    }
    int res = INF;
    for (int cnt = 0; cnt < n; ++cnt) {
        int cur = x * cnt;
        for (int i = 1; i <= n; ++i) {
            cur += mn[i][cnt];
        }
        uin(res, cur);
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 31616
def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

def Ind(b,n):
    count=0
    while n%b==0:
        count+=1
        n//=b
    return count

prime=get_sieve_of_eratosthenes_new(10**4+1)

from fractions import gcd

N=int(input())
a=[]
for i in range(N+1):
    a.append(int(input()))

a=a[::-1]
ans=set([])
for p in prime:
    data=[0 for i in range(p)]
    for i in range(1,N+1):
        data[(i-1)%(p-1)]+=a[i]%p
        data[(i-1)%(p-1)]%=p
    check=(a[0]%p==0)
    for i in range(p):
        check=check&(data[i]%p==0)
    if check:
        ans.add(p)


n=a[0]
for i in range(N+1):
    n=gcd(n,a[i])

prime=get_sieve_of_eratosthenes_new(32000)

for p in prime:
    i=Ind(p,n)
    if i!=0:
        ans.add(p)
    n//=pow(p,i)

if abs(n)!=1:
    ans.add(abs(n))

ans=list(ans)
ans.sort()
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 80852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int n,m; cin>>n>>m;
	double a[n]; double sum=0;
	for(int i=0;i<n;i++){ cin>>a[i]; sum+=a[i]; }
	double p = (1.0*sum)/(4.0*m);
	sort(a,a+n,greater<int>());
	if( a[m-1] >= p ) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}


Measured memory_bytes: 256
//NAME-DEEPESH BHATT
//Institute-IIT Dhanbad
//MOTTO-THINK FIRST,CODE LATER
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007  ;
#define pb push_back
#define mp make_pair
#define pi 3.14159265359
#define fill(a,b) memset(a, b, sizeof(a))
#define endl '\n'
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a,ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}
struct compare{
    bool operator()(pair<int,int>p1,pair<int,int>p2){
        int l1=p1.second-p1.first+1;
        int l2=p2.second-p2.first+1;
        if(l1==l2){
            return p1.first<p2.first;
        } else
            return l1>l2;
    }
};
int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    int test=1;
    /*cin>>test;*/
    while(test--) {
        int n;
        cin>>n;
        vector<int>h(n);
        for(int i=0;i<n;i++){
            cin>>h[i];
        }
        vector<int>dp(n,0);
        dp[0]=0;
        dp[1]=abs(h[1]-h[0]);
        for(int i=2;i<n;i++){
            dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
        }
        cout<<dp[n-1];
    }
    return 0;
}




Measured memory_bytes: 1024
#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;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int  long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 998244353
// order_of_key and *find_by_order
#define N 200001
int32_t main() {
	fast;
	int n;
	cin >> n;
	int base = 26;
	string s = "";
	while (n) {
		n--;
		int rem = n % base;
		s = ((char)('a' + rem)) + s;

		n /= base;

	}
	cout << s;









}

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

//S:c = 1:2  2c = S 4cで１つの組み合わせ。
int main(){
	long long N,M;
	cin >> N >> M;
	if(M>=2*N){
		cout << (M + 2*N)/4 << endl;
	}else{
		cout << M/2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
  class Main{
    public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    
    double a = scan.nextDouble();
    
    System.out.println(String.format("%.6f",a*a*Math.PI)+" "+String.format("%.6f",2*a*Math.PI));
  }
}


Measured memory_bytes: 28024
h, w = list(map(int, input().split()))
a = [input() for i in range(h)]

row = [False]*h
cow = [False]*w

for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      row[i] = True
      cow[j] = True
      
for i in range(h):
  if row[i]: 
    for j in range(w):
      if cow[j]:
        print(a[i][j], end="")
 
    print()

Measured memory_bytes: 4468
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;


int32_t main() {
	// your code goes here
int n,d,i,j,count=0;
cin>>n>>d;
vi x(n),y(n);
	for(i=0;i<n;i++)
	{
	    cin>>x[i]>>y[i];
	    if((x[i]*x[i]+y[i]*y[i])<=(d*d))
	    count++;
	}
	cout<<count<<"\n";
	return 0;
}


Measured memory_bytes: 6420
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const [a, b] = (await sc.getLine()).split(' ').map((x) => +x);
    if (b % a === 0) {
      console.log(a + b);
    } else {
      console.log(b - a);
    }
    sc.close();
  }

  slove();
}


Measured memory_bytes: 7628