akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> u(N-1), v(N-1), w(N-1);
    for(int i=0; i<N-1;i++){
        cin >> u.at(i) >> v.at(i) >> w.at(i);
    }

    vector<bool> color(N, false), painted(N, false);
    int num_painted = 0;

    while(num_painted < N){
        for(int i=0;i<N-1;i++){
            if(num_painted == 0){
                color.at(u.at(i)-1) = true;
                painted.at(u.at(i)-1) = true;
                num_painted++;
                color.at(v.at(i)-1) = (w.at(i)%2 == 0);
                painted.at(v.at(i)-1) = true;
                num_painted++;
            }
            else if(painted.at(u.at(i)-1) && !painted.at(v.at(i)-1)){
                if(color.at(u.at(i)-1)){
                    color.at(v.at(i)-1) = (w.at(i)%2 == 0);
                    painted.at(v.at(i)-1) = true;
                    num_painted++;
                }
                else{
                    color.at(v.at(i)-1) = (w.at(i)%2 != 0);
                    painted.at(v.at(i)-1) = true;
                    num_painted++;
                }
            }
            else if(!painted.at(u.at(i)-1) && painted.at(v.at(i)-1)){
                if(color.at(v.at(i)-1)){
                    color.at(u.at(i)-1) = (w.at(i)%2 == 0);
                    painted.at(u.at(i)-1) = true;
                    num_painted++;
                }
                else{
                    color.at(u.at(i)-1) = (w.at(i)%2 != 0);
                    painted.at(u.at(i)-1) = true;
                    num_painted++;
                }
            }
        }
    }

    for(int i=0;i<N;i++){
        cout << color.at(i) << endl;
    }
}

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

int main()
{
    int n;
    int temp;
    bool can = true;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        if (temp % 2 == 1)
            continue;
        else
        {
            if (temp % 3 == 0 || temp % 5 == 0)
                continue;
            else
            {
                can = false;
                break;
            }
        }
    }
    if (can)
        cout << "APPROVED";
    else
        cout << "DENIED";
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
    int N, K;
    cin >> N >> K;

    int t = K*2 - 1;
    cout << (t <= N ? "YES" : "NO") << endl;
}




}

int main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev;
    struct Node *next;
};
   
struct Node *note;
   
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    note->next->prev = x;
    x->next = note->next;
    note->next = x;
    x->prev = note;
}
   
struct Node* listSearch(int key) {
    struct Node *cur = note->next;
    while(cur != note && cur->key != key ) {
        cur = cur-> next;
    }
    return cur;
}
   
