akhauriyash/Code-Regression huggingface dataset:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def main():
  n=I()

  ans=0
  for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
      ans+=i

  return ans

# main()
print(main())


Measured memory_bytes: 10696
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define int ll
int p[212345];
vector<vi> facto(123456),sum1(123456),sum2(123456);

main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin>>n;
    int i;
    rep(i,n){
    	cin>>p[i];
    }
    int sz,j;
    for(i=1;i<123456;i++){
    	sum1[i].pb(0);
    	sum2[i].pb(0);
    	for(j=i;j<123456;j+=i){
    		facto[j].pb(i);
    		sz=sum1[i].size();
    		if(j<=n-1)
    			sum1[i].pb(sum1[i][sz-1]+p[j]);
    		sz=sum2[i].size();
    		if(n-1-j>=0)
    			sum2[i].pb(sum2[i][sz-1]+p[n-1-j]);
    	}
    }
    //return 0;
    int ans=0,req,a,b,ab,gg,h;
    f(i,1,n-1){
    	a=i;
    	req=n-1-a;
    	rep(j,facto[req].size()){
    		if(facto[req][j]>=a)
    			break;
    		b=a-facto[req][j];
    		ab=a-b;
    		h=req/ab;
    		if(a%ab==0 && a/ab<=h)
    			continue;
    		//cout<<a<<" "<<b<<endl;
    		gg=sum1[ab][h];
    		gg+=sum2[ab][h];
    		ans=max(ans,gg);
    	}
    }
    cout<<ans<<endl;
    return 0;   
}


Measured memory_bytes: 55144
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const rows = input.split('\n')
    const N = parseInt(rows[0].split(' ')[0], 10)
    const M = parseInt(rows[0].split(' ')[1], 10)

    const map = Array(N + 1).fill(null).map(() => [])
    for (var i = 0; i < M; i++) {
        const [a, b] = rows[i + 1].split(' ')
        map[a].push(b - 0)
        map[b].push(a - 0)
    }
    
    const res = Array(N).fill(0)
    const s = [1]
    let n = 0
    while (n = s.shift()) {
        map[n].forEach(_n => {
            if (res[_n - 1] === 0) {
                s.push(_n)
                res[_n - 1] = n
            }
        })
    }

    if (res.indexOf(0) === -1) {
        res[0] = 'Yes'
        res.forEach(val => {
            console.log(val)
        })
    } else {
        console.log('No')
    }

})(input)


Measured memory_bytes: 102640
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

struct UnionFind{
    vector<long long> par;
    vector<long long> siz;
    //Constractor
    UnionFind(long long sz_) : par(sz_),siz(sz_,1LL){
        for(long long i = 0;i < sz_;i++)par[i] = i;
    }
    void init(long long sz_){
        par.resize(sz_);
        siz.resize(sz_);
        for(long long i = 0;i < sz_;i++)par[i] = i;
    }
    //MemberFunc
    long long find(long long x){
        while(par[x] != x)x = par[x] = par[par[x]];
        return x;
    }
    void unite(long long x, long long y){
        x = find(x);
        y = find(y);
        if(x == y)return;
        if(siz[x] < siz[y])swap(x,y);
        siz[x] += siz[y];
        par[y] = x;
    }
    bool same(long long x, long long y){
        return find(x) == find(y);
    }
    long long size(long long x){
        return siz[find(x)];
    }
};

