akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
#define pii pair<lli,lli>
#define vi vector <lli>
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y);
lli modInverse(lli b, lli m)
{
    lli x, y;
    lli g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x%m + m) % m;
}
lli modDivide(lli a, lli b, lli m)
{
    a = a % m;
    lli inv = modInverse(b, m);
    return (inv * a) % m;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    lli x1, y1;
    lli gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    lli ans=0;
    if(n%1000>0){
    	ans=ans+(1000-n%1000);
	}
	cout<<ans;
    return 0;
}


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

using namespace std;

int main() {
  int num_switch, num_light;
  cin >> num_switch >> num_light;

  vector<vector<int>> light2switches(num_light, vector<int>());
  for (int li = 0; li < num_light; li++) {
    int K;
    cin >> K;
    light2switches[li].resize(K);
    for (int si = 0; si < K; si++) {
      cin >> light2switches[li][si];
      light2switches[li][si]--;
    }
  }

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

  int answer = 0;
  for (int pattern = 0; pattern < (1 << num_switch); pattern++) {
    bool ok = true;
    for (int li = 0; li < num_light; li++) {
      int connected = 0;
      for (int si : light2switches[li]) {
	if (pattern & (1 << si)) {
	  connected++;
	}
      }

      if (P[li] != (connected % 2)) {
	ok = false;
      }
    }

    if (ok) {
      answer++;
    }
  }


  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
#import sympy

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
ans = 1

#dic = sympy.factorint(n)
arr = factorization(n)

cnt  = 1
ans = 0
flag = False
while True:
  for k in arr:
    if k[1] >= cnt:
      k[1] -= cnt
      ans += 1
      flag = True
  if not flag:
    break
  cnt += 1
  flag = False

if n == 1:
  print(0)
else:
  print(ans)

Measured memory_bytes: 9504
/*
 * @Author: Kaizyn
 * @Date: 2020-08-27 18:34:19
 * @LastEditTime: 2020-08-27 20:41:19
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 2e5+7;
const int M = 1e6+7;

int n;
string s[N];
int nex[M][26], num[M][26], tot;

void insert(const string &s) {
  static int cnt[26];
  // memset(cnt, 0, sizeof cnt);
  for (const char &c : s) ++cnt[c-'a'];
  int p = 0;
  for (int i = s.size()-1, c; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) if (cnt[j]) ++num[p][j];
    c = s[i]-'a';
    if (!nex[p][c]) nex[p][c] = ++tot;
    p = nex[p][c];
    --cnt[c];
  }
}

int query(const string &s) {
  int p = 0;
  for (int i = s.size()-1, c; i; --i) {
    c = s[i]-'a';
    if (!nex[p][c]) return 0;
    p = nex[p][c];
  }
  return num[p][s[0]-'a']; // minus itself
}

inline void solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
  }
  sort(s+1, s+n+1, [](const string &s1, const string &s2) {
    return s1.size() < s2.size();
  });
  for (int i = 1; i <= n; ++i) {
    insert(s[i]);
  }
  long long res = -n; // (i, -i)
  for (int i = 1; i <= n; ++i) {
    res += query(s[i]);
  }
  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, Q;
string s;
void solve(){
	cin >> n;
	cin >> s;
	cin >> Q;
	
	for(int t = 0; t < Q; t++){
		int k = 0;
		cin >> k;
		i64 a=0,b=0,c=0;
		i64 cnt = 0;
		for(int i = 0; i < n; i++){
			if(i >= k){
				if(s[i-k] == 'D'){
					c-=b;
					a--;
				}
				if(s[i-k] == 'M') b--;
			}
			if(s[i] == 'D') a++;
			if(s[i] == 'M'){ b++; c+=a; }
			if(s[i] == 'C') cnt += c;
		}
		cout << cnt << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1948
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
// const double PI=3.1415926535897932;

//#define __DBG__


void solve(void){
  
  int N, K;
  
  cin >> N >> K;
  
  vector<int> h(N);
  
  int ans=0;
  
  REP(i,N){
    cin >> h[i];
    if(h[i]>=K){
      ans++;
    }
  }
 
  cout << ans << endl; 

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}




Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    S n;
    cin >> n;
    vi a;
    rp(i,n.size()-2){
        a.pb((n.at(i)-'0')*100+(n.at(i+1)-'0')*10+n.at(i+2)-'0');
    }
    int Min=INT_MAX;
    rp(i,a.size()){
        Min=min(Min,abs(a.at(i)-753));
    }
    cout << Min << endl;

    return 0;
}


Measured memory_bytes: 256
# XORだと思っていた ORだった
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

ans = 0
for a, b in ab:
    if a | k == k:
        ans += b
for i in range(30):
    if k & 1<<i != 1<<i:
        continue
    #print(~(1<<(i+1) - 1))
    l = k^(1<<i) | (1<<i) - 1
    #print(bin(l))
    s = 0
    for a, b in ab:
        if a | l == l:
            s += b
    ans = max(ans, s)
print(ans)

Measured memory_bytes: 27380
import java.util.*;
 
class Main {
    static Scanner sc;
    static int n, m;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();

        UnionFindTree uft = new UnionFindTree(n);
        for (int i = 0; i < m; i++) {
            int x, y;
            x = sc.nextInt() - 1;
            y = sc.nextInt() - 1;
            uft.unite(x, y);
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans = Math.max(uft.getGroupSize(i), ans);
        }
        System.out.println(ans);
    }
}

class UnionFindTree {
    int size;
    int groupNum;
    int[] parents;
    int[] heights;
    int[] groupSizes;
    
    UnionFindTree(int size) {
        parents = new int[size];
        heights = new int[size];
        groupSizes = new int[size];
        for (int i = 0; i < size; i++) {
            parents[i] = i;
            heights[i] = 0;
            groupSizes[i] = 1;
        }
        groupNum = size;
    }

    public void unite(int x, int y) {
        int x_root = findRoot(x);
        int y_root = findRoot(y);

        if (x_root == y_root) {
            return;
        }

        if (heights[x_root] > heights[y_root]) {
            parents[y_root] = x_root;
            groupSizes[x_root] += groupSizes[y_root];
        } else if (heights[x_root] < heights[y_root]) {
            parents[x_root] = y_root;
            groupSizes[y_root] += groupSizes[x_root];
        } else {
            parents[y_root] = x_root;
            heights[x_root]++;
            groupSizes[x_root] += groupSizes[y_root];
        }
        groupNum--;
    }

    public Boolean is_equiv(int x, int y) {
        return findRoot(x) == findRoot(y);
    }

    public int getGroupSize(int x) {
        return groupSizes[x];
    }

    int findRoot(int x) {
        ArrayList<Integer> paths = new ArrayList<Integer>();
        int crt = x;
        while (parents[crt] != crt) {
            paths.add(crt);
            crt = parents[crt];
        }
        for (Integer v: paths) {
            parents[v] = crt;
        }
        heights[crt] = 1;
        return crt;
    }
}

Measured memory_bytes: 53016
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(10**6)
while 1:
	a, d, n = map(int, raw_input().split(" "))
	if (a,d,n) == (0,0,0):
		break
	count = 0
	number = a - d
	while count < n :
		number += d
		if prime[number] == 1:
			count += 1
	print number

Measured memory_bytes: 44008
#include <bits/stdc++.h>
using namespace std;
#define int long long

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, k;
    cin >> n >> k;

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

    int min_mon = -1;
    for(int b=0; b<(1<<n); b++){
        if(__builtin_popcount(b) < k) continue;
        int tempb = b;
        int height = 0, mon = 0;
        for(int i=0; i<n; i++){
            if(a[i] > height){
                // i 番目はもう見えている
                height = a[i];
            }
            else{
                if(tempb % 2 == 1){
                    // i 番目を見えるようにする
                    if(a[i] <= height){
                        height++;
                        mon += (height - a[i]);
                    }
                }
            }
            tempb /= 2;
        }
        if(min_mon == -1 || min_mon > mon){
            min_mon = mon;
        }
    }
    cout << min_mon << endl;

    return 0;
}


Measured memory_bytes: 3460
#include <iostream>

using namespace std;

int n;
int memo[100005];

int calc(int x)
{
	if(memo[x] != -1) return memo[x];
	if(x == 0) return 0;
	
	int ret = calc(x-1) + 1;
	int mul = 1;
	while(mul <= x){
		ret = min(ret, calc(x-mul) + 1);
		mul *= 6;
	}
	mul = 1;
	while(mul <= x){
		ret = min(ret, calc(x-mul) + 1);
		mul *= 9;
	}
	
	return memo[x] = ret;
}

int main(void)
{
	cin >> n;
	for(int i = 0; i <= n; i++) memo[i] = -1;
	
	cout << calc(n) << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
template<typename T = int, T mod = 1'000'000'007, typename U = long long>
struct umod{
    T val;
    umod(): val(0){}
    umod(U x){ x %= mod; if(x < 0) x += mod; val = x;}
    umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
    umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
    umod& operator *= (umod oth){ val = ((U)val) * oth.val % mod; return *this; }
    umod& operator /= (umod oth){ return *this *= oth.inverse(); }
    umod& operator ^= (U oth){ return *this = pwr(*this, oth); }
    umod operator + (umod oth) const { return umod(*this) += oth; }
    umod operator - (umod oth) const { return umod(*this) -= oth; }
    umod operator * (umod oth) const { return umod(*this) *= oth; }
    umod operator / (umod oth) const { return umod(*this) /= oth; }
    umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
    bool operator < (umod oth) const { return val < oth.val; }
    bool operator > (umod oth) const { return val > oth.val; }
    bool operator <= (umod oth) const { return val <= oth.val; }
    bool operator >= (umod oth) const { return val >= oth.val; }
    bool operator == (umod oth) const { return val == oth.val; }
    bool operator != (umod oth) const { return val != oth.val; }
    umod pwr(umod a, U b) const { umod r = 1; for(; b; a *= a, b >>= 1) if(b&1) r *= a; return r; }
    umod inverse() const {
        U a = val, b = mod, u = 1, v = 0;
        while(b){
            U t = a/b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        if(u < 0)
            u += mod;
        return u;
    }
};
using U = umod<>;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<U> harm(n);
	for(int i = 1; i < n; i++) harm[i] = harm[i - 1] + U(1) / i;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	U ans = 0;
	for(int i = 1; i < n; i++) ans += harm[i] * (a[i] - a[i - 1]);
	for(int i = 1; i < n; i++) ans *= i;
	cout << ans.val << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    int in[n] = {};
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        in[y]++;
    }

    int dist[n] = {};
    int mx = -1;
    bool visited[n] = {};
    rep(i, 0, n) {
        if (in[i] == 0 && !visited[i]) {
            queue<int> que;
            que.push(i);
            visited[i] = true;
            while (!que.empty()) {
                int now = que.front();
                que.pop();
                for (int next : g[now]) {
                    in[next]--;
                    if (in[next] == 0) {
                        que.push(next);
                        visited[next] = true;
                    }
                    dist[next] = max(dist[next], dist[now] + 1);
                    mx = max(mx, dist[next]);
                }
            }
        }
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>

#define MODNUM 1000000007

long long modpow(long long a, long long n, long long mod){
	long long result = 1;
	while(n > 0){
		if(n & 1){
			result = result * a % mod;
		}
		a = a * a % mod;
		n /= 2;
	}

	return result;
}

long long modinv(long long a, long long mod){
	return modpow(a, mod - 2, mod);
}

int main(){
	int n, k;
	long long ans;
	long long fc1, fc2, fm, finv;
	int i, min;

	scanf("%d %d", &n, &k);

	min = (k < n) ? k : n;
	ans = 1;
	fc1 = n;
	fc2 = n-1;
	fm = 1;
	finv = modinv(fm, MODNUM);
	ans += ((fc1 * finv % MODNUM) * (fc2 * finv % MODNUM)) % MODNUM;
	ans %= MODNUM;
	for(i=2; i<=min; i++){
		fc1 = fc1 * (n-i+1) % MODNUM;
		fc2 = fc2 * (n-i) % MODNUM;
		fm = fm * i % MODNUM;
		finv = modinv(fm, MODNUM);
		ans += ((fc1 * finv % MODNUM) * (fc2 * finv % MODNUM)) % MODNUM;
		ans %= MODNUM;
	}

	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdtr1c++.h>

using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 1e5 + 10;
const int maxM = 1e6 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

struct Point {
    vector <int> X;
};
int Dist(Point A, Point B) {
    int n = (int)A.X.size();
    int Res = 0;
    for (int i = 0; i < n; i++) {
        int x = A.X[i] - B.X[i];
        Res += x * x;
    }
    return Res;
}
bool Check(int x) {
    return (int)sqrt(x) == sqrt(x);
}
void solve() {
    int n, D;
    cin >> n >> D;
    Point a[n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < D; j++) {
            int x;
            cin >> x;
            a[i].X.push_back(x);
        }
    }
    int Res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int KC = Dist(a[i], a[j]);
            Res += Check(KC);
        }
    }
    cout << Res;
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

bool visited[100010] = {};
struct choten{
    ll pnt = -1;
    ll ance = 0;
    vector<ll> chld;
};
choten c[100010];

void dfs(ll x, ll y){
    c[x].pnt = y;
    visited[x] = true;
    rep(i, c[x].chld.size())c[c[x].chld[i]].ance--;
    rep(i, c[x].chld.size())if(c[c[x].chld[i]].ance==0&&!visited[c[x].chld[i]])dfs(c[x].chld[i], x);
}

int main(){
   ll n, m;
   cin >> n >> m;
   rep(i, n+m-1){
       ll a, b;
       cin >> a >> b;
       c[a].chld.push_back(b);
       c[b].ance++;
   }
   ll bigdaddy;
   rep(i, n)if(c[i+1].ance == 0){
       bigdaddy = i+1;
       break;
   }
   dfs(bigdaddy, 0);
   rep(i, n)cout << c[i+1].pnt << endl;
}

Measured memory_bytes: 12672
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,a,b,c,l[10],ans;
void dfs(int x,int A,int B,int C,int s)
{
    if(x > n)
    {
        if(A && B && C) ans = min(ans,s+abs(a-A)+abs(b-B)+abs(c-C));
        return;
    }
    dfs(x+1,A,B,C,s);
    dfs(x+1,A+l[x],B,C,s+10*(A > 0));
    dfs(x+1,A,B+l[x],C,s+10*(B > 0));
    dfs(x+1,A,B,C+l[x],s+10*(C > 0));
}
int main ()
{
    ans = 1000000000;
    scanf("%d %d %d %d", &n, &a, &b, &c);
    for(int i = 1;i <= n;i++) scanf("%d",&l[i]);
    dfs (1,0,0,0,0);
    printf("%d",ans);
    return 0;
}

#endif // 1++

Measured memory_bytes: 256
/**
 *  Author: Wasi Ur Rahman
 *  FROM RMSTU
**/
#include <bits/stdc++.h>
#define    fast    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
#define ll long long
int main()
{
    fast;
    int n,m;
    cin >> n >> m;

    if(m >= n)
        cout << "unsafe" << endl;
    else cout << "safe\n";
    return 0;
}



Measured memory_bytes: 3652
if __name__ == '__main__':
    input_list = list(map(int, input().split()))
    N = input_list[0]
    M = input_list[1]

    AB = [list(map(int, input().split())) for i in range(N)]

    sorted_AB = sorted(AB, key=lambda x:x[0])

    answer = 0
    cnt = 0
    for e in sorted_AB:
        pre_cnt = cnt

        Ai = e[0]
        Bi = e[1]

        cnt = min(M, cnt+Bi)
        answer += Ai * (cnt - pre_cnt)

        if cnt == M:
            break

    print(answer)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)

