akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int ();
        int[] d = Ints ();

        int sum = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                sum += d[i] * d[j];
            }
        }

        Console.WriteLine (sum);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 13396
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){if(p==1){return a;}long x=Modpow(a,p/2,m);x=(x*x)%m;return (p&1l)!=0? (x*a)%m:x;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
static long help(long k){
	if(k<=1){return 1;}
	long x=help(k/2);
	return 2*x+1;
}
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       StringBuilder sb=new StringBuilder();
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       long n=s.nextLong();
        
       out.write(help(n)+"");
        out.flush();
  }
}


Measured memory_bytes: 21716
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: "List[int]", B: "List[int]"):
    #s = sorted([(b - a, i ) for i, (a, b) in enumerate(zip(A, B))])
    s = sorted([(b, i ) for i, (a, b) in enumerate(zip(A, B))])

    t = 0
    for _, i in s:
        a, b = A[i], B[i]
        t += a
        if b < t:
            return 'No'

    return 'Yes'


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    result = solve(N, A, B)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42544
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  int cnt=0;
  
  
  
  rep(i,N){
    cin >> H[i];
  }
  
  rep(i,N){
    if(H[i] >= K){
      cnt++;
    }
  }
  cout << cnt << endl;
}
    

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
	string s;
    int n;
    while(cin>>s){
    	if(s[1]=='R'){
    		cout<<"ABC"<<endl;
    	}
    	else{
    		cout<<"ARC"<<endl;
    	}
    }
  return 0;
}