void deleteNode(struct Node *t) {
    if (t == note) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
   
void deleteFirst() {
    deleteNode(note->next);
}
   
void deleteLast() {
    deleteNode(note->prev);
}
void deleteKey(int key) {
    deleteNode(listSearch(key));
}
   
void printList() {
    struct Node *cur;
    cur = note->next;
    int isf = 0;
   
    while(1) {
        if (cur == note) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
   
   
int main(void) {
    int key, n;
    char order[20];
    scanf("%d", &n);
    note = (struct Node *)malloc(sizeof(struct Node));
    note->next = note;
    note->prev = note;
    for (int i = 0; i < n; i++) {
        scanf("%s%d",order, &key);
        if(order[0] == 'i') {
            insert(key);
        }else if(order[0] == 'd') {
            if(strlen(order) > 6) {
                if( order[6] == 'F') {
                    deleteFirst();
                }else if(order[6] == 'L') {
                    deleteLast();
                }
            }else {
                deleteKey(key);
            }
        }
    }
    printList();
    return 0;
}

Measured memory_bytes: 32956
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define pai 3.1415926535

int main(void) {
	int N, T, A;
	scanf("%d%d%d", &N, &T, &A);
	int H[1000];
	double min = 100000;
	int a=0;
	double b;
	for (int i = 0; i < N; i++) {
		scanf("%d", &H[i]);
		b = T - H[i] * 0.006;
		if (fabs((double)A-b) < min) {
			min = fabs((double)A- b);
			a = i;
		}

	}


	printf("%d", a+1);

	return 0;
}




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

using namespace std;

typedef struct {
	int val;
	int add;
} Node;

Node seg[1 << 20];
int n, q;
char s[300001];

inline void evaluate(int idx)
{
	seg[idx].val += seg[idx].add;
	if (idx < (1 << 19) - 1){
		seg[idx * 2 + 1].add += seg[idx].add;
		seg[idx * 2 + 2].add += seg[idx].add;
	}
	
	seg[idx].add = 0;
}

void update(int k)
{
	seg[k].val = min(seg[k * 2 + 1].val, seg[k * 2 + 2].val);
}

void add(int a, int b, int x, int k = 0, int l = 0, int r = n)
{
	evaluate(k);
	if (r <= a || b <= l) return;
	
	if (a <= l && r <= b){
		seg[k].add += x;
		evaluate(k);
		return;
	}
	
	add(a, b, x, k * 2 + 1, l, (l + r) / 2);
	add(a, b, x, k * 2 + 2, (l + r) / 2, r);
	update(k);
}

int getMin(int a, int b, int k = 0, int l = 0, int r = n)
{
	evaluate(k);
	if (r <= a || b <= l) return (INT_MAX);
	
	if (a <= l && r <= b){
		evaluate(k);
		return (seg[k].val);
	}
	
	int left = getMin(a, b, k * 2 + 1, l, (l + r) / 2);
	int right = getMin(a, b, k * 2 + 2, (l + r) / 2, r);
	update(k);
	
	return (min(left, right));
	
}

void fix(set<int> *a, set<int> *b, char before, int x)
{
    a->erase(x);
    b->insert(x);
    
    int base = before == '(' ? -1 : 1;
    s[x] = before == '(' ? ')' : '(';
    
    add(x, n, 2 * base);
    
    int l = 0, r = x;
    int p;
    
    while (l != r){
        int mid = l + r >> 1;
        p = *b->lower_bound(mid);
        if (getMin(p, n) >= 2 * base) r = mid;
        else l = mid + 1;
    }
    
    p = *b->lower_bound(l);
    add(p, n, -2 * base);
    b->erase(p);
    a->insert(p);
    s[p] = before;
    
    printf("%d\n", p + 1);
}

int main()
{
    scanf("%d %d", &n, &q);
    scanf("%s", s);
    
    set<int> lf, rg;
    
    for (int i = 0; s[i]; i++){
        if (s[i] == '('){
            add(i, n, 1);
            lf.insert(i);
        }
        else {
            add(i, n, -1);
            rg.insert(i);
        }
    }
    
    for (int i = 0; i < q; i++){
        int x;
        scanf("%d", &x); x--;
        
        if (s[x] == '(') fix(&lf, &rg, '(', x);
        else fix(&rg, &lf, ')', x);
    }
    
    return (0);
}

Measured memory_bytes: 23740
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

void fsscan(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    fsscan();
    int n;
    cin>>n;
    int a[n+1];
    a[0]=0;
    int s=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        s+=abs(a[i]-a[i-1]);
    }
    //cout<<s<<endl;
    for(int i=1;i<=n;i++)
    {
        if(i==n)
        {
            cout<<s+(abs(a[n-1]))-(abs(a[n]-a[n-1]))<<endl;
        }
        else
        {
            //cout<<"//"<<abs(a[i]-a[i-1])<<"//"<<abs(a[i]-a[i+1])<<"//"<<abs(a[i+1]-a[i-1])<<endl;
            cout<<s-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])+abs(a[n])<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define N 100010
#define INF (1e9)
using namespace std;

int n,K;
int par[N];
vector<int> G[N];

int bfs(){
  queue<int> Q;
  vector<int> D(N,INF);
  
  for(int i=1;i<=n;i++) if(par[i] == 0) Q.push(i),D[i] = 1;
  
  int res = 0;
  while(!Q.empty()){
    int pos = Q.front();Q.pop();
    int cost = D[pos];
    int to = G[pos].empty()? -1:G[pos][0];
    res += to == 0 || cost <= K;
    if(to >0 && D[to] == INF) Q.push(to),D[to] = cost+1;
  }
  return res;
}


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

  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    G[i].push_back(a);
    par[a] = 1; 
  }
  cout<<bfs()<<endl;
  
  return 0;
}

Measured memory_bytes: 9200
//50
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n;
  cin>>n;
  int s[100]={},ss[100]={};
  for(int i=0;i<n*(n-1)/2;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    b--;
    if(c!=d){
      s[(c>d)?a:b]+=3;
    }else{
      s[a]++;
      s[b]++;
    }
  }
  copy(s,s+n,ss);
  sort(ss,ss+n);
  for(int i=0;i<n;i++){
    cout<<n-(upper_bound(ss,ss+n,s[i])-ss)+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int i,n,a[100009];
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
cout<<a[n/2]-a[(n/2)-1]<<endl;
return 0;
}



Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		while(true){
			int X = 10;
			int Y = 10;
			int[][] map = new int[21][21]; 
			int N = sc.nextInt();
			if(N==0) break;
			for(int s=0;s<N;s++){
				map[sc.nextInt()][sc.nextInt()]=1;;
			}
			int M = sc.nextInt();
			for(int s=0;s<M;s++){
				String tmp = sc.next();
				int d = sc.nextInt();
				for(int k=1;k<=d;k++){
					if(tmp.equals("N")){
						Y++;
					}else if(tmp.equals("E")){
						X++;
					}else if(tmp.equals("S")){
						Y--;
					}else if(tmp.equals("W")){
						X--;
					}
					map[X][Y] = 0;
				}
			}
			boolean e = true;
			for(int x=0;x<21;x++){
				for(int y=0;y<21;y++){
					if(map[x][y]!=0){
						e = false;
					}
				}
			}
			if(e){
				pr.println("Yes");
			}else{
				pr.println("No");
			}
		}
		pr.flush();
		sc.close();
	}
	static class Point{
		int x,y;
		public Point(int x,int y){
			this.x = x;
			this.y = y;
		}
	}
}

