akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

struct disjoint_sets {
    vector<int> xs;
    disjoint_sets() = default;
    explicit disjoint_sets(size_t n) : xs(n, -1) {}
    bool is_root(int i) { return xs[i] < 0; }
    int find_root(int i) { return is_root(i) ? i : (xs[i] = find_root(xs[i])); }
    int set_size(int i) { return - xs[find_root(i)]; }
    int union_sets(int i, int j) {
        i = find_root(i); j = find_root(j);
        if (i != j) {
            if (set_size(i) < set_size(j)) swap(i,j);
            xs[i] += xs[j];
            xs[j] = i;
        }
        return i;
    }
    bool is_same(int i, int j) { return find_root(i) == find_root(j); }
};
template <typename T> struct weighted_edge_t { int u, v; T w; };
template <typename T> bool operator < (weighted_edge_t<T> const & a, weighted_edge_t<T> const & b) { return make_tuple(a.w, a.u, a.v) < make_tuple(b.w, b.u, b.v); }
template <typename T>
vector<vector<weighted_edge_t<T> > > minimum_spanning_tree(int n, vector<weighted_edge_t<T> > edges) { // Kruskal's method, O(E \log E)
    vector<vector<weighted_edge_t<T> > > tree(n);
    disjoint_sets sets(n);
    whole(sort, edges);
    for (auto e : edges) {
        if (not sets.is_same(e.u, e.v)) {
            sets.union_sets(e.u, e.v);
            tree[e.u].push_back( (weighted_edge_t<T>) { e.u, e.v, e.w } );
            tree[e.v].push_back( (weighted_edge_t<T>) { e.v, e.u, e.w } );
        }
    }
    return tree;
}

int main() {
    int n, m; cin >> n >> m;
    vector<weighted_edge_t<int> > es(m);
    repeat (i,m) {
        int a, b, c; cin >> a >> b >> c; -- a; -- b;
        es[i] = { a, b, c };
    }
    auto mst = minimum_spanning_tree(n, es);
    ll total = 0;
    repeat (i,n) for (auto e : mst[i]) {
        if (e.u < e.v) total += e.w;
    }
    vector<vector<int> > drop = vectors(n, n, int()); {
        repeat (i,n) {
            function<void (int, int)> dfs = [&](int j, int parent) {
                for (auto e : mst[j]) if (e.v != parent) {
                    drop[i][e.v] = max(drop[i][j], e.w);
                    dfs(e.v, j);
                }
            };
            drop[i][i] = 0;
            dfs(i, i);
        }
    }
    int q; cin >> q;
    while (q --) {
        int s, t; cin >> s >> t; -- s; -- t;
        cout << total - drop[s][t] << endl;
    }
    return 0;
}


Measured memory_bytes: 69040
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){
    double l;
    cin >> l;

    double ans = (l/3.0)*(l/3.0)*(l/3.0);
    std::cout << std::fixed;
    cout << std::setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]	

dic = defaultdict(int)

for a in A:
	#print(dic[a])
	dic[a] ^= 1

#print(dic)
ans = 0
for x in dic:
	ans += dic[x]
print(ans)
	


Measured memory_bytes: 18352
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val str = readLine()!!

    var check = str[0]
    var count = 0
    for (c in str) {
        if (check == c) {
            continue
        }
        count++
        check = c
    }
    println(count + 1)
}