Measured memory_bytes: 3600
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        String s = scan.next();
        int a = 0;
        for(int i = 0; i < n - 2; i++){
            if(s.charAt(i) == 'A' && s.charAt(i + 1) == 'B' && s.charAt(i + 2) == 'C' ){
                a++;
            }
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 23764
n = int(input())
ax = list(map(int, input().split()))
bx = list(map(int, input().split()))

if sum(ax) < sum(bx):
    print(-1)
    exit()

ans = 0
plus = []
minus = 0
for a, b, in zip(ax, bx):
    if a > b:
        plus.append(a-b)
    elif a < b:
        minus += b-a
        ans += 1
plus.sort(reverse=True)
for i in plus:
    if minus <= 0:
        break
    minus -= i
    ans += 1
print(ans)

Measured memory_bytes: 19052
#include<stdio.h>
int main(void){
    int i;
    char s[3];
    scanf("%s",s);
    if(s[0]==s[1]||s[1]==s[2]||s[0]==s[2]){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
	return 0;		
}

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

int top,S[1000];
void push(int x){
S[++top]=x;
}
int pop(){
top--;
return S[top+1];
}
int main(){
int a,b;
top = 0;
char s[100];
while(scanf("%s",s)!=EOF){
if (s[0]=='+'){
a=pop();
b=pop();
push(a+b);
}else if (s[0]=='-'){
b=pop();
a=pop();
push(a-b);
}else if (s[0]=='*'){
a=pop();
b=pop();
push(a*b);
}else{
push(atoi(s));
}
}
printf("%d\n",pop());
return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

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

using namespace std;

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

string src[1010];

map<int,int> ary[52];
int size[52],pos,cur;

int array_name(){
	int ret=-1;
	if(islower(src[pos][cur])) ret=src[pos][cur]-'a';
	if(isupper(src[pos][cur])) ret=src[pos][cur]-'A'+26;
	cur++;
	return ret;
}

int digit(){ return src[pos][cur++]-'0';}


int number(){ 
	int ret=digit();
	while(isdigit(src[pos][cur])) ret=10*ret+digit();
	return ret;
}


int expresssion(){
	if(isdigit(src[pos][cur])) return number();
	int idx=array_name();
	assert(src[pos][cur++]=='[');
	int idx2=expresssion();
	assert(src[pos][cur++]==']');
	if(idx2==-1 || size[idx] <= idx2 || ary[idx].find(idx2)==end(ary[idx]))
		return -1;
	else
		return ary[idx][idx2];
}

int assignment(){
	int idx=array_name();
	assert(src[pos][cur++]=='[');
	int idx2=expresssion();
	assert(src[pos][cur++]==']');
	assert(src[pos][cur++]=='=');
	int val=expresssion();

	if(idx2==-1 ||  val == -1 || size[idx] <= idx2)
		return -1;
	else
		return ary[idx][idx2]=val;
}

void declaration(){
	int idx=array_name();
	assert(src[pos][cur++]=='[');
	size[idx]=number();
	assert(src[pos][cur++]==']');
	return;	
}

int program(int n){
	rep(i,52) size[i]=-1,ary[i].clear();

	rep(i,n){
		pos=i,cur=0;
		bool eq=false;
		rep(j,src[i].size()) if(src[i][j]=='=') eq=true;
		if(eq){
			int res=assignment();
			if(res==-1) return i+1;
		}else
			declaration();
	}

	return 0;
}

int main(void){
	while(cin >> src[0],src[0]!="."){
		int n=1;
		while(cin >> src[n],src[n]!=".") n++;
		cout << program(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3324
#include <iostream>
#include <vector>

int main()
{
	int n, l;
	std::vector<int> h;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		std::cin >> l;
		h.push_back(l);
	}
	int result_count = 1;
	int max = h[0];
	for (unsigned int i = 1; i < h.size(); i++)
	{
		if (h[i] >= max)
		{
			result_count++;

		}
		if (max < h[i])
		{
			max = h[i];
		}
	}
	std::cout << result_count << "\n";
    return 0;
}



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

ans = 0
A.sort()

for i in range(n):
    a = A[i]
    if i == n-1:
        if x-a==0:
            ans += 1
        continue
    if x-a>=0:
        x -= a
        ans += 1

print(ans)


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

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

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int H[] = new int[N];
    int count = 0;
    List<Integer> list = new ArrayList<Integer>();

    for (int i = 0; i < N; i++) {
      H[i] = sc.nextInt();
    }

    for (int i = 0; i < N - 1; i++) {
      if (H[i] >= H[i + 1]) {
        count++;
      } else {
        list.add(count);
        count = 0;
      }

      if (i == N - 2) {
        list.add(count);
      }

    }

    int max = 0;
    for (int i = 0; i < list.size(); i++) {
      if (max <= list.get(i)) {
        max = list.get(i);
      }
    }

    System.out.println(max);

    sc.close();
  }
}


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

int main()
{
    int n = 0;
    cin >> n;
    int max = 0;
    int max_ct = 0;
    //1,2..n までのすべての数を調べる
    for (int i = 1; i <= n; i++)
    {
        int num = i;
        int ct = 0;
        //２で割れる回数を求める
        while (true)
        {
            if (num % 2 != 0)
            {
                break;
            }
            num /= 2;
            ct++;
        }

        //最高回数が更新された
        if (ct >= max_ct)
        {
            max_ct = ct;
            max = i;
        }

    }

    cout << max << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int x, n, count, i, k;
	while (1) {
		scanf("%d %d", &x, &n);
		if (x == 0 && n == 0) {
			break;
		}
		count = 0;
		for (i = 1; i < x; i++) {
			for (k = i+1; k <= x; k++) {
				if (n - i - k > k && n - k - i <= x) {
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

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


int main()
{
    string s;
    cin >> s;
    bool ans = true;
    for(ll i = 0; i < s.length(); i++){
        if(i % 2 == 0){
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                continue;
            }else ans = false;
        }else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                continue;
            }else{
                ans = false;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
H, W=map(int, input().split())
frame=["".join(["#" for _ in range(W+2)])]
S=frame+["#"+input()+"#" for _ in range(H)]+frame
score=[[0 for _ in range(W+2)] for _ in range(H+2)]
for i in range(H+2):
  sharp_j=0
  for j in range(W+2):
    if S[i][j]=="#":
      for k in range(sharp_j+1, j):
        score[i][k]+=j-sharp_j-1
      sharp_j=j
for j in range(W+2):
  sharp_i=0
  for i in range(H+2):
    if S[i][j]=="#":
      for k in range(sharp_i+1, i):
        score[k][j]+=i-sharp_i-2
      sharp_i=i
ans=0
for i in range(H+2):
  for j in range(W+2):
    ans=max(ans, score[i][j])
print(ans)

Measured memory_bytes: 100312
#include<bits/stdc++.h>
using namespace std;
 
int main(){

    int x;
    cin >> x;
    vector<int> sosu  = {};

    int i = 2;
    int n = 0;
    while(1){
        if(i < 10 ||i%10 == 0)n = sosu.size();
        bool so = 1;
        
        for(int j = 0; j < n; ++j){
            if(i%sosu[j]  == 0)so = 0;
        }

        if(so){
            if(i >= x)break;
            else sosu.push_back(i);
        }

        ++i;
    }

    cout << i << endl;

}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DKnapsack1 solver = new DKnapsack1();
        solver.solve(1, in, out);
        out.close();
    }

    static class DKnapsack1 {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int WWW = in.scanInt();
            long v[] = new long[n];
            int wei[] = new int[n];

            for (int i = 0; i < n; i++) {
                wei[i] = in.scanInt();
                v[i] = in.scanInt();
            }


            long K[][] = new long[n + 1][WWW + 1];


            for (int i = 0; i <= n; i++) {
                for (int w = 0; w <= WWW; w++) {
                    if (i == 0 || w == 0)
                        K[i][w] = 0;
                    else if (wei[i - 1] <= w)
                        K[i][w] = Math.max(v[i - 1] + K[i - 1][w - wei[i - 1]], K[i - 1][w]);
                    else
                        K[i][w] = K[i - 1][w];
                }
            }


            out.println(K[n][WWW]);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 133588
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;


int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int a,b,c;
        cin>>a>>b>>c;
        cout<<c<<" "<<a<<" "<<b;
    }
    return 0;
}
    

Measured memory_bytes: 3644
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String none = sc.nextLine();
        String line = sc.nextLine();
        long[] a = Stream.of(line.split(" ")).mapToLong(Long::parseLong).toArray();
        long max = Arrays.stream(a).max().getAsLong();
        long min = Arrays.stream(a).min().getAsLong();
        long sum = Arrays.stream(a).sum();
        System.out.printf("%d %d %d\n", min, max, sum);
    }
}



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

string S, T;

int main(){
	cin >> S >> T;
	int result = 2e9;
	for (int i = 0; i <= S.size() - T.size(); i ++){
		string R = S.substr(i, T.size());
		// cout << R << " ";
		int ct = 0;
		for (int j = 0; j < T.size(); j ++)
			ct += (T[j] != S[i + j]);
		// cout << ct << "\n";
		result = min(result, ct);
	}
	cout << result << "\n";
}

Measured memory_bytes: 3640
#include <stdio.h>

int main() {
    int a, b;
    char op;
    scanf("%d %c %d", &a, &op, &b);

    if (op == '+') {
        printf("%d\n", a+b);
    } else {
        printf("%d\n", a-b);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main() {
	int a, b;
	std::cin >> a >> b;
	if ( a+b == 15 ) {
		std::cout << "+" << std::endl;
	} else if ( a*b == 15 ) {
		std::cout << "*" << std::endl;
	} else {
		std::cout << "x" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,ans=0,d,e,f;
    cin>>a>>b>>c;
    if(a%2||b%2||c%2){
        cout<<ans<<endl;
        return 0;
    }
    if(a==b&&b==c){
        cout<<-1<<endl;
        return 0;
    }
    while(1){
        if(a%2||b%2||c%2){
            cout<<ans<<endl;
            return 0;
        }
        d=(b/2)+(c/2),e=(a/2)+(c/2),f=(a/2)+(b/2),a=d,b=e,c=f;
        ans++;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
 
/*
struct SegmentTree{
   
  vector<lol> SumV(1000005,0);
  vector<lol> MaxV(1000005,0);
  vector<lol> MinV(1000005,0);
  int N;
   
  void update(int i,int x){
    i += N - 1;
    minv[i] = x;
    maxv[i] = x;
    sumv[i] = x;
    while(i > 0){
      i = (i - 1)/2;
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
    }
  }
   
  void add(int i,int x){
    i += N - 1;
    sumv[i] += x;
    maxv[i] += x;
    minv[i] += x;
    while(i > 0){
      i = (i - 1)/2;
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
    }
  }
   
  int getmax(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return -INF;
    if(a <= l && r <= b) return maxv[k];
    else{
      int c1 = getmax(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmax(a,b,2*k+2,(l+r)/2,r);
      return max(c1,c2);
    }
  }
   
  int getmin(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return minv[k];
    else{
      int c1 = getmin(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmin(a,b,2*k+2,(l+r)/2,r);
      return min(c1,c2);
    }
  }
   
  int getsum(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return sumv[k];
    else{
      int c1 = getsum(a,b,2*k+1,l,(l+r)/2);
      int c2 = getsum(a,b,2*k+2,(l+r)/2,r);
      return c1+c2;
    }
  }
}
*/
 
//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  vector<pair<double, int> > ans;
  int n;
  double t, a;
  cin >> n >> t >> a;
  int h;
  reps(i, n){
    cin >> h;
    ans.push_back(mp(abs(a, t - h * 0.006), i));
  }
  sort(all(ans));
  cout << ans[0].second << '\n';
  return 0;
}


Measured memory_bytes: 3792
N = int(input())
L = list(map(lambda x:int(x)*(-1),input().split()))
L.sort()
count = 0
import bisect
for i in range(N-1):
  for j in range(i+1,N-1):
    a = bisect.bisect_left(L,L[i] - L[j])
    if a - j - 1 <= 0:
      count += 0
    else:
      count += a - j - 1
print(count)
    

Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std;
#define ld long double 
#define float long double 
#define ll long long
#define int long long
#define vl vector<ll> 
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define MAXN 100009
#define CASET int ___T; scanf("%lld", &___T); for(int cs=1; cs <= ___T; cs++)
template<class T> bool umin(T& a, T b) { if(a > b){ a = b;return 1;}return 0;}
template<class T> bool umax(T& a, T b) { if(a < b){ a = b;return 1;}return 0;}
const int N = 200 * 1000 + 9;
const int  inf = 1e18;
const int mod=1e9+7;
int i,j,k;
void solve(){
  ll n; cin >> n;
  cout << (n+1)/2 << endl;
  
 





 return ;
}
    signed main(){
   
   // CASET
    solve();
    
   
    return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  ll n, k;
  cin >> n >> k;
  
  ll ways = k;
  
  for (int i = 1; i < n; ++i) {
    ways *= (k-1);
  }
  
  cout << ways << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){

  
int X,A,B;
  cin>>X>>A>>B;
  if(B-A<=0){
    cout<<"delicious"<<endl;
  }
   if(X>=B-A&&0<B-A){
  cout<<"safe"<<endl;
   }
  
   if(X<B-A){
    cout<<"dangerous"<<endl;
  }
}

    


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;


public class Main {
	public static void main(String args[]){
		new Main().run();
	}
	
	void run(){
		double loan = 100000;
		BigDecimal bd;
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		for(int i=0; i < a; i++){
			bd = new BigDecimal(loan * 1.05);
			BigDecimal bdup = bd.setScale(-3, BigDecimal.ROUND_UP);
			loan = bdup.doubleValue();
		}
		System.out.println((int)loan);
	}
}

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

int main()
{
    int n,p,r;
    cin>>n;

    p=n;
    while(p!=0)
    {
        r=p%10;

        if(r==7)
        {
            cout<<"Yes"<<endl;
                return 0;
        }

        p/=10;
    }

    cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

const int N = 105;

vector <int> v[26];

int main(){
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < s.length(); i++) v[t[i] - 'a'].push_back(s[i] - 'a');
    for (int i = 0; i < 26; i++) {
        sort(v[i].begin(), v[i].end());
        v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
    }

    for (int i = 0; i < 26; i++) if (v[i].size() > 1) return cout << "No", 0;
    for (int i = 0; i < 26; i++) v[i].clear();
    for (int i = 0; i < t.length(); i++) v[s[i] - 'a'].push_back(t[i] - 'a');
    for (int i = 0; i < 26; i++) {
        sort(v[i].begin(), v[i].end());
        v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
    }
    
    for (int i = 0; i < 26; i++) if (v[i].size() > 1) return cout << "No", 0;
    cout << "Yes";
	return 0;
}


Measured memory_bytes: 2684
#include <stdio.h>
 
 
int main()
{
	int N, K, Q;
	int i;
	int tmp;
	static int array[100000];
 
	scanf("%d %d %d", &N, &K, &Q);
 
	for (i = 0; i < N; i++) {
		array[i] = K - Q;
	}
 
	for (i = 0; i < Q; i++) {
		scanf("%d", &tmp);
		array[tmp - 1]++;
	}
 
	for (i = 0; i < N; i++) {
 
		if (array[i] <= 0) {
			printf("No\n");
		}
		else {
			printf("Yes\n");
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>

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

using namespace std;

// ABC103-C - Modulo Summation
int main()
{
    int N;
    vector<int> a;

    cin >> N;
    RPT(i, N) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    int ans = 0;
    RPT(i, N) ans += a[i];
    ans -= N;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<int>> Z(H,vector<int>(W,0));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      int a;
      cin>>a;
      if(a%2==1){
        Z[i][j]=1;
      }
    }
  }
//移動配列つくる
  vector<int> Y(H*W,0), X(H*W,0);
  int k=0;
  for(int i=0; i<H; i++){
    if(i%2==0){
      for(int j=0; j<W; j++){
        Y[k]=i;
        X[k]=j;
        k++;
      }
    }
    else if(i%2==1){
      for(int j=W-1; j>=0; j--){
        Y[k]=i;
        X[k]=j;
        k++;
      }
    }
  }
//Nのカウント
  int N=0;
  bool move=false;
  for(k=0; k<H*W; k++){
    if(move==true)
      N++;
    if(Z[Y[k]][X[k]]==1){
      if(move==false)
        move=true;
      else
        move=false;
    }
  }
  cout<<N<<endl;
//座標の表示
  move=false;
  for(k=0; k<H*W; k++){
    if(move==true)
      cout<<Y[k]+1<<" "<<X[k]+1<<endl;
    if(Z[Y[k]][X[k]]==1){
      if(move==false){
        move=true;
      }
      else
        move=false;
    }
    if(move==true && k<H*W-1)
      cout<<Y[k]+1<<" "<<X[k]+1<<" ";
  }
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n;
    cin >> n;
    vector<vll> dp(3, vll(n + 2));
    vector<vll> nums(3, vll(n));
    FOR(i ,n) cin >> nums[0][i] >> nums[1][i] >> nums[2][i];
    FORN(i, 2, n + 2)
    {
        FOR(j, 3)
        {
            dp[j][i] = max(max(dp[j][i - 2], dp[(j + 1) % 3][i - 1]), dp[(j + 2) % 3][i - 1]) + nums[j][i - 2];
        }
    }
    cout << max(max(dp[0][n + 1], dp[1][n + 1]), dp[2][n + 1]) << '\n';
}



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


int main(void){
 
    long long H,W;
    
    cin >> H >> W;
    
    if(H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
        
    }
    
    if(H%2 ==1 && W % 2 == 1){
        cout << H * W / 2 + 1<< endl;
    }else{
        cout << H * W / 2 << endl;
    }
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, M;
  cin >> N >> M;
  priority_queue< int > que;
  REP(i, N) {
    int x;
    cin >> x;
    que.push(x);
  }
  REP(i, M) {
    int val = que.top();
    que.pop();
    val /= 2;
    que.push(val);
  }
  int ans = 0;
  REP(i, N) {
    int val = que.top();
    que.pop();
    ans += val;
  }
  print(ans);
}

Measured memory_bytes: 1400
#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>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define max 100005
#define nil -1

int main() {
	int  n,m=0,b=0;
	cin >> n;
	vector<int> a(n, 0);
	rep(i, n) {
		cin >> a[i];
		m += a[i];
	}
	if (m % 2 == 0) {
		cout << m / 2 << endl;
	}
	else {
		sort(a);
		rep(i, n) {
			if (a[i] % 2 != 0) {
				b = a[i];
				break;
			}
		}
		cout << (m - b) / 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include <stdio.h>
int main()
{

  int a,b;
  scanf("%d%d",&a,&b);

  if(a>b){
    printf("a > b\n");
  }
  if(a<b){
     printf("a < b\n");
  }
  if(a==b){
    printf("a == b\n");
  }

  return 0;
  }

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	using P = pair<string,int>;
	vector<P> line(n);
	foreach(i,line){
		cin >> i.first >> i.second;
	}
	string name;
	cin >> name;
	int ans = 0;
	bool flag = false;
	foreach(i,line){
		if(flag){
			ans += i.second;
		}else{
			if(i.first == name){
				flag = true;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

ll N, M, Q;
vector<ll> a(55), b(55), c(55), d(55);

ll res = 0;

void dfs(ll depth, vector<ll> &now){
    //dump(depth)
    if(depth==N){
        ll tmp = 0;
        REP(i, Q){
            if(now[b[i]] - now[a[i]] == c[i]){
                tmp += d[i];
            }
        }
        chmax(res, tmp);
        return;
    }
    for(int i=now[depth-1];i<=M;i++){
        now[depth] = i;
        dfs(depth+1, now);
        now[depth] = 0;
    }
    return;
}

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

    cin >> N >> M >> Q;
    REP(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    REP(i, Q) a[i]--, b[i]--;

    vector<ll> now(N, 0);
    now[0] = 1;
    dfs(1, now);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int a, b, c, d;

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

    if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) printf("Yes\n");
    else printf("No\n");

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum1 = 0;
        long ans1 = 0;
        long sum2 = 0;
        long ans2 = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            sum1 += a;
            sum2 += a;
            if(i % 2 == 0){
                if(sum1 >= 0){
                    ans1 += sum1 + 1;
                    sum1 = -1;
                }
                if(sum2 <= 0){
                    ans2 += Math.abs(sum2) + 1;
                    sum2 = 1;
                }
            }else{
                if(sum1 <= 0){
                    ans1 += Math.abs(sum1) + 1;
                    sum1 = 1;
                }
                if(sum2 >= 0){
                    ans2 += sum2 + 1;
                    sum2 = -1;
                }
            }
        }

        System.out.println(Math.min(ans1, ans2));
        sc.close();
    }

}


Measured memory_bytes: 48452
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

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

int main(){
    long long N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    long long g = gcd(N, M);

    string s, t;
    for(int i=0; i<N; i+=N/g){
        s.push_back(S[i]);
    }
    for(int i=0; i<M; i+=M/g){
        t.push_back(T[i]);
    }
    cout << (s == t ? N*M/g : -1) << endl;
    return 0;
}


Measured memory_bytes: 512
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func countGreaterOrEq(ints []int) (count int) {
	min := ints[0]
	for _, v := range ints {
		if min >= v {
			min = v
			count++
		}
	}
	return
}

func main() {
	n := nextInt()
	ps := make([]int, n)
	for i := 0; i < n; i++ {
		ps[i] = nextInt()
	}

	r := countGreaterOrEq(ps)

	fmt.Println(r)
}


Measured memory_bytes: 3584
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    R=int(input())
    G=int(input())
    print((G-R)*2+R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/
	
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	vector<ll> s(n + 1, 0);
	map<ll, ll> num;
	for (int i = 0; i < n; i++) {
		s[i + 1] = s[i] + a[i];
	}
	for (int i = 0; i < n + 1; i++) {
		num[s[i]]++;
	}

	ll res = 0;
	for (auto it : num) {
		ll num = it.second;
		res += num * (num - 1) / 2; // nC2
	}

	out(res);

	return 0;
}

Measured memory_bytes: 15872
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


from collections import defaultdict, deque, Counter
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys

# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *


def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1 / f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret

MOD = 10 ** 9 + 7
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
def solve():
    n, m = getList()
    uf = WeightedUnionFind(n+1)
    for i in range(m):
        l, r, d = getList()
        if uf.same(l, r):
            if abs(uf.weight[l] - uf.weight[r]) != d:
                print("No")
                return
        else:
            uf.union(l, r, d)
    print("Yes")
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    solve()

Measured memory_bytes: 12392
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int X,Y;
    cin>>X>>Y;
    int flg=0;
    for(int i=0;i<=X;i++){
        if(i*2+(X-i)*4==Y){
                cout<<"Yes"<<endl;
            flg=1;
        }
    }
    if(!flg)cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll l,r,a,x,y,z, b, c, i, j, k, n, m;
ll arr[2000005],ans[2000005];
string s, str;

int main() {
	cin >> n;
	n = n % 1000;
	n = 1000 - n;
	n = n % 1000;
	cout << n;
	return 0;
}
/*
5
30 40 975
*/

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)        int x; cin>>x; while(x--)
//Actual Code Is At The Top
const int mod = 1e9 + 7;
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int32_t main()
{   
	very_slow
//	no_of_test(x)
	{  
      int n;
      cin>>n;
      int r=0,k=0;
      if(n>=500)
      {
         r=n/500;
         n=n-(r*500);
      }
      if(n>=20)
      {
           k=n/5;

      }
      cout<<r*1000+k*5<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3656
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,x=0,y=0;
  string s;
  cin >> n >> a >> b >> s;
  for(auto p:s) {
    if(p=='c') {
      cout << "No" << "\n";
    }
    else if(p=='a') {
      if(x<a+b) {
        cout << "Yes" << "\n";
        x++;
      }
      else {
        cout << "No" << "\n";
      }
    }
    else {
      if(x<a+b&&y<b) {
        cout << "Yes" << "\n";
        x++,y++;
      }
      else {
        cout << "No" << "\n";
      }
    }
  }
}

Measured memory_bytes: 848
N = int(input())
Hlist = list(map(int, input().split()))
now = Hlist[0]
ans = 0
num = 0
for i in range(N - 1):
    if Hlist[i + 1] <= now:
        num += 1
    else:
        ans = max(ans, num)
        num = 0
    now = Hlist[i + 1]
    # print(ans, num)
print(max(ans, num))


Measured memory_bytes: 14252
from functools import reduce

point_judge = {
    'card_taro > card_hanako': (3,0),
    'card_taro == card_hanako': (1,1),
    'card_taro < card_hanako': (0,3)
}

def solve():
    input_line = input()
    n = int(input_line)
    input_lines = [input() for _ in range(n)]

    print("{0} {1}".format(
        *reduce(lambda x,y: (x[0]+y[0],x[1]+y[1]) , 
                [ v for card_taro, card_hanako in 
                 [ input_line.split(' ') for input_line in input_lines ]
                 for k,v in point_judge.items() if eval(k) ]
               )))

solve()


Measured memory_bytes: 6380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string S;
	cin >> S;

	int N = S.size();

	deque<int> dq;
	int cnt = 1;
	REP(i, 1, N - 1) {
		if (S[i] != S[i - 1]) {
			dq.push_back(cnt);
			cnt = 1;
		} else {
			cnt++;
		}
	}
	dq.push_back(cnt);

	int maxV = *max_element(all(dq));

	int ret = N;
	while (true) {
		if (maxV >= ret) break;

		int tmp = N - ret;
		while (dq.front() <= tmp && dq.size() > 1) {
			int tmp2 = dq.front();
			dq.pop_front();
			tmp2 += dq.front();
			dq.pop_front();
			dq.push_front(tmp2);
			maxV = max(maxV, tmp2);
		}
		while (dq.back() <= tmp && dq.size() > 1) {
			int tmp2 = dq.back();
			dq.pop_back();
			tmp2 += dq.back();
			dq.pop_back();
			dq.push_back(tmp2);
			maxV = max(maxV, tmp2);
		}

		if (maxV >= ret) break;

		ret--;
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
main(){
int a,b,c,d,e;
char f[1002];
scanf("%d\n",&a);
while(a--){
gets(f);
c=strlen(f);
for(d=0;d+6<c+1;d++){
if(((f[d]=='H'&&f[d+1]=='o')&&(f[d+2]=='s'&&f[d+3]=='h'))&&(f[d+4]=='i'&&f[d+5]=='n')&&(f[d+6]=='o')){
f[d+6]='a';
}
}
puts(f);
}
return 0;
}

Measured memory_bytes: 580