Measured memory_bytes: 42444
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100005
using namespace std;
const int mod = 1e9+7;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n, m, S, S_;
int x[N], y[N];

void upd(int &x, int y){ x += y; if(x >= mod) x -= mod; }

int main(){
	n = read(); m = read();
	for(int i = 1; i <= n; i++) x[i] = read(), upd(x[i], mod), upd(S, 1LL * x[i] * (n - i * 2 + 1 + mod) % mod);
	for(int i = 1; i <= m; i++) y[i] = read(), upd(y[i], mod), upd(S_, 1LL * y[i] * (m - i * 2 + 1 + mod) % mod);
	printf("%lld\n", 1LL * S * S_ % mod);
}

Measured memory_bytes: 896
fun main(args: Array<String>) {
    val N = nextLong()
    var ans = 0
    divisor(N).drop(1).forEach { x ->
        var w = N
        while (w % x == 0L) w /= x
        if (w % x == 1L) ans += 1
    }
    ans += divisor(N - 1).drop(1).size
    println(ans)
}

fun divisor(value: Long) =
    (1 .. Math.sqrt(value.toDouble()).toLong())
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .distinct()
        .sorted()


fun next() = readLine()!!
fun nextLong() = next().toLong()



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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	int k;
	cin>>k;
	int a[32]={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};
	cout << a[k-1] << endl;

	return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int x, a; cin >> x >> a;
  if(x <a) cout << 0 <<endl;
  else cout << 10 << endl;
}


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

#define int long long
#define ll long long
#define pb push_back