Measured memory_bytes: 32560
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        // 入力処理
        Scanner sc = new Scanner(System.in);

        int[] nums = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int n = nums[0];
        int k = nums[1];
        String[] strs = sc.nextLine().split("");
        StringBuilder result = new StringBuilder();

        for (int i = 0; i < n; i++) {
            String tmp = "";
            if (i + 1 == k) {
                tmp = strs[i].toLowerCase();
            } else {
                tmp = strs[i];
            }
            result.append(tmp);
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1000000000;

void printVi(vi &ar) {
	for (int i = 0; i < (int)ar.size(); i++) {
		if (i > 0) cout << " ";
		cout << ar[i];
	}
	cout << "\n";
}

int main() {FIN
    
    int n, i, j, k;
    cin >> n;
    vi ns(n);
    
    for (i = 0; i < n; i++)
		cin >> ns[i];
	
	printVi(ns);
	for (i = 1; i < n; i++) {
		k = ns[i];
		for (j = i - 1; j >= 0; j--) {
			if (ns[j] > k)
				swap(ns[j], ns[j + 1]);
			else
				break;
		}
		printVi(ns);
	}
    
    return 0;
}



Measured memory_bytes: 3116
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

v=array(4,0)
3.times do|i|
  a,b=get_i.map{|x| x-=1}
  v[a]+=1
  v[b]+=1
end
v.each do|x|
    if x==3
        puts "NO"
        exit
    end
end
puts "YES"

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#define mod 1000000007

using namespace std;

long long factorial(long long n)
{
	long long x = 1;
	for (int i = 1; i <= n; ++i)
	{
		x = x*i% mod;
	}
	return x;
}

int main()
{
	
	long long N, M;
	cin >> N >> M;
	long long res = 0;
	if (abs(N - M) > 1)
	{
		cout << 0 << endl;
	}
	else if (N - M == 0)
	{
		res = (long long)factorial(N)*factorial(M) * 2 % mod;
		//res = (long long) * res % (long long)(10e9 + 7);
		cout << res << endl;
	}
	else
	{
		res = factorial(N)*factorial(M) % mod;
		cout << res << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	string s; 
	cin >> s;
	int len = s.length();
	bool good = true;
	if (len & 1)
	{
		good = false;
	}
	else
	{
		int index = 0;
		while (index < len)
		{
			if (s[index] == 'h' and s[index + 1] == 'i')
			{
				index += 2;
			}
			else
			{
				good = false;
				break;
			}
		}

		
	}
	cout << (good ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int a, b;
string sa, sb;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> sa >> sb;
	a = atoi(sa.c_str());
	b = atoi(sb.c_str());
	int e = sb.size();
	int D = 1;
	for(int i=0; i<e; i++){
		D *= 10;
	}
	D = D * a + b;
	for(int i=1; i*i<=D; i++){
		if(i*i == D){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();
        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.ReadSplit();
            long A = input[0];
            long B = input[1];
            long g = Gcd(Max(A, B), Min(A, B));
            Console.WriteLine(g * (A / g) * (B / g));

            //Console.Out.Flush();
        }
        static public long Gcd(long a, long b)
        {
            if (a % b == 0)
            {
                return b;
            }
            return Gcd(b, a % b);
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }
    public class Scanner
    {
        public int[] ReadSplit()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitL()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplitD()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

    }
}


Measured memory_bytes: 11220
class Dice:
    def __init__(self, p):
        self.y = [p[0], p[1], p[5], p[4]]
        self.x = [p[0], p[2], p[5], p[3]]
        self.z = [p[1], p[2], p[4], p[3]]
    def roll(self, c):
        if c == 'y':
            self.y.append(self.y.pop(0))
            self.x[0] = self.y[0]
            self.x[2] = self.y[2]
            self.z[0] = self.y[1]
            self.z[2] = self.y[3]
        elif c == 'x':
            self.x.append(self.x.pop(0))
            self.y[0] = self.x[0]
            self.y[2] = self.x[2]
            self.z[1] = self.x[1]
            self.z[3] = self.x[3]
        elif c == 'z':
            self.z.append(self.z.pop(0))
            self.x[1] = self.z[1]
            self.x[3] = self.z[3]
            self.y[1] = self.z[0]
            self.y[3] = self.z[2]
    def num(self, n):
        n = n - 1;
        pos_y = [0, 1, 5, 4]
        pos_x = [0, 2, 5, 3]
        if n in pos_y:
            return self.y[pos_y.index(n)]
        else:
            return self.x[pos_x.index(n)]
    def same(self, other):
        for _ in range(4):
            if self == other:
                return True
            other.roll('x')
            for _ in range(4):
                if self == other:
                    return True
                other.roll('y')
                for _ in range(4):
                    if self == other:
                        return True
                    other.roll('z')
        return False
    def __eq__(self, other):
        for i in range(1,7):
            if (self.num(i) != other.num(i)):
                return False
        return True



n = int(input())
dices = []
for _ in range(n):
    dices.append(Dice([int(i) for i in input().split()]))


yes = all([not dices[0].same(other) for other in dices[1:]])
print('Yes' if yes else 'No')


Measured memory_bytes: 5660
s = gets.chomp.chars

cnt = 0
s.each_with_index {|v, i|
  cnt = 1 if v == 'R' && i == 0
  if v == 'R' && i > 0
    if v == s[i-1]
      cnt += 1
    else
      cnt = 1
    end
  end
}

p cnt

Measured memory_bytes: 14296
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n,x;
	cin >> n >> x;
	vector<int> l(n);
	for(int i=0;i<n;i++){
		cin >> l[i];
	}

	int count=1;
	int dist=0;
	for(int i=0;i<n;i++){
		dist+=l[i];
		if(dist>x) break;
		count++;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

H, W, D = map(int ,input().split())

dict = {}
for i in range(1,H+1):
    A = [0] + list(map(int, input().split()))
    for j in range(1, W+1):
        dict[A[j]] = (i,j)

P = [[]]
for i in range(1,D+1):
    q = [0]
    k = i + D
    while k <= H*W:
        p = abs(dict[k][0] - dict[k-D][0]) + abs(dict[k][1] - dict[k-D][1])
        q.append(q[-1]+p)
        k = k + D
    P.append(q)

Q = int(input())

for i in range(Q):
    L, R = map(int, input().split())
    j = L % D
    if j == 0: j = D
    print(P[j][(R-1) // D] - P[j][(L-1) // D])


Measured memory_bytes: 93296
/*Program from Luvwgyx*/
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fir first
#define sec second
#define pi pair<int ,int >
#define mp(x,y) make_pair(x,y)
#define int long long
using namespace std;
const int inf=1e9;
const int maxn=1e5+10;
priority_queue<pi >q;
int n,K,tot,a[maxn],head[maxn];
struct node{int to,nxt;}e[maxn<<1];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);putchar('\n');}
void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;}
void insert(int u,int v){add(u,v);add(v,u);}
void init(){for(int i=0;i<maxn;i++)a[i]=inf;}
signed main(){
    n=read();init();
    for(int i=2;i<=n;i++)insert(read(),read());
    K=read();
    for(int i=1;i<=K;i++){
        int x=read(),y=read();
        a[x]=y;q.push(mp(-y,x));
    }
    while(q.size()){
        int y=-q.top().fir,x=q.top().sec;q.pop();
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to){
            if(a[v]==inf)a[v]=y+1,q.push(mp(-a[v],v));
            if(abs(a[x]-a[v])!=1){puts("No");return 0;}
        }
    }puts("Yes");for(int i=1;i<=n;i++)write(a[i]);
    return 0;
}
/*
4
1 2
2 3
3 4
2
1 2
4 4
 */


Measured memory_bytes: 7280
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        char[] w = br.readLine().toCharArray();

        br.close();

        Map<Character, Integer> map = new HashMap<>();
        for (char c : w) {
            if (map.containsKey(c)) {
                map.put(c, map.get(c) + 1);
            } else {
                map.put(c, 1);
            }
        }

        for (var entry : map.entrySet()) {
            if (entry.getValue() % 2 == 1) {
                bw.write("No");
                bw.flush();
                return;
            }
        }

        bw.write("Yes");
        bw.flush();

    }
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 1e5+100;
ll ans,lef;
string s;

int main(){
    cin >> s;
    deque<char> bot,to;
    char mem;

    for(int i = 1; i < s.length(); i++) to.push_back(s[i]);
    bot.push_back(s[0]);

    while(!to.empty()){
        if(!bot.empty()){
            //cout << bot.back() << ' ' << to.front() << endl;
            if(bot.back() != to.front()){
                ans += 2;
                bot.pop_back();
                to.pop_front();
            }
            else{
                mem = to.front();
                to.pop_front();
                bot.push_back(mem);
            }
        }
        else{
            mem = to.front();
            to.pop_front();
            bot.push_back(mem);
        }
        
    }

    cout << ans << endl;
}

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



int main() {
    int n;
    string s;
    cin >> n >> s;
    
    rep(i,s.size()) {
        s[i] += n;
        if(s[i] > 'Z') {
            s[i] -= 26;
        }
    }
    
    cout << s << endl;
    
    
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll a, b, x;
  cin >> a >> b >> x;

  ll ans = b / x;
  ans -= a / x;
  if (a%x == 0) ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
e=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(lambda x:int(x)-1,input().split())
  e[a].append(b)
  e[b].append(a)

d=[-1 for i in range(n)]
c=[0 for i in range(n)]
m=[-1 for i in range(n)]
d[0]=0
s=[0]
while s:
  ns=[]
  for i in s:
    for j in e[i]:
      if d[j]!=-1:
        continue
      ns.append(j)
      m[j]=i
      c[i]+=1
      d[j]=d[i]+1
  s=ns

mod=10**9+7
frac=[1]
for i in range(1,10**5):
  frac.append((frac[-1]*i)%mod)

r=k
for i in range(n):
  if c[i]==0:
    continue
  if d[i]==0:
    if k-1-c[i]<0:
      r=0
      break
    r=(r*frac[k-1]*pow(frac[k-1-c[i]],mod-2,mod))%mod
  else:
    if k-2-c[i]<0:
      r=0
      break
    r=(r*frac[k-2]*pow(frac[k-2-c[i]],mod-2,mod))%mod
print(r)

Measured memory_bytes: 121668
#include<iostream>

using namespace std;

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

  if ( (n/10)%9 == 0 || (n%10) == 9 ) {
    cout << "Yes" << endl;    
  } else {
    cout << "No" << endl;
  }

  return 0;
}



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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
int PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

vector<ll> A;

void Primefactor(ll n){
  ll a = n;
  for(ll i = 2;i * i <= n;i++){
    while(a % i == 0){
      A.push_back(i);
      a /= i;
    }
    if(a == 1){
      break;
    }
  }
  if(a != 1){
    A.push_back(a);
  }
  return;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   ll res = 1;
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
}

int main(){
  ll N,M;cin >> N >> M;
  Primefactor(M);
  //sort(A.begin(),A.end());
  ll n = A.size();
  ll ans = 1;
  ll cnt = 1;
  for(int i = 0;i < n;i++){
    if(A[i] == A[i+1]){
      cnt++;
    }else{
      ans *= modCON(cnt+N-1,N-1,MOD);
      cnt = 1;
    }
    if(i == N-1 && A[i+1] == A[i]){
      ans *= modCON(cnt+N-1,N-1,MOD);
    }
    ans %= MOD;
  }
  cout << ans << endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(b==1){
    cout << 0 << endl;
  }
  for (int n=1 ; n<25 ; n++){
    if (b>=(n-1)*a-(n-3)&&b <= n*a-n+1){
      cout << n << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll x;
	cin >> x;
	ll l = 0LL, r = 1e9 + 10;
	rep(i, 128) {
		ll m = (l + r) / 2;
		if(m * (m + 1) >= 2 * x) r = m;
		else l = m;
	}
	cout<<r<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int N;
  cin >> N;
  vector<P> A(N);
  REP(i,N) cin >> A[i].second >> A[i].first;

  sort(ALL(A));
  int time = 0;
  int flag = 0;
  REP(i,N){
    if(time+A.at(i).second>A.at(i).first){
      flag = 1;
      break;
    }
    time+=A.at(i).second;
  }

  if(flag == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1792
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)
for x, y, c in xyc:
    x -= 1
    y -= 1
    ans = min(ans, (a[x] + b[y] - c))

print(ans)

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

int main()
{
	int a,b,sum=0;
	cin>>a>>b;
	for(int i=1;i<=a-1;i++)
		sum+=i;
	if(b==1||b==0)
		;
	else
		sum+=b*(b-1)/2;
	cout<<sum;

	return 0;
}

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

const ll mod= 998244353;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a%=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

void comb(ll *c, ll n){
  c[0] = 1;
  rep1(i,n){
    c[i] = mu(c[i - 1], mu(n + 1 - i, dv(1,i)));   
  }

}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k;
  cin >> n >> m >> k;

  ll C[n];
  comb(C, n-1);

  ll ans = 0;
  rep(j,k+1){
    ll res = mu(C[j],mu(m,pw(m-1,n-j-1)));
    // cout << C[j] << " " << m << " " << pw(m-1,n-j-1) << endl;
    // cout << res << endl;
    ans = ad(ans,res);
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 5204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	a = a * 4 + b * 2 + c;
	if( a == 4 ) cout << "Close" << endl;
	if( a == 2 ) cout << "Close" << endl;
	if( a == 6 ) cout << "Open" << endl;
	if( a == 1 ) cout << "Open" << endl;
	if( a == 0 ) cout << "Close" << endl;
}

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

using namespace std;

int main (void) {
  int N;
  cin >> N;
  int a;
  long long ans = 0;
  for ( int i = 0; i < N; i++ ) {
    cin >> a;
    ans += a - 1;
  }
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 256
#include<cstdlib>
char nm[][9]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
int cl[][3]={{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};
char rgb[3][3];
int main(){
	while(scanf(" #%2s%2s%2s",rgb,rgb+1,rgb+2)==3){
		int mn=99999999,mi,d2,d;
		for(int i=0;i<8;i++){
			d2=0;
			for(int j=0;j<3;j++)d=cl[i][j]-strtol(rgb[j],NULL,16),d*=d,d2+=d;
			if(d2<mn)mn=d2,mi=i;
		}
		printf("%s\n",nm[mi]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
using namespace std;
int M,D;
bool Judge(int m,int d) {
    if(!(d%10>=2&&d/10>=2))
        return 0;
    return (d%10)*(d/10)==m;
}
int main()
{
    int Ans=0;
    scanf("%d%d",&M,&D);
    for(int m=1;m<=M;m++)
        for(int d=1;d<=D;d++)
            Ans+=Judge(m,d);
    printf("%d",Ans);
}


Measured memory_bytes: 128
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI 3.14159265358979323846264338327950L

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

 ll N, M, K, Q, i, j, k, l, tmp, ans;

int main(){
    cin >> N >> M;

    if (N >= 2){
        ans = N * (N - 1) / 2;
    }
    if (M >= 2){
        ans += M * (M - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  ll a, b; cin >> a >> b;
  ll big = (ll)(max(a,b));
  ll small = (ll)(min(a,b)); 
  bool flag = true;
  while(flag){
    if(big%small == 0) flag = false;
    else big += (ll)(max(a,b));
  }
  
  cout << big << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,x=0,y=0;
  for(int i=0;i<3;i++){
    cin>>a;
    if(a==5)
      x++;
    if(a==7)
      y++;
  }
  if(x==2 && y==1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<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[] ans = {0, 1, 2, 4, 6, 16, 12, 64, 24, 36, 48, 1024, 60};
		int i = sc.nextInt();

		System.out.println(ans[i]);
	}

}


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

int main(){
  long long A,B,C,K,ans=0;
  cin>>A>>B>>C>>K;
  if(K>A){
    K-=A;
    ans+=A;
    if(K>B){
      K-=B;
      ans-=K;
    }
  }else{
    ans=K;
  }
  cout<<ans;
}
    

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int X = scanner.nextInt() - 1;
    int Y = scanner.nextInt() - 1;
    int[] res = new int[N];

    for (int i = 0; i < N; i++) {
      for (int j = 0; j < i; j++) {
        int d = i - j;
        d = Math.min(d, Math.abs(i - Y) + Math.abs(j - X) + 1);
        res[d]++;
      }
    }

    for (int i = 1; i < N; i++) {
      System.out.println(res[i]);
    }
  }
}


Measured memory_bytes: 22356
n=int(input())
w=[]
ws=[]
count=1
for i in range(n):
    w.append(input())
    ws.append(list(w[i]))
for i in range(n):
    if (w.count(w[i]))>1:
        count-=1
for j in range(n-1):
    if (ws[j][len(w[j])-1])==(ws[j+1][0]):
        count+=1
if count==int(n):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=310;
const ll mod=998244353;

bitset<maxn> bi[maxn];
ll tav[maxn];

bitset<maxn> f[maxn];
ll cnt=1;
ll koj[maxn];

bool add(bitset<maxn> bi,ll m){
	for(ll i=m-1;i>=0;i--){
		if(bi[i]){
			if(koj[i]==-1){
				f[cnt]=bi;
				koj[i]=cnt;
				cnt++;
				return 0;
			}else{
				bi^=f[koj[i]];
			}
		}
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	tav[0]=1;
	for(ll i=1;i<maxn;i++){
		tav[i]=(tav[i-1]*2)%mod;
	}
	fill(koj,koj+maxn,-1);

	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<m;j++){
			ll a;
			cin>>a;
			bi[i][j]=a;
		}		
	}
	ll sefr=0;
	for(ll i=0;i<n;i++){
		sefr+=add(bi[i],m);
	}
	cout<<((tav[m-1]*(tav[n]-tav[sefr]))%mod+mod)%mod;
}




















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

int main(){
  int n;cin >> n;
  for(int i=1;i<=9;++i){
    for(int j=1;j<=9;++j){
      if(i*j == n){cout << "Yes" << endl;return 0;}
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int N, arr[100005];
long long memo[2][100005];

long long func(int flag, int idx)
{
    if(idx == N - 1)
    {
        if(flag == 1)
        {
            return arr[idx] * -1;
        }
        return arr[idx];
    }
    long long &ret = memo[flag][idx];
    if(ret != -1)
    {
        return ret;
    }
    ret = 0;
    if(flag == 1)
    {
        ret = max(ret, func(0, idx + 1) + arr[idx] * -1);
        ret = max(ret, func(1, idx + 1) + arr[idx]);
    }
    else
    {
        ret = max(ret, func(0, idx + 1) + arr[idx]);
        ret = max(ret, func(1, idx + 1) + arr[idx] * -1);
    }
    return ret;
}

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &arr[i]);
    }
    memset(memo, -1, sizeof memo);
    printf("%lld", func(0, 0));
}

Measured memory_bytes: 5376
n, k = gets.chomp.split.map(&:to_i)
@nega_candles = []
@posi_candles = []
gets.chomp.split.each do |candle|
  if candle.to_i  <= 0
    @nega_candles.push candle.to_i
  else
    @posi_candles.push candle.to_i
  end
end

# 0から近い順にしておく
@nega_candles.reverse!

cal_distance = lambda do |l, r|
  left = l.zero? ? 0 : @nega_candles[l - 1]
  right = r.zero? ? 0 : @posi_candles[r - 1]
  [2 * right - left, right - 2 * left ].min
end

ans = Float::INFINITY
(k + 1).times do |i|
  l = i
  r = k - i
  next if r > @posi_candles.size
  break if l > @nega_candles.size
  ans = [ans, cal_distance.(l, r)].min
end

puts ans

Measured memory_bytes: 21800
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void)
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string a;
		char c;
		int p = 0;
		int cnt = 0;
		cin >> a;
		for (int i = 0; i < a.size(); ++i) {
			switch(a[i]) {
				case '0':
					if (c != 'P') {
						cout << c;
					}
					p = 0;
					cnt = 0;	
					c = 'P';		
					break;
				case '1':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 5 == 1) {
						c = '.';
					} else if (cnt % 5 == 2) {
						c = ',';
					} else if (cnt % 5 == 3) {
						c = '!';
					} else if (cnt % 5 == 4) {
						c = '?';
					} else if (cnt % 5 == 0) {
						c = ' ';
					}
					break;
				case '2':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 3 == 1) {
						c = 'a';
					} else if (cnt % 3 == 2) {
						c = 'b';
					} else if (cnt % 3 == 0) {
						c = 'c';
					}
					break;
				case '3':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 3 == 1) {
						c = 'd';
					} else if (cnt % 3 == 2) {
						c = 'e';
					} else if (cnt % 3 == 0) {
						c = 'f';
					}
					break;
				case '4':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 3 == 1) {
						c = 'g';
					} else if (cnt % 3 == 2) {
						c = 'h';
					} else if (cnt % 3 == 0) {
						c = 'i';
					}
					break;
				case '5':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 3 == 1) {
						c = 'j';
					} else if (cnt % 3 == 2) {
						c = 'k';
					} else if (cnt % 3 == 0) {
						c = 'l';
					}
					break;
				case '6':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 3 == 1) {
						c = 'm';
					} else if (cnt % 3 == 2) {
						c = 'n';
					} else if (cnt % 3 == 0) {
						c = 'o';
					}
					break;
				case '7':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 4 == 1) {
						c = 'p';
					} else if (cnt % 4 == 2) {
						c = 'q';
					} else if (cnt % 4 == 3) {
						c = 'r';
					} else if (cnt % 4 == 0) {
						c = 's';
					}
					break;
				case '8':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 3 == 1) {
						c = 't';
					} else if (cnt % 3 == 2) {
						c = 'u';
					} else if (cnt % 3 == 0) {
						c = 'v';
					}
					break;
				case '9':
					if (p == 0) {
						p = 1;
					}
					if (p == 1) {
						++cnt;
					}
					if (cnt % 4 == 1) {
						c = 'w';
					} else if (cnt % 4 == 2) {
						c = 'x';
					} else if (cnt % 4 == 3) {
						c = 'y';
					} else if (cnt % 4 == 0) {
						c = 'z';
					}
					break;
			}
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;

int main(){
//freopen("input.txt", "r", stdin);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int L[n];
	L[0] = 1;
	set<pair<int,int>, greater< pair<int,int> > >  s;
	s.insert({L[0], 0});
	for(int i = 1; i < n; i++){
		L[i] = 1;
		for(auto it = s.begin(); it!= s.end(); it++){
			if(abs(a[it->second] - a[i]) <= k){
				L[i] = max(L[i], it->first + 1);
				break;
			}
		}
		s.insert({L[i], i});
	}
	cout << *max_element(L, L + n) << endl;
}

Measured memory_bytes: 19568
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

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

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  ll D, G;
  cin >> D >> G;
  vector<ll> p(D);
  vector<ll> c(D);
  for (ll i = 0; i < D; i++) {
    cin >> p[i];
    cin >> c[i];
  }

  ll ans = 10000;
  for (ll bit = 0; bit < (1 << D); bit++) {
    ll points = 0;
    ll num = 0;
    for (ll i = 0; i < D; i++) {
      if (bit & (1 << i)) {
        points += p[i] * (i + 1) * 100 + c[i];
        num += p[i];
      }
    }

    // cout << "intermidiate " << points << " " << num << endl;

    if (points >= G) {
      ans = min(ans, num);
    } else {
      for (ll i = D - 1; i >= 0; i--) {
        if (bit & (1 << i)) {
          continue;
        }

        for (ll j = 0; j < p[i]; j++) {
          points += (i + 1) * 100;
          num++;
          if (points >= G) {
            ans = min(ans, num);
          }
        }
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,a[1003];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];sort(a,a+n);
	int ans=0;
	for(int i=0;i<k;i++)ans+=a[i];
	cout<<ans;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  
  if (k >= a + b){
    cout << a - k + a + b << endl;
  }
  else if (a <= k && k ){
    cout << a << endl;
  }
  else 
    cout << k << endl;
  
  

  return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N, M;
    cin >> N >> M;
    vector<double> A(0);
    double total = 0;
    rep(i, N) {
        double ai;
        cin >> ai;
        total += ai;
        A.push_back(ai);
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] < total / (4 * M)) { continue; }
        cnt++;
    }
    cout << (cnt >= M ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    long[] b = new long[n];
    long[] c = new long[n];
    long[] bc = new long[n];
    for(int i = 0;i < n;i++)a[i]=sc.nextLong();
    for(int i = 0;i < n;i++)b[i]=sc.nextLong();
    for(int i = 0;i < n;i++)c[i]=sc.nextLong();
    Arrays.parallelSort(a);
    Arrays.parallelSort(b);
    Arrays.parallelSort(c);
    int k = 0;
    for(int j = 0;j < n;j++){
      while(k <= n-1&&b[j]>=c[k])k++;
      if(k==n)break;
      bc[j]=(long)n-k;
    }
    long tmp = 0;
    long sum = 0;
    int j = n-1;
    for(int i = n-1;i >= 0;i--){
      while(j >= 0&&a[i]<b[j]){
        tmp+=bc[j];
        j--;
      }
      if(j==n-1)continue;
      sum+=tmp;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 99856
R,G,B,N = map(int, input().split())
count=0

for i in range(N//R+1):
    for j in range(N//G+1):
        if (N-(R*i+G*j))<0:
            break
        if (N-(R*i+G*j))%B==0:
            count=count+1
print(count)

Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s, t;
  cin >> s >> t;
  ll ans = 0;

  REP(i, SZ(s)) {
    if (s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x,y;
  cin >> x >> y;
  if(x.size() != y.size()){
    cout << (x.size() > y.size()?"GREATER":"LESS") << endl;
  }else{
    int f = 0;
    for(int i=0;i<x.size() && f == 0;i++){
      if(x[i] > y[i]) f = 1;
      if(x[i] < y[i]) f = -1;
    }
    cout << (f?(f>0?"GREATER":"LESS"):"EQUAL") << endl;
  }
}

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

const long MOD = 1e9 + 7;

int main() {
    string L; cin >> L;
    vector<long> dp_un(L.length()), dp_le(L.length());
    dp_un[0] = 2; dp_le[0] = 1;
    for (int i = 1; i < L.length(); i++) {
        if (L[i] == '0') {
            dp_un[i] = dp_un[i-1] % MOD;
            dp_le[i] = (3 * dp_le[i-1]) % MOD;
        }
        else {
            dp_un[i] = (2 * dp_un[i-1]) % MOD;
            dp_le[i] = (3 * dp_le[i-1] + dp_un[i-1]) % MOD;
        }
    }
    cout << (dp_un[L.length()-1] + dp_le[L.length()-1]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

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

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, n, m);
  vector<bool> vi(m, true);
  for (int i = 0; i < n; ++i) {
    vector<bool> tmp(m, false);
    Cin(int, k);
    for (int j = 0; j < k; ++j) {
      Cin(int, a);
      tmp[a - 1] = true;
    }
    for (int j = 0; j < m; ++j) vi[j] = vi[j] & tmp[j];
  }
  int ans = 0;
  for (auto e : vi) ans += e == true;
  cout << ans << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll w,h;
	cin>>w>>h;
	priority_queue<ll,vector<ll>,greater<ll>> p;
	priority_queue<ll,vector<ll>,greater<ll>> q;
	REP(i,w) {
		ll n;
		cin>>n;
		p.push(n);
	}
	REP(i,h) {
		ll n;
		cin>>n;
		q.push(n);
	}
	ll pc=0,qc=0;
	__int128 ret=0;
	while(!p.empty()||!q.empty()) {
		if(q.empty()||(!p.empty()&&p.top()<q.top())) {
			ret+=p.top()*(h+1-qc);
			p.pop();
			++pc;
		} else {
			ret+=q.top()*(w+1-pc);
			q.pop();
			++qc;
		}
	}
	cout<<(ll)ret<<endl;
}


Measured memory_bytes: 2548
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int u = scan.nextInt();
			int[][] graph = new int[u][u];
			for(int i = 0;i < u;i++){
				int v = scan.nextInt();
				int e = scan.nextInt();
				for(int j = 0;j < e;j++){
					graph[v-1][scan.nextInt()-1] = 1;
				}
			}
			for(int i = 0;i < u;i++){
				for(int j = 0;j < u;j++){
					System.out.print(graph[i][j] + ((j != u-1)?" ":"\n"));
				}
			}
		}
	}
}

Measured memory_bytes: 23960
#include<bits/stdc++.h>
#define MAX 1000
using namespace std;
typedef long long ll;
int N,M,K,ans = 0;
int main () {
    ios_base::sync_with_stdio(false);
    cin>>K>>N>>M;
    bool flag = false;
    for(int i=N;i<=M;i++) {
        if(i%K == 0) {
            flag = true;
            break;
        }
    }
    if(flag) {
        cout<<"OK"<<"\n";
    }
    else {
        cout<<"NG"<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3596