akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scan(&N)
	fmt.Scan(&S)
	list := make([]string, N)

	var R, G, B []int
	for i := 0; i < N; i++ {
		j := S[i : i+1]
		if j == "R" {
			R = append(R, i+1)
		}
		if j == "G" {
			G = append(G, i+1)
		}
		if j == "B" {
			B = append(B, i+1)
		}
		list[i] = j
	}

	max := len(R) * len(G) * len(B)
	var count int
	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			k := 2*j - i
			if k >= len(list) {
				continue
			}
			if list[i] != list[j] && list[j] != list[k] && list[k] != list[i] {
				count++
				continue
			}
		}
	}
	fmt.Println(max - count)

}


Measured memory_bytes: 2008
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define loop(q) for(auto it:q)
#define rloop(q) for(auto&it:q)
#define input(a) for(auto &t:a){cin>>t;}
#define maxe(a,b,c) max(a,max(b,c))
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
#define fill(a,val) memset(a,val,sizeof(a))
#define in(k) int k;cin>>k
#define edl cout<<"\n"
#define ll  long long
#define ld  long double
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define cyes cout<<"Yes"<<endl; 
#define cno cout<<"No"<<endl;
const ll mod=1e9+7;
signed main()
{
    //cout<<fixed<<setprecision(20);
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	string s,t;cin>>s>>t;
	t=t.substr(0,s.size());
	if (s==t)
		{cyes;}
	else
		cno;
	/**************/
	#ifndef ONLINE_JUDGE
    printclock;
	#endif
    return 0;
}

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

int main(void){
    int h1,h2,k1,k2,a,b,c,d;
    cin >> h1 >> h2;
    cin >> k1 >> k2;
    cin >> a >> b >> c >> d;
    int H,K;
    H = h1*a + h2*b + (h1/10)*c + (h2/20)*d;
    K = k1*a + k2*b + (k1/10)*c + (k2/20)*d;
    if(K == H)    cout << "even";
    if(K > H) cout << "kenjiro";
    if(K < H) cout << "hiroshi";
    cout << endl;
}


Measured memory_bytes: 3100
n = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[n-1])

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

int main(){
  int n; cin >> n;
  int a[10];
  for(int i = 0; i < n; i++){
    a[i] = i;
  }
  int x[10];
  int y[10];
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
  }
  double sum = 0;
  int cnt = 0;
  do{
    for(int i = 0; i < n - 1; i++){
      int xdis = (x[a[i]] - x[a[i + 1]]);
      int ydis = (y[a[i]] - y[a[i + 1]]);
      sum += sqrt(xdis*xdis + ydis*ydis);
    }
    cnt++;
  }while(next_permutation(a, a + n));
  double ans = sum/cnt;
  printf("%.10lf", ans);
}
      

Measured memory_bytes: 256
n, m = map(int, input().split())

g = [[0 for _ in range(n)] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a][b] = 1
    g[b][a] = 1

#print(g)

ans = 0
visited = [0 for _ in range(n)]

def dfs(v):
    visited[v] = 1
    if all(x == 1 for x in visited):
        global ans
        ans += 1
        return

    for i in range(n):
        if g[v][i] == 1 and visited[i] == 0:
            visited[i] = 1
            dfs(i)
            visited[i] = 0

    return