main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> s(n);
    for(int i = 0; i < n; i++) s[i].resize(m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            char tu;
            cin >> tu;
            if (tu == '1') s[i][j] = 1;
            else s[i][j] = 0;
        }
    }
    n--;
    int mask = (1 << n);
    int ans = 1000000;
    for (int i = 0; i < mask; i++){
        int nowans = 0;
        vector<bool> uy(n);
        for(int j = 0; j < n; j++){
            if (1 & (i >> j)){
                uy[j] = 1;
                nowans++;
            }
            else uy[j] = 0;
        }
        int summ = 1;
        vector<int> all;
        for(int j = 0; j < n; j++){
            if (uy[j] == 0) summ++;
            else{
                all.pb(summ);
                summ = 1;
            }
        }
        all.pb(summ);
        int p = all.size();
        vector<int> nowsumm(p);
        bool verybad = 0;
        for(int j = 0; j < m; j++){
            int ty = 0;
            for(int qw = 0; qw < p; qw++){
                for(int qwe = 0; qwe < all[qw]; qwe++){
                    nowsumm[qw] += s[ty][j];
                    ty++;
                }
            }
            bool bad = 0;
            for(int qw = 0; qw < p; qw++){
                if (nowsumm[qw] > k){
                    bad = 1;
                    break;
                }
            }
            if (bad == 1){
                nowans++;
                for(int qw = 0; qw < p; qw++){
                    nowsumm[qw] = 0;
                }
                int ab = 0;
                for(int qw = 0; qw < p; qw++){
                    for(int qwe = 0; qwe < all[qw]; qwe++){
                        nowsumm[qw] += s[ab][j];
                        ab++;
                    }
                }
                for(int qw = 0; qw < p; qw++){
                    if (nowsumm[qw] > k){
                        verybad = 1;
                        break;
                    }
                }
            }
            if (verybad == 1) break;
        }
        if (verybad == 1) continue;
        ans = min(ans, nowans);
    }
    cout << ans;
}


Measured memory_bytes: 384
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(scan.hasNext())
	    {
	int n=scan.nextInt();
	int i=0,field=0;
	if(n==1 || n==2)
	    {
		field=2*n;
	    }
	else
	    {
		field=4;
		for(i=2;i<=n-1;i++)
		    {
			field+=i;
			
		    }
		field+=n-2;
		
		
		
	    }
	System.out.println(field);
	    }
    }
}

Measured memory_bytes: 18248
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias INCOME = Tuple!(long, "after", long, "salary");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    bool flag;
    foreach (_; iota(n))
    {
        auto a = lread();
        flag = flag || a % 2;
    }
    if (flag)
        writeln("first");
    else
        writeln("second");
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 1276
#include <iostream>
#include <cstdio>

using namespace std;

void binPrint(int x, int bits){
  for (int i=bits-1; i>=0; i--){
    cout << (x&(1<<i)?1:0);
  }
  cout << endl;
}
int main(void){
  unsigned a,b;
  cin >> a >> b;

  binPrint(a&b, 32);
  binPrint(a|b, 32);
  binPrint(a^b, 32);
  
  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int d[303][303];
void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

signed main(){
	int N,M;
	cin >> N >> M;
	REP(i,303)REP(j,303)d[i][j] = INF;
	REP(i,303)d[i][i] = 0;
	REP(i,M){
		int a,b;
		cin >> a >> b;
		a--;b--;
		d[a][b] = 1;
	}
	warshall_floyd(N);
	vector<int>ans[N];
	
	REP(i,N){
		REP(j,N){
			if(d[i][j]!=INF&&d[j][i]!=INF)ans[i].push_back(j+1);
		}
		REP(j,ans[i].size())cout << ans[i][j] << " \n"[j+1 == ans[i].size()];
	}
}



Measured memory_bytes: 4964
#include <stdio.h>

int main()
{
    int n;
    int m;
    int a[10010];
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d",&a[i]);
    }
    int sum=0;
    for(int i=0;i<m;i++)
    {
        sum+=a[i];
    }
    printf("%d\n",(n-sum)<0?-1:n-sum);
}

