akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include"math.h"
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

VI h;
int N,A,B;

bool check(long long a){
	long long ans = 0;
	REP(i,N){
		long long sub = h[i] - a*B;
		if(sub < 0)
			continue;
		ans += ceil((double)sub / (A-B));
	}
	if(ans <= a){
		return true;
	}
	else
		return false;
}


int binary_search(int l,int r){
	if(l >= r) {
		if(check(l))
			return l;
		else
			return l+1;
	}

	int mid = l+(r-l)/2;
	if(check(mid)) {
		return binary_search(l,mid-1);
	} else {
		return binary_search(mid+1,r);
	}
}

int main(){

	cin >> N >> A >> B;
	h.resize(N);
	int M = 0;
	REP(i,N){
		cin >> h[i];
		if(M < h[i])
			M = h[i];
	}

	int left = 1,right  = M/B;
	cout << binary_search(left,right) << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string S;int cnt=0;
int main(){
	cin>>S;int pos=(S.size()+1)/2;
	for(int i=0;i<pos;i++){if(S[i]=='p')cnt--;}
	for(int i=pos;i<S.size();i++){if(S[i]=='g')cnt++;}
	cout<<cnt<<endl;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c,d=MI()
    cc=b//c - (a-1)//c
    dd=b//d - (a-1)//d
    
    import math
    g=(c*d)//math.gcd(c,d)
    gg=b//g - (a-1)//g
    
    print(b-a+1 -cc-dd+gg)

main()


Measured memory_bytes: 62216
n = int(input())
s = [0] * 5
for i in range(n):
    name = input()[0]
    if(name == "M"):
        s[0] += 1
    elif(name == "A"):
        s[1] += 1
    elif(name == "R"):
        s[2] += 1
    elif(name == "C"):
        s[3] += 1
    elif(name == "H"):
        s[4] += 1

ans = 0
for i in range(5):
    for j in range(5):
        if(i == j):
            break
        for k in range(5):
            if(j == k):
                break
            ans += s[i] * s[j] * s[k]
print(ans)
            


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

using namespace std;
typedef long long ll;


int main()
{
    int n;
    cin >> n;

    if (n%1000==0) cout << 0;
    else {
        int k = n/1000;
        cout << (k+1)*1000 - n;
    }

    return 0;
}



Measured memory_bytes: 3632
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int Mod=1e9+7;
int f[1000010];
int tot=0;
int mult(int x,int y){
	return(int)((long long)x*(long long)y%(long long)Mod);
}
int main(){
	int n;
	scanf("%d",&n);
	f[1]=n;f[2]=mult(n,n);
	for (int i=3;i<=n;++i){
		f[i]=((f[i-1]+mult(n-1,n-1))%Mod+Mod)%Mod;
		f[i]=((f[i]+n-i+2)%Mod+Mod)%Mod;
		if (i>3) f[i]=((f[i]+tot)%Mod+Mod)%Mod; 
		if (i>=3) tot=((tot+f[i-2])%Mod+Mod)%Mod;
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 4096
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    System.out.println(String.format("%s", ((N+(N%2))/2>=K) ? "YES" : "NO"));
  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
struct node{int x,y;}p[300300];
bool operator <(node p,node q) {return p.x<q.x;}
int w,h,ans=0,n,seg[1200200],tag[1200200],sta[2][300300];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

void pushdown(int id)
{
	if (tag[id])
	{
		seg[id<<1]+=tag[id];
		tag[id<<1]+=tag[id];
		seg[id<<1|1]+=tag[id];
		tag[id<<1|1]+=tag[id];
		tag[id]=0;
	}
}

void build(int id,int l,int r)
{
	seg[id]=h<<1;tag[id]=0;
	if (l==r) return;
	int mid=(l+r)>>1;
	build(id<<1,l,mid);build(id<<1|1,mid+1,r);
}

void modify(int id,int l,int r,int ql,int qr,int val)
{
	if (ql>qr) return;
	if ((l>=ql) && (r<=qr))
	{
		seg[id]+=val;tag[id]+=val;
		return;
	}
	pushdown(id);
	int mid=(l+r)>>1;
	if (ql<=mid) modify(id<<1,l,mid,ql,qr,val);
	if (qr>mid) modify(id<<1|1,mid+1,r,ql,qr,val);
	seg[id]=max(seg[id<<1],seg[id<<1|1]);
}

void solve()
{
	sort(p+1,p+1+n);
	build(1,1,n);
	int tp0=0,tp1=0;
	sta[0][0]=sta[1][0]=1;
	rep(i,2,n)
	{
		modify(1,1,n,1,i-1,(p[i].x-p[i-1].x)<<1);
		ans=max(ans,seg[1]);
		if (p[i].y>=h/2)
		{
			modify(1,1,n,sta[0][tp0],i-1,(p[i].y-h)<<1);
			while ((tp0) && (p[sta[0][tp0]].y>=p[i].y))
			{
				int delta=p[i].y-p[sta[0][tp0]].y;
				modify(1,1,n,sta[0][tp0-1],sta[0][tp0]-1,delta*2);
				tp0--;
			}
			sta[0][++tp0]=i;
		}
		else
		{
			modify(1,1,n,sta[1][tp1],i-1,-(p[i].y<<1));
			while ((tp1) && (p[sta[1][tp1]].y<=p[i].y))
			{
				int delta=p[sta[1][tp1]].y-p[i].y;
				modify(1,1,n,sta[1][tp1-1],sta[1][tp1]-1,delta*2);
				tp1--;
			}
			sta[1][++tp1]=i;
		}
	}
}

int main()
{
	w=read();h=read();n=read();
	rep(i,1,n) {p[i].x=read();p[i].y=read();}
	p[++n].x=w;p[++n].y=h;
	p[++n].x=0;p[++n].y=0;
	solve();
	swap(w,h);
	rep(i,1,n) swap(p[i].x,p[i].y);
	solve();
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MIN = -1e18;

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

  int32_t N;
  cin >> N;
  int64_t K;
  cin >> K;
  vector<int32_t> P(N);
  vector<int64_t> C(N);
  for (auto& p : P) {
    cin >> p;
    p--;
  }
  for (auto& c : C) {
    cin >> c;
  }

  vector<bool> visited(N,false);
  vector<pair<int32_t,int64_t>> loop;
  vector<vector<int>> loop_ids;
  for (int i = 0; i < N; i++) {
    if (visited[i] == true) continue;
    vector<int> ids = {i};
    int32_t looplen = 1;
    int64_t loopsum = C[i];
    visited[i] = true;
    int next = P[i];
    while (visited[next] == false) {
      looplen++;
      loopsum += C[next];
      ids.push_back(next);
      visited[next] = true;
      next = P[next];
    }
    loop.emplace_back(make_pair(looplen, loopsum));
    loop_ids.emplace_back(ids);
  }


  int64_t res = MIN;
  for (int i = 0; i < (int)loop_ids.size(); i++) {
    int32_t loop_len = loop[i].first;
    int64_t loopsum = loop[i].second;
//    cout << "loop, len, sum :" << i << "," << loop_len << "," << loopsum << endl;

    int max_step = min((int64_t)loop_len, K);
    vector<int64_t> cur(N, MIN);
    vector<int64_t> next(N, MIN);
    vector<int> ids = loop_ids[i];
    for (auto it = ids.begin(); it < ids.end(); it++) {
      cur[*it] = 0;
    }
    vector<int64_t> max_val(max_step + 1, MIN);
    for (int j = 1; j <= max_step; j++) {
      int64_t maxsum_step = MIN;
      for (auto it = ids.begin(); it < ids.end(); it++) {
        next[P[*it]] = cur[*it] + C[P[*it]];
        maxsum_step = max(maxsum_step, next[P[*it]]);
      }
      max_val[j] = max(maxsum_step, max_val[j-1]);
//      cout << "j,max: " << j << "," << max_val[j] << endl;
      cur = next;
    }

    int64_t maxOnLoop = MIN;
    if (K < loop_len) {
      maxOnLoop = max_val[K];
    } else {
      maxOnLoop = max_val[max_step];
      if (loopsum > 0) {
        int64_t cur_max = loopsum * (K / loop_len);
        cur_max += max_val[K % loop_len];
        maxOnLoop = max(cur_max, maxOnLoop);
        if (K/ loop_len > 0) {
          cur_max = loopsum * ((K / loop_len) -1);
          cur_max += max_val[max_step];
          maxOnLoop = max(cur_max, maxOnLoop);
        }
      }
    }

    res = max(res, maxOnLoop);
  }

  cout << res << endl;

  return 0;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;


int main() {
    ll N, A, B; cin >> N >> A >> B;
    vi p(N);
    rep(i, N) cin >> p[i];

    /*dp[i][j] := i 個まで見て、右にうごさないことを確定した最大の値が j である状態を実現する
    最小コスト LISのO(N^2)解放にちょっと類似*/
    vector<vll> dp(N + 1, vll(N + 1, INF));
    dp[0][0] = 0;
    rep(i, N) {
        rep(j, N + 1) {
            if (dp[i][j] == INF) continue;
            if (p[i] > j) {
                chmin(dp[i + 1][p[i]], dp[i][j]);
                chmin(dp[i + 1][j], dp[i][j] + A);
            }
            else {
                chmin(dp[i + 1][j], dp[i][j] + B);
            }
        }
    }

    ll ans = INF;
    rep(j, N + 1) chmin(ans, dp[N][j]);
    cout << ans << endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int d;
  cin >> d;
  vector<int> c(26);
  int i,j,k;
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(d,vector<int>(26));
  rep(i,d)rep(j,26) cin >> s[i][j]; 
  vector<int> t(d);
  /*rep(i,d)
  {
    int ind = -1;
    int val = -1;
    rep(j,26)
    {
      if(s[i][j] > val)
      {
        val = s[i][j];
        ind = j;
      }
    }
    t[i] = ind;
  }*/
  vector<int> las(26,0);
  vector<int> rowans(26,0);
  int sums = 0;
  int kans = 0;
  rep(i,d)
  {
    int vind = -1;
    int vval = -100000000;
    rep(j,26)
    {
      vector<int> klas(26);
      klas = las;
      klas[j] = i+1;
      sums += s[i][j];
      vector<int> krowans(26);
      krowans = rowans;
      rep(k,26)
      {
        krowans[k] += c[k]*(i+1-klas[k]);
      }
      int ks = sums;
      rep(k,26) ks -= krowans[k];
      if(vval < ks)
      {
        vval = ks;
        vind = j;
      }
      sums -= s[i][j];
    }
    t[i] = vind;
    las[t[i]] = i+1;
    sums += s[i][t[i]];
    kans += s[i][t[i]];
    rep(j,26)
    {
      kans -= c[j]*(i+1-las[j]);
      rowans[j] += c[j]*(i+1-las[j]);
    }
  }
  int m = 100000;
  //double tmp = 100.0;
  //double alpha = 0.9999;
  //int inds = 0;
  rep(i,m)
  {
    int tans = 0;
    int tod,q;
    tod = rand()%d;
    q = rand()%26;
    int bq = t[tod];
    sums -= s[tod][bq];
    sums += s[tod][q];
    int browq = rowans[bq];
    int rowq = rowans[q];
    t[tod] = q; //change
    rowans[q] = 0;
    rowans[bq] = 0;
    rep(j,26)
    {
      las[j] = 0;
    }
    rep(j,d)
    {
      las[t[j]] = j+1;
      rowans[bq] += c[bq]*(j+1-las[bq]);
      rowans[q] += c[q]*(j+1-las[q]);
    }
    tans = sums;
    rep(j,26) tans -= rowans[j];
    //double prob = ((double)rand())/32767.0;
    int dis = kans-tans;
    if(tans >= kans)
    {
      kans = tans;
    }
    else
    {
      rowans[bq] = browq;
      rowans[q] = rowq;
      t[tod] = bq;
    }
    /*else if(prob <= exp(-(double)dis/(double)tmp))
    {
      kans = tans;
    }*/
    
    //tmp *= alpha;
    //cout << tmp << endl;
    //if(i%1000 == 0)cout << kans << endl;
  }
  rep(i,d)
  {
    cout << t[i]+1 << "\n";
  }
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

bool check(int N, int K, vector<int> a) {
    int count_diff = 0;
    rep(i,N) if (a[i] == K - 1) count_diff++;
    if (N == count_diff) return N == K;
    return (K - count_diff >= 1 && (N - count_diff) / (K - count_diff) >= 2);
}

int main() {

    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    sort(a.begin(), a.end());
    
    if (a[N - 1] - a[0] > 1) {
        cout << "No" << endl;
    }
    if (a[N - 1] - a[0] == 1) {
        if (check(N, a[N - 1], a)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    if (a[N - 1] - a[0] == 0) {
        if (check(N, a[N - 1], a)) cout << "Yes" << endl;
        else if (check(N, a[N - 1] + 1, a)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const noexcept { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const noexcept { return x != p.x; }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is, ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

long long n;
string s;
vector<vector<ModInt<>>> dp;

ModInt<> solve();

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    char x;
    cin >> x;
    if (x != '-') s += x;
  }
  n = s.size();
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  dp.assign(n + 1, vector<ModInt<>>(n + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j <= i + 1; ++j) {
      if (s[i] == 'U') {
        if (j != 0) dp[i + 1][j] += dp[i][j - 1];
        dp[i + 1][j] += dp[i][j] * j;
      } else {
        if (j != n) dp[i + 1][j] += dp[i][j + 1] * (j + 1) * (j + 1);
        dp[i + 1][j] += dp[i][j] * j;
      }
    }
  return dp[n][0];
}


Measured memory_bytes: 3316
#include <iostream>
#include <cstring>

using namespace std;

int main(){
  string str;
  int lenstr=0,number=0,big=0,small=0;
  int temp=0;
  
  cin>>str;

  if(str.size()>=6)
    lenstr=1;
  
  if(temp>=6)
    lenstr=1;

  for(int i=0;i<str.size();i++){
    if('0'<=str[i] && str[i]<='9')
      number=1;

    if ('a'<=str[i] && str[i]<='z')
      small=1;

    if ('A'<=str[i] && str[i]<='Z')
      big=1;
  }

  if(number==1 && lenstr==1 && small==1 && big==1)
    cout<<"VALID"<<endl;
  else
    cout<<"INVALID"<<endl;
  
  return 0;
}



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

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

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

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



int main()
{
	ll W, H, x, y;
	cin >> W >> H >> x >> y;

	ld area = (ld)W*H / 2;
	bool multi = (W == x * 2) && (H == y * 2);
	cout << fixed << setprecision(10) << area << " " << (multi ? 1 : 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    if(a+b >= 10){ Cout("error"); }
  else{ Cout(a+b);}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

@SuppressWarnings("unchecked")
static class MinCostFlow{
    class Edge{
        int to,cap,cost,rev;
        Edge(int to,int cap,int cost,int rev){this.to=to;this.cap=cap;this.cost=cost;this.rev=rev;}
    }
    List<Edge> edges[];
    void add_edge(int from,int to,int cap,int cost){
        edges[from].add(new Edge(to,cap,cost,edges[to].size()));
        edges[to].add(new Edge(from,0,-cost,edges[from].size()-1));
    }
    int[] dis;
    int[] h;
    int[] prevv;
    Edge[] preve;
    MinCostFlow(int V){
        edges = new ArrayList[V];
        dis =new int[V];
        h = new int[V];
        prevv=new int[V];
        preve=new Edge[V];
        for(int i=0;i<V;++i)edges[i]=new ArrayList<>();
    }

    int get(int s,int t,int f){
        int res = 0;
        class Node{
            int v,cost;
            Node(int v,int cost){this.v=v;this.cost=cost;}
        }
        Arrays.fill(h,0);
        while(f>0){
            Arrays.fill(dis, Integer.MAX_VALUE);
            dis[s]=0;
            PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.cost-b.cost);
            que.add(new Node(s,0));
            while(!que.isEmpty()){
                Node node = que.poll();
                if(dis[node.v]<node.cost)continue;
                for(Edge e : edges[node.v])if(dis[node.v]+e.cost + (h[e.to]-h[node.v]) <dis[e.to] && e.cap>0){
                    dis[e.to] = dis[node.v]+e.cost + (h[e.to]-h[node.v]);
                    prevv[e.to]=node.v;
                    preve[e.to]=e;
                    que.add(new Node(e.to, dis[e.to]));
                }
            }
            if(dis[t]==Integer.MAX_VALUE)return -1;
            for(int i=0;i<h.length;++i)h[i] -= dis[i];
            int d = f;

            for(int v=t;v!=s;v=prevv[v])d=Math.min(d, preve[v].cap);
            res += d * -h[t];
            f-=d;
            for(int v=t;v!=s;v=prevv[v]){
                preve[v].cap-=d;
                edges[v].get(preve[v].rev).cap+=d;
            }
        }
        return res;
    }
}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int V = sc.nextInt();
        int E = sc.nextInt();
        int F = sc.nextInt();
        MinCostFlow mcf = new MinCostFlow(V);
        for (int i=0;i<E;i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            mcf.add_edge(u, v, c, d);
        }
        System.out.println(mcf.get(0, V-1, F));
    }
}


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

int main() {
  int x, n;
  cin >> x >> n;
  vector<bool> p(105, true);
  vector<bool> p2(105, true);  //マイナス
  rep(i, n) {
    int a;
    cin >> a;
    if (a >= 0)
      p[a] = false;
    else
      p[-a] = false;
  }
  int now = 110;
  int ans = 110;
  rep(i, 105) {
    if (p[i] == true) {
      if (now > abs(x - i)) {
        ans = i;
        now = abs(x - i);
      }
    }
    if (p2[i] == true) {
      if (now > abs(x + i)) {
        ans = -i;
        now = abs(x + i);
      }
    }
  }

  cout << ans << endl;
}

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


isSucceed = False
cnt = 0
f = False
for _ in range(N):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        if not isSucceed:
            isSucceed = True
            cnt = 1
        else:
            cnt += 1
            if cnt >= 3:
                f = True
                
    else:
        isSucceed = False
        cnt = 0

if f:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 62356
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
 
int main() {
	long double n;
	cin >> n;
	vector<long double> v(5);
	for (int i = 0; i < 5; ++i) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	long tmp = ceil(n / v[0]);
	unsigned long long out = 4 + tmp;
	cout << out << endl;
	return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  string s, t; cin >> s >> t;

  for (ll i = 0; i < N; i++) {
    if (s.substr(i) == t.substr(0, N - i)) {
      cout << i + N << endl;
      return 0;
    }
  }
  cout << 2 * N << endl;

  return 0;
}



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

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    long double r;cin>>r;
    cout<<fixed<<setprecision(18)<<2.0*3.14159265358979323846*r<<"\n";
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1

int main() {
  int K;
  string S;
  cin >> K >> S;
  if(K >= S.size()){
    cout << S << endl;
  }
  else{
    string SS = S.substr(0,K) + "...";
    cout << SS << endl;
  }
}

Measured memory_bytes: 3632
N,K = map(int,input().split())
S = input()

def press(array):
    pressed = []
    cnts = []
    remark = array[0]
    cnt = 0
    for i in range(len(array)):
        cnt += 1
        if i == N-1:
            pressed.append(remark)
            cnts.append(cnt)
        elif S[i] != S[i+1]:
            pressed.append(remark)
            cnts.append(cnt)
            remark = S[i+1]
            cnt = 0
    return pressed,cnts

pressed, cnts = press(list(S))
if pressed[0] == "0":
    pressed = ["1"] + pressed
    cnts = [0] + cnts
if pressed[-1] == "0":
    pressed = pressed + ["1"]
    cnts = cnts + [0]

acc = [0]*(len(cnts)+1)
for i in range(len(cnts)):
    acc[i+1] = acc[i] + cnts[i]

ans = 0

for l in range(0,len(cnts),2):
    r = min(l + 2*K,len(acc)-2)
    res = acc[r+1] - acc[l]
    ans = max(ans,res)

print(ans)

Measured memory_bytes: 9340
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=300009;
int n,a[N],maxi[N<<3],val,locate,l,r,len=0,k,ans=0;
void update(int o,int left,int right)
{
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    if(left==right)
    {
        maxi[o]=val;
    }
    else
    {
        if(locate<=mid)
            update(lc,left,mid);
        else
            update(rc,mid+1,right);
        maxi[o]=max(maxi[lc],maxi[rc]);
    }
}
int query(int o,int left,int right)
{
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    if(l<=left&&r>=right)
    {
        return maxi[o];
    }
    else
    {
        int res=0,res1=0;
        if(l<=mid)
            res=query(lc,left,mid);
        if(r>mid)
            res1=query(rc,mid+1,right);
        return max(res,res1);
    }
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]),a[i]++,len=max(a[i],len);
    for(int i=1; i<=(n<<3); i++)
        maxi[i]=0;
    for(int i=1; i<=n; i++)
    {
        l=max(a[i]-k,1),r=min(a[i]+k,len);
        int res;
        res=query(1,1,len);
        res++;
        //cout<<res<<endl;
        ans=max(ans,res);
        locate=a[i];
        val=res;
        update(1,1,len);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 14368
<?php
while(True){
  fscanf(STDIN, "%d %s %d", $a, $ope, $b);
  if($ope === "?"){
    break;
  }
  switch ($ope) {
    case "+":
        echo $a + $b;
        break;
    case "-":
        echo $a - $b;
        break;
    case "*":
        echo $a * $b;
        break;
    case "/":
        echo floor($a / $b);
        break;
  }
  echo "\n";
}


Measured memory_bytes: 9208
h,w = map(int, input().split())
d = []
for i in range(h):
    d.append(input())
row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if d[i][j] == '#':
            row[i] = True
            col[j] = True
for i in range(h):
    if row[i]:
        s = ""
        for j in range(w):
            if col[j]:
                s += d[i][j]
        if len(s) > 0:
            print(s)

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

using namespace std;

int n;
int W;
const int maxn = 1e5 + 5;

typedef long long LL;

LL f[maxn];
int w[maxn], v[maxn];

int main(){
    cin >> n >> W;
    for(int i = 1;i <= n;i++){
        scanf("%d%d", &v[i], &w[i]);
    }
    for(int i = 1;i < maxn;i++){
        f[i] = 1e18;
    }
    f[0] = 0;
    for(int i = 1;i <= n;i++){
        for(int j = maxn - 1;j >= w[i];j--){
            f[j] = min(f[j], f[j - w[i]] + v[i]);
        }
    }
    for(int i = maxn - 1;i >= 0;i--){
        if(f[i] <= W){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

     
int main(void){
	ios::sync_with_stdio(false);
	int num;

	cin >> num;
	
	int mochi[num];
	int answer = 0;
	int tmp = 0;
	
	for(int i = 0; i < num; i++){
		cin >> mochi[i];
	}
	
	sort(mochi, mochi + num);
	
	for(int i = 0; i < num; i++){
		if(tmp != mochi[i]){
			answer = answer + 1;
			tmp = mochi[i];
		}
	}
	
	cout << answer << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string S;
int cnt0,cnt1;

int main(){
    cin>>S;
    rep(i,S.length()){
        if(i%2==0){
            if(S[i]=='0')cnt0++;
            else cnt1++;
        }
        else{
            if(S[i]=='1')cnt0++;
            else cnt1++;
        }
    }
    out(min(cnt0,cnt1));
}


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

int main() {
    ll n,d,a;
    std::cin >> n>>d>>a;
    vector<pair<ll,ll>> xh(n);
    for (int i = 0; i < n; i++) {
        std::cin >> xh[i].first>>xh[i].second;
    }

    sort(xh.begin(),xh.end());
    
    ll res = 0;
    ll now = 0;
    
    priority_queue< pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> q;
    for (int i = 0; i < n; i++) {
        while(q.size()){
            if(q.top().first<xh[i].first){
                now -= q.top().second;
                q.pop();
            }else{
                break;
            }
        }
        ll tmp = max((ll)0,xh[i].second - now);
        // std::cout << tmp << std::endl;
        ll kai =(tmp+a-1)/a; 
        res += (tmp+a-1)/a;
        if(tmp>0){
            q.push({xh[i].first+2*d, kai*a});
            now += kai*a;
        }
    }
    
    std::cout << res << std::endl;
}

Measured memory_bytes: 5492
from heapq import heappop,heappush
from math import sqrt
def distf(xyr,i,j):
  x,y,r=xyr[i]
  x1,y1,r1=xyr[j]
  d=max(0,sqrt((x-x1)**2+(y-y1)**2)-r-r1)
  return d

def main():
  xs,ys,xt,yt=map(int,input().split())
  n=int(input())
  xyr=[list(map(int,input().split())) for _ in range(n)]
  xyr.append([xs,ys,0])
  xyr.append([xt,yt,0])
  inf=float('inf')
  dist=[[inf]*(n+2) for _ in range(n+2)]
  for i in range(n+2):
    dist[i][i]=0
  for i in range(n+1):
    for j in range(i+1,n+2):
      dist[i][j]=distf(xyr,i,j)
      dist[j][i]=dist[i][j]
  seen=[inf]*(n+2)
  seen[n]=0
  mi=set(range(n+2))
  while mi:
    d,v=inf,-1
    for j in mi:
      if d>seen[j]:
        d=seen[j]
        v=j
    mi.remove(v)
    for nv in mi:
      nd=dist[v][nv]
      if seen[nv]>seen[v]+nd:
        seen[nv]=seen[v]+nd
  print(seen[n+1])
if __name__=='__main__':
  main()


Measured memory_bytes: 83600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main{
	static ArrayDeque<Integer> list = new ArrayDeque<Integer>();
	static int weight[] = {1,2,4,8,16,32,64,128,256,512};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;

		while(null != (str=br.readLine())){
			int n = Integer.parseInt(str);
			weightCount(n);
			OutPut();
		}
	}

	static void weightCount(int n){
		for(int i=weight.length-1; 0<=i || 0<n; i--){
			if(n>=weight[i]){
				n -= weight[i];
				list.push(weight[i]);
			}
		}
	}

	static void OutPut(){
		for(int i=list.size(); i>0 && !list.isEmpty(); i--){
			if(i != 1){
				System.out.print(list.pop() + " ");
			}else{
				System.out.println(list.pop());
			}
		}
	}

}

Measured memory_bytes: 16896
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
a=[0]*14
a[0]=1
a[8]=9
for i in range(1,8):
    a[i]=a[i-1]*6
for i in range(9,14):
    a[i]=a[i-1]*9
inf=10**6
dp=[[inf]*(n+1) for _ in range(15)]
dp[0][0]=0
for i in range(14):
    for j in range(n+1):
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        if j+a[i]<n+1:
          dp[i+1][j+a[i]]=min(dp[i+1][j]+1,dp[i+1][j+a[i]])
print(dp[-1][-1])

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

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000000000000018
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>

ll bigmod(ll b, ll p, ll m) {
	ll res = 1, x = b%m;
	while(p > 0) {
        if(p&1) res = (res*x)%m;
        x = (x*x)%m;
        p >>= 1;
	}
	return res;
}

#define MX 1000006
const ll mod = 998244353;

ll f[MX], num[MX], mx;

ll g(ll d) {
    ll x_sm = 0, x2_sm = 0, ret;

    for(ll i = d; i <= mx; i+=d) {
        if(num[i]) {
            x_sm = ( x_sm + (i*num[i])%mod )%mod;
            x2_sm = (x2_sm + (i*i*num[i])%mod)%mod;
        }
    }
    ret = ((((x_sm*x_sm)%mod)-x2_sm+mod)%mod * bigmod(2, mod-2, mod)) % mod;
    return ret;
}

int main()
{
	ll n, x;
    scanf("%lld", &n);

	mx = 0;
    for(ll i = 0; i < n; i++) {
		scanf("%lld", &x);
		num[x]++;
		mx = max(mx, x);
    }

    ll sm, ans = 0;
    for(ll d = mx; d >= 1; d--) {
    	sm = 0;
		for(ll k = 2*d; k <= mx; k+=d) {
            sm = (sm+f[k])%mod;
		}

        f[d] = (g(d)-sm+mod)%mod;
        ans = (ans+(f[d]*bigmod(d, mod-2, mod))%mod)%mod;
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
typedef long long ll;
using namespace std;

int main(){
    int n, sum=0; cin >> n;
    vector<int> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
        sum += t[i];
    }
    int m; cin >> m;
    
    for(int i = 0; i < m; i++){
        int p, x; cin >> p >> x;
        cout << sum - t[p-1] + x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

const MAX: i64 = 1 << 30;

fn compact(a: Vec<(i64, i64)>) -> Vec<(i64, i64)> {
    let mut ret = Vec::new();
    let mut lo = 0;
    let mut hi = -1;
    for (x, y) in a {
        if hi == -1 || hi <= x - 2 {
            if hi >= 0 {
                ret.push((lo, hi));
            }
            lo = x;
            hi = y;
        } else {
            hi = y;
        }
    }
    if hi >= 0 {
        ret.push((lo, hi));
    }
    ret
}

fn trans(rcur: i64, b: i64) -> i64 {
    if b >= 2 * (rcur + 1) {
        return rcur;
    }
    return b + rcur;
}

fn solve() {
    let n = get();
    let dd: i64 = get();
    let d: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let qn = get();
    let q: Vec<usize> = (0 .. qn).map(|_| get()).collect();
    let mut dsim = vec![dd; n + 1];
    for i in 0 .. n {
        let c = dsim[i];
        let x = min((c - d[i]).abs(), c);
        dsim[i + 1] = x;
    }
    let mut rcur = 0;
    let mut poss = vec![false; n];
    for i in (0 .. n).rev() {
        // Can block dsim[i] -> rcur ?
        let mut ok = false;
        let dcur = dsim[i];
        ok = rcur < dcur;
        poss[i] = ok;
        rcur = trans(rcur, d[i]);
    }
    for v in q {
        println!("{}", if poss[v - 1] { "YES" } else { "NO" });
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 22524
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    ll A, B, K; cin >> A >> B >> K;
    ll a = min(A, K);
    A -= a; K -= a;
    B -= min(B, K);
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    char c[100000];
    int i,n,le;
    for(i=0;i<100000;i++){
        c[i]=0;
    }
    scanf("%d",&n);
    scanf("%s",c);
    le=strlen(c);
    for(i=0;i<le;i++){
        c[i]+=n;
        if(c[i]>'Z'){
            c[i]-=26;
        }
    }
    printf("%s\n",c);
    return 0;
}

Measured memory_bytes: 256
import Data.Char
import Control.Monad

ops :: String -> [String]
ops [a, b, c, d] = do
    [(sp1, op1), (sp2, op2), (sp3, op3)] <- replicateM 3 [('+', (+)), ('-', (-))]
    guard (digitToInt a `op1` digitToInt b `op2` digitToInt c `op3` digitToInt d == 7)
    return $ a : sp1 : b : sp2 : c : sp3 : d : "=7"
ops _ = []

main :: IO ()
main = putStrLn . head . ops =<< getLine


Measured memory_bytes: 380
import numpy as np
import re

N=int(input())
"""
count = 0
for a in range(1,n):
  if n%(a+1) == 0:
    count += a
print(count)
"""
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return np.array(divisors)
 

## 平方根が元を越える必要あり
divs = make_divisors(N)-1
print(np.sum(divs[np.where(divs>N**0.5)[0]]))

Measured memory_bytes: 21464
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(all(h));
    int res =LLONG_MAX;
    rep(i, n - k + 1)
    {
        int dis = h[i + k - 1] - h[i];
        res = min(res,dis);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>  
      
    using namespace std;  
      
    #define ll          long long int   
    #define inf         (ll)1e17  
      
    static const int maxn = 100 + 5;  
    static const int Max = 1e5 + 5;  
      
    ll dp[maxn][Max];  
    bool memoize[maxn][Max];  
      
    int w[maxn], val[maxn];  
      
    int N, W;  
      
    ll solve(int pos, int make)  
    {  
      if (pos >= N)   
      {  
          if (make == 0) return 0;  
          return inf;  
      }  
      ll &ret = dp[pos][make];  
      bool &mem = memoize[pos][make];  
      if (mem) return ret;  
      mem = 1;  
      ret = inf;  
      if (make - val[pos] >= 0) ret = min(ret, w[pos] + solve(pos+1, make - val[pos]));  
      ret = min(ret, solve(pos+1, make));  
      return ret;  
    }  
                                            
    int main()  
    {  
        scanf("%d %d", &N, &W);  
        for (int i = 0; i < N; i++) scanf("%d %d", &w[i], &val[i]);  
        for (int make = 100000; make >= 0; make--)  
        {  
            ll ans = solve(0, make);  
            if (ans <= W)   
            {  
                printf("%d\n", make);  
                break;  
            }  
        }  
      	return 0;
    }  




Measured memory_bytes: 90368
#line 1 "/workspaces/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

constexpr int m = 26;

// i日目のスコアを計算する
ll calc_day(const int i, const int ans, const ll s, const vl &c, const vi &last) {
  ll ret = 0;
  ret += s;
  REP(j, m) {
    if (j != ans)
      ret -= c[j] * (i + 1 - last[j]);
  }
  return ret;
}

// d日目までのスコアを計算する
ll calc_ans(const int d, const vi &ans, const vector<vl> &s, const vl &c, vi &last) {
  ll ret = 0LL;
  REP(i, d) { ret += calc_day(i, ans[i], s[i][ans[i]], c, last); }
  return ret;
}

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

  int d;
  cin >> d;

  vl c(m);
  REP(i, m) { cin >> c[i]; }

  vector<vl> s(d, vl(m, 0));
  REP(i, d) {
    REP(j, m) { cin >> s[i][j]; }
  }

  vi ans(d), last(d, 0);
  REP(i, d) {
    ll ma = -1e9;
    ll mai = -1;
    REP(j, m) {
      ll tmp = calc_day(i, j, s[i][j], c, last);
      if (ma < tmp) {
        chmax(ma, tmp);
        mai = j;
      }
    }
    ans[i] = mai + 1;
  }

  REP(i, d) { cout << ans[i] << endl; }

  return 0;
}


Measured memory_bytes: 3760
sl = list(input())
move = len(set(sl))

if move == 4:
    print('Yes')
elif move == 2:
    if ('N' in set(sl) and 'S' in set(sl)) or ('E' in set(sl) and 'W' in set(sl)):
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int main(){
  int N;
  cin >> N;
  vector<string>s(N);
  rep(i,N){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
  }
  map<string, int> str2count;
  for (string x : s) str2count[x]++;
  long long ans = 0;
  for (pair<string, int> p : str2count){
     long long c = p.second;
     ans += c * (c - 1) / 2;
  }
  cout << ans << endl;
  return 0;
  
}
      
  
  
  

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
 
int main()
{

    int n;
    cin>>n;

    vector<int> a(n);
    for(int i=0;i<n;i++){
      cin>>a.at(i);
    }

    vector<int> b;
    for(int i=0;i<n;i++){
      if(i%2==0)
        b.push_back(a.at(i));
      else
        b.insert(b.begin(),a.at(i));
    }

    if(n%2==1)
      reverse(b.begin(),b.end());
      
    for(int i=0;i<n;i++){
      if(i<n-1)
        cout<<b.at(i)<<' ';
      else
        cout<<b.at(i)<<endl;
      
    }
    return 0;
}  

Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int N, x, y, t;
int main(){
    cin >> N;
    int px=0, py=0, pt=0;
    bool c=0;
    while(N--){
        cin >> t >> x >> y;
        if(c) continue;
        if((abs(x-px) + abs(y-py) > t-pt) || ( ((abs(x-px) + abs(y-py))&1) != ((t-pt)&1) ))c=1;
        px=x, py=y, pt=t;
    }
    if(c==1) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

ll ulabs(ll n) {
  if (n<0) return -n;
  return n;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n;
  cin >> n;
  ll a[n];
  for (ul i=0; i<n; ++i) cin >> a[i];
  sort(a, a+n);
  ll ans = a[0];
  for (int i=0; i<n; ++i) {
    if (ulabs(ans*2-a[n-1]) > ulabs(a[i]*2-a[n-1])) ans = a[i];
  }
  cout << a[n-1] << " " << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
"""
ABCABC
BCABCA
BCBCAA

"""

s =input().replace('BC', 'Z')
ss = s.split('B')
sss = []
for t in ss:
    sss.extend(t.split('C'))
ss = [t for t in sss if t]

# 各文字列について全てのZは自身より前のAと反応できる
def solve(s):
    a_cnt = 0
    cnt = 0
    for c in s:
        if c == 'A':
            a_cnt += 1
        else:
            cnt += a_cnt
    return cnt

total = 0
for s in ss:
    total += solve(s)
print(total)

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

int main() {
    int64_t n;
    cin >> n;
    std::vector<int64_t> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    int64_t ans = 1000;
    // if ( a[0] != *max_element(ALL(a)) ) {
        int64_t have = 0;
        rep(i, n-1) {
            if ( a[i] < a[i+1] ) {
                have = ans/a[i];
                ans += (a[i+1]-a[i])*have;
            }
        }
    // }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600