akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,a=0,b=0,c=0,d=0;
cin>>n;
string s;
for(int i=0;i<n;i++)
{cin>>s;
if(s=="AC")
    a++;
else if(s=="WA")
    b++;
else if(s=="TLE")
    c++;
else if(s=="RE")
    d++;
}
cout<<"AC x "<<a<<"\nWA x "<<b<<"\nTLE x "<<c<<"\nRE x "<<d;;
}


Measured memory_bytes: 3580
module Main where

import           Control.Monad

main :: IO ()
main = do
    [d, g] <- map read . words <$> getLine
    list   <-
        map ((\[a, b] -> (a, b)) . map read . words) <$> replicateM d getLine

    let
        res =
            (callF . (f g 0) . reverse . map (\(a, (b, c)) -> (a, b, c)) . zip
                    [100, 200 ..]
                )
                list
    print res

inf :: Int
inf = 99999999


callF :: (Bool -> Int) -> Int
callF f = min (f True) (f False)

f :: Int -> Int -> [(Int, Int, Int)] -> Bool -> Int
f 0 c []       _     = c
f _ c []       _     = inf
f g c (_ : xs) False = callF $ f g c xs
f g c ((x, y, z) : xs) True | fewG > 0  = callF $ f (max 0 allG) (c + y) xs
                            | otherwise = callF $ f 0 (c + divN) xs
  where
    fewG = g - x * (y - 1)
    allG = g - x * y - z
    divN = g `bigDiv` x


bigDiv :: Int -> Int -> Int
bigDiv a b = (a + b - 1) `div` b


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

int N,M;
vector<int> G[1010],R[1010],T[1010],id[1010];
int ord[1010] = {0};
bool vis[1010];
int mem[1010];
int cnt,cnt1,cnt2;
vector<int> V;
int A[200010],B[200010];
bool can[200010];
int now = 0;

void unit(int v)
{
    if(vis[v])return;
    vis[v] = true;
    mem[v] = 1;
    for(int i = 0; i < G[v].size(); i++)if(now != v || (i < cnt1 && cnt2 < i))unit(G[v][i]);
    return;
}

void DFS1(int v)
{
    if(vis[v])return;
    vis[v] = true;
    for(int i = 0; i < G[v].size(); i++)DFS1(G[v][i]);
    V.push_back(v);
    return;
}

void DFS2(int v)
{
    if(ord[v] != 0)return;
    ord[v] = cnt;
    for(int i = 0; i < R[v].size(); i++)DFS2(R[v][i]);
    return;
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        R[b].push_back(a);
        A[i] = a;
        B[i] = b;
        id[a].push_back(i);
    }

    memset(vis,false,sizeof(vis));
    cnt = 0;
    for(int i = 1; i <= N; i++)if(!vis[i])DFS1(i);
    reverse(V.begin(),V.end());
    for(int i = 0; i < N; i++)if(ord[V[i]] == 0)cnt++,DFS2(V[i]);


    for(int i = 1; i <= N; i++)
    {
        now++;
        memset(mem,0,sizeof(mem));
        memset(vis,false,sizeof(vis));
        cnt1 = cnt2 = 0;
        for(int j = 0; j < G[i].size(); j++)
        {
            cnt1++;
            if(mem[B[id[i][j]]])can[id[i][j]] = true;
            unit(G[i][j]);
        }
        memset(mem,0,sizeof(mem));
        memset(vis,false,sizeof(vis));
        cnt1 = cnt2 = G[i].size() - 1;
        for(int j = G[i].size() - 1; j >= 0; j--)
        {
            cnt2--;
            if(mem[B[id[i][j]]])can[id[i][j]] = true;
            unit(G[i][j]);
        }
    }

    for(int i = 0; i < M; i++)
    {
        int a = A[i],b = B[i];
        if(ord[a] != ord[b])
        {
            if(can[i])printf("diff\n");
            else printf("same\n");
        }
        else
        {
            if(can[i])printf("same\n");
            else printf("diff\n");
        }
    }
    return 0;
}




Measured memory_bytes: 7680
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = [list(map(int,readline().split())) for i in range(n)]

lst2 = [list(map(int,readline().split())) for i in range(n)]

#曜日、時刻にどの店が営業しているかを埋め込む
lst3 = [[] for _ in range(10)]
for i in range(n):
    for j in range(10):
        if lst1[i][j] == 1:
            lst3[j].append(i)

#ビット全探索
def bit_search(lst):
    keta = len(lst)
    bit_lst = []
    for i in range(2**keta):
        sub = [0]*n
        for j in range(keta):
            if ((i>>j) &1):
                for k in lst3[j]:
                    sub[k] += 1
        bit_lst.append(sub)
    return bit_lst


dummy = [0]*(10)
all_lst = bit_search(dummy)