Measured memory_bytes: 1744
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        av: [isize; n * 3]
    };

    // left
    let mut left_sum = 0;
    let mut left_heap = BinaryHeap::new();
    for &a in &av[0..n] {
        left_sum += a;
        left_heap.push(std::cmp::Reverse(a));
    }
    let mut left_cumax = vec![0; n + 1];
    left_cumax[0] = left_sum;
    for i in n..n * 2 {
        let a = av[i];
        let std::cmp::Reverse(left_min) = *left_heap.peek().unwrap();
        if a > left_min {
            left_heap.pop();
            left_heap.push(std::cmp::Reverse(a));
            left_sum += a - left_min;
        }
        left_cumax[i - (n - 1)] = left_sum;
    }

    // right
    let mut right_sum = 0;
    let mut right_heap = BinaryHeap::new();
    for &a in &av[n * 2..] {
        right_sum += a;
        right_heap.push(a);
    }
    let mut right_cumin = vec![0; n + 1];
    right_cumin[0] = right_sum;
    for i in (n..n * 2).rev() {
        let a = av[i];
        let right_max = *right_heap.peek().unwrap();
        if a < right_max {
            right_heap.pop();
            right_heap.push(a);
            right_sum += a - right_max;
        }
        right_cumin[n * 2 - i] = right_sum;
    }

    // calc
    let mut res = std::isize::MIN;
    for i in 0..n + 1 {
        let score = left_cumax[i] - right_cumin[n - i];
        if score > res {
            res = score;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 9496
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}

const int INF = 100000; 

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

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

    sort(a.begin(), a.end());

    cout << a[n-1] - a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

using namespace std;

int main() 
{
    int n; cin >> n;
    vector<int> t(n), x(n), y(n);
    int pre_t = 0, pre_x = 0, pre_y = 0;

    rep(i,n) {
        int t, x, y;
        cin >> t >> x >> y;
        int dist = abs(x-pre_x) + abs(y-pre_y);
        int time = t - pre_t;
        if(time < dist) {
            cout << "No" << endl; return 0;
        } else {
            if ((dist - time) % 2 == 0) {
                pre_t = t; 
                pre_x = x;
                pre_y = y;
            } else {
                cout << "No" << endl; return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}
    



Measured memory_bytes: 1408
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a = [str(input()) for _ in range(5)]

n = 9
cnt = 0
for i in range(len(a)):
	if int(a[i][-1]) < n and int(a[i][-1]) != 0 :
		n = int(a[i][-1])
		cnt = i
for i in range(len(a)):
	if i == cnt:
		a[i] = int(a[i])
	elif int(a[i][-1]) == 0:
		a[i] = int(a[i])
	else:
		a[i] = (int(a[i])//10 + 1)*10
print(sum(a))


Measured memory_bytes: 9160
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            cnt++;
        }
    }

    if (cnt == N) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }
}


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

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

using namespace std;

signed main(){
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  
  vector<int> v;
  vector<int> v2;
  int A[X];
  int B[Y];
  int C[Z];
  rep(i,X) cin >> A[i];
  rep(i,Y) cin >> B[i];
  rep(i,Z) cin >> C[i];
  
  rep(i,X){
    rep(j,Y){
        v.push_back(A[i]+B[j]);
    }
  } 
  
  sort(v.begin(), v.end(),greater<int>());
  


  int num;
  num = min(K, X*Y); 
  rep(i, num){
    rep(k, Z){
      v2.push_back(v[i]+C[k]); 
    }
  }

  sort(v2.begin(), v2.end(),greater<int>());
  int count = 0; 
  for(int x : v2){
    if(count==K) break;
    count++;
    cout << x << endl;
  }
  
  return 0;
}


Measured memory_bytes: 42852
#include <iostream>
#include <vector>
#include <cstdio>
#include <math.h>

using namespace std;

int main(void){
	double arr[6];
	vector<double> x,y;

	while (cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> arr[4] >> arr[5]){
		double a = arr[0]; double b = arr[1]; double c = arr[2]; double d = arr[3]; double e = arr[4]; double f = arr[5];
		x.push_back((c/a)-(b/a)*(a*f-c*d)/(a*e-b*d));
		y.push_back((a*f-c*d)/(a*e-b*d));
	}
	for (unsigned int i=0; i<x.size(); ++i){
		printf("%.3lf %.3lf\n", x[i], y[i]);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    cout << "?" << " ";
    rep(i,n) cout << i+1 << " ";
    cout << endl;
    //fflush(stdout);
    string s; cin >> s;
    if(s=="-1") return 0;
    vl v(2*n,0);
    ll left = 0;
    ll right = n;
    ll mid = 0;
    while(right-left>1){
        mid = (left+right)/2;
        cout << "?" << " ";
        REP(i,mid,mid+n){
            cout << i+1 << " ";
        }
        cout << endl;
        //fflush(stdout);
        string t; cin >> t;
        if(t=="-1") return 0;
        else if(t=="Red"){
            if(s=="Red"){
                left = mid;
            }else{
                right = mid;
            }
        }else{
            if(s=="Blue"){
                left = mid;
            }else{
                right = mid;
            }
        }
    }
    ll red = 1, blue = -1;
    v[left] = s=="Red" ? red : blue;
    v[left+n] = s=="Red" ? blue : red;
    vl query(n-1);
    rep(i,n-1) query[i] = left+i+2;
    vl query2(n-1);
    ll index = 0;
    rep(i,left){
        cout << "?" << " ";
        cout << i+1 << " ";
        for(auto j : query) cout << j << " ";
        cout << endl;
        //fflush(stdout);
        string t; cin >> t;
        if(t=="-1") exit(0);
        v[i] = t=="Red" ? red : blue;
        query2[index] = i+1; index++;
    }
    REP(i,left+n+1,2*n){
        cout << "?" << " "; 
        for(auto j : query) cout << j << " ";
        cout << i+1 << " ";
        cout << endl;
        //fflush(stdout);
        string t; cin >> t;
        if(t=="-1") exit(0);
        v[i] = t=="Red" ? red : blue;
        query2[index] = i+1; index++;
    }
    REP(i,left+1,left+n){
        cout << "?" << " ";
        cout << i+1 << " ";
        for(auto j : query2) cout << j << " ";
        cout << endl;
        //fflush(stdout);
        string t; cin >> t;
        if(t=="-1") exit(0);
        v[i] = t=="Red" ? red : blue;
    }
    cout << "!" << " ";
    rep(i,2*n){
        if(v[i]==red) cout << "R";
        else cout << "B";
    }
    cout << " " << endl;
}

Measured memory_bytes: 724
#![allow(dead_code, unused)]

use std::cmp::*;
use std::collections::*;
use std::collections::HashSet;
use std::io::stdin;
use std::io::Write;
use std::process::exit;
use std::ptr::read;
use std::str::FromStr;

macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (x, y) = get!(i128,i128);
    for i_t in 0..x + 1 {
        if i_t * 2 + (x - i_t) * 4 == y {
            println!("{}", "Yes");
            exit(0);
        }
    }
    println!("{}", "No");
}

Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<double> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  double sum=0;
  for(auto a:as) sum+=1.0/a;
  cout<<1.0/sum<<endl;
  return 0;
}


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 FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	char A,B,C;
	A=a.at(0)+('A'-'a');
	B=b.at(0)+('A'-'a');
	C=c.at(0)+('A'-'a');
	cout<<A<<B<<C<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = {}

