akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
vi in,used;
vvi G;
bool h=true;
ll dfs(int a){
	used[a]=true;
	vi t;
	rep(i,G[a].size()){
		int to=G[a][i];
		if(used[to])continue;
		t.pb(dfs(to));
	}
	if(!t.size())return in[a];
	ll sum=0,ma=0;
	rep(i,t.size()){
		sum+=t[i];
		ma=max(ma,t[i]);
	}
	ll w=in[a];
	if(sum-ma>=ma){
		if(sum<w||w*2<sum)h=false;
		else{
			ll W=sum-w;
			in[a]-=W;
			w-=W;
		}
	}else{
		if(sum<w)h=false;
		else{
			ll W=sum-w;
			W=min(W,sum-ma);
			w-=W;
			in[a]-=W;
//			cout<<in[a]<<" "<<sum-2*W<<endl;
			if(in[a]!=sum-2*W||W<0||in[a]<0)h=false;
		}
	}
//	cout<<" "<<a<<" "<<w<<endl;
	return w;
}
int main(){
	cin>>n;
	in=used=vi(n);
	G=vvi(n);
	rep(i,n)cin>>in[i];
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	ll out=dfs(0);
	int T=G[0].size();
	if((T==1&&out==in[0]||T!=1&&out==0)&&h)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}



Measured memory_bytes: 15232
A,B,C,D = map(int,input().split())

if A < C:
    if B < D:
        if B - C >= 0:
            print(B-C)
        else:
            print(0)
    else:
        if D - C >= 0:
            print(D-C)
        else:
            print(0)
else:
    if B < D:
        if B - A >= 0:
            print(B-A)
        else:
            print(0)
    else:
        if D - A >= 0:
            print(D-A)
        else:
            print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2+5;

int s1, s2;
int a[N], n, sum;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	int r1, r2;
	r1 = sum / n; r2 = r1 + 1;
	for (int i = 0; i < n; i++){
		s1 += (r1 - a[i]) * (r1 - a[i]);
		s2 += (r2 - a[i]) * (r2 - a[i]);
	}
	printf("%d\n", min(s1, s2));
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class APluralForm {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String s = in.next();
            if (s.charAt(s.length() - 1) == 's') out.println(s + "es");
            else out.println(s + "s");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(){
  int N,L;
  cin>>N>>L;
  vector<string> S(N);
  for(string &s:S)
    cin>>s;
  sort(S.begin(),S.end());
  for(string &s:S)
    cout<<s;
  cout<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N);
    var(string, s);

    vector<int> pos[10];
    rep(i, 0, N) { pos[s[i] - '0'].push_back(i); }
    rep(i, 0, 10) {
        pos[i].push_back(INF + 0);
        pos[i].push_back(INF + 1);
        pos[i].push_back(INF + 2);
    }

    int cnt = 0;

    rep(a, 0, 10) rep(b, 0, 10) rep(c, 0, 10) {
        const int i = pos[a].front();
        const int j = *upper_bound(all(pos[b]), i);
        const int k = *upper_bound(all(pos[c]), j);
        if (i < N && j < N && k < N) ++cnt;
    }

    print(cnt);

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,K;string S; cin>>N>>S>>K;
  rep(i,0,N){
    if(S[i]==S[K-1])
      cout<<S[i];
    else
      cout<<'*';
  }
  cout<<endl;
  }


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        var dp = new bool[A.Sum() + 1];
        dp[0] = true;

        for (int i = 0; i < N; i++)
            for (int prev = dp.Length - 1; prev >= 0; prev--)
                if (dp[prev])
                    dp[prev + A[i]] = true;

        int ans = 0;
        for (int s = 1; s < dp.Length; s++)
            if (s % 10 != 0 && dp[s]) ans = Math.Max(ans, s);

        Console.WriteLine(ans);
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===


