akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int a, b;
    int d, r;
    double f;

    cin >> a >> b;

    d = a / b;
    r = a % b;
    f = a / (double)b;

    printf("%d ", d);
    printf("%d ", r);
    printf("%f\n", f);

    return 0;
}

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

const int N = 300005;

int n, p[N];
int f[N][2];
vector <int> to_left, to_right;

bool increasing(vector <int> &a) {
	for (int i = 1; i < a.size(); ++i) {
		if (a[i] <= a[i - 1]) {
			return false;
		}
	}
	return true;
}

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

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
	}

	for (int i = 1; i <= n; ++i) {
		f[i][0] = f[i - 1][0];
		f[i][1] = f[i - 1][1];
		f[i][i % 2] += (p[i] == i);
	}

	for (int i = 1; i <= n; ++i) {
		int dif = i - p[i];
		if (dif % 2 != 0) {
			return cout << "No\n", 0;
		}
		if (dif == 0) continue;
		if (dif > 0) {
			if (f[i][1 - i % 2] - f[p[i]][1 - i % 2] != dif / 2 || f[i][i % 2] - f[p[i] - 1][i % 2] != 0) {
				return cout << "No\n", 0;
			}
			to_left.push_back(p[i]);
		}
		else { // dif < 0
			if (f[p[i]][1 - i % 2] - f[i][1 - i % 2] != -dif / 2 || f[p[i]][i % 2] - f[i - 1][i % 2] != 0) {
				return cout << "No\n", 0;
			}
			to_right.push_back(p[i]);
		}
	}

	if (increasing(to_left) && increasing(to_right)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 5052
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	d := readInt()
	answer := solve(float64(n), float64(d))
	fmt.Println(answer)
}

func solve(n, d float64) float64 {
	return math.Ceil(n / ((d * 2) + 1))
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int parent(int i){
	return i/2;
}

int left(int i){
	return 2*i;
}

int right(int i){
	return 2*i +1;
}

int heapsize(vector <int> &x){
	return x.size()-1;
}

int maxheapify(vector <int> &X, int i){
	int l, r;
	l = left(i);
	r = right(i);

	if (r < X.size() && X[l] < X[r] && X[r] > X[i]){
		swap(X[r], X[i]);
		maxheapify(X, r);
	}
	else if (l < X.size() && X[l] > X[i]){
		swap(X[l], X[i]);
		maxheapify(X, l);
	}
	return 0;
}

int buildmaxheap(vector <int> &X){
	int hsize = heapsize(X);
	for (int i= hsize/2; i>0; i--){
		maxheapify(X, i);
	}
	return 0;
}

int main(void){

	int n;
	cin >> n;

	vector <int> X(n+1);

	for (int i=1; i<n+1; i++){
		cin>>X[i];
	}

	buildmaxheap(X);

	stringstream buf;
	for (int i=1; i<n+1; i++){
		buf<<" "<<X[i];
	}
	cout<<buf.str()<<endl;
	buf.str("");
	return 0;
} 

Measured memory_bytes: 9792
#include<iostream>
#include<bitset>
using namespace std;
int main() {
    long long n;
    cin >> n;
    auto b =bitset<32>(n);
    cout << b << endl;
    cout << (~b) << endl;
    cout << (b<<1) << endl;
    cout << (b>>1) << endl;
    return 0;
}


Measured memory_bytes: 3148
import sys
sys.setrecursionlimit(1000000)
def solve():
    n = int(input())
    ans = [-1] * (n + 1)
    li = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        li[u].append((v, w))
        li[v].append((u, w))
    def f(i, ans, c):
        if li[i] == []:
            return
        for u, w in li[i]:
            if ans[u] == -1:
                if w % 2 == 0:
                    ans[u] = c
                    f(u, ans, c)
                else:
                    ans[u] = c ^ 1
                    f(u, ans, c ^ 1)
    for i in range(1, n):
        if li[i] != [] and ans[i] == -1:
            ans[i] = 0
            f(i, ans, 0)
    print(*ans[1:], sep="\n")
solve()


Measured memory_bytes: 92332
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn rec(l: usize, r:usize, lv:usize, ans:&mut Vec<Vec<usize>>) {
    // debug!(l, r);

    if r-l==1 {
        return
    }

    let half = (r-l)/2 + l;
    rec(l, half, lv+1, ans);
    rec(half, r, lv+1, ans);

    for i in 0..half {
        for j in half..r {
            ans[i][j] = lv;
        }
    }
}

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
    }

    let mut ans = vec![vec![0; n]; n];
    rec(0, n, 1, &mut ans);

    for i in 0..n-1 {
        for j in i+1..n {
            puts!("{} ", ans[i][j]);
        }
        puts!("{}\n", "");
    }
}


Measured memory_bytes: 6652
import collections
import sys

INF = sys.maxsize // 2


def solve(num_vs, adj_list, source, dest):
    visited = [False for _ in range(num_vs)]
    dist = [INF for _ in range(num_vs)]
    q = collections.deque()
    dist[source] = 0
    q.append(source)
    while q:
        s = q.popleft()
        if s == dest:
            return dist[dest] == 2
        for t in adj_list[s]:
            if not visited[t]:
                visited[t] = True
                q.append(t)
                dist[t] = dist[s] + 1
    return False