dfs(0)
print(ans)


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define previous fake_previous
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 1000001;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	int n;
	cin >> n;
	VI a(n * 2);
	FOR(i, 0, n * 2)
		cin >> a[i];

	int ans = 0;
	sort(ALL(a));
	FOR(i, 0, n)
		ans += a[2 * i];

	cout << ans;
	//cin >> n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define pb push_back
    #define mp make_pair
    #define fst first
    #define snd second
    #define all(cont) cont.begin(), cont.end()
    #define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
    #define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
    #define SZ(x) ((int)x.size())
    #define EPS 1e-9
    #define PI 3.1415926535897932384626433832795
    #define MOD 1000000007
    #define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
     
    const int N = 0;
     
    typedef long long int ll;
     
    using namespace std;
     
    int main(){
        int n;cin>>n;
        ll prev = 1;
        ll ans = 1;
        fore(i,0,n){
            ll num;cin>>num;
            if(ans*num>=0){    
                ans = (ans/(__gcd(ans,num)))*num;
            }else{
                ans = max(ans,num);
            }
        }
        cout<<ans;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a >= b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  vector<ll> LIS(N + 1, INF);
  LIS.at(0) = -INF;
  for (ll i = 0; i < N; i++)
  {
    ll ind = distance(LIS.begin(), upper_bound(LIS.begin(), LIS.end(), -A.at(i)));
    chmin(LIS.at(ind), -A.at(i));
  }

  ll ans = -1 + distance(LIS.begin(), lower_bound(LIS.begin(), LIS.end(), INF));
  cout << ans << endl;

  /*
  for (ll i = 0; i < N + 1; i++)
  {
    cerr << LIS.at(i) << endl;
  }
  */
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int MAX=0;
struct edge{int to;int id;};
vector<vector<edge>>G;
vector<bool>seen;
vector<int>color;
void dfs(int v,int p=-1,int cr=-1){
  seen[v]=true;
  int k=1;
  for(auto nx:G[v]){
    if(nx.to==p)continue;
    if(seen[nx.to])continue;
    if(cr==k)k++;
    color[nx.id]=k;
    MAX=max(MAX,k);
    k++;
    dfs(nx.to,v,color[nx.id]);
  }
}
int main(){
  int N;
  cin>>N;
  G.resize(N);
  seen.assign(N,false);
  color.resize(N-1,0);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(edge{b,i});
    G[b].push_back(edge{a,i});
  }
  dfs(0);
  cout<<MAX<<endl;
  for(int i=0;i<N-1;i++){
    cout<<color[i]<<endl;
  }
}

Measured memory_bytes: 11076
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

int main()
{
	int num[5];
	for(int i=0;i<5;i++){
		scanf("%d",num+i);
	}
	sort(num,num+5,greater<int>());

	for(int i=0;i<5;i++){
		printf("%d%s",num[i],i==4 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> dList = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			dList.add(sc.nextInt());
		}

		int sum = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i; j < n - 1; j++) {
				sum += dList.get(i) * dList.get(j + 1);
			}
		}
		System.out.println(sum);
		sc.close();

	}

}

Measured memory_bytes: 21972
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    int N;
    int[] A;
    void Solve() {
        //input
        N = io.Int;
        A = new int[N];
        for (int i = 0; i < N; ++i)
            A[i] = io.Int;
        //cal
        var dict = new Dictionary<int, int>();
        foreach(var v in A) {
            if (!dict.ContainsKey(v)) dict[v] = 0;
            dict[v]++;
        }
        var overCnt = dict.Values.Aggregate(0, (n, next) => n + (next - 1));
        var ans = A.Distinct().Count() - (overCnt % 2 == 0 ? 0 : 1);
        //ret
        WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 26976
import java.util.*;
public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        String X = sc.nextLine();
        String Y = sc.nextLine();

        String[] sa1 = X.split(" ");
        String[] sa2 = Y.split(" ");

        int[] a1 = new int[sa1.length];
        int[] a2 = new int[sa2.length];

        for(int i=0; i<sa1.length;i++){
            a1[i]=Integer.parseInt(sa1[i]);
            a2[i]=Integer.parseInt(sa2[i]);
        }

        int ret=0;

        for(int i=0;i<a1.length;i++){
            int sum=0;
            for(int j=0;j<a1.length;j++){
                if(j<=i){
                    sum+=a1[j];
                }else{
                    sum+=a2[j];
                }
            }
            sum+=a2[i];
            ret=Math.max(ret,sum);
        }

        System.out.println(ret);

    }
}

Measured memory_bytes: 21844
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]


    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range (m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)


print(uf.group_count()-1)




Measured memory_bytes: 13088
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    set<char> c;
    cin >> s;
    repi(i, s){
        c.insert(*i);
    }
    if(c.size() == s.size()){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))