int main() {
	int N;
	cin >> N;
	Vl A(N + 1), B(N);
	for (int i = 0; i < N + 1; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
	}
	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		ll taosu = min(A[i], B[i]);
		B[i] -= taosu;
		ans += taosu;
		taosu = min(A[i + 1], B[i]);
		A[i + 1] -= taosu;
		ans += taosu;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 ==1 and d1 == 31:
  print('1')
elif m1==2 and d1 == 28:
  print('1')
elif m1==3 and d1 == 31:
  print('1')
elif m1==4 and d1 == 30:
  print('1')
elif m1==5 and d1 == 31:
  print('1')
elif m1==6 and d1 == 30:
  print('1')
elif m1==7 and d1 == 31:
  print('1')
elif m1==8 and d1 == 31:
  print('1')
elif m1==9 and d1 == 30:
  print('1')
elif m1==10 and d1 == 31:
  print('1')
elif m1==11 and d1 == 30:
  print('1')
else:
  print('0')

Measured memory_bytes: 3064
#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() {
        ll x, k, d;
        cin >> x >> k >> d;
        ll sho, amari, ans;
        x = abs(x);
        sho = x/d;
        if(sho>k){
                x-=k*d;
                cout << x << endl;
                return 0;
        }
        k -= sho;
        amari = x%d;
        if(k%2==0){
                ans = amari;
        }else{
                ans = amari - d;
        }

        cout << abs(ans) << endl;
        return 0;

}