def main():
    n, m = (int(x) for x in input().split())
    adj_list = [set() for _ in range(n)]
    for _ in range(m):
        a, b = (int(x) - 1 for x in input().split())
        adj_list[a].add(b)
        adj_list[b].add(a)
    res = solve(n, adj_list, 0, n - 1)
    print("POSSIBLE" if res else "IMPOSSIBLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 121676
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))

if 0 in D:
    print(0)
    exit()

counter = defaultdict(int)
for d in D:
    counter[d] += 1

for k in counter:
    if counter[k] >= 3:
        print(0)
        exit()

# 解を求める
ans = 0
for b in range(2 ** 13):
    tmp = [0] # 高橋くんがいる
    for key in range(13):
        if counter[key] == 2:
            tmp += [key, 24 - key]  # 両方
        elif counter[key] == 1:
            # 左右どちらかを試す (b次第)
            if b & 1:
                tmp += [key]
            else:
                tmp += [24 - key]
        b = b >> 1
    
    # gapの計算
    gap = 12
    for i in range(len(tmp)):
        for j in range(i + 1, len(tmp)):
            gap = min(gap, min(abs(tmp[j] - tmp[i]), 24 - tmp[j] + tmp[i]))
    ans = max(ans, gap)

print(ans)

Measured memory_bytes: 69144
N = list(map(int, list(input())))[::-1]
kuriage, up5, ans = False, False, 0

for i in range(len(N)):
    if up5:
        if N[i] < 5:
            ans += N[i] + 5
        else:
            ans += 14 - N[i]
            kuriage = True
        up5 = False
    else:
        if kuriage:
            if N[i] == 4:
                up5, kuriage = True, False
            elif N[i] + 1 < 9 - N[i]:
                ans += N[i] + 1
                kuriage = False
            else:
                ans += 9 - N[i]
        else:
            if N[i] == 5:
                up5 = True
            elif N[i] < 10 - N[i]:
                ans += N[i]
            else:
                ans += 10 - N[i]
                kuriage = True

if up5:
    ans += 5
if kuriage:
    ans += 1
print(ans)

Measured memory_bytes: 21228
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<ll, pair<ll,ll>>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

double n, d, x, y;

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

    int cnt = 0;

    rep(i,n){
        cin >> x >> y;

        double di = sqrt(x*x + y*y);

        if (di <= d) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
   int n;
   cin>>n;
   int a[n],b[n];
   int kai,mai;
   rep(i,n){
       cin>>a[i];
       b[i]=a[i];
   }
   sort(a,a+n);
   reverse(a,a+n);
   kai=a[0];
   mai=a[1];
   if(kai==mai){
       rep(i,n){
           cout<<kai<<endl;
       }
   }
   else{
       rep(i,n){
           if(kai!=b[i]){
               cout<<kai<<endl;
           }
           else{
               cout<<mai<<endl;
           }
       }
   }
}


Measured memory_bytes: 4736
/*author:anshumanc007
   created on:05/01/2019
            */
#include <bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;