max_val = 0
for i in range(n):
  key = input()
  try:
    s[key] += 1
  except:
    s[key] = 1
  if s[key] > max_val:
    max_val = s[key]

ans = dict(filter(lambda kv: kv[1] == max_val, s.items()))
for k,v in sorted(ans.items()):
  print(k)

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

void scan();
int caut(int inc, int sf, int val);

vector <int> v;
int n,c,k,val,b,nr,ind, jnd;

int main()
{
    scan();
    sort(v.begin(),v.end());

    do{
        jnd=caut(ind, min(n-1,ind+c-1), v[ind]+k);
        ++b;
        ind=jnd+1;
    }while(ind<n);

    cout<<b<<'\n';
    return 0;
}

void scan()
{
    cin>>n>>c>>k;
    for(int i=1; i<=n; ++i)
    {
        cin>>val;
        v.push_back(val);
    }
}

int caut(int inc, int sf, int val)
{
    int mij=0, poz=inc, st=inc, dr=sf;

    while(st<=dr)
    {
        mij=(st+dr)/2;
        if(v[mij]<=val)
            poz=mij, st=mij+1;
        else dr=mij-1;
    }
    return poz;
}


Measured memory_bytes: 892
import sys
input = sys.stdin.readline
N = int(input())
p = list(map(float, input().split()))
dp = [[0] * (N + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
  for j in range(N + 1):
    if dp[i][j] == 0: continue
    dp[i + 1][j] += dp[i][j] * (1 - p[i])
    dp[i + 1][j + 1] += dp[i][j] * p[i]
res = 0
for j in range(N // 2 + 1, N + 1): res += dp[-1][j]
print(res)

Measured memory_bytes: 269320
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=3005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int dp[N][N];
int32_t main()
{
    IOS;
    int n,s;
    cin>>n>>s;
    int ar[n+1];
    for(int i=1;i<=n;i++)
    cin>>ar[i];
    dp[0][0]=2;
    int inv=power(2, mod-2,mod);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j+ar[i]<=s;j++)
        dp[i][j+ar[i]]=(dp[i-1][j]*inv)%mod;
        for(int j=0;j<=s;j++)
        dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
        if(i!=n)
        {
            for(int j=0;j<=s;j++)
            dp[i][j]=(dp[i][j]*2)%mod;
        }
    }
    //print2d(dp,n,s);
    cout<<dp[n][s];
}


Measured memory_bytes: 74052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    int l=s.length();
    int cnt[n]={};
    /* 
    for(int i=n-1;i>=0;i--){
        if(s[i]=='x')cnt[i]=0;
        else if(i!=n-1)cnt[i]=cnt[i+1]+1;
    }
    */
    set<int> don;
    set<int> ans;
    rep(i,n){
        if(s[i]=='o'){
          	debug(i);
            don.insert(i);
            i+=c;
        }
    }
    if(sz(don)>k)return 0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='o'){
          	debug(i);
            ans.insert(i);
            i-=c;
        }
    }
    set<int> res;
    set_intersection(all(don),all(ans),inserter(res,res.end()));
    for(auto x:res)cout << x+1 << endl;
    /*for(int i=n-1;i>=0;i--){
        if(s[i]=='!')cnt[i]=0;
        else if(i!=n-1)cnt[i]=cnt[i+1]+1;
    }
    for(int p=sz(don)-1;p>=0;p--){
        int x=don[p];
        bool y=true;
        for(int i=x+1;i<=x+c;i++){
            if(s[i]=='o' && cnt[i]<=c+1){
                y=false;
                break;
            }
        }
        if(y)ans.insert(x);
    }*/


    


}