"""
indexのi,jについて、 j - i = A[i] + A[j] になる組の数を数え上げる。
愚直にやると、i,jを全ペアためす。N(O^2)で間に合わない

二つの変数が出てきて、ある式で関係性が表せる場合は、iの式 = jの式 みたいにしてやるとうまくいきことが多い
j - i = A[i] + A[j] 
-> A[i] + i = j - A[j]

なので、各参加者について、iとして使う時とjとして使うときで分けて数えていって、最後に組の数を数え上げる
A[i], i >=1 なので、２以上
1 <= j <= N, A[j] >= 1 なので、N未満
の範囲を調べればよい
"""
from collections import defaultdict
I = defaultdict(int)
J = defaultdict(int)

for i in range(N):
    I[A[i] + i+1] += 1
    J[i+1 - A[i]] += 1

ans = 0
for i in range(2, N):
    ans += I[i] * J[i]

print(ans)

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BMagic2 {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int A, B, C, K;
        cin >> A >> B >> C;
        cin >> K;
        int num = 0;
        while (B <= A) {
            B *= 2;
            num++;
        }
        while (C <= B) {
            C *= 2;
            num++;
        }
        cout << (num <= K ? "Yes" : "No") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BMagic2 solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

ll n, ans, pow2, pow5;

inline ll min(ll a, ll b){
	return a < b ? a : b;
}

int main(){

	scanf("%lld", &n);
	if(n & 1) puts("0");
	else if(n == 0) puts("0");
	else{
		for(ll i = 5; i <= n; i *= 5)
			pow5 += n / (i * 2);
		printf("%lld\n", pow5);
	}

	return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  ABC_169_C
//
//  Created by Joe Mori on 2020/05/31.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>

int main() {
    // insert code here...
    long double b;
    long long int a;
    std::cin>>a>>b;
    long long int c;
    c=b*a;
    std::cout<<c<<std::endl;
    return 0;
}


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

signed main(){
    ll h;
    cin >> h;
    ll ans=0;
    int count=0;
    while(h>0){
        count++;
        h>>=1;
    }
    int save=1;
    rep(i,count){
        ans+=save;
        save*=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def solve():
    SX, SY, TX, TY = map(int, input().split())
    # print(SX, SY, "->", TX, TY)

    # 上
    # (SX, SY + 1)
    # (TX, TY + 1)
    # 下
    # (SX, SY - 1)
    # (TX, TY - 1)
    # 左
    # (SX - 1, SY)
    # (TX - 1, TY)
    # 右
    # (SX + 1, SY)
    # (TX + 1, TY)

    right_to_bottom_from_start = "R" + "R" * abs((SX + 1) - TX) + "U" + "U" * abs(SY - (TY - 1))
    left_to_top_from_target = "L" + "L" * abs((TX - 1) - SX) + "D" + "D" * abs(TY - (SY + 1))
    left_to_top_from_start = "L" + "U" * abs(SY - (TY + 1)) + "R" * abs((SX - 1) - TX) + "D"
    right_to_bottom_from_target = "R" + "D" * abs(TY - (SY - 1)) + "L" * abs((TX + 1) - SX) + "U"

    return right_to_bottom_from_start + left_to_top_from_target + left_to_top_from_start + right_to_bottom_from_target


if __name__ == '__main__':
    res = solve()
    print(res)


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

ll N;
int NMAX = 1000000;
const ll MOD = 1000000007;

long long exgcd(long long a, long long b, long long &x, long long &y)
{
    int d = a;
    if (b != 0)
    {
        d = exgcd(b, a % b, y, x);
        y -= a / b * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}


int main()
{
    cin >> N;
    ll Mmin = (N + 1) / 2;

    vector<long long> factorial(N);
    vector<long long> inverse(N);
    factorial[0] = 1;
    for (int i = 1; i < N; i++)
    {
        factorial[i] = (factorial[i - 1] * i) % MOD;
    }

    for (int i = 0; i < N; i++)
    {
        long long tmp1, tmp2;
        exgcd(MOD, factorial[i], tmp1, tmp2);
        inverse[i] = (tmp2 + MOD) % MOD;
    }

    ll comb_m = 0;
    ll ans = 0;
    for (ll m = Mmin; m < N; m++)
    {
        ll comb_m_new;
        comb_m_new = ((factorial[m - 1] * inverse[N - m - 1] % MOD) * inverse[2 * m - N]) % MOD;
        comb_m_new = (comb_m_new * (factorial[m] * factorial[N - 1 - m] % MOD)) % MOD;
        ans += (((comb_m_new - comb_m + MOD) % MOD) * m) % MOD;
        comb_m = comb_m_new;
        ans %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
}


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

int main(){
    int N;
    int c = 0;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
      cin >> a.at(i);
    }
    for (int i = 0; i<N; i++) {
      if (i%2==0 && a[i]%2==1){
        c++;
      }
    }
    cout << c << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int i,j,n,s=0,t=0;
	for(i=1;i<=4;i++)
	{
		cin>>n;
		s+=n;
	}
	for(i=1;i<=4;i++)
	{
		cin>>n;
		t+=n;
	}
	if(s>=t)cout<<s<<endl;
	else cout<<t<<endl;
}

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

int main() {
  int A, B;
  int n = 500;
  cin >> A;
  cin >> B;
  
  int amr = A % n;

  if (B < amr) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  // ここにプログラムを追記
}


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

from collections import deque

n = int(input())
a = [[]]
for _ in range(n):
    a.append(deque([int(x) for x in input().split()]))

day = 1
next_day = []
used_player = [set() for _ in range(n**2)]

# 1日目
for i in range(1, n + 1):
    if a[a[i][0]][0] == i and (i not in used_player[day]) and (a[i][0] not in used_player[day]):
        used_player[day].add(i)
        used_player[day].add(a[i][0])
        next_day.append(a[a[i][0]].popleft())
        next_day.append(a[i].popleft())

# print(a)
# print(next_day)
from copy import deepcopy
# 2日目以降
while next_day:
    day += 1
    u = deepcopy(next_day)
    next_day = []
    # print(u)
    # print(a)
    for i in u:
        if len(a[i]) > 0 and len(a[a[i][0]]) > 0:
            if a[a[i][0]][0] == i and (i not in used_player[day]) and (a[i][0] not in used_player[day]):
                used_player[day].add(i)
                used_player[day].add(a[i][0])
                next_day.append(a[a[i][0]].popleft()) 
                next_day.append(a[i].popleft())

for i in a:
    if len(i) != 0:
        print(-1)
        sys.exit()

print(day - 1)


    








Measured memory_bytes: 196304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if ( Math.abs(A - B) % 2 == 0 ){
            System.out.println(Math.min(A,B) + Math.abs(A - B) / 2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 22996
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let (a, b): (usize, usize);
    input!(a, b);
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}

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

#define ll long long
#define maxn 100000

pair<ll,int> a[maxn];

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

	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+n);
	int c=0;
	ll res=0;
	for(int i=0;i<n;i++){
		if(c+a[i].second<=m){
			res+=a[i].first*a[i].second;
			c+=a[i].second;
		}
		else{
			res+=(m-c)*a[i].first;
			c=m;
			break;
		}
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 1792
SA = [n for n in input()]
SB = [n for n in input()]
SC = [n for n in input()]

D = {"a":SA,"b":SB,"c":SC}

def card(i):
    if len(D[i]) != 0:
        k = D[i].pop(0)
        # print(k,D[i])
        card(k)
    else:
        print(i.upper())

card(SA[0])

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

using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin >> s;

	if(s[0] == s[1]){
		if(s[2] == s[3] && s[0] != s[2]){
			cout << "Yes";
		} else {
			cout << "No";
		}
	} else if(s[0] == s[2]){
		if(s[1] == s[3] && s[0] != s[1]){
			cout << "Yes";
		} else {
			cout << "No";
		}
	} else if(s[0] == s[3]){
		if(s[1] == s[2] && s[0] != s[1]){
			cout << "Yes";
		} else {
			cout << "No";
		}
	} else {
		cout << "No";
	}
	
}

Measured memory_bytes: 256
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 
int main(int argc, char* argv[]){
    ll d, n;
    cin >> d >> n;
 
    if(n == 100) {
        n += 1;
    }
    rep(i, d){
        n *= 100;
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[51],b[51],c[51],s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){
		cin>>b[i];
		s+=b[i];
    }
	for(int i=1;i<=n-1;i++)
		cin>>c[i];
	for(int i=2;i<=n;i++){
		if((a[i]-a[i-1])==1)
			s=s+c[a[i-1]];
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
ls=list(map(int,input().split()))
prev=1
ans=0
for i in range(n):
  k=ls[i]
  if k%2==1:
    ans+=prev*2*(3**(n-i-1))
  else:
    ans+=prev*3**(n-i-1)
    prev*=2
print(ans)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n, m;
  cin >> n >> m;
  set<int> from1, toN;
  REP(i, 0, m) {
    int a, b;
    cin >> a >> b;
    if(a>b)
      swap(a, b);
    if(a==1)
      from1.insert(b);
    if(b==n)
      toN.insert(a);
  }
  for(auto v:from1){
    if(toN.count(v)>0){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 9600
N = int(input())
tmp_t, tmp_x, tmp_y = 0, 0, 0
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    T = t - tmp_t
    D = abs(x - tmp_x) + abs(y - tmp_y)
    if T >= D and T%2 == D%2:
        pass
    else:
        flag = False
result = 'Yes' if flag else 'No'
print(result)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	string s;
	int ac=0,wa=0,re=0,tle=0;
	cin>>n;
	rep(i,n)
	{
		cin>>s;
		if(s=="AC")ac++;
		else if(s=="WA")wa++;
		else if(s=="TLE")tle++;
		else re++;
	 } 
	 cout<<"AC x "<<ac<<endl;
	 cout<<"WA x "<<wa<<endl;
	 cout<<"TLE x "<<tle<<endl;
	 cout<<"RE x "<<re<<endl;
	return 0;
}



Measured memory_bytes: 3660
import java.util.Scanner;

//Exploring Caves
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			int max = 0;
			int tx = 0, ty = 0;
			int x = 0, y = 0;
			for(;;){
				int dx = sc.nextInt();
				int dy = sc.nextInt();
				if(dx==0&&dy==0)break;
				x+=dx; y+=dy;
				int d = x*x+y*y;
				if(max<d){
					max = d;
					tx = x; ty = y;
				}
				else if(max==d&&tx<x){
					tx = x; ty = y;
				}
			}
			System.out.println(tx+" "+ty);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int n,a,b,d[1000];
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   int c;
   cin>>a>>b>>c;
   if(b/a>=c){
     cout<<c<<endl;
   }else{
     cout<<b/a<<endl;
   }

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

int main() {
  ll n;
  cin >> n;
  ll d[n];
  for (ll i=0;i<n;i++) cin >> d[i];
  sort(d,d+n);
  int n2 = n/2;
  int ans = d[n2] - d[n2-1];
  cout << ans << endl; 
}

Measured memory_bytes: 1024
#include <stdio.h>
#define swap(type, x, y) do{ type t = x; x = y; y = t; }while(0)

void quick(int array[], int left, int right){
  int pl = left, pr = right, x = array[(left+right)/2];
  do{
    while(array[pl] < x)  pl++;
    while(array[pr] > x)  pr--;
    if(pl <= pr){
      swap(int, array[pl], array[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right) quick(array, pl, right);
  if(pr > left)  quick(array, left, pr);
}

int main(){
  int n, k;  scanf("%d %d", &n, &k);
  int p[1005];
  for(int i=0; i<n; i++)
    scanf("%d", p+i);

  quick(p, 0, n-1);

  int sum = 0;
  for(int i=0; i<k; i++)
    sum += p[i];

  printf("%d\n", sum);
  
  return 0;
}


Measured memory_bytes: 1684
#include <stdio.h>

int main() {
	int a, b, c, count = 0;
	scanf("%d %d %d", &a, &b, &c);

	for (int i = a; i <= b; i++) {
		if (c % i == 0) count++;
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2104
n=int(input())
ls=[]
ans=[]
for i in range(n-1):
  ls.append(list(map(int,input().split())))

def calculate(i):
  time=ls[i][1]+ls[i][0]
  for j in range(i+1,len(ls)):
    if time<ls[j][1]:
      time=ls[j][1]+ls[j][0]
    else:
      additional_time=ls[j][2]
      while time %additional_time!=0:
        time+=1
      time+=ls[j][0]
  return time

for i in range(len(ls)):
  ans.append(calculate(i))
ans.append(0)
for i in ans:
  print(i)


Measured memory_bytes: 3188
N = 5
D = [int(input()) for _ in range(N)]

srv_t = 0
last_srv = 0

for d in D:
   if d%10!=0:
       t = 10 - d%10
   else:
       t = 0
    
   srv_t += (d+t)
    
   last_srv = max(last_srv,t)
    
print(srv_t-last_srv)

Measured memory_bytes: 3060
import queue
import numpy as np
n = int(input())
class Node:
    def __init__(self):
        self.nextNode = []
        self.checkNgo = -1
        self.group = -1
        
Nodes = [Node() for i in range(n)]
for i in range(n):
    s = input()
    for j in range(len(s)):
        if s[j] == '1':
            Nodes[i].nextNode.append(j)
            
def check(node,ngo):
    if node.checkNgo == -1:
        node.checkNgo = ngo
    elif node.checkNgo != ngo:
        return False
    elif node.checkNgo == ngo:
        return True
    for i in node.nextNode:
        if not check(Nodes[i],(ngo+1)%2):
            return False
    return True
    
def ngoCheck():
    stack = [Nodes[0]]
    Nodes[0].checkNgo = 0
    while stack:
        node = stack.pop()
        for i in node.nextNode:
            if Nodes[i].checkNgo != -1 and Nodes[i].checkNgo == node.checkNgo:
                return False
            if Nodes[i].checkNgo == -1:
                Nodes[i].checkNgo = (node.checkNgo+1)%2
                stack.append(Nodes[i])
    return True
    
if not check(Nodes[0],0):
    print(-1)
    exit(0)
    
def solv():
    d = [[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(n):
            if j in Nodes[i].nextNode:
                d[i][j] = 1
            else:
                d[i][j] = np.inf
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k]+d[k][j]:
                    d[i][j] = d[i][k]+d[k][j]
    return d
    
def saidai(d):
    maxi = 0
    for i in range(n):
        for j in range(n):
            if i==j:
                continue
            maxi = max(maxi,d[i][j])
    return maxi
    
d = solv()
print(saidai(d)+1)

Measured memory_bytes: 23380
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

using namespace std;

vector<int> poles;

long long PRIME = 1000000007;

int main(int argc, char* argv[]){
    int N;
    cin >> N;

    string S1, S2;
    cin >> S1;
    cin >> S2;

    int prev_type;
    long long ret;
    int cur;

    if(S1[0] == S2[0]){
        prev_type = 1;
        ret = 3;
        cur = 1;
    }
    else{
        prev_type = 2;
        ret = 6;
        cur = 2;
    }


    while(cur < N){
        if(S1[cur] == S2[cur]){
            cur += 1;
            if(prev_type == 1){
                ret *= 2;
            }
            prev_type = 1;
        }
        else{
            cur += 2;
            if(prev_type == 2){
                ret *= 3;
            }
            else{
                ret *= 2;
            }
            prev_type = 2;
        }

        ret %= PRIME;
    }

    cout << ret;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

struct UnionFind {
    vector<int> par, w;
    
    UnionFind(int n) : par(n, -1), w(n, 0) { }
    void init(int n) { par.assign(n, -1); w.assign(n, 0); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) {
            ++w[x];
            return false;
        }
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        w[x] += w[y];
        ++w[x];
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
 
    int wei(int x) {
        return w[root(x)];
    }
};

//密グラフのMSTは考えるべき辺の本数を減らす
//MST　は　O(ElogV)

void solve() {
	int n; cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    using edge = pair<ll, LP>;
    vector<edge> edges;

    vector<int> ids(n);
    iota(all(ids), 0);
    sort(all(ids), [&](int i, int j){ return x[i] > x[j];});
    rep(i, n - 1) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(edge(x[u] - x[v], LP(u, v)));
    }

    sort(all(ids), [&](int i, int j){ return y[i] > y[j];});
    rep(i, n - 1) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(edge(y[u] - y[v], LP(u, v)));
    }

    sort(all(edges));
    UnionFind uf(n);
    ll res = 0;
    for(auto e: edges) {
        int u = e.sc.fr, v = e.sc.sc;
        ll cost = e.fr;
        if(uf.issame(u, v)) continue;
        uf.merge(u, v);
        res += cost;
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 10864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll a[3 * n];
    rep(i, 3 * n) {
        cin >> a[i];
    }
    priority_queue<ll, vector<ll>, greater<ll> > lque;
    ll lsum[3 * n + 1] = {};
    for (int i = 0; i < 3 * n; i++) {
        lsum[i + 1] = lsum[i] + a[i];
        lque.emplace(a[i]);
        if ((int)lque.size() <= n) continue;
        lsum[i + 1] -= lque.top();
        lque.pop();
    }
    ll ans = -LINF;
    priority_queue<ll> rque;
    ll rsum = 0;
    for (int i = 3 * n - 1; i >= n; i--) {
        rsum += a[i];
        rque.emplace(a[i]);
        if ((int)rque.size() > n) {
            rsum -= rque.top();
            rque.pop();
        }
        if (i <= 2 * n) {
            ans = max(ans, lsum[i] - rsum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10216
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#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;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         SET(m)                      memset(m, 1,sizeof m)
#define         RESET(m)                    memset(m,0,sizeof m)
#define         mp(a,b)                     make_pair(a,WWb)
#define         mod                         1000000007
#define         INF                         1e17
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
vector<ll>v;
int main(){
    ll h,n,x;
    sfl(h),sfl(n);
    for(ll i=1;i<=n;i++){
        sfl(x);
        v.pb(x);
    }
    sort(all(v));
    for(ll i=v.size()-1;i>=0;i--){
        h -= v[i];
    }
    if(h<=0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vv<pair<ll, int>> graph;
vector<bool> visited;
vll dist;

void dfs(int v, ll cost) {
    visited[v] = true;
    dist[v] = cost;

    for (const auto& e : graph[v]) {
        if (!visited[e.second]) {
            dfs(e.second, cost + e.first);
        }
    }
}

int main() {
    cin >> N;
    graph.resize(N);
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        graph[u - 1].emplace_back(w, v - 1);
        graph[v - 1].emplace_back(w, u - 1);
    }

    visited.resize(N, false);
    dist.resize(N, LINF);

    dfs(0, 0);

    rep(i, N) {
        if (dist[i] % 2) {
            write(0);
        }
        else {
            write(1);
        }
    }
}

Measured memory_bytes: 9984
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func judge(str []int) (int, bool) {
	i := len(str) - 1
	for ; i > 0; i-- {
		if (str[i] == str[i-1] || str[i] == str[i-1]-1) && str[i] < 9 {
			return i, true
		}
	}
	return len(str), false
}

func solve() {
	k := scanInt()
	var ans []int = nil
	ans = append(ans, 1)
	for i := 1; i < k; i++ {
		if i < 9 {
			ans[0]++
			continue
		}
		index, jud := judge(ans)
		if jud == true {
			ans[index]++
			for j := index + 1; j < len(ans); j++ {
				if ans[j-1] >= 1 {
					ans[j] = ans[j-1] - 1
				} else {
					ans[j] = 0
				}
			}
			continue
		} else if ans[0] < 9 {
			ans[0] += 1
			for j := 1; j < index; j++ {
				if ans[j-1] >= 1 {
					ans[j] = ans[j-1] - 1
				} else {
					ans[j] = 0
				}
			}
			continue
		} else {
			ans = make([]int, index+1)
			ans[0] = 1
			continue
		}
	}
	var answer int64
	answer = 0
	// fmt.Println(ans)
	for i, num := range ans {
		answer += int64(pow(10, len(ans)-i-1) * num)
	}
	fmt.Println(answer)
}

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func pow(n int, m int) int {
	ans := 1
	for i := 0; i < m; i++ {
		ans *= n
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)
	solve()
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		int i=0;
		while(true) {
			if(X <= i*(i+1)/2) {
				break;
			}else {
				i++;
			}
		}
		System.out.println(i);
	}
}


Measured memory_bytes: 21844
// バケット法による解
#include <iostream>
using namespace std;

int main() {
    string S;
    cin >> S;
    bool app[30];
    bool flug = false;
    for(int i = 0; i< 26;++i){
      app[i] = false;
    }
    for(int i = 0;S[i] != '\0';++i){
      app[S[i]-'a']= true;
    }
    for(int i = 0;i<26;++i){
      if(!app[i]){
        cout << (char)(i + 'a') << endl;
        flug = true;
        break;
      }
    }
    if(!flug) {
        cout << "None" << endl;
    }
}


Measured memory_bytes: 3728
#include<stdio.h>
#define MAX 200000

int main(){
  int n, i, R[MAX], maxv, minv;

  scanf("%d", &n);
  for (i=0; i<n; i++) {
      scanf("%d", &R[i]);
  }

  maxv = -2000000000;
  minv = R[0];

  for (i=1; i<n; i++) {
      if (maxv < R[i]-minv) {
          maxv = R[i]-minv;
      }
      if (minv > R[i]) {
          minv = R[i];
      }
  }

  printf("%d\n", maxv);
  return 0;
}

Measured memory_bytes: 2624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define vec vector
#define fi first
#define se second
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
#define bit(x) (1ll<<(x))

void mainsolve(){
	
	ll a,b,k;
	cin >> a >> b >> k;
	ll tmp = a;
	a = max(0ll,a-k);
	k = k-tmp;

	if(k>0){
		b = max(0ll, b-k);
	}


	cout << a << " " << b << endl;

	
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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

int GCD(int m, int n) {
	if (n == 0)
		return m;
	return GCD(n, m%n);
}

int main()
{
	int W, H, C,g;
	cin >> W >> H >> C;
	g= GCD(W, H);
	while (g != 1) {
		W /= g;
		H /= g;
		g = GCD(W, H);
		if (g == 1) 
			break;
	}
	cout << W*H*C<<endl;
	return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int n, p;
VI A;
LL numWays()
{
    int even = count_if(ALL(A), [](int& i){return i % 2 == 0;});
    int odd = count_if(ALL(A), [](int& i){return i % 2 == 1;});
    if(even == n)
        return (p == 1) ? 0 : (1ll << n);
    return (1ll << (n - 1));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> n >> p;

    A.assign(n, 0);
    REP(i, 0, n) cin >> A[i];

    cout << numWays() << endl;

	return 0;
}

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

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	std::vector<int> height(n);
	std::vector<long long> cost(n, 1LL << 50);
	for (int i{}; i < n; i++)
		scanf("%d", &height[i]);
	cost[0] = 0;
	for (int i{}; i < n - 1; i++)
	{
		const int j_limit{std::min(n - 1, i + k)};
		for (int j{i + 1}; j <= j_limit; j++)
			cost[j] = std::min(cost[j], cost[i] + std::abs(height[i] - height[j]));
	}
	printf("%lld\n", cost.back());

	return 0;
}

Measured memory_bytes: 1408