#define first fi
#define second se
typedef pair<long long int,long long int> pa;
#define MAX 100005
long long int MOD=1e9+7;
long long int INF=1e18;
long long int dp[MAX][3];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l,m,n,o,p,q,r,x,y,a,b,mini=INF,maxi=0,cnt=0;
    cin>>n;
    long long int A[n+1][3];
    for(i=0;i<n;i++)
    {
        cin>>A[i][0];
        cin>>A[i][1];
        cin>>A[i][2];
    }
    
    for(i=0;i<=n;i++)
    {
        dp[i][0]=0;
        dp[i][1]=0;
        dp[i][2]=0;
    }
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    for(i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+A[i-1][0],dp[i-1][2]+A[i-1][0]);
        dp[i][1]=max(dp[i-1][2]+A[i-1][1],dp[i-1][0]+A[i-1][1]);
        dp[i][2]=max(dp[i-1][0]+A[i-1][2],dp[i-1][1]+A[i-1][2]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#define MSG(x) std::cout << (x) << std::endl;

using namespace std;

int main() {
    std::string s;
    std::string first, second, third, ans;
    cin >> s;
    first = s.substr(0, 5);
    second = s.substr(6, 7);
    third = s.substr(14, 5);

    ans = first + ' ' + second + ' ' + third;
    MSG(ans);
}

Measured memory_bytes: 256
n,m=map(int,input().split())
p=[list(map(int,input().split()))for _ in range(n)]
s=[list(map(int,'0'*m))for _ in range(n)]
for j in range(m):
  c,d=map(int,input().split())
  for i in range(n):
    s[i][j]=abs(p[i][0]-c)+abs(p[i][1]-d)
else:
  for i in range(n):print(1+s[i].index(min(s[i])))


Measured memory_bytes: 3064
using System;
class A {
	static void Main() {
		var a = new string[3];
		var pos = new int[3];
		var p = 0;
		var s = "abc";
		var ss = "ABC";
		for(var i = 0;i < 3;i++) {
			a[i] = Console.ReadLine();
		}

		while(true) {
			if(pos[p] == a[p].Length) {
				Console.WriteLine(ss[p]);
				return;
			}
			for(var i = 0;i < 3;i++) {
				if(s[i] == a[p][pos[p]]) {
					pos[p]++;
					p = i;
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 2648
#include <iostream>

using namespace std;

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

    pair<int, int> m1, m2;
    m1.second = m2.second = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (m1.second <= a) {
            m2.first = m1.first;
            m2.second = m1.second;
            m1.first = i;
            m1.second = a;
        } else if (m2.second <= a) {
            m2.first = i;
            m2.second = a;
        }
    }

    for (int i = 0; i < n; i++) {
        if (i == m1.first) cout << m2.second << endl;
        else cout << m1.second << endl;
    }
}

Measured memory_bytes: 1664
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class ROTN
{
    static void Main(string[] args)
    {
        var number  = int.Parse(Console.ReadLine());

        var words = Console.ReadLine();
        int words_number;

        char[] after_words = new char[words.Length];

        for(var i = 0; i < words.Length; i++)
        {
            
           words_number  = number + (int)(words[i]);
            if(words_number > 90)
            {
                words_number = 64 + (words_number -90);
            }
            //Console.WriteLine(words_number);
            after_words[i] = (char)(words_number);
        }

       foreach(var c in after_words)
        {
            Console.Write(c);
        }



      
    }
}

Measured memory_bytes: 13192
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
P p[100001];
signed main(){
    int n,k;
    int neta[100001]={};
    
    priority_queue<P,vector<P>,greater<P> > que1;
    priority_queue<P> que2;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>p[i].S>>p[i].F;
    sort(p,p+n);
    reverse(p,p+n);
    int sum=0;
    int cnt=0;
    int mp[100001]={};
    
    for(int i=0;i<n;i++){
        if(i>k-1) que2.push(p[i]);
        else {
            que1.push(p[i]);
            sum+=p[i].F;
            if(neta[p[i].S]==0) cnt++;
            neta[p[i].S]++;
        }
    }
    
    sum+=cnt*cnt;
    mp[cnt]=sum;
    while(!que2.empty()){
        P tmp = que2.top();
        que2.pop();
        if(neta[tmp.S]!=0) continue;
        else{
	  neta[tmp.S]++;
            while(!que1.empty()){
	      P tmp2 = que1.top();
	      que1.pop();
                if(neta[tmp2.S]>1){
                    neta[tmp2.S]--;
                    sum= sum-tmp2.F-cnt*cnt+tmp.F+(cnt+1)*(cnt+1);
		    
                    cnt++;
                    mp[cnt]=sum;
                    break;
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<=k;i++) ans = max(ans,mp[i]);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6004
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef vector<int> vi;

int N, M;
vector<vi> V;
priority_queue<int> Q;

void input_init(void) {
	cin >> N >> M;
	V.resize(M + 1);
	int a, b;
	for (int i = 0; i < N; ++i) {
		cin >> a >> b;
		if (a > M)
			continue;
		V[a].push_back(b);
	}
}

int solve(void) {
	int sum = 0;
	for (int i = 1; i <= M; ++i) {
		int sz = V[i].size();
		for (int j = 0; j < sz; ++j)
			Q.push(V[i][j]);
		if (!Q.empty()) {
			sum += Q.top();
			Q.pop();
		}
	}
	return sum;
}

int main(void) {
	input_init();
	int ans = solve();

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


Measured memory_bytes: 5504
N, Y = [int(a) for a in input().split()]
xMax = Y//10000
x, y, z = -1, -1, -1
existsOtoshidama = False

for i in range(xMax+1):
    if existsOtoshidama == True:
        break
    for j in range(N-i+1):
        if 10*i+5*j+(N-i-j) == Y//1000:
            x, y, z = i, j, N-i-j
            existsOtoshidama = True
            break
print(x, y, z)

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

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

	vector<int> v(m + 1, 0);
	for (int i = 0; i < n; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int a;
			cin >> a;
			++v[a];
		}
	}

	int ret = 0;
	for (auto& t : v) {
		if (t == n) {
			++ret;
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Group{
	void init(){
		child_group.clear();
		child_member.clear();
	}
	char name[16];
	vector<int> child_group;
	vector<int> child_member;
};

struct Member{
	char name[16];
};


int check[1000];
bool visited[100];
Group group[100];
Member member[1000];

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

void recursive(int group_id){
	visited[group_id] = true;

	for(int i = 0; i < group[group_id].child_member.size();i++){
		check[group[group_id].child_member[i]] = 1;
	}

	for(int i = 0; i < group[group_id].child_group.size(); i++){
		if(visited[group[group_id].child_group[i]] == false){
			recursive(group[group_id].child_group[i]);
		}
	}
}


int main(){

	int N,count,group_index,member_index,work_index,calc_index,tmp;
	char data[100][300],work[16];
	bool FLG;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		for(int i = 0; i < 1000; i++)check[i] = 0;
		for(int i = 0; i < 100; i++){
			visited[i] = false;
			group[i].init();
		}

		group_index = member_index = 0;

		for(int loop = 0; loop < N; loop++){
			scanf("%s",data[loop]);

			for(work_index = 0;data[loop][work_index] != ':';work_index++){
				work[work_index] = data[loop][work_index];
			}
			work[work_index] = '\0';
			strcpy(group[group_index].name,work);
			group_index++;
		}

		for(int loop = 0; loop < N; loop++){
			for(calc_index = 0; data[loop][calc_index] != ':';calc_index++);
			while(true){

				work_index = 0;
				for(++calc_index;data[loop][calc_index] != ',' && data[loop][calc_index] != '.';calc_index++){
					work[work_index++] = data[loop][calc_index];
				}
				work[work_index] = '\0';

				FLG = false;
				for(int i = 0; i < group_index; i++){
					if(strCmp(group[i].name,work)){
						FLG = true;
						tmp = i;
						break;
					}
				}

				if(FLG){
					group[loop].child_group.push_back(tmp);
				}else{

					FLG = false;
					for(int i = 0; i < member_index; i++){
						if(strCmp(member[i].name,work)){
							FLG = true;
							tmp = i;
							break;
						}
					}

					if(FLG){
						group[loop].child_member.push_back(tmp);
					}else{
						group[loop].child_member.push_back(member_index);
						strcpy(member[member_index].name,work);
						member_index++;
					}
				}

				if(data[loop][calc_index] == '.')break;
			}
		}

		recursive(0);

		count = 0;
		for(int i = 0; i < member_index; i++)count += check[i];
		printf("%d\n",count);
	}

	return 0;
}

Measured memory_bytes: 2780
N, Y = map(int, input().split())
Y //= 1000
i = 0
f = 0
while 1:
  if 10 * i > Y:
    break
  y = Y - 10 * i
  n = N - i
  if n <= y <=  5 * n and (y - n) % 4 == 0:
    print(str(i) + " " + str((y-n)//4) + " " + str((5 * n - y) // 4))
    f = 1
    break
  i += 1
if f == 0:
  print("-1 -1 -1")

Measured memory_bytes: 63160
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);

constexpr int64 MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vint64 bit(64);
    Rep(i, n)
    {
        int64 ai;
        cin >> ai;
        Rep(j, 64)
        {
            if ((ai & (1LL << j)) > 0)
            {
                ++bit[j];
            }
        }
    }

    int64 sum = 0;
    Rep(i, 64)
    {
        int64 count = bit[i] * (n - bit[i]) % MOD;
        sum += (1LL << i) % MOD * count % MOD;
        sum %= MOD;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    scanf("%d",&n);
    char ara[102];
    scanf(" %[^\n]",ara);
    if(n%2==1) {
        printf("No\n");

        return 0;
    }
     int l=strlen(ara);
     int s=l/2;
     for(int k=0;k< l/2;k++){
        if(ara[k]==ara[s])
        {
            s++;

        }
        else {
            printf("No\n");
            return 0;
        }
     }
     printf("Yes\n");
     return 0;
}


Measured memory_bytes: 128
S = list(input())
cnt = 0

for i in range(0,len(S)):
    if i == 0:
        if S[i] != "A":
            print("WA")
            exit()
    elif 2 <= i <= len(S) - 2:
        if S[i] == "C":
            cnt += 1
    if S[i].isupper() and S[i] != "C" and i != 0:
        print("WA")
        exit()

if cnt == 1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <iostream>
#include <set>

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

char s[100000 + 10];

int main(){
  const int n = getInt();
  const int a = getInt();
  const int b = getInt();

  int ac = 0;
  int bc = 0;

  scanf("%s", s);

  REP(i,n){
    bool ret = false;
    if(s[i] == 'a'){
      if(ac + bc < a + b){
        ret = true;
        ac++;
      }
    }else if(s[i] == 'b'){
      if(ac + bc < a + b && bc < b){
        ret = true;
        bc++;
      }
    }

    puts(ret ? "Yes" : "No");
  }

  return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int d = a+b+c;
    if (d >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win"<< endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int H,W;
    for(int i = 0;; i++){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(int j = 1; j <= W; j++){
            printf("#");
        }
        printf("\n");
        for(int j = 2; j < H; j++){
            printf("#");
            for(int k = 2; k < W; k++){
                printf(".");
            }
            printf("#");
            printf("\n");
        }
        for(int j = 1; j <= W; j++){
            printf("#");
        }
        printf("\n\n");
    }
    return 0;
}


Measured memory_bytes: 2604
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int bit = 0, ub = 0, ans = 0;
    for(int i=0; i<N; i++) {
        while(ub < N && (bit & A[ub]) == 0) {
            bit |= A[ub];
            ub++;
        }

        // valid: [i, ub)
        // printf("ub = %lld, i = %lld\n", ub, i);
        ans += ub - i;
        bit ^= A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
def f(i,x):
  while i<=n:
    b[i]+=x
    i+=i&-i
def g(i):
  s=0
  while i:
    s+=b[i]
    i-=i&-i
  return s
(n,q),a,*t=[map(int,t.split())for t in open(0)]
b=[0]*-~n
*map(f,range(1,n+1),a),
for q,l,r in t:
  if q:print(g(r)-g(l))
  else:f(l+1,r)

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

using namespace std;
#define debug(x) { cerr << #x < " = " << x << endl; }

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

	int seven;
	while(n){
		seven = n % 10;
		if(seven == 7) {
			cout << "Yes" << "\n";
			return 0;
		} else {
			n /= 10;
		}
	}
	
	cout << "No" << "\n";
	
	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int L = A + B;
    int R = C + D;

    if(L > R){
        cout << "Left" << endl;
    }
    else if(R > L){
        cout << "Right" << endl;
    }
    else if(L == R){
        cout << "Balanced\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, pair<int, int>>> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
 

 
 
int main(){
    int n,q;
    int sum = 0;
    cin >> n >> q;
    queue<pair<string, int>> a;
    string s; int t;
    for(int i = 0 ;i < n; i++){
        cin >> s >> t;
        a.push(make_pair(s, t));
    }
    while(!a.empty()){
        pair<string,int> b = a.front();
        a.pop();
        if(b.second <= q){
            sum += b.second;
            cout << b.first << " " << sum << endl;
        }else{
            sum += q;
            b.second -= q;
            a.push(b);
        }
        
    }
    
    
    
    return 0;
}


Measured memory_bytes: 6328
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int q = in.nextInt();

		// 子をキーにして親を記録 → 木なので根以外は必ず単一の親を持つ
		HashMap<Integer, Integer> map = new HashMap<>();
		for ( int i = 1; i < n; i++ ) {
			int a = in.nextInt();
			int b = in.nextInt();
			map.put(b, a);
		}

		int[] cnt = new int[n + 1];
		for ( int i = 1; i <= q; i++ ) {
			int p = in.nextInt();
			int x = in.nextInt();
			cnt[p] += x;
		}

		System.out.println( cnt[1] );
		for ( int i = 2; i <= n; i++ ) {
			// 子に親から降りてきたカウントを加算して表示			
			System.out.println( cnt[i] += cnt[map.get(i)] );
		}
		in.close();
	}
}


Measured memory_bytes: 189312
from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000)

def DFS(node):
    if not checked[node]:
        global point
        checked[node] = True
        point += pointlist[node]
        
        for child in neighborlist[node]:
            if not checked[child]:
                DFS(child)
        
        anslist[node] += point
        point -= pointlist[node]

N,Q = map(int, input().split())
neighborlist = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = map(int, input().split())
    neighborlist[a].append(b)
    neighborlist[b].append(a)

pointlist = [0]*(N+1)
for _ in range(Q):
    p,x = map(int, input().split())
    pointlist[p] += x

checked = [False]*(N+1)
anslist = [0]*(N+1)
point = 0

DFS(1)

print(*anslist[1:])

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

int main() {
  int x = 0;
  string s;
  cin >> s;
  if (s[0] == '1') x++;
  if (s[1] == '1') x++;
  if (s[2] == '1') x++;
  cout << x << endl;
}  
  


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }
  vector<int> dp(N);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < N; ++i) {
    dp[i] =
        min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int a=scn.nextInt();
		int b=scn.nextInt();
		int q=scn.nextInt();
		TreeSet<Long> set_a=new TreeSet<>();
		TreeSet<Long> set_b=new TreeSet<>();
		for(int i=0;i<a;i++) {
			set_a.add(scn.nextLong());
		}
		for(int i=0;i<b;i++) {
			set_b.add(scn.nextLong());
		}
		long ans=0;
		for(int i=0;i<q;i++) {
			long x=scn.nextLong();
			if(set_b.ceiling(x)==null) {
				long t2=set_b.floor(x);
				if(set_a.ceiling(x)==null) {
					long s2=set_a.floor(x);
					ans=x-Math.min(s2, t2);

				}else if(set_a.floor(x)==null) {
					long s1=set_a.ceiling(x);
					ans=s1-t2+Math.min(s1-x, x-t2);
				}else {
					long s1=set_a.ceiling(x);
					long s2=set_a.floor(x);
					long a2=x-Math.min(s2, t2);
					long a1=s1-t2+Math.min(s1-x, x-t2);
					ans=Math.min(a1, a2);
				}
			}else if(set_b.floor(x)==null) {
				long t1=set_b.ceiling(x);
				if(set_a.ceiling(x)==null) {
					long s2=set_a.floor(x);
					ans=t1-s2+Math.min(t1-x, x-s2);
				}else if(set_a.floor(x)==null) {
					long s1=set_a.ceiling(x);
					ans=Math.max(s1, t1)-x;
				}else {
					long s1=set_a.ceiling(x);
					long s2=set_a.floor(x);
					long a2=Math.max(s1, t1)-x;
					long a1=t1-s2+Math.min(t1-x, x-s2);
					ans=Math.min(a1, a2);
					
				}
			}else {
				long t2=set_b.floor(x);
				long t1=set_b.ceiling(x);
				if(set_a.ceiling(x)==null) {
					long s2=set_a.floor(x);
					long a1=x-Math.min(s2, t2);
					long a2=t1-s2+Math.min(t1-x, x-s2);
					ans=Math.min(a1, a2);
				}else if(set_a.floor(x)==null) {
					long s1=set_a.ceiling(x);
					ans=Math.max(s1, t1)-x;
					long a1=s1-t2+Math.min(s1-x, x-t2);
					ans=Math.min(ans, a1);
				}else {
					long s1=set_a.ceiling(x);
					long s2=set_a.floor(x);
					long a1=s1-t2+Math.min(s1-x, x-t2);
					long a2=Math.max(s1, t1)-x;
					long a3=x-Math.min(s2, t2);
					long a4=t1-s2+Math.min(t1-x, x-s2);

					ans=Math.min(a1, Math.min(a3, Math.min(a4, a2)));
				}
			}
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 116248
#include <stdio.h>

int main()
{
int cards[4][13];
int i,j,x,b,c;
char a;

for (i=0;i<4;i++){ //??????????????????
for (j=0;j<13;j++){
cards[i][j]=0;
}
}

scanf("%d",&x);
getchar();
for (i=0;i<x;i++){
scanf("%c %d%*c",&a,&b);
if (a=='S') c=0;
else if (a=='H') c=1;
else if (a=='C') c=2;
else c=3;

cards[c][b-1]=1;
}

for (i=0;i<4;i++){
for (j=0;j<13;j++){
if (cards[i][j]!=1){
if (i==0) printf("S");
else if (i==1) printf("H");
else if (i==2) printf("C");
else printf("D");
printf(" %d\n",j+1);
}
}
}
return 0;
}

Measured memory_bytes: 604
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy

if dx == 0:
    if dy > 0:
        d1 = "U"
        d2 = "D"
    else:
        d1 = "D"
        d2 = "U"
    dy = abs(dy)
    ans = d1 * dy
    ans += "R" + d2 * dy + "L"
    ans += "L" + d1 * dy + "R"
    ans += d1 + "RR" + d2 * (dy + 2) + "LL" + d1
    print(ans)
    
elif dy == 0:
    if dx > 0:
        d1 = "R"
        d2 = "L"
    else:
        d1 = "L"
        d2 = "R"
    dx = abs(dx)
    ans = d1 * dx
    ans += "U" + d2 * dx + "D"
    ans += "D" + d1 * dx + "U"
    ans += d1 + "UU" + d2 * (dx + 2) + "DD" + d1
    print(ans)

else:
    if dy > 0:
        d1 = "U"
        d2 = "D"
    else:
        d1 = "D"
        d2 = "U"
    if dx > 0:
        d3 = "R"
        d4 = "L"
    else:
        d3 = "L"
        d4 = "R"
    dx = abs(dx)
    dy = abs(dy)
    ans = d1 * dy + d3 * dx
    ans += d2 * dy + d4 * dx
    ans += d4 + d1 * (dy + 1) + d3 * (dx + 1) + d2
    ans += d3 + d2 * (dy + 1) + d4 * (dx + 1) + d1
    print(ans)

Measured memory_bytes: 9204
decompose :: String -> [Int]
decompose s = map read $ words s

solve :: [Int] -> String
solve [x, y]
    | x < y     = show x ++ " " ++ show y
    | otherwise = show y ++ " " ++ show x

main :: IO ()
main = interact (unlines . map solve . takeWhile (\[x, y] -> x /= 0 || y /= 0) . map decompose . lines)

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

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

    // sort each string by characters inside 
    map<string, ll> cnt;
    for (int i = 0; i < n; i++) {
        sort(s[i].begin(), s[i].end());
        cnt[s[i]] ++;
    }

    // check if the map is the same as intended
    // for (auto p : cnt) {
    //     cout << p.first << " " << p.second << endl;
    // }

    ll ans = 0;
    for (auto p : cnt) {
        ll num = p.second;
        ans += num*(num-1)/2;
    }

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

Measured memory_bytes: 18176
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	string S;
	int ans = 1;

	cin >> N >> S;

	for (int i = 1; i < N; i++) {
		if (S[i - 1] != S[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
H, W = gets.chomp.split(" ").map(&:to_i)
S = []
H.times do
  S << gets.chomp.split("")
end

$VISITED = Hash.new(false)

def calc_next(pt)
  x, y = pt[0], pt[1]
  return [] if S[y][x] == "#"

  next_pt = []
  $VISITED[pt] = true
  [[0,1],[1,0],[0,-1],[-1,0]].each do |d|
    dx, dy = x + d[0], y + d[1]
    next if dx < 0 || dx >= W || dy < 0 || dy >= H ||
            S[dy][dx] == "#" || $VISITED[[dx, dy]]

    next_pt << [dx, dy]
    $VISITED[[dx, dy]] = true
  end
  next_pt
end

results = []

H.times do |y|
  W.times do |x|
    $VISITED = Hash.new(false)
    d = Hash.new(0)
    distance = 0
    next_pt = [[x, y]]
    until next_pt.empty? do
      next_next_pt = []
      next_pt.each do |pt|
        d[pt] = distance
        next_next_pt.concat(calc_next(pt))
      end
      distance += 1
      next_pt = next_next_pt
    end
    results << d.max{|h| h[1]}[1]
  end
end

puts results.max

Measured memory_bytes: 2300
#include<iostream>
#include<algorithm>
using namespace std;
int N, W, H, S, T;
bool mas[100][100];
int rec(int& oldy, int& oldx){
  int cnt = 0;
  for(int i = 0 ; i < T ; i++ ){
    for(int j = 0 ; j < S ; j++ ){
      if(mas[oldy+i][oldx+j]) cnt++;
    }
  }
  return cnt;
}
int main(){
  while(cin >> N , N){
    fill_n(mas[0],10000,false);
    cin >> W >> H;
    while(N--){
      int x, y;
      cin >> x >> y;
      mas[y][x]++;
    }
    cin >> S >> T; //S:W T:H

    int ret = 0;
    for(int i = 0 ; i <= H ; i++ ){
      for(int j = 0 ; j <= W ; j++ ){
        ret = max( ret, rec( i, j) );
      }
    }
    cout << ret << endl;
  }
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int a,b,c; cin>>a>>b>>c;
  if (b-a==c-b) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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


Measured memory_bytes: 256
from collections import deque

com = input().split()
dq = deque()

for op in com:
    if op == '+':
        a = dq.pop()
        b = dq.pop()
        dq.append(a+b)
    elif op == '*':
        a = dq.pop()
        b = dq.pop()
        dq.append(a*b)
    elif op == '-':
        a = dq.pop()
        b = dq.pop()
        dq.append(b-a)
    else :
        dq.append(int(op))
print (dq.pop())


Measured memory_bytes: 5996
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int num = Integer.parseInt(in.nextLine());
    List<Integer> dif = new ArrayList<>();
    while(in.hasNext()){
      dif.add(Integer.parseInt(in.next()));
    }
    Collections.sort(dif);
    int ans = dif.get(num / 2) - dif.get(num / 2 - 1);
    System.out.println(ans);
  }
}
      

Measured memory_bytes: 48836
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
        a[i]=sc.nextInt();
    }
    int count=0;
    for(int i=1;i<n-1;i++){
      if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i+1]<a[i]&&a[i]<a[i-1])){
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    int bad=0;
    cin>>N;
    for(int i=1;i<=N;i++){
        int a;
        cin>>a;
        if(i!=a)bad++;
    }
    cout<<(bad<=2?"YES":"NO")<<endl;
}

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

int main()
{
	int R;

	cin >> R;

	if (R<1200){ 
		cout << "ABC" << endl;
	}

	else if (1200 <= R && R < 2800) {
		cout << "ARC" << endl;
	}

	else if(2800<=R && R<=4208){
		cout << "AGC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* UnionFind */

struct UnionFind{
  vector<int> data;
  vector<ll> sum, sum2, sum3;
  vector<priority_queue<pair<int,pair<int,int> > > > pqs;

  UnionFind(int s):data(s, -1), sum(s, 0), sum2(s), sum3(s), pqs(s) {}

  int root(int x){
    if(data[x] < 0) return x;
    return data[x] = root(data[x]);
  }

  bool set(int x, int y){
    x = root(x); y = root(y);
    if(x == y) return false;
    data[x] += data[y];
    sum[x] += sum[y];
    sum2[x] += sum2[y];
    sum3[x] += sum3[y];

    while(pqs[y].size()) {
      pqs[x].push(pqs[y].top());
      pqs[y].pop();
    }

    data[y] = x;
    sum[y] = sum2[y] = 0;
    return true;
  }

  bool check(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return -data[root(x)];
  }
};



int main(){
  int n, m;
  int x[SIZE];
  vector<pair<int,pair<int,int> > > vec;

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

  UnionFind uf(n);

  for(int i=0;i<n;i++){
    scanf("%d", x+i);
    uf.sum[i] = x[i];
  }

  for(int i=0;i<m;i++){
    int a, b, y;
    scanf("%d%d%d", &a, &b, &y);
    vec.push_back({y, {a-1, b-1}});
  }

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

  int ans = 0;

  for(int i=0;i<m;i++){
    int a = vec[i].second.first;
    int b = vec[i].second.second;
    int y = vec[i].first;

    uf.set(a, b);

    int r = uf.root(a);

    auto &pq = uf.pqs[r];
    uf.sum3[r]++;

    if(uf.sum[r] < y)
      pq.push({-y, {a, b}});

    while(pq.size()){
      if(uf.sum[r] >= -pq.top().first)
        pq.pop();
      else
        break;
    }

    if(pq.size() == 0) {
      ans += uf.sum3[r] - uf.sum2[r];
      uf.sum2[r] = uf.sum3[r];
    }

  }

  cout << m - ans << endl;


  return 0;
}


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

const int MAX_N = 1e5 + 5, inf = 1e9 + 7;
int n, k;
int dp[MAX_N];
int h[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];

	for (int i = 1; i < n; i++) {
		dp[i] = inf;
		for (int j = i - 1; i <= j + k && ~j; j--)
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
	}

	cout << dp[n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long sum=0, mn=1e9+1,i,a,n,b;
	cin>>n;
	
	for(i=0;i<n;i++){
		cin>>a>>b;
		sum+=a;
		if(a>b)
		mn=min(mn,b);
	}
	if(mn==1e9+1)
		cout<<0<<endl;
	else
		cout<<sum-mn;
}

Measured memory_bytes: 256
import java.util.*;
    import java.util.Collections; // sorting use
    import java.io.*;
    import static java.lang.System.*;
    public class Main  {
        public static void main(String[] args) {
    	int i, cnt = 0;
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int k = sc.nextInt();
    	int h[] = new int[n];
     
    	for (i = 0; i < n; i++) {
    	    h[i] = sc.nextInt();		
    	    if ( h[i] >= k) {
    		cnt++;
    	    }
    	}
    	sc.close();
    	out.println(cnt);  
        }
    }

Measured memory_bytes: 48264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iK = int.Parse(sS);
            sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            if (sS.Length > iK) { sS = sS.Substring(0, iK) + "..."; }

            // 出力
            System.Console.WriteLine("{0}", sS.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27296
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    if(n == m){
       cout << "Yes";
       return 0;
    }
    cout << "No";
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int n, d, x;
  int ans = 0;
  cin >> n >> d >> x;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    if (d % vec.at(i) == 0) ans += d / vec.at(i);
    else ans += d / vec.at(i) + 1;
  }
  cout << ans + x << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b)
		printf("a < b\n");
	else if(a>b)
		printf("a > b\n");
	else
		printf("a == b\n");
	return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)x.size())
typedef vector<int> vint;
typedef pair<int,int> PII;
int read(){
	char c=getchar();int d=0,f=1;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';d=d*10+c-48,c=getchar());
	return d*f;
}
const int N=1000010;
const int mod=998244353;
int n,a[N+1];
vector<int> fc[N+1];int p[N+1];
void inc(int&a,int b){a+=b;if(a>=mod)a-=mod;}
void dec(int&a,int b){a-=b;if(a<0)a+=mod;}
int mi(int a,int b){
	int s=1;
	for(;b;b>>=1,a=1LL*a*a%mod)
		if(b&1)s=1LL*s*a%mod;
	return s;
}
int main(){
	for(int i=1;i<=N;++i)
		for(int j=i;j<=N;j+=i)fc[j].pb(i);
	n=read();
	ref(i,1,n)a[i]=read();
	ref(i,1,n){
		ref(j,0,SZ(fc[a[i]])-1)
			inc(p[fc[a[i]][j]],a[i]);
	}
	int ans=0;
	def(i,N,1){
		p[i]=1LL*p[i]*p[i]%mod;
		for(int j=i+i;j<=N;j+=i)
			dec(p[i],p[j]);
		inc(ans,1LL*p[i]*mi(i,mod-2)%mod);
	}
	ref(i,1,n)dec(ans,a[i]);
	cout<<1LL*ans*mi(2,mod-2)%mod<<endl;
}

Measured memory_bytes: 119936
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	int a,b;
	scanf("%d",&a);
	for(int i=1;i<=9;i++)
		if(a/i<=9&&a%i==0)
		{
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  vec A(3),B(3),C(3);
  rep(i,0,3) cin>>A[i]>>B[i]>>C[i];
  ll N,K;
  cin>>N;
  rep(i,0,N) {
    cin>>K;
    rep(i,0,3) {
      if(A[i]==K)
        A[i]=0;
      if(B[i]==K)
        B[i]=0;
      if(C[i]==K)
        C[i]=0;
    }
  }
  bool ans=true;
  rep(i,0,3) {
    if(A[i]==0 &&B [i]==0  && C[i]==0) {
      ans=false;
    }
  }
   
  if(A[0]==0 && A[1]==0 && A[2]==0)
    ans=false;
  if(B[0]==0 && B[1]==0 && B[2]==0)
    ans=false;
  if(C[0]==0 && C[1]==0 && C[2]==0)
    ans=false;
  if(A[0]==0 && B[1]==0 && C[2]==0)
    ans=false;
  if(C[0]==0 && B[1]==0 && A[2]==0)
    ans=false;
  if(ans)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}
  
  
  
  
  
  
    
  


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

int main() {
  double L;cin>>L;
  
  cout << fixed << setprecision(8);
  
  cout << (L/3)*(L/3)*(L/3) << endl;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define F(i, j, k) for(int i = j; i <= k; ++i)
#define pp pair<int, int>
#define mp make_pair
const int maxn = 2e5+5;
int n, m, x;
int read() {
    char ch = getchar();
    int x = 0,f = 1;
    while(!isdigit(ch)) {
	if(ch == '-') f = -1;
	ch = getchar();
    }
    while(isdigit(ch)) {
	x = x * 10 + ch - '0';
	ch = getchar();
    }
    return x * f;
}
int main() {
#ifdef orz
   // freopen("input", "r", stdin);
#endif
    x = read();
    while(x) {
	if(x % 10 == 9) {
	    puts("Yes");
	    return 0;
	}
	x /= 10;
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256