ans = -10**9
for i in all_lst[1:]:
    res = 0
    for j in range(n):
        res += lst2[j][i[j]]
    ans = max(res,ans)

print(ans)

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

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1

class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, Q, A, B;
    cin >> N >> Q;
    UnionFind uf(N);
    int a[Q], b[Q];
    REP(i, Q){
        cin >> A >> B;
        a[i] = --A; b[i] = --B;
    }
    ll ans[Q];
    ll fai = ((ll)N*(N-1))/2;
    ans[Q-1] = fai;
    for(int i = Q-2; i >= 0; i--){
        if(!uf.issame(a[i+1], b[i+1])){
            ans[i] = ans[i+1]-uf.size(a[i+1])*uf.size(b[i+1]);
            uf.merge(a[i+1], b[i+1]);
        }
        else ans[i] = ans[i+1];
    }
    REP(i, Q) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    long long ans = 0;
    rep(i,n/r+2){
        rep(j,n/g+2){
            if((n-i*r-j*g)>=0 && (n-i*r-j*g)%b==0){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<map>
using namespace std;

int main(){
    string s1,s2,s3;
    int a,b;
    cin>>s1>>s2>>a>>b>>s3;
    if (s1==s3) a--;
    else b--;
    cout<<a<<' '<<b<<endl;
    
    return 0;


}


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

#define MOD 998244353
long long power(long long x, long long y) 
{ 
    long long res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % MOD; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % MOD;  // Change x to x^2 
    } 
    return res; 
}


int main() {
    // oh hi mark
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,m,v, p ; cin >> n >> m >> v >> p;
    int a[n];
    for(int i = 0; i< n; i++) cin >> a[i];
    long long c[n],up[n];
    sort(a, a+n);
    for(int i = 0; i < n; i++) {
        if(i == 0) {
            c[i] = a[i]; 
            up[i] = a[i]+m;
        }
        else {
            c[i] = c[i-1] + a[i];
            up[i] = up[i-1] + (a[i] + m);
        }

    }

    

    int pth = a[n-p];
    
    long long left = 0;
    long long right = (p-1) * m;
    long long gap = n - p;
    for(int i = 0; i < n; i++) {
        left += m;
        long long dis = m*v;
        dis -= left;
        dis -= right;

        int ind = upper_bound(a, a+n, a[i]+m) - a;
        if(ind <= n-p) continue;
       // cout << " ind L " << ind << endl;
        long long sum = c[n-p] - c[i];
        long long safe = (long long)(a[i] + m) * (n-p - i);
        
        

        long long canabsorb = safe - sum;

        // cout << i << "safe : " << safe << " - sum " << sum  << endl;
        // cout << "can absorb: " << canabsorb << endl;
        long long extra = dis - canabsorb;
        
        if(extra  <= 0) {
            cout << n-i << endl;
            break;
        }
        gap--;
    }
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(a, n) sort(a, a+n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX(a, n) *max_element(a, a+n)

using namespace std;

int main()
{
    int N, W;

    cin >> N >> W;

    int w[N];
    long v[N];

    REP(i, N) {
        cin >> w[i] >> v[i];
    }

    long val[N][W+1];
    REP(j, W+1) {
        if(j+w[0] <= W) { val[0][j] = (long)v[0]; }
        else { val[0][j] = (long)0; }
    }

    FOR(i, 1, N) {
        REPR(j, W+1) {
            if(j+w[i] <= W) { val[i][j] = (long)max(val[i-1][j], val[i-1][j+w[i]] + v[i]); }
            else { val[i][j] = (long)val[i-1][j]; }
        }
    }

    cout << MAX(val[N-1], W+1) << endl;

    return 0;
}

Measured memory_bytes: 78336
S = input()
T = input()

sd = {S[0]: 0}
td = {T[0]: 0}

def len_match():
    for i in range(1, len(S)):
        if (S[i-1] == S[i] and T[i-1] == T[i]) or (S[i] != S[i-1] and T[i] != T[i-1]):
            slast = sd.get(S[i], -1)
            tlast = td.get(T[i], -1)
            if slast != tlast:
                return False
            sd[S[i]] = i
            td[T[i]] = i
        else:
            return False
    return True

def ans():
    result = len_match()
    return 'Yes' if result else 'No'

print(ans())

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
//#define INF 0x3f3f3f3f
#define INF 2147483647
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=305;
//int arr[SIZE]={};
//???????????§???????????¬
//???????°????????±???????SegmentTree
struct SegmentTreeMin {
private:
    int n;
    vector<int> node;

public:
    // ????????? v ????????°???????????¨??§??¨?????????
    SegmentTreeMin(vector<int> v) {
        // ???????????????????????°??????????????????????????\????????????????°???? 2 ??? -> ????????? n ??¨??????
        // ?????°???????????¨??¨?????§????????????????????°??? 2n-1 ?????§??????
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n+1, INF);

        // ????????????????????\???????????¨??????????????????????????????????????\??????
        // ????????\?????????????????????????????? 2 ???????????§????????°??????
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
	void update(int x, int val) {
		// ??????????????????????????¢???????????????
		x += (n - 1);

		// ??????????????????????????´??°?????????????????¨??????????????£?????´??°????????????
		node[x] = val;
		while(x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2*x+1], node[2*x+2]);
		}
	}
	int getmin(int a, int b, int k=0, int l=0, int r=-1) {
		// ?????????????????????????????¨??????????±?????????? [0, n)
		if(r < 0) r = n;

		// ????±?????????¨????±????????????????????????? -> ???????????????
		if(r <= a || b <= l) return INF;

		// ????±??????????????±???????????????¨????¢???? -> ????±????????????????????¨?????????????
		if(a <= l && r <= b) return node[k];

		// ????±??????????????±???????????????¨????¢???? -> ?????????????????¢?´¢?????????
		// ?????´????????? vl ??? ?????´????????? vr ??¨????????????
		// ??°??????????±??????????????????¨???????±????????????????????????£?????????
		int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
		int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
		return min(vl, vr);
	}
};
//???????°????????±???????SegmentTree
vector<int> node;
signed main(){
    int N,Q;
    cin>>N>>Q;
    for(int i=0;i<N;i++){
        node.push_back(INF);
    }
    SegmentTreeMin mini(node);
    for(int i=0;i<Q;i++){
        int a,b,c;
		cin>>a>>b>>c;
        if(a){
            cout<<mini.getmin(b,c+1)<<endl;
        }
        else{
            mini.update(b,c);
        }
    }
    return 0;
}

Measured memory_bytes: 4696
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

//#define DEBUG

using namespace std;
#define rg register
#define ll long long 
#define inf 0x7fffffff/2;
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
int a[100005],b1[100005],b2[100005];
int n;
int main(){
    //freopen("c.in","r",stdin);
    n=read();
    int maxn=0;
    for(rg int i=1;i<=n;i++)
        a[i]=read(),maxn=max(a[i],maxn);
    for(rg int i=1;i<=n;i+=2)
        b1[a[i]]++;
    for(rg int i=2;i<=n;i+=2)
        b2[a[i]]++;
    #ifdef DEBUG
    for(int i=1;i<=n;i++)
        cout<<b2[i]<<" ";
    cout<<endl;
    #endif
    int m1=0,m2=0,k1=0,k2=0;
    for(rg int i=1;i<=maxn;i++)
    {
        if(m1<b1[i])
            k1=i,m1=b1[i];
        if(m2<b2[i])
            k2=i,m2=b2[i];
    }
    if(k1!=k2)
    {
        printf("%d\n",n-m1-m2);
        return 0;
    }
    int mm1=0,mm2=0;
    for(rg int i=1;i<=maxn;i++)
    {
        if(mm1<b1[i]&&i!=k1)
            mm1=b1[i];
        if(mm2<b2[i]&&i!=k2)
            mm2=b2[i];
    }
    if(m1-mm1>=m2-mm2)
        printf("%d\n",n-m1-mm2);
    else
        printf("%d\n",n-mm1-m2);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const long long int mod = 2019;
 
int main(){
    long long int L,R;
    cin >> L >> R;
 
    long long int min = LONG_LONG_MAX;
    for(long long int i=L;i<R;i++){
        for(long long int j=i+1;j<R+1;j++){
            long long int a = i*j%mod;
            if (min > a){
                min = a;
            }
            if (a == 0){
            	cout << 0 << endl;
              	return 0;
            }
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#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 sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,n) for(ll i=0;i<n;i++)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
bool compare(const pair<int, int>&i, const pair<int, int>&j)
    {
        return i.second < j.second;
    }   
int main()
{
        // added the two lines below 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s;
    cin>>s;
    map<char,int>m;
    int flag=0;
    for(int i=0;i<s.size();i++){
        m[s[i]]++;
    }
    for(auto i=m.begin();i!=m.end();i++){
        if((*i).second!=2){
            flag=1;
            break;
        }
    }
    if(flag) cout<<"No";
    else cout<<"Yes";
}
    
    
    


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

int main() {
  // ここにプログラムを追記
  string S;
  cin>> S;
  char a,b;
   int x = S.size();
  a = S[0];
  b = S[x-1];
  
    cout << a << x-2 << b << endl;
}


Measured memory_bytes: 256
//#pragma GCC diagnostic error "-std=c++11"
#include <bits/stdc++.h>
using namespace std;
#include<iostream>
#include<bitset>
using namespace std;
typedef bitset<12> bit;
const int N=107;
int n,i,j,m,mp[N][12],x,ans=-2e9,res;
bit s[N],tmp;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	for(cin>>n,i=1;i<=n;++i)for(j=0;j<10;++j)cin>>x,s[i][j]=x;
	for(i=1;i<=n;++i)for(j=0;j<=10;++j)cin>>mp[i][j];
	for(m=(1<<10)-1,i=1;i<=m;++i){
		tmp=bit(i);
		for(res=0,j=1;j<=n;++j)res+=mp[j][(tmp&s[j]).count()];
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
string s;
s(s);
f(i,1,3){
    if(s[i] != s[i-1]){
        out<<"Yes"<<endl;
        return;
    }
}
out<<"No"<<endl;
}

class AStationAndBus {
public:
	void solve(std::istream& in, std::ostream& out) {
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	AStationAndBus solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


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

int main(){
	int a[30];
	int b[30];
	int n,m;

	int c[30];
	for(int i = 0; i < 30; i++){
		c[i] = i + 1;
	}
	cin  >> n >> m;
	for(int i = 0; i < m; i++){
		scanf("%d,%d", &a[i], &b[i]);
	}


	for(int i = 0; i < m; i++){
		swap(c[a[i] - 1], c[b[i] - 1]);
	}

	for(int i = 0; i < n; i++){
		cout << c[i] << endl;
	}



}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  string a,b;
  cin >> a >> b;
  string s = a + b;
  int n = stoi(s);
  bool flag = false;
  for(int i = 0;i*i <= n;i++)if(i*i == n)flag = true;
  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;





  

  return 0;
}


Measured memory_bytes: 256
N,K = map(int ,input().strip().split(" "))

hs = []
for i in range(N):
    h = int(input())
    hs.append(h)

Hs = sorted(hs)
min = 10000000000000

for i in range(N - K + 1):
    right = i + K - 1
    diff = Hs[i + K -1] - Hs[i]
    if diff < min:
        min = diff

print(min)

Measured memory_bytes: 8280
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, e, t, g[1000], dp[300];
bool ok[300];
vi s[1000];

int main(){
	cin >> n >> e >> t;
	rep(i, n) cin >> ok[i];
	rep(i, e){
		int k, a;
		cin >> g[i] >> k; g[i]--;
		rep(j, k) cin >> a, s[i].pb(a - 1);
	}
	rep(i, n) dp[i] = ok[i] ? 1 : inf;
	rep(it, n) rep(i, e){
		int dp2[300], res = 0;
		rep(j, s[i].size()) dp2[j] = dp[s[i][j]];
		sort(dp2, dp2 + s[i].size(), greater<int>());
		rep(j, s[i].size()) res = max(res, j + dp2[j]);
		dp[g[i]] = min(dp[g[i]], res);
	}
	cout << (dp[t - 1] >= inf ? -1 : dp[t - 1]) << endl;
	return 0;
}

Measured memory_bytes: 1292
#include <cstdio>
const int mo=1000000007;
int f[15],dp[1<<15],c[1<<15],n,m;
int calc(int x,int y){
	if (!x) return 1;
	long long cnt=1;
	for (int i=0;i<n && cnt;i++)
		if ((x>>i)&1) cnt=cnt*(c[f[i]&y]-1)%mo;
			else if ((y>>i)&1) cnt=cnt*c[f[i]&x]%mo;
	return cnt;
}
int main(){
	scanf("%d%d\n",&n,&m);
	int L=1<<n,ans=1;
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		(ans<<=1)%=mo;
		f[x-1]|=1<<(y-1);
	}
	c[0]=1;
	for (int i=1;i<L;i++) c[i]=c[i>>1]<<(i&1);
	dp[0]=1;
	for (int i=1;i<L;i++)
	if (!((i>>1^i)&1))
		for (int j=i;j;j=(j-1)&i)
			if (!((j>>1^j)&1))
				dp[i]=(dp[i]+1ll*calc(i^j,j)*dp[i^j])%mo;
	printf("%d\n",(ans-dp[L-1]+mo)%mo);
}

Measured memory_bytes: 512
while True:
    n = int(input())
    if n == 0: break
    a = list(map(int, input().split()))
    i, o = 0, 32
    while o > 0:
        o = o - (o-1)%5
        print(o)
        o = 0 if a[i] > o else o - a[i]
        print(o)
        i = 0 if i == n-1 else i+1

Measured memory_bytes: 7616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
struct Edge {
  P from, to;
  int cost;
  Edge() {}
  Edge(P from, P to, int cost): from(from), to(to), cost(cost) {}
};
using Edges = vector<Edge>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  map<P, Edges> g;
  for(int i=0;i<m;++i) {
    int p, q, c; cin >> p >> q >> c;
    p--; q--;
    g[{p, c}].push_back(Edge({p, c}, {q, c}, 0));
    g[{q, c}].push_back(Edge({q, c}, {p, c}, 0));
    g[{p, c}].push_back(Edge({p, c}, {p, -1}, 0));
    g[{q, c}].push_back(Edge({q, c}, {q, -1}, 0));
    g[{p, -1}].push_back(Edge({p, -1}, {p, c}, 1));
    g[{q, -1}].push_back(Edge({q, -1}, {q, c}, 1));
  }
  priority_queue<pair<int, P>, vector<pair<int, P>>, greater<pair<int, P>>> pq;
  map<P, int> dist;
  pq.push({0, {0, -1}});
  dist[{0, -1}] = 0;
  while(!pq.empty()) {
    auto now = pq.top(); pq.pop();
    int cost = now.first;
    P idx = now.second;
    if(dist[idx] < cost) continue;
    for(const auto &e: g[idx]) {
      P next = e.to;
      int l = e.cost;
      if(dist.find(next) == dist.end() || dist[next] > cost + l) {
        dist[next] = cost + l;
        pq.push({cost + l, next});
      }
    }
  }
  if(dist.find({n-1, -1}) == dist.end()) cout << -1 << endl;
  else cout << dist[{n-1, -1}] << endl;
}


Measured memory_bytes: 102580
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
	int n,s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		int count=0;
		while(true){
			if(s/10==0)
				break;
			int best=0,check=10;
			for(int j=1;j<6;j++){
				if((s/check)*(s%check)>best)
					best=(s/check)*(s%check);
				check*=10;
			}
			s=best;
			count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
i=0
while i<4:
   t,n=map(int,input().split())
   if t==1:
       money=n*6000
       print(money)
   elif t==2:
       money=n*4000
       print(money)
   elif t==3:
       money=n*3000
       print(money)
   elif t==4:
       money=n*2000
       print(money)
   i+=1


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int K;
vector<ll> all;
void dfs(int d, ll val, vector<ll>& all){
  all.push_back(val);
  if (d == 11) return;

  for (int i = -1; i <= 1; ++i){
    int add = (val % 10) + i;
    if (add >= 0 && add <= 9) dfs(d + 1, val * 10 + add, all);
  }
}

int main(){
  cin >> K;

  for (int v = 1; v < 10; ++v) dfs(1, v, all);
  sort(all.begin(), all.end());
  cout << all[K - 1] << endl;
}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
 
int L[100005],R[100005],n,w[100005];
long long ans;
int main(){
	cin>>n;
	int x;
	for (int i=1;i<=n;i++){
		cin>>x;
		w[x]=i;
		L[i]=i-1;
		R[i]=i+1;
	}
	
	for (int i=1;i<=n;i++){
		int b=L[w[i]],a=L[b];
		int c=R[w[i]],d=R[c];
		if (b!=0) ans+=1ll*(b-a)*(c-w[i])*i;
		if (c!=n+1) ans+=1ll*(d-c)*(w[i]-b)*i;
		
		L[c]=b;
		R[b]=c;
	}
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <math.h>
#define EPS (1e-6)
using namespace std;

double tri (double a, double b, double c) {
    double s = (a + b + c) * 0.5;
    double res = sqrt(s * (s - a) * (s - b) * (s - c));
    return res;
}

int main ()
{
    double x1, x2, x3, y1, y2, y3, xp, yp;
    while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
        double a = hypot(x2 - x1, y2 - y1);
        double c = hypot(x3 - x1, y3 - y1);
        double b = hypot(x3 - x2, y3 - y2);
        double x = hypot(xp - x1, yp - y1);
        double y = hypot(xp - x2, yp - y2);
        double z = hypot(xp - x3, yp - y3);

        if (tri(a, x, y) + tri(b, y, z) + tri(c, x, z) - tri(a, c, b) < EPS) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1228
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=200005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n, c[max_n];
vector<int> G[max_n];
int sz[max_n];
bool big[max_n];
ll ans[max_n];
int par[max_n];
void dfs1(int u,int fa)
{
    sz[u]=1;
    for(auto v:G[u])
    {
        if(v==fa)continue;
        par[v] = u;
        dfs1(v,u);
        sz[u]+=sz[v];
    }
}
int cur[max_n];
bool vis[max_n];
void add(int u,int fa,int val)
{
    bool f = false;
    if(!vis[c[u]]){
        f = true;
        vis[c[u]] = true;
        cur[c[u]] += val * sz[u];
    }
    for(auto v:G[u])
    {
        if(v==fa||big[v])continue;
        add(v,u,val);
    }
    if(f)vis[c[u]] = false;
}
void dfs(int u,int fa,bool keep)
{
    int mx=-1,son=-1;
    for(auto v:G[u])
    {
        if(v==fa)continue;
        if(sz[v]>mx)mx=sz[v],son=v;
    }
    for(auto v:G[u])
    {
        if(v==fa||v==son)continue;
        dfs(v,u,0);
    }
    if(~son)dfs(son,u,1),big[son]=1;
    //vis[c[u]]=true,cur[c[u]] = sz[u];
    cur[c[u]] = 0;
    add(u,fa,1);
    int x=c[par[u]];
    if(par[u]){
        ll y = sz[u] - cur[x];
        ans[x] += 1ll* y*(y+1)/2;
    }
    if(~son)big[son]=0;
    if(!keep)add(u,fa,-1);
}
int main() {
    scanf("%d", &n);
    for(int  i = 1; i <= n; i++ )scanf("%d",c + i);
    for(int i = 1; i < n; i++) {
        int u, v; scanf("%d%d", &u, &v);
        G[u].push_back(v), G[v].push_back(u);
    }
    dfs1(1,0);
    dfs(1,0,1);
    for(int i = 1; i <= n; i++) ans[i] += 1ll * (n - cur[i]) * ( n -cur[i] + 1) /2;
    for(int i = 1; i <= n; i++) printf("%lld\n", 1ll*n*(n+1)/2 -ans[i]);
    return 0;
}

Measured memory_bytes: 38480
#include<cstring>
#include<cstdio>

#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define MEM(X,Y) memset(X,Y,sizeof(X));
#define OPEN freopen("abc.in","r",stdin);
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
char s[1000];
char t[2] = { 'h','i' };

int main(void)
{
	bool flag = 1;
	scanf("%s", s);
	for (int i = 0; s[i]; ++i)
	{
		if (s[i] != t[i & 01])
		{
			flag = 0;
			break;
		}
	}
	if (flag && strlen(s) % 2 == 0)
		printf("Yes");
	else
		printf("No");
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	cin >> S;
	ll ans = 0;
	for (ll n = 0; n < S.size() / 2; n++) {
		if (S[n] != S[S.size() - 1 - n])ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back

int bexp(int a, int b, int mod)
{
    int res = 1;
    if (mod <= 0)
        return 0;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

#define N 500010
#define MOD 1000000007

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int sum(int n)
{
    int res = 0;
    while (n)
        res += n % 10, n /= 10;
    return res;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;
    int i = 1;
        
    while (n && i < 10)
    {
        cout << i << "\n";
        i++;
        n--;
    }

    i = 19;
    int p = 10;
    while (n)
    {
        while (i < sum(i) * p && n)
        {
            n--;
            cout << i << "\n";
            i += p;
        }
        i -= p;
        p *= 10;
        i += p;
    }
    return 0;
}
    

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
int n; 
long long a[90];
main()
{
  cin>>n;
  a[0]=2;
  a[1]=1;
  for(int i=2;i<=n;i++)
  {
    a[i]=a[i-1]+a[i-2];
  }
  cout<<a[n]<<endl;
}

Measured memory_bytes: 256
# include <cstdio>
# include <iostream>
# include <cstring>
# include <string>
# include <cmath>
# include <algorithm>
# define R register int

using namespace std;

const int maxn=100005;
int n,k,p1,p2,equ;
int cnt,a[maxn],ans;

int ab (int x)
{
	if(x<0) return -x;
	return x;
}

int ask (int x,int y)
{
	if(x<0&&y<0) return -min(x,y);
	if(x>0&&y>0) return max(x,y);
	return ab(x)+ab(y)+min(ab(x),ab(y));
}

int main()
{
	scanf("%d%d",&n,&k);
	for (R i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]<0) equ=i;
	}
	p1=p2=equ;
	if(p2<k) p2=p1=k;
	cnt=1;
	while (cnt<k&&p1>1) p1--,cnt++;
	if(cnt==k) ans=ask(a[p1],a[p2]);
	while (p2<n)
	{
		p1++;
		p2++;
		ans=min(ask(a[p1],a[p2]),ans);
	}
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	vector<bool> a(4, false);
	for (int i = 0; i < s.length(); i++) {
		if (s.at(i) == 'N')a.at(0)=true;
		else if (s.at(i) == 'W')a.at(1) = true;
		else if (s.at(i) == 'S')a.at(2) = true;
		else if (s.at(i) == 'E')a.at(3) = true;
	}
	if ((a.at(0) ^ a.at(2)) || (a.at(1) ^ a.at(3))) {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
infty = 1000000000
count = 0

def merge(A, left, mid, right):
	global count
	L = A[left:mid]
	R = A[mid:right]
	L.append(infty)
	R.append(infty)
	i = 0
	j = 0
	n1 = mid - left
	for k in range(left, right):
		if L[i] <= R[j]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
			count += n1 - i


def mergeSort(A, left, right):
	if left + 1 < right:
		mid = (left + right) // 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)


if __name__ == "__main__":
	n = int(input())
	S = list(map(int, input().split()))
	mergeSort(S, 0, n)
	print(count)


Measured memory_bytes: 27468
object Main extends App {
  
  val sc = new java.util.Scanner(System.in) 
  val a, b, c, x = sc.nextInt()
  var ans = 0
  for (i <- 0 to a; j <- 0  to b; k <-  0 to c) {
    if (i * 500 + j * 100 + k * 50 == x) {
      ans += 1
    }
  }
  println(ans)
}

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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<ll, ll>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;
const ll MAX = 1000005;

ll ans;
vector<P> vv;
bool isprime[10000000];
vector<long long> prime_list;

void seive(long long n) {

	int _n = (int)sqrt(n);
	if (_n>10000000) {
		puts("nが大きすぎます");
		abort();
	}

	for (int i = 2; i <= _n+1; i++) isprime[i] = true;

    for (int i = 2; i <= _n+1; i++) {
    	if ( isprime[i] == true ) {
    		prime_list.push_back((long long)i);
    		for (int j = i + i; j <= _n+1; j += i) isprime[j] = false;
    	}
    }
    return;
}

vector<pair<long long, long long> > prime_factrization(long long n) {

	if (prime_list.size()==0) {
		puts("seiveを実行してください");
		abort();
	}

	vector<pair<long long, long long> > res;

	for (int i = 0; i < prime_list.size(); i++) {
		
		if (n % prime_list[i] == 0) {
			long long _c = 0;
			while (n % prime_list[i] == 0) {
				_c++;
				n /= prime_list[i];
			}
			res.push_back(make_pair(prime_list[i], _c));
		}
	}
	
	if (n > 1) res.push_back(make_pair(n, 1));
	return res;
}
int main(void) {
    ll N;
    cin >> N;

    seive(N);
    vv = prime_factrization(N);

    for (auto x : vv) {

        ll xx = x.second;
        ll j = 1;
        while (xx-j>=0) {
            xx -= j;
            j++;
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 5332
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
	int h,w,m;
    cin >> h >> w >> m;
	vp x(h,pii(0,0)),y(w,pii(0,0));
	vi xi(m),yi(m);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--,b--;
		xi[i] = a;
		yi[i] = b;
		x[a].first++;
		y[b].first++;
	}
	rep(i,h)x[i].second = i;
	rep(i,w)y[i].second = i;
	sort(all(x));
	sort(all(y));
	int ans = x.back().first + y.back().first;
	vi xx(h,0),yy(w,0);
	int c1 = 0,c2 = 0;
	rep(i,h)if(x[i].first == x.back().first){
		xx[x[i].second]++;
		c1++;
	}
	rep(i,w)if(y[i].first == y.back().first){
		yy[y[i].second]++;
		c2++;
	}
	set<pii> st;
	rep(i,m){
		if(xx[xi[i]] && yy[yi[i]]){
			st.insert(pii(xi[i],yi[i]));
		}
	}
	///cout << c1 << " " << c2 << " " << st.size() << endl;
	if(c1*c2 == st.size()){
		ans--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 40248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fi first
#define se second
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll n,m;
    cin>>n>>m;
    ll arr[n],i,j;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    ll sum=0;
    for(i=0;i<n;i++)
    {
        sum+=arr[i];
    }

    ll ct=0;

    for(i=0;i<n;i++)
    {
        if(arr[i]*4*m >= sum)
        {
            ct++;
        }
    }
    if(ct>=m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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



int main() {

    int N;
    int A[100001];
    cin >> N;
    for (int i = 0; i < N + 1; i++) cin >> A[i];
    //今の深さの点の数
    long long now = 1;
    //int mae = 0;
    long long ans = 0;
    //末端の数
    long long sum = 0;
    //分岐した回数
    long long route = 1;
    
    for (int i = 0; i < N + 1; i++)
    {
        sum += A[i];
    }
    int s = sum;
    //cout << sum << endl;
    for (int i = 0; i < N + 1; i++)
    {
        
        //cout << now <<route<< endl;
        ans += now;
        //cout << now<< " ";
        now -= A[i];
        sum -= A[i];
        now = min(now * 2, sum);

        //cout << now << endl;
        if (i != N && now <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        else if (i == N && now != 0)
        {
            cout << -1 << endl;
            return 0;
        }

        /*
        ans += now;
        now -= A[i];
        s -= A[i];
        //できるだけ早く分岐しておく
        int a = now;*/
        /*
        //now 2倍ルート
        if (route + a < sum)
        {
            //新しい分岐はa個
            now += a;
            route += a;
        }
        //nowがそれ以降の和になるルート
        else
        {
            //基本的にrouteは1+枝の数
            //ある瞬間のroute-1がそれまでの葉の数と等しければいい
            //分岐した数だけ葉が増える、route+=nはA[i]=nを意味する
            //つまりrouteはそれまでのA[i]の和、route= sum-sumA[i]
            //now-A[i]（分岐＝葉の数）=葉以外の数、
            //葉の枚数＋全部の和-分岐の数（）

            //now=sum-sumA[i-1]なら、

            //新しい分岐はsum-route個
            //（最終的な道の数）ー（今の道の数）をnow（今の道の数）に足して（最終的な道の数）にする
            //now += sum - route;
            now = s;
            route += sum - route;
        }*/
        //now = min(a * 2, s);

        if (i != N && now <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        else if (i == N && now != 0)
        {
            cout << -1 << endl;
            return 0;
        }


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

Measured memory_bytes: 4008
N=int(input())
W=list(map(int,input().split()))
M=abs(W[0]-sum(W[1:N]))
for i in range(1,N):
    Mae=sum(W[0:i])
    Ato=sum(W[i:N])
    if abs(Mae-Ato)<M:
        M=abs(Mae-Ato)
print(M)
        


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a,b,les,k,i,count=0,res[20];
    scanf("%d%d%d",&a,&b,&k);
    if(a>b)
    les=b;
    else
    les=a;
    for(i=1;i<=les;i++)
    {
        if(a%i==0&&b%i==0)
        {
            res[count]=i;
            count++;
            
        }
    }
 
    count=count-k;
    printf("%d",res[count]);
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
	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: 580
#include <bits/stdc++.h>
using namespace std;

const int N = 100005;

int n, m;
vector<int> g[N];
int deg[N];
int d[N];
int root = 0;
int par[N];

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n + m - 1; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
		++deg[v];
	}
	for (int u = 1; u <= n; ++u) if (deg[u] == 0) {
		root = u;
		break;
	}
	queue<int> q;
	q.push(root);
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (int v : g[u]) {
			d[v] = max(d[v], d[u] + 1);
			if (--deg[v] == 0) {
				q.push(v);
			}
		}
	}
	q.push(root);
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (int v : g[u]) {
			if (par[v] == 0 && d[v] == d[u] + 1) {
				par[v] = u;
				q.push(v);
			}
		}
	}
	for (int u = 1; u <= n; ++u) {
		printf("%d\n", par[u]);
	}
}

Measured memory_bytes: 7424
N,M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
li = []
for i in range(M):
  li.append(list(map(int, input().split())))
  li[i][0],li[i][1] = li[i][1],li[i][0]
li.sort(reverse=True)
D = [0] * N
idx = 0
for i, j in li:
  for k in range(j):
    if idx >= N:
      break
    D[idx] = i
    idx += 1
  if idx >= N:
    break
  
for i in range(N):
  if A[i] >= D[i]:
    break
  A[i] = D[i]
print(sum(A))
           

Measured memory_bytes: 32204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, n) for(int i=1; i<=(int)(n); i++)

using namespace std;

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

    for (int i=A; i<=B; i++) {
        if ((i % K) == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}



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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c;
	int p = -100000, q, r, s, t , u;
	while(true)
	{
		k = a + b + p;
		t = k - b - c;
		u = k - a - c;
		r = k - p - u;
		q = k - c - r;
		s = k - p - c;
		if (s + t + u == k)
		{
			break;
		}
		++p;
	}
	cout << a << " " << b << " " << p << endl;
	cout << q << " " << c << " " << r << endl;
	cout << s << " " << t << " " << u << endl;
}

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

using namespace std;

const int N = 2e5 + 3;

int n;

int main()
{
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += i * 1ll * (n - i + 1);
    }
    for (int i = 1, u, v; i < n; i++)
    {
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * 1ll * (n - v + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = int(input())
print(N*180-360)


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
deque<char>q;
string s;
int qq,com,f;
char c;
int main()
{
    cin>>s>>qq;
    rep(i,0,s.size()-1)q.push_back(s[i]);
    bool flag=true;
    rep(i,1,qq){
        cin>>com;
        if(com==1)flag=!flag;
        else{
            cin>>f>>c;
            if(flag){
                if(f==1)q.push_front(c);
                else q.push_back(c);
            }else{
                if(f==2)q.push_front(c);
                else q.push_back(c);
            }
        }
    }
    if(flag){
        while(!q.empty()){
            cout<<q.front();
            q.pop_front();
        }
    }else{
        while(!q.empty()){
            cout<<q.back();
            q.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
	int n,s,d;
    cin>>n>>s;
    d=2*s+1;
    cout<<(n-1)/d+1;
	return 0;
}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

int32_t main(){
	fastio;
	string s;
	// int m;
	cin>> s;
	// cin >> m;
	if(s == "Sunny") cout<< "Cloudy\n";
	else if(s == "Cloudy") cout<< "Rainy\n";
	else cout<< "Sunny\n";

	return 0;
}


Measured memory_bytes: 256