const int N = ((int)1e5) + 5;

long long int a,b,c;
long long int tot;

int main ()
{
	scanf("%lld %lld %lld",&a,&b,&c);
	tot = a * b * c;
	if (tot % 2 == 0)
		return printf("0"),0;
	printf("%lld",min(a * b,min(b * c,a * c)));
}

Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 23.08.2020 19:14:26
**/

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
typedef long long ll;
#define mod 1000000007
using namespace std;

int main() {

    int n;
    cin >> n;
    vector<tuple<int,int>> p(n),q(n*(n+1)/2);
    int x,y;
    rep(i,n){
        cin >> x >> y;
        p[i]=make_tuple(x,y);
    }

    sort(all(p));
    int cost=0,count=0;
    int k=0;

    for(int i=0; i<n-1; i++){
        for(int j=n-1; j>i; j--){
            q[k]=make_tuple<int,int>(get<0>(p[j])-get<0>(p[i]),get<1>(p[j])-get<1>(p[i]));
            k++;
        }
    }

    for(int i=0; i<n*(n-1)/2; i++){
        for(int j=0; j<n*(n-1)/2; j++){
            if(q[i]==q[j]) count++;
        }
        cost=max(cost,count);
        count=0;
    }

    cout << n-cost << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	long long n, c, k; cin >> n >> c >> k;
	vector<long long> a(n);
	for(auto &i : a) cin >> i;	

	sort(a.begin(), a.end());
	
	long long res = 0, l = 0;
	for(long long i = l; i < n; i = l){
		long long ans = 1, cur = a[i] + k;
		for(l = i + 1; l < n && ans < c && cur >= a[l]; l++){
			ans++;	
		}
		res += (ans > 0);
	}
	
	cout << res;;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,m;
    cin>>n;
    m=sqrt(n);
    cout<<m*m<<endl;



    return 0;
}