Measured memory_bytes: 3612
#include<iostream>
#include<bits/stdc++.h>
#define nodes 100010
using namespace std;
int dp[nodes];
bool visited[nodes]={false};
int util(vector<vector<int>>&edges,int i)
{
  if(dp[i]>=0)
  return dp[i];
  if(edges[i].size()==0)
  {
    dp[i]=0;
    //cout<<"returning "<<i<<endl;
    return dp[i];
  }
  visited[i]=true;
  for(auto v:edges[i])
  {
    dp[i]=max(dp[i],1+util(edges,v));
  }
  return dp[i];
}
int main()
{
  int n,m;
  cin>>n>>m;
  vector<vector<int>> edges(n+1);
  for(int i=0;i<=n;i++)
  dp[i]=-1;
  for(int i=0;i<m;i++)
  {
    int x,y;
    cin>>x>>y;
    edges[x].push_back(y);
  }
  //cout<<"input taken"<<endl;
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    //cout<<"calc"<<endl;
    if(dp[i]<0)
    {
      //cout<<"calling util"<<i<<endl;
      ans=max(ans,util(edges,i));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8192
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  n <- getl toInt
  when (n /= 0) $ do
    xs <- rgetl n $ split toInt
    mapM_ (\(i,n) -> putStrLn $ show i ++ " " ++ show n) $ solve xs
    main
    
solve :: [[Int]] -> [(Int,Int)]
solve = sortBy (\a b -> if snd a == snd b then fst a `compare` fst b else snd b `compare` snd a) . map (f (calc 0 1))
  where
    f g (y:ys)= (y, g ys)


calc :: Int -> Int -> [Int] -> Int
calc acc 10 (x:y:zs)
  | x == 10 = acc + x + y + head zs
  | x + y == 10 = acc + x + y + head zs
  | otherwise = acc + x + y
calc acc t (x:y:z:zs)
  | x == 10 = calc (acc + x + y + z) (t+1) (y:z:zs)
  | x + y == 10 = calc (acc + x + y + z) (t+1) (z:zs)
  | otherwise = calc (acc + x + y) (t+1) (z:zs)

toInt :: String -> Int
toInt s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine


tests :: [Test]
tests = [
  "test1" ~: 273 ~=? calc 270 10 [1,2],
  "test2" ~: 285 ~=? calc 270 10 [1,9,5],
  "test3" ~: 300 ~=? calc 270 10 [10,10,10],
  "test4" ~: 123 ~=? calc 0 1 [6, 3, 10, 7, 1, 0, 7, 9, 1, 10, 6, 2, 4, 3, 9, 1, 9, 0],
  "test5" ~: 127 ~=? calc 0 1 [5, 3, 9, 1, 7, 1, 0, 0, 8, 1, 10, 10, 4, 3, 9, 1, 8, 2, 9],
  "test6" ~: 60 ~=? calc 0 1 [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
  "test7" ~: 200 ~=? calc 0 1 [8, 2, 10, 9, 1, 7, 0, 10, 10, 10, 0, 8, 10, 10, 10, 10],
  "test8" ~: 122 ~=? calc 0 1 [5, 0, 10, 9, 1, 4, 1, 9, 0, 10, 10, 7, 1, 5, 2, 8, 1],
  "test9" ~: 300 ~=? calc 0 1 [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
  "test10" ~: 175 ~=? calc 0 1 [8, 2, 7, 3, 6, 4, 8, 2, 8, 2, 9, 1, 7, 3, 6, 4, 8, 2, 9, 1, 7]
  ]

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


 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=k;i<n;i++){
    if(a[i]>a[i-k]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }


}

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

typedef pair <int, int> ii;

const int Maxd = 4;
const int dy[Maxd] = {-1, 0, 1, 0};
const int dx[Maxd] = {0, -1, 0, 1};
const int Maxn = 1005;
const int Inf = 1000000000;

int n, m;
char B[Maxn][Maxn];
int dist[Maxn][Maxn];
vector <ii> Q;
int res;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", B[i]);
    fill((int*)dist, (int*)dist + Maxn * Maxn, Inf);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) if (B[i][j] == '#') {
            dist[i][j] = 0;
            Q.push_back(ii(i, j));
        }
    for (int i = 0; i < Q.size(); i++) {
        ii v = Q[i];
        int di = dist[v.first][v.second];
        res = di;
        for (int d = 0; d < Maxd; d++) {
            ii u = ii(v.first + dy[d], v.second + dx[d]);
            if (0 <= u.first && u.first < n &&
                0 <= u.second && u.second < m &&
                di + 1 < dist[u.first][u.second]) {
                dist[u.first][u.second] = di + 1;
                Q.push_back(u);
            }
        }
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 15212
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n;
	long long int l[100];
	l[0] = 2;
	l[1] = 1;
	cin >> n;
	if (n==1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 2; i <= n;i++) {
		l[i] = l[i - 1] + l[i - 2];
	}
	cout << l[n] << endl;
}

Measured memory_bytes: 256
# coding: utf-8
H,N=map(int,input().split())
AB=[[0,0]]
for i in range(N):
    AB.append(list(map(int,input().split())))
 
INF=10**9

dp=[INF for i in range(H+1)]
dp[0]=0

for i in range(1,N+1):
    for j in range(1,H+1):
        dp[j]=min(dp[j],dp[max(0,j-AB[i][0])] + AB[i][1])

print(dp[H])

Measured memory_bytes: 42732
n_vertex, n_edge = gets.split.map(&:to_i)
#puts "#{n_vertex} #{n_edge}"
edges = n_vertex.times.map { Array.new(n_vertex, -1) }
for i in 0...n_edge do
  u, v, d = gets.split.map(&:to_i)
#  puts "#{u} #{v} #{d}"
  edges[u - 1][v - 1] = d
  edges[v - 1][u - 1] = d
end
#for i in 0...n_vertex do
#  puts edges[i].join(" ")
#end
f = gets.split.map(&:to_i)
#puts f.join(" ")

for i in 1...n_vertex do
  if edges[0][i] > 0
    targ_v = i
    targ_d = edges[0][i]
    break
  end
end
#puts "#{targ_v} #{targ_d}"

t_max = gets.to_i
#puts "#{t_max}"
count = 0
for t in 0...t_max do
  n_new = gets.to_i
#  puts "#{n_new}"
  for i in 0...n_new do
    new_id, dst = gets.split.map(&:to_i)
#    puts "#{new_id} #{dst}"
  end
  n_put = gets.to_i
#  puts "#{n_put}"
  for i in 0...n_put do
    put_id = gets.to_i
#    puts "#{put_id}"
  end
  
  if t < (t_max * 3 / 4)
    command = -1
  else
    if count < targ_d
      command = targ_v + 1
      count += 1
    else
      command = -1
    end
  end
  puts command
  $stdout.flush
  
  verdict = gets.chomp
  break if verdict == "NG"
  n_achieve = gets.to_i
#  puts "#{n_achieve}"
  for i in 0...n_achieve do
    achieve_id = gets.to_i
#    puts "#{achieve_id}"
  end
end


Measured memory_bytes: 6476
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}


int main() {
  ll i, j, k;
  
  ll N, K;
  cin >> N >> K;
  
  ll ans=0;
  ll cnt[MAX]={};
  for(i=K; i>=1; i--) {
    cnt[i]=moP(K/i, N);
    
    for(j=i*2; j<=K; j+=i) cnt[i]-=cnt[j];
    
    moC(ans, +, i*cnt[i]%MOD);
  }
  
  pt(ans);
}




Measured memory_bytes: 4320
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100100;
int deg[N];
int n, m;
vector<int> g[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &m);
	if (m < n + 2) {
		printf("No\n");
		return 0;
	}
	while(m--) {
		int v, u;
		scanf("%d%d", &v, &u);
		g[v].push_back(u);
		g[u].push_back(v);
		deg[v]++;deg[u]++;
	}
	int cnt4 = 0, cnt6 = 0;
	for (int i = 1; i <= n; i++) {
		if (deg[i] & 1) {
			printf("No\n");
			return 0;
		}
		if (deg[i] >= 4) cnt4++;
		if (deg[i] >= 6) cnt6++;
	}
	if (cnt6 > 0 || cnt4 > 2) {
		printf("Yes\n");
		return 0;
	}

	for (int v = 1; v <= n; v++) {
		if (deg[v] != 4) continue;
		for (int u : g[v]) {
			int w = u, old = v;
			while(deg[w] == 2) {
				int nw = g[w][0] ^ g[w][1] ^ old;
				old = w;
				w = nw;
			}
			if (w == v) {
				printf("Yes\n");
				return 0;
			}
		}
	}

	printf("No\n");

	return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){
	int N,K;
	cin>>N>>K;
	int cnt=0;
	for(int i=0;i<N;i++){
		int t;
		cin>>t;
		if(t>=K)
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  long int sx,sy,tx,ty;
  scanf("%ld %ld %ld %ld", &sx, &sy, &tx, &ty);
  long int dx=tx-sx, dy=ty-sy;
  
  for(int i=0;i<dy; i++)
    putchar('U');
  for(int i=0;i<dx;i++)
    putchar('R');
    
  for(int i=dy;i>0;i--)
    putchar('D');
  for(int i=dx;i>0;i--)
    putchar('L');
  
  putchar('L');
  for(int i=0;i<dy+1; i++)
    putchar('U');
  for(int i=0;i<dx+1;i++)
    putchar('R');
  putchar('D');
  
  putchar('R');
  for(int i=dy;i>-1;i--)
    putchar('D');
  for(int i=dx;i>-1;i--)
    putchar('L');
    
  putchar('U');
  
   
  return 0;
}
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e4+10;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];