//ミョ(-ω- ?)
int main() {
    ll n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<unordered_set<ll>> friends(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        uf.unite(a-1,b-1);
        friends[a-1].insert(b-1);
        friends[b-1].insert(a-1);
    }
    vector<unordered_set<ll>> block(n);
    rep(i,k){
        ll c,d;
        cin >> c >> d;
        if(uf.same(c-1,d-1)){
            block[c-1].insert(d-1);
            block[d-1].insert(c-1);
        }
    }
    rep(i,n){
        ll res = max(0LL,uf.size(i) - (long long)friends[i].size() - (long long)block[i].size() -1);
        cout << res << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 35508
n = int(input())
# 初期位置
x_old, y_old, t_old = 0, 0, 0

for _ in range(n):
    # 都度読み込み
    t, x, y = map(int, input().split())
    d = (t - t_old) - abs(x - x_old) - abs(y - y_old)
    if d >= 0 and d % 2 == 0:
        x_old, y_old, t_old = x, y, t
    else:
        print('No')
        exit()

print('Yes')

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

int main(){
  string txt[110],str,buf;
  char c;
  int x,y;

  y = 0;
  while(1){
    getline(cin,str);
    if(str == "END_OF_TEXT")break;
    txt[y] = str + '\n';
    y++;
  }

  x = y = 0;
  while(1){
    c = getchar();
    if(c == '-')break;
    if(c == 'a'){
      x = 0;
    }
    if(c == 'e'){
      x = (int)txt[y].size() - 1;
    }
    if(c == 'p'){
      if(y){
	y--;
	x = 0;
      }else x = 0;
    }
    if(c == 'n'){
      if(txt[y+1].size()){
	y++;
	x = 0;
      }else x = 0;
    }
    if(c == 'f'){
      if(x != (int)txt[y].size() - 1)x++;
      else if(txt[y+1].size()){
	y++;
	x = 0;
      }
    }
    if(c == 'b'){
      if(x)x--;
      else if(y){
	y--;
	x = (int)txt[y].size() - 1;
      }
    }
    if(c == 'd'){
      if(txt[y][x] != '\n'){
	txt[y].erase(txt[y].begin()+x);
      }else if(txt[y+1].size()){
	txt[y].erase(txt[y].begin()+x);
	txt[y] += txt[y+1];
	int tmp = y+1;
	while(txt[tmp+1].size()){
	  txt[tmp] = txt[tmp+1];
	  tmp++;
	}
	txt[tmp].clear();
      }
    }
    if(c == 'k'){
      if(x == (int)txt[y].size() - 1){
	if(txt[y+1].size()){
	  txt[y].erase(txt[y].begin()+x);
	  txt[y] += txt[y+1];
	  int tmp = y+1;
	  while(txt[tmp+1].size()){
	    txt[tmp] = txt[tmp+1];
	    tmp++;
	  }
	  txt[tmp].clear();
	  buf = '\n';
	}
      }else{
	buf.clear();
	while(txt[y][x] != '\n'){
	  buf.push_back(txt[y][x]);
	  txt[y].erase(txt[y].begin()+x);
	}
      }
    }
    if(c == 'y'){
      if(buf.size()){
	if(buf == "\n"){
	  int tmp = y+1;
	  str = txt[y+1];
	  txt[y+1].clear();
	  while(txt[y][x] != '\n'){
	    txt[y+1].push_back(txt[y][x]);
	    txt[y].erase(txt[y].begin()+x);
	  }
	  txt[y+1].push_back('\n');
	  while(txt[++tmp].size())swap(txt[tmp],str);
	  txt[tmp] = str;
	  y++;
	  x = 0;
	}else{
	  str.clear();
	  for(int i=0;i<x;i++)str.push_back(txt[y][i]);
	  str += buf;
	  for(int i=x;i<(int)txt[y].size();i++)str.push_back(txt[y][i]);
	  txt[y] = str;
	  x += buf.size();
	}
      }
    }
    //cout << c << ":" << y << " " << x << endl;
    getchar();
  }
  y = 0;
  while(txt[y].size())cout << txt[y++];
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    String a = input.next();
    String b = input.next();
    for(int i=0;i<n;i++)
      System.out.print(a.charAt(i)+""+b.charAt(i));
  }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

#define MAX_N 4000
class MinCostFlow {
public:
  struct Edge { int to, cap, cost, rev; };
  vector<Edge> G[MAX_N];
  int dist[MAX_N];
  int prevv[MAX_N], preve[MAX_N];

  void add_edge(int from, int to, int cap, int cost) {
    G[from].pb((Edge) { to, cap, cost, (int)G[to].size() });
    G[to].pb((Edge) { from, 0, -cost, (int)G[from].size() - 1 });
  }

  int min_cost_flow(int s, int t, int f) {
    int res = 0;
    while (f > 0) {
      rep(i, MAX_N) dist[i] = INF;
      dist[s] = 0;
      bool update = true;
      while (update) {
        update = false;
        rep(x, MAX_N) {
          if (dist[x] == INF) continue;
          rep(i, G[x].size()) {
            Edge &e = G[x][i];
            if (e.cap > 0 && dist[e.to] > dist[x] + e.cost) {
              dist[e.to] = dist[x] + e.cost;
              prevv[e.to] = x;
              preve[e.to] = i;
              update = true;
            }
          }
        }
      }
      if (dist[t] == INF) return -1;
      int d = f;
      for (int v=t; v!=s; v=prevv[v]) {
        d = min(d, G[prevv[v]][preve[v]].cap);
      }
      f -= d;
      res += d*dist[t];
      for (int v=t; v!=s; v=prevv[v]) {
        Edge &e = G[prevv[v]][preve[v]];
        e.cap -= d;
        G[v][e.rev].cap += d;
      }
    }
    return res;
  }
};

int N;
int A[1000], B[1000];
MinCostFlow flow;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  int S = 0, T = 1;
  // S:0 T:1 P:2+i X:2+N+i

  // S->V
  flow.add_edge(S, T, N, 0);
  vector<int> xs;
  rep(i, N) {
    cin >> A[i] >> B[i];
    xs.pb(A[i]);
    xs.pb(B[i]);

    // S->P
    flow.add_edge(S, 2+i, 1, 0);
  }
  sort(all(xs));
  uniq(xs);

  rep(i, N) {
    // P->X
    int a = lower_bound(all(xs), A[i]) - xs.begin(),
        b = lower_bound(all(xs), B[i]) - xs.begin();
    flow.add_edge(2+i, 2+N+a, 1, -B[i]);
    flow.add_edge(2+i, 2+N+b, 1, -A[i]);
  }

  rep(i, xs.size()) {
    // X->T
    flow.add_edge(2+N+i, T, 1, 0);
  }
  cout << -flow.min_cost_flow(S, T, N) << "\n";
  return 0;
}

Measured memory_bytes: 3532
def main():
    N = int(input())
    def fact(x):
        r = []
        i = 0
        while x % 2 == 0:
            x //= 2
            i += 1
        if i:
            r.append((2, i))
        t = 3
        i = 0
        while t * t <= x:
            if x % t == 0:
                x //= t
                i += 1
            else:
                if i:
                    r.append((t, i))
                    i = 0
                t += 2
        if i:
            r.append((t, i))
        if x != 1:
            r.append((x, 1))
        return r
    f = {}
    for i in range(2, N + 1):
        for j, k in fact(i):
            f[j] = f.get(j, 0) + k
    f75, f25, f15, f5, f3 = 0, 0, 0, 0, 0
    for j, k in f.items():
        if k >= 74:
            f75 += 1
        if k >= 24:
            f25 += 1
        if k >= 14:
            f15 += 1
        if k >= 4:
            f5 += 1
        if k >= 2:
            f3 += 1
    return f75 + f25 * (f3 - 1) + f15 * (f5 - 1) + f5 * (f5 - 1) * (f3 - 2) // 2

print(main())


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

int main()
{
  int n;
  while (cin >> n, n){
    int res = 0, num;
    for (int i = 0; i < n / 4 ; i++){
      cin >> num;
      res += num;
    }
    cout << res << endl;
  }
  return (0);
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long 	ll;
const ll   INF   =  LLONG_MAX;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6+5;
ll dp[N][5];
ll a[N][5];
ll n;
ll solve(ll i,ll p)
{
	if(i==n+1)
	{
		return 0;
	}
	if(dp[i][p]!=-1)
	{
		return dp[i][p];
	}
	ll ans=-INF;
	for(ll j=1;j<=3;j++)
	{
		if(j==p)
		{
			continue;
		}
		ans=max(ans,solve(i+1,j)+a[i][j]);
	}
	return dp[i][p]=ans;
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=3;j++)
		{
			cin>>a[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(1,0);
}

Measured memory_bytes: 91684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int V, E;
vector<vector<ll>> d;

void floyd();

int main(){
    cin >> V >> E;
    d.resize(V);
    FOR(i,0,V){
        FOR(j,0,V){
            d[i].push_back(INF);
        }
        d[i][i] = 0;
    }
    int s,t;
    ll u;
    FOR(i,0,E){
        cin >> s >> t >> u;
        d[s][t] = u;
    }
    floyd();
    
    bool flg=true;
    FOR(i,0,V){
        if(d[i][i]<0LL){
            flg=false;
            break;
        }
    }

    if(flg){
        FOR(i,0,V){
            FOR(j,0,V){
                if(j!=0) cout << " ";
                if(d[i][j]>=INF/2){
                    cout << "INF";
                }else{
                    cout << d[i][j];
                }
            }
            cout << endl;
        }
    }else{
        cout << "NEGATIVE CYCLE" << endl;
    }
    return 0;
}

void floyd(){
    FOR(k,0,V) FOR(i,0,V) FOR(j,0,V){
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }
}



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

int main() {
	int n,k;
	cin>>n>>k;
	int* frog = new int[n];
	for(int i=0;i<n;i++){
	    cin>>frog[i];
	}
		int* dp = new int[n];
	if(k<=n){
	dp[0] = 0;
	for(int i=1;i<n;i++){
	    dp[i]=INT_MAX;
	    for(int j=i-1;j>=0&&j>i-k-1;j--){
	    dp[i] = min(dp[i],dp[j]+abs(frog[i]-frog[j]));
	    }
	}
	cout<<dp[n-1]<<'\n';
	}
	else{
	    cout<<abs(frog[n-1]-frog[0])<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1024
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
//const input = fs.readFileSync('./input.txt', 'utf8');

_c(input);

function _c(input: string) {
  const [NK, _A] = input.split('\n');
  const [N, K] = NK.split(' ').map((s) => parseInt(s));
  const A = _A.split(' ').map((s) => parseInt(s));

  // A[i+K] > A[i] かどうかを調べる（掛け算する必要はない）
  for (let i = 0; i < N - K; i++) {
    console.log(A[i + K] > A[i] ? 'Yes' : 'No');
  }
}


Measured memory_bytes: 62420
N = int(input())
D,X = [int(i) for i in input().split()]
eaten_day = []
a_li = []
for i in range(N) :
    a_li.append(int(input()))

for i in range(N) :
    for d in range(1,D+1) :
        eat_day = (d-1) * a_li[i] + 1
        if (0 < eat_day and eat_day <= D) :
            eaten_day.append(eat_day)
print(len(eaten_day) + X)


Measured memory_bytes: 3060
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        long M = sc.nextLong();
        sc.close();

        long count = 0;

        count += Math.min(N, M/2);
        N -= count;
        M -= 2*count;
        if(M > 0){
            count += M/4;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = " " + s;
    int pre[n + 5] = {};
    int suf[n + 5] = {};
    f1(n) {
        if (s[i] == 'W') {
            pre[i] = pre[i - 1] + 1;
        }
        else {
            pre[i] = pre[i - 1];
        }
    }
    for (int i = n ; i >= 1 ; i--) {
        if (s[i] == 'E') {
            suf[i] = suf[i + 1] + 1;
        }
        else {
            suf[i] = suf[i + 1];
        }
    }
    int mi = 1e9;
    f1(n) {
        mi = min(mi, pre[i - 1] + suf[i + 1]);
    }
    cout << mi << '\n';
}


Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int P=1e9+7;
int n,m,a[N],ans[N],tot;
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>a[i];
    ans[0]=1;
    for(int i=1;i<=n;i++){
        if(a[tot]==i){tot++;continue;}
        ans[i]=i>1?(ans[i-1]+ans[i-2])%P:ans[i-1];
    }
    cout<<ans[n];
    return 0;
}

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

using namespace std;
using llint = long long;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

int a, b, ans;

int main() {
    // Input
    cin >> a >> b;

    // Output
    if (b%a==0)
    {
        ans = a+b;
    } else {
        ans = b-a;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const ll MOD = 1e9+7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;
  
int main() {
    int cnt = 0;
    int cnt_s = 0;
    string x;
    cin >> x;
    int n = x.size();
    rep(i,n){
        if(x[i]=='S'&&x[i+1]=='T') {
            i++;
            continue;
        }
        if(x[i]=='S') cnt_s++;
        if(x[i]=='T') {
            if(cnt_s>0) cnt_s--;
            else cnt++;
        }
        
    }
    cout << cnt*2 << endl;
    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>

int main() {
	int q;
	int a = 0;
	for (int i=0;i<4;i++) {
		scanf("%d", &q);
		switch(q) {
			case 1: a += 1; break;
			case 9: a += 2; break;
			case 7: a+=4; break;
			case 4: a+=8;break;
		}
	}
	printf("%s\n",(a==15)?"YES":"NO");
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

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


Measured memory_bytes: 256
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            a[j][a[j].index(b)] = 0

ans = "No"

if not(sum(a[0]) and sum(a[1]) and sum(a[2]) and 
        sum([a[0][0],a[1][0],a[2][0]]) and sum([a[0][1],a[1][1],a[2][1]]) and sum([a[0][2],a[1][2],a[2][2]]) and
        sum([a[0][0],a[1][1],a[2][2]]) and sum([a[0][2],a[1][1],a[2][0]])):
    ans = "Yes"

print(ans)

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


#define int long long 



const int N = 5005;

int p[N], c[N], vis[N], entry[N];

vector <int> vv;


int dfs(int v) {
	if(vis[v]) {
		return v;
	}
	vis[v] = true;
	vv.push_back(v);
	return dfs(p[v]);
}


int solve(int x, int k) {
	int ans = -2e18;
	int y = x, sum = 0;
	while(y != entry[x]) {
		sum += c[y];
		if(k > 0)
		ans = max(ans, sum);
		k--;
		y = p[y];
	}

	vector <int> cycle;
	int tot = 0;
	while(!vis[y]) {
		cycle.push_back(y);
		tot += c[y];
		vis[y] = true;
		y = p[y];
	}
	for(int x: cycle) {
		vis[x] = false;
	}
//	cout << cycle.size() << endl;
	int ss = 0, kk = cycle.size();
	for(int i = 1; i <= cycle.size() && i <= k; i++) {
		ss += c[cycle[i- 1]];
		int lft = k - i;
		if(tot >= 0) {
			ans = max(ans, sum + tot * (lft / kk) + ss);
		} else {
			ans = max(ans, sum + ss);
		}
	}
	return ans;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k; cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
	}

	for(int i = 1; i <= n; i++) {
		for(auto x: vv) {
			vis[x] = false;
		}
		vv.clear();
		entry[i] = dfs(i);
	}

	for(auto x: vv) {
		vis[x] = false;
	}

	int ans = -2e18;

	for(int i = 1; i <= n; i++) {
		ans = max(ans, solve(i, k));
	}

	cout << ans << endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int res = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			if (a[i] == a[j])
			{
				continue;
			}
			int sum = a[i] + a[j];
			int dif = a[i] - a[j];
			for (int k = j + 1; k < n; ++k)
			{
				if (a[i] == a[k] || a[j] == a[k]) {
					continue;
				}
				if (sum > a[k] && dif+ a[k] > 0
				        && a[k] > dif) {
					res++;
				}
			}
		}
	}
	cout<<res<<endl;

}
int main()
{
	std::ios::sync_with_stdio(false);
		solve();

	return 0;
}


Measured memory_bytes: 3592
package main

import (
        "fmt"
)

func solution(h []int, matrix [][]int) int {
        visit := make([]bool, len(h))
        for i := range visit {
                visit[i] = true
        }
        for i := range matrix {
                ai := matrix[i][0] - 1
                bi := matrix[i][1] - 1

                if h[ai] > h[bi] {
                        visit[bi] = false
                } else if h[ai] < h[bi] {
                        visit[ai] = false
                } else {
                        visit[ai] = false
                        visit[bi] = false
                }
        }
        c := 0
        for i := 0; i < len(h); i++ {
                if visit[i] {
                        c++
                }
        }
        return c
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        h := make([]int, 0, n)
        for i := 0; i < n; i++ {
                var num int
                fmt.Scan(&num)
                h = append(h, num)
        }
        matrix := make([][]int, 0, m)
        for i := 0; i < m; i++ {
                var a, b int
                fmt.Scan(&a, &b)
                matrix = append(matrix, []int{a, b})
        }
        fmt.Println(solution(h, matrix))
}

Measured memory_bytes: 10380
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int N;
vector <int> card;
int main(){
  int ans = 0;
  cin>>N;
  for(int i = 0; i < N; i++){
    int n;
    cin>>n;
    card.push_back(n);
  }
  sort(card.begin(),card.end());
  card.erase(unique(card.begin(),card.end()),card.end());

  if(card.size() % 2 == 0){
    cout<<card.size()-1<<endl;
  }
  else {cout<<card.size()<<endl;}
  
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;
int main(){
   vector<int> a(3);
   rep(i,3) cin>>a[i];
   sort(a.begin(),a.end());
   cout<<a[0]*a[1]/2<<endl;
   return 0;
}


Measured memory_bytes: 256
/*
By Tianyi Chen. All rights reserved.
Date: 2016-07-16
*/
#include<bits/stdc++.h>
using namespace std;
int n,a[222],ans;
int main() {
 scanf("%d",&n);n<<=1;
 for(int i=0;i<n;++i)scanf("%d",a+i);
 sort(a,a+n);
 for (int i=0;i<n;i+=2)ans+=min(a[i],a[i+1]);
 printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll n;
ll ans;
//string s;
signed main(){
	acc_io;
	ans=0;
	cin>>n;
	int a;
	int col[10]={0};
	rep(i,0,n){
		cin>>a;
		if(a<400) col[0]++;
		else if(a<800)  col[1]++;
		else if(a<1200) col[2]++;
		else if(a<1600) col[3]++;
		else if(a<2000) col[4]++;
		else if(a<2400) col[5]++;
		else if(a<2800) col[6]++;
		else if(a<3200) col[7]++;
		else            col[8]++;
	}
	int colmin=0;
	int colmax;
	rep(i,0,8){
		if(col[i]) colmin++;
	}
	colmax=colmin+col[8];
	if(colmin==0) colmin++;
	cout<<colmin<<" "<<colmax<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;


int main(){
	DRI(n);
	int l=1;
	LL ans=0;
	//vector<int> v;
	REP(i,n){
		DRI(x);
		ans+=(x-1)/(l);
		if((x-1)/(l))x=max(l-1,1);
		else x=(x-1)%l+1;
		l=max(l,x+1);
		//v.PB(x);
	}
	//for(int i:v)printf("%d ",i);
	printf("%lld",ans);
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

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

    static class Div {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int ans = 0;
            for (int i = 1; i <= n; i += 2) {
                int c = 0;
                for (int j = 1; j <= i; j++) {
                    if (i % j == 0) c++;
                }

                if (c == 8) ans++;
            }

            out.println(ans);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define ll long long
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)
#define for0(n) for(int i=0;i<n;i++)
#define for1(n) for(int i=1;i<=n;i++)
const long double pi=3.1415926535897932;
using namespace std;
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main()
{   ios::sync_with_stdio(0);
    
    cin.tie(0);
    cout.tie(0);
 long double a,b,c,d;
 cin>>a>>b>>c>>d;
 long double angle=2*pi*(c*60+d)/(12*60)-2*pi*(d)/60;
 long double ans=sqrt(a*a+b*b-2*a*b*cos(angle));
 printf("%.13Lf",ans);
 
    
    return 0;
}


Measured memory_bytes: 4184
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll H, W;
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W));
    vector<vector<pair<ll, ll>>> num(H, vector<pair<ll, ll>>(W));
    Rep (i, H) {
        Rep (j, W) {
            cin >> S.at(i).at(j);
        }
    }

    Rep (i, H) {
        Rep (j, W) {
            if (S.at(i).at(j) == '.') {
                queue<ll> q;
                q.push(j);
                ll cnt = 1;
                while(true) {
                    j++;
                    if (j < W && S.at(i).at(j) == '.') {
                        cnt++;
                        q.push(j);
                    } else break;
                }
                while (!q.empty()) {
                    auto e = q.front();
                    q.pop();
                    num.at(i).at(e).first = cnt;
                }
            }
        }
    }

    Rep (i, W) {
        Rep (j, H) {
            if (S.at(j).at(i) == '.') {
                queue<ll> q;
                q.push(j);
                ll cnt = 1;
                while (true) {
                    j++;
                    if (j < H && S.at(j).at(i) == '.') {
                        cnt++;
                        q.push(j);
                    } else break;
                }
                while (!q.empty()) {
                    auto e = q.front();
                    q.pop();
                    num.at(e).at(i).second = cnt;
                }
            }
        }
    }

    ll ans = 0;
    Rep (i, H) {
        Rep (j, W) {
            ans = max (ans, num.at(i).at(j).first + num.at(i).at(j).second);
        }
    }
    cout << ans-1 << "\n";

}

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

using namespace std;

int main(){
    int n,t,c,tt;
    vector< pair<int,int> > v;

    cin >> n >> t;
    int min = 99999999;
    for(int i = 0;i < n;i++){
        cin >> c >> tt;
        if(t >= tt){
            if(min > c){
                min = c;
            }
        }
    }
   if(min != 99999999){
       cout << min << endl;
   }else{
       cout << "TLE" << endl;
   }

    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    vector<int> c(n);
    rep(i,n) c[i]=0;
    

    rep(i,n-1){
        if(s[i] == 'R' && s[i+1] == 'L'){
            int cr = 0, cl = 0;
            int idx = i; 
            while(s[idx] == 'R'){
                cr++;
                idx--;
            }
            idx = i+1; 
            while(s[idx] == 'L'){
                cl++;
                idx++;
            }
            c[i] = (cr+cl)/2;
            c[i+1] = (cr+cl)/2;
            if((cr+cl) %2 == 1){
                if(cr % 2 ==0){
                    c[i+1]++;
                }else{
                    c[i]++;
                }
            }
        }
    
    }
    rep(i,n){
        cout<<c[i]<<" ";
    }
    cout<<endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a;
        cin >> a;
        N -= a;
    }
    cout << max(N, -1) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    long long N;
    cin >> N;
    for (int h = 1; h <= 3500; ++h) {
        for (int n = 1; n <= 3500; ++n) {
            long long a = N * h * n;
            long long b = 4ll * h * n - N * (h + n);
            if (b && a % b == 0 && a / b > 0) {
                cout << h << ' ' << n << ' ' << a / b << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int H = nextInt();
        int N = nextInt();
        long sum = 0;
        for(int i=0; i<N; i++){
            sum += nextInt();
        }
        if(sum>=H)
            println("Yes");
        else{
            println("No");
        }
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 45636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

void solve(void) {
  ll N;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  for (ll ni = 0; ni < N; ++ni) cin >> A[ni];
  for (ll ni = 0; ni < N; ++ni) cin >> B[ni];
  for (ll ni = 0; ni < N; ++ni) cin >> C[ni];

  sort(A.begin(), A.end());
  sort(C.begin(), C.end());

  ll res = 0;
  for (ll ni = 0; ni < N; ++ni) {
    auto t_a = lower_bound(A.begin(), A.end(), B[ni]);
    auto t_c = upper_bound(C.begin(), C.end(), B[ni]);

    res += (t_a - A.begin()) * (C.end() - t_c);
  }
  cout << res << endl;
}
int main(void) {
  solve();
  return 0;
}

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

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 1e5+7;
int read(){
    int c = getchar(),Nig = 1,x = 0;
    while(!isdigit(c))
        c = getchar();
    if(c == '-')
        Nig = -1,c = getchar();
    while(isdigit(c))
        x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
    return Nig*x;
}
#define read read()
int main(){
    int n,h,w,a,b,ans = 0;
    n = read,h = read, w = read;
	while(n--){
        a = read, b = read;
        ans += min(a/h,b/w);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))
BC = sorted(BC, reverse=True, key=lambda x:x[1])

first_idx = 0
last_idx = 0
for num, val in BC:
    if last_idx >= N:
        break

    if A[last_idx] >= val:
        break
    

    for _ in range(num):
        if A[last_idx] < val:
            last_idx += 1
        else:
            A[first_idx:last_idx] = [val] * (last_idx - first_idx)
            first_idx = last_idx
            break

        if last_idx >= N:
            A[first_idx:last_idx] = [val] * (last_idx - first_idx)
            break
    else:
        A[first_idx:last_idx] = [val] * (last_idx - first_idx)
        first_idx = last_idx

print(sum(A))

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

int main() {
  int S, h, m;
  // 3600秒 = 60分 = 1時間
  cin >> S;
  // 1時間で割ってみる。
  h = S / 3600;
  S %= 3600;
  // 1分で割ってみる。
  m = S / 60;
  S %= 60;
  cout << h << ":" << m << ":" << S << endl;
}


Measured memory_bytes: 3084
def get_prime_factorized(N):
    R = []
    b, e = 2, 0
    while b ** 2 <= N:
        while N % b == 0:
            N  = N // b
            e += 1
        if e > 0:
            R.append([b, e])
        b, e = b + 1, 0
    if N > 1:
        R.append([N, 1])
    return R

def get_list_divisor(N, reverse=True):
    try:
        F = get_prime_factorized(N)
        L = re_func_divisior(F)
        R = []
        for l in L:
            for i, x in enumerate(l):
                if i == 0:
                    r = x
                else:
                    r *= x
            R.append(r)
        R.sort()
        if reverse == True:
            R.reverse()
    except:
        if N == 1:
            R = [1]
        else:
            R = [N]
    return R

def re_func_divisior(F):
    b, e = F.pop()
    P = re_func_divisior(F) if F else [[]]
    Q = [[b ** k] for k in range(e + 1)]
    return [p + q for p in P for q in Q]


N, M = map(int, input().split())

for d in get_list_divisor(M, reverse=True):
    if d * N <= M and M % d == 0:
        print(d)
        break


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

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

    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    bool B[n][61] = {};
    int C[61] = {};
    for(int i = 0; i <= 60; i++){
        int cnt = 0;
        for(int j = 0; j < n; j++){
            if(A[j] >> i & 1){
                B[j][i] = true;
                cnt++;
            }
        }
        C[i] = cnt;
    }

    for(int i = 0; i < n; i++){
        int ans = 0;
        long long two = 1;
        for(int j = 0; j <= 60; j++){
            int tmp = C[j] - (B[i][j] == true);
            if(tmp % 2){
                ans += two;
            }
            two *= 2;
        }
        cout << ans << ' ';
    }
    cout << endl;

    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  sort(xs.begin(), xs.end());

  int64 sum = 0;
  for (int i = 1; i + 1 < n; i++) {
    int k = n - 1;
    for (int j = i -1; j >= 0; j--) {
      while (k > i && xs[k] >= xs[i] + xs[j]) k--;
      sum += k - i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n, sum = 0;
  cin >> n;
  vector<int> a(n);
  REP(i, n) { cin >> a[i]; }
  REP(i, n) {
    FOR(j, i + 1, n) { sum += a[i] * a[j]; }
  }
  cout << sum << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int L,A,B,C,D;
    scanf("%d%d%d%d%d",&L,&A,&B,&C,&D);
    int a=A/C,b=B/D;
    if(A%C) a++;
    if(B%D) b++;
    printf("%d\n",L-max(a,b));
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> product(N);
  double sum = 0;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    product.at(i)=a;
    sum+=a;
  }
  int count = 0;
  for(int i=0; i<N; i++){
    if(product.at(i) >= sum/(4*M)){
      count++;
    }
    else{
      continue;
    }
  }
  if(count>=M){
    cout << "Yes" << endl;
  }
  if(count<M){
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using System;
class Program{
	public static void Main(){
		int i;
		
		string[] str = Console.ReadLine().Split(' ');
		int N = int.Parse(str[0]);
		int H = int.Parse(str[1]);
		string[] str2;
		int[] a = new int[N];
		int[] b = new int[N];
		for (i = 0 ;i < N ;i++ ){
			str2 = Console.ReadLine().Split(' ');
			a[i] = int.Parse(str2[0]);
			b[i] = int.Parse(str2[1]);
		}
		
		Array.Sort(a);
		Array.Reverse(a);
		Array.Sort(b);
		Array.Reverse(b);
		
		int c = 0;
		
		for (i = 0 ;i < N ;i++ ){
			if (a[0] < b[i]){
				H -= b[i];
				c ++;
				if (H <= 0)
					break;
			}else{
				break;
			}
		}
		
		if (H <= 0)
			Console.WriteLine(c);
		else{
			if (H % a[0] == 0)
				c += H / a[0];
			else
				c += 1 + H / a[0];
			Console.WriteLine(c);
		}
	}
}

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

vector<int> g[100001] ;

bool visited[100001] ;

void dfs( int i ) {
   visited[i] = true ;
   for( int child : g[i] ) {
       if( visited[child] == false) dfs(child) ;
   }
}

int main() { 
/*  #ifndef ONLINE_JUDGE
  freopen("/home/yash/Desktop/CPP/input.txt","r",stdin);
  freopen("/home/yash/Desktop/CPP/output.txt","w",stdout);
  #endif*/
  int  n, m ;
  cin >> n >> m ;
  while( m-- ){
        int node1 , node2;
        cin>> node1 >> node2;
        g[node1].push_back(node2);
        g[node2].push_back(node1);
  }
  int cc_count = 0 ;
  for( int i=1 ; i<=n ; i++ ) { 
     if( visited[i] == false ) {
        dfs(i) ;
        cc_count++;
     }
  }
  cout<<cc_count-1<<endl;
}
  


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

struct _pond{
  int a; //area
  int s; //start
  int e; //end
};


int main(){

  int i;
	char n;
  int drop[30000];
  int pt_drop;
  struct _pond pond[30000];
  int pt_pond;
  int total;


  total=0;
	i=0; pt_drop = 0; pt_pond=0;
	while( (n=getchar()) != '\n' && n!=EOF ){
	
  	
		if( n == '/' && pt_drop > 0){ //pop
//      printf( " POP: %d\n", i );
      pt_drop--;

      total += i - drop[pt_drop];

      // current pond
      int a = i-drop[pt_drop];
      int e = i;
      int s = drop[pt_drop];

//      printf( " AREA: %d - %d =  %d\n", s, e, a );

      for( int k=pt_pond-1; k>=0; k--){
        if( s < pond[k].s ){
//           printf( " ADDING %d + %d = ", a, pond[k].a );
           // POP and update current pond
           pt_pond--;
           a = a + pond[k].a;
//           printf( "%d\n", a );
        }
      }


      // Push to stack
      pond[pt_pond].a = a;
      pond[pt_pond].s = s;
      pond[pt_pond].e = e;
//      printf( " PUSH[%d]: %d:%d:%d\n", pt_pond, pond[pt_pond].s, pond[pt_pond].e, pond[pt_pond].a );
      pt_pond++;


    }

		if( n == '\\' ){ //push
//			printf( " PUSH: %d\n", i );
      drop[pt_drop] = i;
      pt_drop++;
		}

    i++;
	}


  printf( "%d\n", total );
	
  printf( "%d%c", pt_pond, (pt_pond!=0)?' ':'\n' );

  for( int i=0; i<pt_pond; i++ )
    printf( "%d%c", pond[i].a, (i==(pt_pond-1))?'\n':' ' );  

	return 0;

}



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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	
	int n, k;
	cin >> n >> k;
	cout << floor(log10(n) / log10(k) + 1) << "\n";




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a>b)
	{
		printf("a > b\n");
	}

		
	
	else if(a<b)
	{
		printf("a < b\n");
	}
	else
	{
		printf("a == b\n");
	}	
	return 0;		
	
}


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<vector<int>> v(N);
    vector<pair<int, int>> e(N - 1);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
        e[i] = make_pair(a, b);
    }
    vector<int> c(N);
    for(int i = 0; i < N; i++) cin >> c[i];
    sort(c.rbegin(), c.rend());
    vector<bool> visited(N, false);
    vector<int> val(N);
    queue<int> q;
    q.push(0);
    visited[0] = true;
    int count = 0;
    while(!q.empty()){
        int idx = q.front();
        q.pop();
        val[idx] = c[count++];
        for(auto &neigh : v[idx]){
            if(!visited[neigh]) q.push(neigh);
            visited[neigh] = true;
        }
    }

    // for(int i = 0; i < N; i++) cout << val[i] << endl;

    long long ans = 0;
    for(auto &edge : e){
        ans += min(val[edge.first], val[edge.second]);
    }
    cout << ans << endl;

    for(int i = 0; i < N; i++){
        cout << val[i];
        if(i == N - 1) cout << endl;
        else cout << " ";
    }
    return 0;
}


Measured memory_bytes: 1152
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

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

    int n,d;
    cin >> n >> d;
    if((2*d+1)>n)
        cout << 1;
    else
    {
        if(n%(2*d+1)==0)
            cout << n/(2*d+1);
        else
            cout << n/(2*d+1)+1;
    }

    return 0;
}


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

int data[3];

int main() {
  scanf("%d%d%d", &data[0], &data[1], &data[2]);
  std::sort(data, data+3);
  printf("%d %d %d\n", data[0], data[1], data[2]);
  return 0;
}

Measured memory_bytes: 1040