Measured memory_bytes: 3660
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int INF = 2000000000;
int d[100][100];
int main() {
	int n, e;
	cin >> n >> e;
	fill(d[0], d[100], INF);
	for (int i = 0; i < n; i++)
		d[i][i] = 0;
	for (int i = 0; i < e; i++) {
		int s, t, dis; cin >> s >> t >> dis;
		d[s][t] = dis; 
	}
	for (int k = 0; k < n; k++)
		for (int i = 0; i < n; i++) {
			if (d[i][k] == INF) continue;
			for (int j = 0; j < n; j++) {
				if (d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	for (int i = 0; i < n; i++)
		if (d[i][i] < 0) { puts("NEGATIVE CYCLE"); return 0; }
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j != 0) cout << " ";
			if(d[i][j] < INF)cout << d[i][j];
			else cout << "INF";
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

const int N=2e5+5;

int n;
string s;
long long pwm[N],pwp[N];
int mem[N];

int get(int x)
{
	if(mem[x]!=-1) return mem[x];
	if(x==0) return 0;
	return mem[x]=1+get(x%__builtin_popcount(x));
}

int main()
{
	cin >> n >> s;
	int cnt=count(s.begin(),s.end(),'1');
	int m=cnt-1,p=cnt+1;
	if(m==-1)
	{
		for(int i=0;i<n;i++) cout << 1 << endl;
		return 0;
	}
	pwm[0]=m?1:0;
	pwp[0]=1;
	for(int i=1;i<=n;i++)
	{
		pwp[i]=(2*pwp[i-1])%p;
		if(m) pwm[i]=(2*pwm[i-1])%m;
		else pwm[i]=0;
	}
	long long pv=0,mv=0;
	for(int i=0;i<n;i++)
	{
		pv+=pwp[n-i-1]*(s[i]=='1');
		pv%=p;
		mv+=pwm[n-i-1]*(s[i]=='1');
		if(m) mv%=m;
	}
	memset(mem,-1,sizeof mem);
	for(int i=0;i<n;i++)
	{
		if(s[i]=='1')
		{
			if(!m) cout << 0 << endl;
			else cout << 1+get((mv-pwm[n-i-1]+m)%m) << endl;
		}
		else
		{
			cout << 1+get((pv+pwp[n-i-1])%p) << endl;
		}
	}
}

Measured memory_bytes: 7608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    const ll mod = 1e9 + 7;
    string s;
    cin >> s;
    ll n = s.size();
    Arr q;
    ll dst = 5;
    forr(i, n - 1, 0)
    {
        static ll w = 1;
        if(s[i] != '?')
            dst = (dst + 13000 - (s[i] - '0') * w) % 13;
        else
            q.push_back(w);
        w = (w * 10) % 13;
    }
    if(q.empty()) return cout << (dst == 0), 0;
    Mat dp(2, Arr(13, 0));
    forn(i, 10) dp[0][(i * q[0]) % 13]++;
    fori(i, 1, q.size())
    {
        forn(j, 13) dp[i % 2][j] = 0;
        forn(j, 10) forn(k, 13)
            (dp[i % 2][(j * q[i] + k) % 13] += dp[(i - 1) % 2][k % 13]) %= mod;
    }
    cout << dp[(q.size() - 1) % 2][dst];
    return 0;
}

Measured memory_bytes: 1528
#include<iostream>
#include<map>
#include<algorithm>

using namespace std;

int main(void){
    int N;
    cin >> N;
    map<long long, int> m;
    for(int i=0; i<N; i++){
        int x;
        cin >> x;
        if(m.count(x)) m[x]++;
        else m.insert(make_pair(x, 1));
    }

    long long a = 0, b = 0;

    for(auto i = m.rbegin(); i != m.rend(); i++) {
        if(i->second >= 2){
            i->second -= 2;
            a = i-> first;
            break;
        }
    }

    for(auto i = m.rbegin(); i != m.rend(); i++) {
        if(i->second >= 2){
            i->second -= 2;
            b = i-> first;
            break;
        }
    }

    cout <<  a*b << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, LIM; scanf("%d %d", &N, &LIM);
  vector<int> W(N), V(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &W[i], &V[i]);
  }

  vector<vector<int>> dp(N + 5, vector<int>(305, 0));
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    int diff = W[i] - W[0];
    sum += diff;
    for (int p = i + 1; p >= 1; --p) {
      for (int j = 0; j <= sum; ++j) {
        if (j - diff >= 0) {
          dp[p][j] = max(dp[p][j], dp[p - 1][j - diff] + V[i]);
        }
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= sum; ++j) {
      if (1LL* i * W[0] + j <= LIM) {
        ans = max(ans, dp[i][j]);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
#n>=25なら鳩ノ巣で0
#2人以上居るdは一意
#あとはしらみつぶし

n = int(input())
if n>=25:
    print(0)
    exit()

d = list(map(int, input().split( )))
if 0 in d:##
    print(0)
    exit()
d.append(0)
dic = {}

for di in d:
    if di in dic:
        dic[di] += 1
    else:
        dic[di]= 1
solo = []
times = []
for di in dic:
    if dic[di]==1:#di=0はここに入る
        solo.append(di)
    elif dic[di]==2:
        times.append(di)
        if di!=12:
            times.append(24-di)
        else:
            print(0)
            exit()
    else:
        print(0)
        exit()
        
ans = 0
m = len(solo)
bit = 1<<m

for i in range(bit):
    times2 = []
    for t in times:
        times2.append(t)
    for j in range(m):
        if i>>j&1:
            times2.append(solo[j])
        else:####???
            times2.append(24-solo[j])
    times2.sort()
    dif = 24
    if len(times2)==1:###
        print(0)
        exit()
    #print(times2)

    for k in range(len(times2)-1):
        dif = min(dif,times2[k+1]-times2[k])
    dif = min(dif,times2[0] + 24 - times2[-1])
    ans = max(ans,dif)
print(ans)
 


Measured memory_bytes: 41712
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N, L; cin >> N >> L;

    Int sum = 0;
    Int minAbs = 1LL<<60;
    bool isPositive = true;

    rep(i, 1, N+1) {
        Int now = L-1+i;
        sum += now;
        if (minAbs > abs(now)) {
            minAbs = abs(now);
            if (now < 0) isPositive = false;
        }
    }

    Int res;
    if (isPositive) res = sum-minAbs;
    else res = sum+minAbs;
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN=3e5+10;
int n,pre[MAXN][20],lg[MAXN],deep[MAXN],m,dis,sum[MAXN],ans[MAXN],tot[MAXN];
struct node{
	int ed,v,co;
};
vector<node> G[MAXN];
struct que{
	int pos,co,val,id;
};
vector<que> Q[MAXN];
void DFS0(int x,int fa){
	//cout<<dis<<" "<<x<<endl;
	for(int i=0;i<Q[x].size();i++){
		ans[Q[x][i].id]+=Q[x][i].pos*(dis-tot[Q[x][i].co]+sum[Q[x][i].co]*Q[x][i].val);
	}
	for(int i=0;i<G[x].size();i++){
		int t=G[x][i].ed;
		if(t==fa)continue;
		dis+=G[x][i].v;
		sum[G[x][i].co]++;
		tot[G[x][i].co]+=G[x][i].v;
		DFS0(t,x);
		dis-=G[x][i].v;
		sum[G[x][i].co]--;
		tot[G[x][i].co]-=G[x][i].v;
	}
}
void DFS(int x,int fa){
	pre[x][0]=fa;
	deep[x]=deep[fa]+1;
	for(int i=1;(1<<i)<=deep[x];i++)pre[x][i]=pre[pre[x][i-1]][i-1];
	for(int i=0;i<G[x].size();i++){
		int t=G[x][i].ed;
		if(t==fa)continue;
		DFS(t,x);
	}
}
int LCA(int x,int y) {
    if(deep[x]<deep[y])swap(x,y);
    while(deep[x]>deep[y])x=pre[x][lg[deep[x]-deep[y]]-1];
    if(x==y)return x;
    for(int i=lg[deep[x]]-1; i>=0; i--) {
        if(pre[x][i]==pre[y][i])continue;
        x=pre[x][i],y=pre[y][i];
    }
    return pre[x][0];
}
signed main(){
	scanf("%lld %lld",&n,&m);
	for(int i=1;i<=MAXN-10;i++)lg[i]=lg[i-1]+((1<<lg[i-1])==i);
	for(int i=1;i<=n-1;i++){
		int st,ed,v,co;
		scanf("%lld %lld %lld %lld",&st,&ed,&co,&v);
		G[st].push_back(node{ed,v,co});
		G[ed].push_back(node{st,v,co});
	}
	DFS(1,0);
	for(int i=1;i<=m;i++){
		int co,val,x,y;
		scanf("%lld %lld %lld %lld",&co,&val,&x,&y);
		Q[x].push_back(que{1,co,val,i});
		Q[y].push_back(que{1,co,val,i});
		Q[LCA(x,y)].push_back(que{-2,co,val,i});
//		cout<<LCA(x,y)<<endl;
	}
	DFS0(1,0);
	for(int i=1;i<=m;i++)printf("%lld\n",ans[i]);
	return 0;
}
	//freopen("tst.txt","r",stdin);
	//freopen("sans.txt","w",stdout);


Measured memory_bytes: 68976
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;

ll mod=1e9+7;
int main()
{
//    ios::sync_with_stdio(0);
    ll n;
    cin>>n;
    ll ar[n+10];
    ll br[n+10];
    for(ll i=0; i<n; i++)
    {
        cin>>ar[i];
        br[i]=ar[i];
    }
    for(ll i=1; i<n; i++)
    {
        ar[i]=(ar[i]+ar[i-1])%mod;
    }
    ll ans=0;
    for(ll i=0; i<n-1; i++)
    {
        ll k=(ar[n-1]-ar[i]+mod)%mod;
        // cout<<ar[i]<<ss;
        //cout<<k*ar[i]<<ss;
        ans=(ans+(br[i]*k)%mod)%mod;
    }
    cout<<ans<<nn;


}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 6756
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    vector<char> s(3);
    VIin(s);
    SORT(s);
    if(s[0] == 'a' && s[1] == 'b' && s[2] == 'c') Yes;
    else No;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string p[h];
    for(int i=0;i<h;i++){
        cin >> p[i];
    }
    bool jadge=0;
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(p[j][i]=='#'){
                if(j==0 && i==0){
                    if(p[0][1]=='.' && p[1][0]=='.'){
                        jadge=1;
                    }
                }
                else if(j==0 && i==h-1){
                    if(p[h-1][1]=='.' && p[h-2][0]=='.'){
                        jadge=1;
                    }
                }
                else if(j==w-1 && i==0){
                    if(p[0][w-2]=='.' && p[1][w-1]=='.'){
                        jadge=1;
                    }
                }
                else if(j==w-1 && i==h-1){
                    if(p[h-1][w-2]=='.' && p[h-2][w-1]=='.'){
                        jadge=1;
                    }
                }
                else if(i==0 && (j!=0 || j!=w-1)){
                    if(p[j-1][0]=='.' && p[j+1][0]=='.' && p[j][1]=='.'){
                        jadge=1;
                    }
                }
                else if(j==0 && (i!=0 || i!=h-1)){
                    if(p[j][i-1]=='.' && p[j][i+1]=='.' && p[j+1][i]=='.'){
                        jadge=1;
                    }
                }
                else if(j==w-1 && (i!=0 || i!=h-1)){
                    if(p[j][i-1]=='.' && p[j][i+1]=='.' && p[j-1][i]=='.'){
                        jadge=1;
                    }
                }
                else if(i==h-1 && (j!=0 || j!=w-1)){
                    if(p[j-1][i]=='.' && p[j+1][i]=='.' && p[j][i-1]=='.'){
                        jadge=1;
                    }
                }
 
                else if(p[j+1][i]=='.' && p[j-1][i]=='.' && p[j][i+1]=='.' && p[j][i-1]=='.'){
                    jadge=1;
                }
            }
            else continue;
 
            if(jadge==1){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N];
int main()
{
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	ll ans = 0;
	for(int l = 0; l <= k; l ++)
	{
		for(int r = 0; r <= k; r ++)
		{
			if(l + r > k || l >= n -  r + 1)
				continue;
			ll s = 0;
			vll fo, ho;
			for(int j = 1; j <= l; j ++)
				fo.pb(a[j]),s += a[j];
			for(int j = n - r + 1; j <= n; j ++)
				fo.pb(a[j]), s += a[j];
			sort all(fo);
			ll cnt = k - l -r;
			for(auto it : fo)
			{
				if(it > 0 || cnt == 0)
					break;
				cnt --;
				s -= it;
			}
			umax(ans, s);
		}
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#define print(x) printf("%d\n",x)

typedef unsigned int uint;

typedef long long ll;

#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int n;
int m;
int s;
int t;

vector<pair<int, ll> > d[100000];
const ll mod = 1000000007;

void f(int s, int t, vector<ll> &dist, vector<int> &path, vector<ll> &cnt){
  typedef pair<ll, int> data;

  {
    priority_queue<data, vector<data>, greater<data> > pq;
    pq.push(data(0, s));
    while(pq.size()){
      const data dd = pq.top(); pq.pop();
      const ll cost = dd.first;
      const int pos = dd.second;
      if(dist[pos] != -1) continue;
      dist[pos] = cost;
      for(const auto p : d[pos]){
        const int next = p.first;
        const ll cc = cost + p.second;
        if(dist[next] == -1) pq.push(data(cc, next));
      }
    }
  }

  {
    priority_queue<data> pq;
    cnt[t] = 1;
    pq.push(data(dist[t], t));
    while(pq.size()){
      const data dd = pq.top(); pq.pop();
      const int pos = dd.second;
      if(path[pos]) continue;
      path[pos] = 1;
      for(const auto p : d[pos]){
        const int next = p.first;
        const ll cc = p.second;
        if(dist[next] + cc == dist[pos]){
          cnt[next] = (cnt[next] + cnt[pos]) % mod;
          pq.push(data(dist[next], next));
        }
      }
    }
  }
}



int main(){
  n = getInt();
  m = getInt();
  s = getInt() - 1;
  t = getInt() - 1;

  REP(i,m){
    const int u = getInt() - 1;
    const int v = getInt() - 1;
    const int dd = getInt();
    d[u].push_back(make_pair(v, dd));
    d[v].push_back(make_pair(u, dd));
  }

  vector<ll> stdist(n, -1);
  vector<int> stpath(n, 0);
  vector<ll> stcnt(n, 0);

  vector<ll> tsdist(n, -1);
  vector<int> tspath(n, 0);
  vector<ll> tscnt(n, 0);

  f(s, t, stdist, stpath, stcnt);
  f(t, s, tsdist, tspath, tscnt);

  /*
  REP(i,n) printf("%2lld ", stdist[i]); puts("");
  REP(i,n) printf("%2d ", stpath[i]); puts("");
  REP(i,n) printf("%2lld ", stcnt[i]); puts("");
  puts("---");
  REP(i,n) printf("%2lld ", tsdist[i]); puts("");
  REP(i,n) printf("%2d ", tspath[i]); puts("");
  REP(i,n) printf("%2lld ", tscnt[i]); puts("");
  */


  ll ans = (stcnt[s] * tscnt[t]) % mod;
  // printf("%lld\n", ans);
  const ll dist = stdist[t];
  // if(stdist[t] != tsdist[s]) puts("bug");

  if(dist % 2 == 0){
    REP(i,n) if(stdist[i] == dist / 2){
      const ll c = (stcnt[i] * tscnt[i]) % mod;
      ans = (ans + mod - (c * c) % mod) % mod;
    }
  }

  REP(i,n){
    for(const auto e : d[i]){
      const int cur = i;
      const int next = e.first;
      if(stdist[cur] * 2 < dist && dist < stdist[next] * 2){
        if(stdist[cur] + e.second == stdist[next]) {
          const ll c = (stcnt[next] * tscnt[cur]) % mod;
          // printf("test %d %d: %lld\n", cur, next, c);
          ans = (ans + mod - (c * c) % mod) % mod;
        }
      }
    }
  }

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

  return 0;
}


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

ans = float('inf')
for i in range(1, N//2+1):
  a = i
  b = N - a
  digitSumA = digitSumB = 0
  for i in range(6):
    digitSumA += a % 10
    a //= 10
    digitSumB += b % 10
    b //= 10
  ans = min(ans, digitSumA + digitSumB)
print(ans)

Measured memory_bytes: 3060
n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    des = 0
    if l[i] + l[i - 1] > x:
        des = (l[i] + l[i - 1]) - x
        if l[i] >= des:
            l[i] -= des
        else:
            l[i] = 0
            l[i - 1] -= (des - l[i])
    ans += des
print(ans)

Measured memory_bytes: 14540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int dp[411111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int L; cin>>L;
	string s,t;
	cin>>s>>t;
	dp[0] = 1;
	for(int i=1;i<=L;i++)
	{
		if(i>=s.length()) dp[i]|=dp[i-s.length()];
		if(i>=t.length()) dp[i]|=dp[i-t.length()];
	}
	if(s.length()>t.length()) swap(s,t);
	bool ispref=1;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		{
			ispref=0; break;
		}
	}
	if(!ispref)
	{
		if(s>t) swap(s,t);
	}
	else
	{
		string t2=t+t;
		for(int i=0;i<t2.length();i++)
		{
			if(s[i%int(s.length())]!=t2[i])
			{
				if(s[i%int(s.length())]>t2[i])
				{
					swap(s,t); 
				}
				break;
			}
		}
	}
	string cur="";
	while(cur.length()<L)
	{
		int l = cur.length();
		if(l+int(s.length())<=L)
		{
			if(dp[L-l-int(s.length())])
			{
				cur+=s;
				continue;
			}
		}
		cur+=t;
	}
	cout<<cur<<'\n';
}	


Measured memory_bytes: 1864
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int data[N+1][3];
	int i;
	data[0][0] = 0;
	data[0][1] = 0;
	data[0][2] = 0;
	for(i=1;i<N+1;i++){
		scanf("%d %d %d",&data[i][0],&data[i][1],&data[i][2]);
		int dT = data[i][0] - data[i-1][0];
		int dR = data[i][1] - data[i-1][1] +data[i][2] - data[i-1][2];
		if(dT < dR || (dT-dR)%2 == 1){printf("No");return 0;}
	}
	printf("Yes");
	
	return 0;
}

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

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

    int N;
    cin >> N;
    int64_t ret = 0;
    int B, prev;
    for (int i = 0; i < N - 1; i++) {
        cin >> B;
        if (i == 0) {
            ret += B;
            prev = B;
            continue;
        }
        if (i > 0) {
            ret += min(prev, B);
            prev = B;
        }
    }
    ret += B;
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] c = new int[n];
        int[][] a = new int[n][m];
        for (int i = 0 ; i < n ; i++) {
            c[i] = sc.nextInt();
            for (int j = 0 ; j < m ; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int min = 100000000;
        for (int i = 0 ; i < Math.pow(2, n) ; i++) {
            int[] b = new int[n];
            int temp = i;
            for (int j = 0 ; j < n ; j++) {
                b[j] = temp % 2;
                temp /= 2;
            }
            int[] p = new int[m];
            int sum = 0;
            for (int j = 0 ; j < n ; j++) {
                if (b[j] == 1) sum += c[j];
                for (int k = 0 ; k < m ; k++) {
                    if (b[j] == 1) {
                        p[k] += a[j][k];
                    }
                }
            }
            boolean flg = true;
            for (int j = 0 ; j < m ; j++) {
                if (p[j] < x) flg = false;
            }
            if (flg) min = Math.min(min, sum);
        }
        System.out.println(min == 100000000 ? -1 : min);
    }

}

Measured memory_bytes: 38284
s=input()

while 1:

    if s[-5:] in ["dream","erase"]:
        s=s[:-5]
    elif s[-6:] == "eraser":
        s=s[:-6]
    elif s[-7:] == "dreamer":
        s=s[:-7]
    elif s == "":
        print("YES")
        exit()
    else:
        print("NO")
        exit()


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

int main() {

	string s;
	cin >> s;

	map<string, int>m;
	m["SUN"] = 7;
	m["MON"] = 6;
	m["TUE"] = 5;
	m["WED"] = 4;
	m["THU"] = 3;
	m["FRI"] = 2;
	m["SAT"] = 1;

	cout << m[s] << endl;

	return 0;
}


Measured memory_bytes: 256