int p ,n;
int val[MAX];

int vis[(1<<16)][16][16];
int  mx;
ll arr[MAX];
int prime[10]={2, 3, 5, 7, 11, 13, 17, 19};
int coun(int x){
	return __builtin_popcount(x);
}
int a1[MAX], a2[MAX], a3[MAX], a4[MAX], a5[MAX], a6[MAX];
int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);
//	#endif
	int n;
	cin>>n;
	string st;
	cin>>st;
	ll cnt=0;
	ll r=0, b=0, g=0;
	for(int i=0;i<n;i++){
		if(st[i]=='R')
			r++;
		else if(st[i]=='G')
			g++;
		else
			b++;
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(st[i]!=st[j]){
				if(2*j-i>=n)
					continue;
				if(st[2*j-i]!=st[i]&&st[2*j-i]!=st[j])
					cnt++;
			}
		}
	}
	cout<<(r*g*b)-cnt;

}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double llf;
typedef pair<int, int> pii;
const int maxn = 2e5 + 5;
const ll inf = 2e15 + 7;

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	if (4 * a * b < (c - a - b) * (c - a - b) && (c > a + b))cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[300005] = {}, b[300005] = {}, z = 890328;
    string s;
    cin >> n >> s;
    for (int i = 1; i <= n; i++) a[i] = a[i - 1] + (s[i - 1] == 'W');
    for (int i = n; i; i--) b[i] = b[i + 1] + (s[i - 1] == 'E');
    for (int i = 1; i <= n; i++) z = min(z, a[i - 1] + b[i + 1]);
    cout << z;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    string N;
    cin >> N;
    ll ans = 0;
    rep(i, N.size()) {
        ans += (N[i] - '0');
    }
    cout << (ans % 9 == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3732
n = gets.chomp.to_i
ab = []
n.times do |i|
  ab[i] = gets.chomp.split.map(&:to_i).reverse
end
ab.sort!
m = 0
n.times do |i|
  m += ab[i][1]
  if m > ab[i][0]
    puts "No"
    exit
  end
end
puts "Yes"


Measured memory_bytes: 18168
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int n;
    cin >> n;


    for (int i = 1; i < 10; ++i) {
        if (n % i == 0) {
            int dif = n /i;
            if (0 < dif && dif < 10) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
N,M=map(int,input().strip().split())
A=list(map(int,input().strip().split()))
BC=[list(map(int,input().strip().split())) for _ in range(M)]
A.sort()
A=deque(A)
BC.sort(key=lambda x:x[1],reverse=True)

ans=0
fin=False
for m in range(M):
    if fin==True:
        break
    i=0
    while i<BC[m][0]:
        if A:
            if BC[m][1]>=A[0]:
                ans+=BC[m][1]
                A.popleft()
                i+=1
            else:
                ans+=sum(A)
                fin=True
                break
        else:
            fin=True
            break
if fin==False and A:
    ans+=sum(A)
print(ans)

Measured memory_bytes: 32996
#include<bits/stdc++.h>
using namespace std;
long long x[100001];
int main()
{
    long long ans=0,n,a,b,i;
    cin>>n>>a>>b;
    for(i=1;i<=n;i++)
     cin>>x[i]; 
    for(i=2;i<=n;i++)
     ans+=min((x[i]-x[i-1])*a,b);
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import math
N = input()
c = 0
p = [0 for i in range(N)]
for i in range(0,N):
	p[i] = input()
for i in range(N):
	s = math.sqrt(p[i])
	j = 2
	while(j <= s):
		if(p[i]%j == 0):
			break
		j += 1
	if(j > s):
		c += 1
print c

Measured memory_bytes: 5008
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    string s;
    int k;
    cin >> s >> k;
    
    vector<vector<vector<int>>> dp(s.size() + 1, vector<vector<int>>(s.size() + 1, vector<int>(k + 1, -1)));
    auto rec = [&](auto f, int l, int r, int m) -> int {
        if (dp[l][r][m] != -1) return dp[l][r][m];
        if (l == r) return dp[l][r][m] = 0;
        if (l + 1 == r) return dp[l][r][m] = 1;
        chmax(dp[l][r][m], f(f, l, r - 1, m));
        chmax(dp[l][r][m], f(f, l + 1, r, m));
        if (s[l] == s[r - 1]) chmax(dp[l][r][m], f(f, l + 1, r - 1, m) + 2);
        else if (m) chmax(dp[l][r][m], f(f, l + 1, r - 1, m - 1) + 2);
        return dp[l][r][m];
    };
    
    cout << rec(rec, 0, (int)s.size(), k) << "\n";
    return 0;
}


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

#define int long long

struct UnionFind {
  int n;
  vector<int> r, p;
  UnionFind() {}
  UnionFind(int sz) :
    n(sz), r(sz, 1), p(sz,0 ) { iota(p.begin(), p.end(), 0); }
  int find(int x) {
    return (x==p[x] ? x : p[x]=find(p[x]));
  }
  bool same(int x, int y) {
    return find(x)==find(y);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if ( x == y ) return;
    if ( r[x] < r[y] ) swap(x, y);
    r[x] += r[y];
    p[y] = x;
  }
};

signed main() {
  int n, q;
  cin >> n >> q;
  
  UnionFind uf(n);
  for ( int i = 0; i < q; i++ ) {
    int c, x, y;
    cin >> c>> x>> y;
    if ( c ) cout << uf.same(x, y) << endl;
    else uf.unite(x, y);
  }
  
  return 0;
}



Measured memory_bytes: 3216
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
struct node{
	LL b,l,r,c;
}a[100010];
LL n,X,sum=0,now,pos;
LL calc(LL x,LL k)
{
	if (k>a[x].b) return a[x].r*k-(a[x].r-a[x].l)*a[x].b;
	return a[x].l*k;
}
bool check(LL x)
{
	for(LL i=pos+1;i<=n;i++)
		if(now-a[pos].c+calc(i,x)>=sum) return true;
	for(LL i=1;i<=pos;i++)
		if(now-a[i].c+calc(i,x)>=sum) return true;
	return false;
}
bool cmp(node x,node y) {return x.c>y.c;}
int main()
{
	scanf("%lld %lld",&n,&X);
	for (LL i=1;i<=n;i++)	
	{
		scanf("%lld %lld %lld",&a[i].b,&a[i].l,&a[i].r);
		a[i].c=a[i].l*a[i].b+(X-a[i].b)*a[i].r;
		sum=sum+a[i].l*a[i].b;
	}
	sort(a+1,a+1+n,cmp);
	pos=0;now=0;
	for (LL i=1;i<=n;i++)
	{
		now=now+a[i].c;
		if(now>=sum) {pos=i;break;}
	}
	LL l=0,r=X,ans;
	while(l<=r)
	{
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans+(pos-1)*X);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        ans += (S[i] == T[i]);
    }
    cout << ans << endl;
}


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


void solve() {
  int N;
  scanf("%d", &N);

  cout << N+N*N+N*N*N << "\n";
}

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


Measured memory_bytes: 3764
N,K=map(int, input().split())
P=list(map(int, input().split()))
C=list(map(int, input().split()))

table=[0]*N
ans=-float("INF")
for i in range(N):
    L=[]
    count=0
    score=0
    max_score=-float("INF")
    now=i+1
    while count<K:
        now=P[now-1]
        add=C[now-1]
        score+=add
        max_score=max(score, max_score)
        L.append(add)
        count+=1
        if now==i+1:
            break
    #print("score", max_score)
    if sum(L)>0 and now==i+1:
        max_score=sum(L)*((K-count)//count)
        res=count+K%count
        score=max_score
        #print("max_score", max_score)
        #print("res", res)
        while res>0:
            now=P[now-1]
            add=C[now-1]
            score+=add
            max_score=max(score, max_score)
            res-=1
            
        
    
    #idx=(K-count)%len(L)
    #if idx!=0:
    #    score+=L[idx-1]
    #print("max_score", max_score)
    ans=max(ans, max_score)
    
print(ans)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int h, n, sum = 0;
	cin >> h >> n;
	while (n--) {
		int a;
		cin >> a;	
		sum += a;
	}
	if (h - sum <= 0) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N) cin >> d[i];
    
    int ans = 0;
    rep(i,N) rep(j,N) if(i > j) ans += d[i]*d[j];
    
    pr(ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll memo[1234][1234],dist[1234],c[1234];
bool done[1234][1234];

ll dp(int d, int p){
	if(done[d][p]){
		return memo[d][p];
	}
	done[d][p] = true;
	if(p == 0){
		memo[d][p] = 0ll;
		return memo[d][p];
	}else if(d == 0){
		memo[d][p] = INFLL;
		return memo[d][p];
	}
	memo[d][p] = min(dp(d-1,p),dp(d-1,p-1)+c[d-1]*dist[p-1]);
	memo[d][p] = min(memo[d][p],INFLL);
	return memo[d][p];
}

int main(void){
	int n,m,i;
	fill(done[0],done[1234],false);
	cin >> n >> m;
	for(i=0; i<n; ++i){
		cin >> dist[i];
	}
	for(i=0; i<m; ++i){
		cin >> c[i];
	}
	cout << (dp(m,n)) << endl;
	return 0;
}



Measured memory_bytes: 12212
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    trip  = input()
    logging.info("Hello!")

    if (not (("S" in trip) ^  ("N" in trip))) and (not (("E" in trip) ^  ("W" in trip))):
        print("Yes")
    else:
        print("No")
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
     long long X;
    cin >> X;
    for (int i=-1000; i<1000; i++) {
        for (int j=-1000; j<1000; j++) {
            if (pow(i,5)-pow(j,5)==X) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4080
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

bool solve(long long p, vector<long long> &A, vector<long long> &B, vector<long long> &C, int X, int Y, int Z, int K, vector<long long> &vec) {
    vec.clear();
    int count = 0;
    for(int a = 0; a < X; a++) {
        for(int b = 0; b < Y; b++) {
            for(int c = 0; c < Z; c++) {
                long long sum = A[a] + B[b] + C[c];
                if(sum < p) break;
                vec.push_back(sum);
                count++;
                if(count >= K) return true;
            }
        }
    }

    return false;
}

int main() {
    int X, Y, Z, K;
    vector<long long> A(1001, 0);
    vector<long long> B(1001, 0);
    vector<long long> C(1001, 0);

    cin >> X >> Y >> Z >> K;
    for(int i = 0; i < X; i++) cin >> A[i];
    for(int i = 0; i < Y; i++) cin >> B[i];
    for(int i = 0; i < Z; i++) cin >> C[i];

    sort(A.begin(), A.end(), greater<long long>());
    sort(B.begin(), B.end(), greater<long long>());
    sort(C.begin(), C.end(), greater<long long>());

    long long min_in_range = A[X-1] + B[Y-1] + C[Z-1];
    long long max_in_range = A[0] + B[0] + C[0];
    long long mid = (min_in_range + max_in_range) / 2;

    vector<long long> vec;

    while(min_in_range < max_in_range) {
        bool ret = solve(mid, A, B, C, X, Y, Z, K, vec);
        if(ret) {
            min_in_range = mid + 1;
        } else {
            max_in_range = mid;
        }
        mid = (min_in_range + max_in_range) / 2;
    }
    solve(min_in_range, A, B, C, X, Y, Z, K, vec);

    sort(vec.begin(), vec.end(), greater<long long>());
    for(int i = 0; i < K; i++) {
        if(i >= vec.size()) cout << min_in_range - 1 << endl;
        else cout << vec[i] << endl;
    }

    return 0;
}

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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }   
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;

int Row,Height;
int total_type;
bool flag_pos[101][101];
char dataSet[101][101];

void count_type (int start_x,int start_y,char bz_type)
{
	if (start_x > 0 && start_x <= Row && start_y > 0 && start_y <= Height && dataSet[start_x][start_y] == bz_type)
	{
		if (flag_pos[start_x][start_y] == false)
		{
			flag_pos[start_x][start_y] = true;
			count_type (start_x-1,start_y,bz_type);
			count_type (start_x+1,start_y,bz_type);
			count_type (start_x,start_y-1,bz_type);
			count_type (start_x,start_y+1,bz_type);
		}
	}
}

int main ()
{
	while (cin>>Row>>Height && Row !=0 && Height != 0)
	{
		total_type = 0;
		memset(flag_pos,true,sizeof(flag_pos[0][0]));
		for (int i=1;i<=Row;i++)
		{
			for (int j=1;j<=Height;j++)
			{
				cin>>dataSet[i][j];
				flag_pos[i][j] = false;
			}
		}
		for (int i=1;i<=Row;i++)
		{
			for (int j=1;j<=Height;j++)
			{
				if (flag_pos[i][j] == false)
				{
						count_type (i,j,dataSet[i][j]);
						total_type++;
				}
			}
		}
		cout<<total_type<<endl;
	}
	return 0;
}

Measured memory_bytes: 3296
#include <stdio.h>
#include <stdbool.h>

#define N_MAX 100
#define INF 1145141919
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int i, j;

int n, m;
int k;

ull t[N_MAX];
bool d[N_MAX][N_MAX];

void solve(){
	return;
}

int main (void) {
	ull x;
	ull a, b;
	ull time = 0;
	scanf("%llu", &n);
	for (i = 0; i < n; i++) {
		scanf("%llu", &t[i]);
		time += t[i];
	}
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		int p;
		ull x;
		scanf("%d%llu", &p, &x);
		printf("%llu\n", time - t[p-1] + x);
	}
	return 0;
}




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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int D, N;
    cin >> D >> N;
    int ans = 1;
    REP(i,D){
        ans *= 100;
    }
    if(N <= 99) ans *= N;
    else ans *= 101;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void){
	int n;
	int count = 0;
	int dp[101] = {};

	cin >> n;
	FOR(i, 1, n) {
		int d;
		cin >> d;
		dp[d]++;
	}
	FOR(i, 1, 100) {
		if (dp[i] >= 1) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");
function A(input: number[]): number {
    const a = input[0];
    const b = input[1];
    const t = input[2];
    return (((t + 0.5) / a) << 0) * b;
}

let input: string = "";
process.stdin.on("data", chunk => {
    input += chunk;
});
process.stdin.on("end", chunk => {
    console.log(A(input.split(" ").map(v => parseInt(v, 10))));
});

Measured memory_bytes: 7628
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
 
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 126876
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=1e6;
const long inf=1e9;
int main(){
	int x;
	rep(i,0,5){
		cin>>x;
		if(x == 0){ cout<<i+1<<endl; return 0; }
	}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------
bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }

    return true;
}

int main(void) {
  int x;
  cin >> x;

  while(!isPrime(x)){
    x++;
  }
  prt(x);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string str1,str2;

ll lcs(ll i,ll j,vector<vector<ll>>& dp)
{
    if(i<=0 || j<=0)
        return dp[i][j]=0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(str1[i]==str2[j] && (i!=str1.size() && j!=str2.size()))
    {
        dp[i][j]=1+lcs(i-1,j-1,dp);
    }
    else
    {
        dp[i][j]=max(dp[i][j],max(lcs(i-1,j,dp),lcs(i,j-1,dp)));
    }
    return dp[i][j];
    

}

void print(vector<vector<ll>>& dp)
{
    ll ans=lcs(str1.size(),str2.size(),dp);
    char str[ans+1];
    str[ans+1]='\0';
    ll i=str1.size();
    ll j=str2.size();
    while(i>0 && j>0)
    {
        if(str1[i]==str2[j])
        {
            str[ans]=str1[i];
            ans--;
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
        j--;
    }
    cout<<str<<endl;

}

int main()
{
    cin>>str1>>str2;
    str1="X"+str1;
    str2="Y"+str2;
    ll n=str1.size();
    ll m=str2.size();
    vector<vector<ll>>dp(n+1,vector<ll>(m+1,-1));
    print(dp);
}

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

/* {{{ */
#define PI(N) (M_PI * (N)) / 180 //?§???????????????¢??????????????????
#define CL(N) cout << (N) << endl
#define DCT(N) cout << "debug " << (N) << endl
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    int l, a, sum_angle = 90;
    double x, y;

    x = y = 0.0;

    while (scanf("%d,%d", &l, &a), l || a){
        x += l * cos(PI(sum_angle));
        y += l * sin(PI(sum_angle));

        sum_angle = (sum_angle - a) % 360;
    }

    CL((int)x);
    CL((int)y);

    return (0);
}

Measured memory_bytes: 3508