/*



 */



Measured memory_bytes: 30596
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;

int main() {
  vector<int> V(3);
  cin >> V[0] >> V[1] >> V[2];
  sort(V.begin(), V.end());
  if (V[0]==5 && V[1]==5 && V[2]==7) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;

class Main{
	int[][] f;
	
	String solve(){
		// ヨコ
		for(int y=0; y<3; ++y){
			int t = f[y][0];
			if(t==0)continue;
			boolean b = true;
			for(int x=0; x<3; ++x){
				b &= t==f[y][x];
			}
			if(b){
				return t==1 ? "o" : "x";
			}
		}
		
		// タテ
		for(int x=0; x<3; ++x){
			int t = f[0][x];
			if(t==0)continue;
			boolean b = true;
			for(int y=0; y<3; ++y){
				b &= t==f[y][x];
			}
			if(b){
				return t==1 ? "o" : "x";
			}
		}
		
		// ナナメ右下
		{
			int t = f[0][0];
			if(t!=0){
				boolean b = true;
				for(int x=0; x<3; ++x){
					b &= t == f[x][x];
				}
				if(b){
					return t==1 ? "o" : "x";
				}
			}
		}
		
		// ナナメ右上
		{
			int t = f[2][0];
			if(t!=0){
				boolean b = true;
				for(int x=0; x<3; ++x){
					b &= t == f[3-1-x][x];
				}
				if(b){
					return t==1 ? "o" : "x";
				}
			}
		}
		
		return "d";
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			f = new int[3][3];
			char[] str = sc.next().toCharArray();
			
			for(int i=0; i<9; ++i){
				f[i/3][i%3] = str[i]=='s' ? 0 : str[i]=='o' ? 1 : -1;
			}
			
			System.out.println(solve());
		}
	}
	
	public static void main(String[] args){
		new Main().io();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 11000
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll kazu = n / (a + b);
    cout << a * kazu + min(n % (a + b), a) << endl;
}


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

using namespace std;
typedef long long ll;
int main()
{
	ll i,j,k,z,n=0,m,s=1,x=0;
	cin>>n;
	if(n%2==0)
	{
		cout<<n/2-1;
	}
	else
	{cout<<n/2;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    System.out.println(lcm(A,B));
  }
  static long lcm(long A, long B){
    return A*B/gcd(A, B);
  }
  static long gcd(long A, long B){
    if(A < B){
      return gcd(B, A);
    }
    if(B == 0){
      return A;
    }
    return gcd(B, A%B);
  }
}

Measured memory_bytes: 21844
using System;
using System.Linq;

namespace atcoder.abc167.a
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = getStringParam();
            string T = getStringParam();

            if (T.StartsWith(S) && T.Length - S.Length == 1)
            {
                char postChar = T.Reverse().ToArray()[0];
                if ('a' <= postChar && postChar <= 'z')
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }

        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
        static decimal getDecimalParam()
        {
            return decimal.Parse(Console.ReadLine());
        }
        static decimal[] getDecimalParams()
        {
            return Console.ReadLine().Split(' ').Select(i => decimal.Parse(i)).ToArray();
        }
    }
}


Measured memory_bytes: 26824
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define PI 3.14159265358979323846
const int MOD = 1e9 + 7 ;
const int EPS = 1e-9;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=201010;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
 
      int n,k;
      cin>>n>>k;
      cout<<(n-k+1);
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=505;
int line[N][N];
int girl[N],used[N];
int k,m,n,a[N],b[N],c[N],d[N];
bool found(int x)
{
    for(int i=1; i<=n; i++)
    {
        if(line[x][i]&&!used[i])
        {
            used[i]=1;
            if(girl[i]==0||found(girl[i]))
            {
                girl[i]=x;
                return 1;
            }
        }
    }
    return 0;
}
int main()
{
    int x,y;
        scanf("%d",&n);
        memset(line,0,sizeof(line));
        memset(girl,0,sizeof(girl));
        for (int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
        for (int i=1;i<=n;i++) scanf("%d%d",&c[i],&d[i]);
        for(int i=1; i<=n; i++) for (int j=1;j<=n;j++)
        {
            if (a[i]<c[j]&&b[i]<d[j])
            line[i][j]=1;
        }
        int sum=0;
        for(int i=1; i<=n; i++)
        {
            memset(used,0,sizeof(used));
            if(found(i)) sum++;
        }
        printf("%d\n",sum);
    return 0;
}

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

using namespace std;

typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int l;
    cin >> l;
    double a = (double)l/3;
    cout << fixed;
    cout.precision(10);
    cout << a * a * a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll n,w,wt[105],v[105],dp[105][100005];

int main()
{
    cin>>n>>w;
    for(ll i=0;i<n;i++) cin>>wt[i]>>v[i];
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(wt[i-1]<=j) dp[i][j] = max(dp[i-1][j],v[i-1]+dp[i-1][j-wt[i-1]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    // for(ll i=0;i<=n;i++)
    // {
    //     for(ll j=0;j<=w;j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<dp[n][w]<<endl;
}

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

int main() {
    int N;
    cin >> N;
    set<int> A;

    for (int i = 0; i < N; i++) {
        int temp = 0;
        cin >> temp;
        A.insert(temp);
    }
    int result = 0;
    while (1) {
        //cout << A.size() << endl;
        if (A.size() == 1) {
            result = *(A.begin());
            break;
        } else {
            auto max = A.end();
            max--;
            auto min = *max;
            for (auto ite = A.begin(); ite != max; ite++) {
                auto temp = ((*max) % (*ite));
                if (temp < min) min = temp;     
                if (min == 0) break;
            }
            A.erase(max);
            //cout << min << endl;
            if (0 != min) A.insert(min);
        }
    }
    cout << *(A.begin()) << endl;

    return 0;
}



Measured memory_bytes: 4992
# 解説AC(できるといいな)
n = gets.to_i
c = 10.times.map { Array.new(10, 0) }
for k in 1..n do
  s = k.to_s
  i = s[0].to_i
  j = s[-1].to_i
  c[i][j] += 1
end
count = 0
for i in 0..9 do
  for j in 0..9 do
    count += c[i][j] * c[j][i]
  end
end
puts count


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include <set>

using namespace std;

int gcd(int m, int n) {
    while(n != 0) { 
        int r = m % n; 
        m = n; 
        n = r; 
    } 
    return m;
}

int main() {

	int res = 0;
	int n, x, y;

	cin >> n >> x;
	while (n--) {
		cin >> y;
		res =  gcd(abs(y - x), res);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256