akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {

	public static void main(String[] args) throws Exception {
		FastScanner scanner = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);//今週知った高速化テク２：これを使う事でオートフラッシュを避ける

		PriorityQueue<Integer> queue = new PriorityQueue<>(Collections.reverseOrder());
		for(;;) {
			String order = scanner.nextString();
			if(order.equals("insert")) {
				queue.offer(scanner.nextInt());
			}else if(order.equals("extract")) {
				out.println(queue.poll());
			}else if(order.equals("end")){
				break;
			}
		}

		out.flush();
	}

}

/**
 * 標準APIのScannerと同様の処理を高速でしたい
 * Javaのchar型は実は16ビット割り当てられているけど
 * 0x00から0x7Fまでの文字しか考えない事にした
 * https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
 */
class FastScanner {

	private InputStream inputStream;
	private byte buffer[];
	private int pointer;
	private int bufferLength;
	private char delimiter;

	FastScanner(InputStream in) {
		inputStream = in;
		buffer = new byte[1024];
		pointer = 0;
		bufferLength = 0;
		delimiter = ' ';
	}

	int nextInt() throws IOException {
		int ret = 0;
		if(!hasNextElement()) throw new NoSuchElementException();
		boolean isMinus = false;
		byte b = read1Byte();
		if(b==0x2D) isMinus=true;
		while(true) {
			/*
			 * 制御文字なら終了、数字ではない文字ならNumberFormatExceptionを投げる
			 * のは面倒なので数字じゃなければ全部終了にした。
			 */
			if(0x30<=b && b<=0x39) {
				ret = ret*10 +b-0x30;
			}else break;
			b = read1Byte();
		}
		if(isMinus) ret*=-1;
		return ret;
	}

	String nextString() throws IOException {
		if(!hasNextElement()) throw new NoSuchElementException();
		StringBuffer sb = new StringBuffer();
		for(;;) {
			byte b = read1Byte();
			if(b==delimiter || isControlCharacter((char) b)) {
				break;
			}else {
				sb.append((char)b);
				continue;
			}
		}
		return sb.toString();
	}

	boolean hasNextElement() throws IOException {
		while(hasNextByte() && isControlCharacter((char) buffer[pointer])) {
			pointer++;
		}
		return hasNextByte();
	}

	void setDelimiter(char d) {
		delimiter = d;
	}

	private boolean isControlCharacter(char c) {
		return (c<=0x1F) || c==0x7F;
	}

	private boolean hasNextByte() throws IOException {
		if(pointer < bufferLength) {
			return true;
		}else {
			//読み込む処理
			pointer = 0;
			bufferLength = inputStream.read(buffer);
			if(bufferLength<=0) return false;
		}
		return true;
	}

	private byte read1Byte() throws IOException {
		if(hasNextByte()) return buffer[pointer++];
		else return -1;
	}
}



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

using namespace std;

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   string s;
   cin >> s;
   if(s.back() == 's') {
      cout << s << "es" << endl;
   } else {
      cout << s << "s" << endl;
   }
}

Measured memory_bytes: 3668
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	X := sc.nextInt()
	x := 100
	i := 0
	for x < X {
		x = int(1.01 * float64(x))
		i++
	}

	fmt.Println(i)
	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 1760
S = input()

jdg = True
cnt = 0

for i, s in enumerate(S):
    if i == 0 and s != 'A':
        jdg = False
        break
    if (i == 1 or i == len(S) - 1) and not s in 'abcdefghijklmnopqrstuvwxyz':
        jdg = False
        break
    if 2 <= i <= len(S) - 2 and s == 'C':
        cnt += 1
    if i >= 1 and not s in 'abcdefghijklmnopqrstuvwxyzC':
        jdg = False
        break
if cnt != 1: jdg = False
            
print('AC' if jdg else 'WA')

Measured memory_bytes: 3064
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());

int n;

int answ[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    cin >> n;
    cout << answ[n] << endl;
	return 0;
}


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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print( pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;


int main(void)
{
    string s; cin >> s;
    bool bol=false;
    for(int i=0;i<s.size();i++){
        if(s[i]=='7'){
            bol=true;
        }
    }
    if(bol){
            cout << "Yes" << endl;
       }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        // freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int n;
const int N = 1e6 + 5;
string s[N];
int cur = 0;
array<int, 3> get (string &s) {
    ++cur;
    int mn = 0, tot = 0;
    for (auto &i: s) {
        if (i == '(')
            tot++;
        else
            tot--;
        mn = min(mn, tot);
    }
    return {tot, mn, ++cur};
}
bool cmp_pos (array<int, 3> a, array<int, 3> b) {
    if (a[1] != b[1])
        return a[1] > b[1];
    if (a[0] != b[0])
        return a[0] > b[0];
    return a[2] < b[2];
}
bool cmp_neg (array<int, 3> a, array<int, 3> b) {
    if (abs(a[0] - a[1]) != abs(b[0] - b[1]))
        return abs(a[0] - a[1]) > abs(b[0] - b[1]);
    if (a[1] != b[1])
        return a[1] > b[1];
    if (a[0] != b[0])
        return a[0] > b[0];
    return a[2] < b[2];   
}
vector<array<int, 3>> pos, neg;
vector<array<int, 3>> sol;
void solve() {  
    cin >> n;
    rep(i, 0, n) {
        cin >> s[i];
        auto lol = get(s[i]);
        if (lol[1] == 0)
            sol.push_back(lol);
        else if (lol[0] >= 0)
            pos.push_back(lol); 
        else
            neg.push_back(lol);
    }
    sort(all(pos), cmp_pos);
    sort(all(neg), cmp_neg);
    for (auto &i: pos)
        sol.push_back(i);
    for (auto &i: neg)
        sol.push_back(i);
    int tot = 0, mn = 0;
    for (auto &i: sol) {
        mn = min(mn, tot + i[1]);
        tot += i[0];
    }
    if (tot == 0 && mn == 0)
        cout << "Yes";
    else
        cout << "No";
}       
    

Measured memory_bytes: 70768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        int a=Integer.parseInt(bf.readLine());
        int[] h=new int[a];

        String[] str=bf.readLine().split(" ");
        for(int i=0;i<a;i++){
            h[i]=Integer.parseInt(str[i]);
        }
        str.clone();
        Sort(h,a);
    }


    public static void Sort(int[] a, int b){
        int j,v;

        for(int i=0; i<a.length; i++){
            v=a[i];
            j=i-1;

            while(j>=0 && a[j]>v){
                a[j+1]=a[j];
                j--;
            }
            a[j+1]=v;
            toArray(a);
        }

    }

    public static void toArray(int[] h){
        StringBuilder sb=new StringBuilder();

        for(int i=0;i<h.length;i++){
            sb.append(h[i]);

            if(i<h.length-1)sb.append(" ");
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 26584
#include <iostream>
using namespace std;
int main()
{
    int ans[] = {0, 0, 0, 61, 230, 865, 3247, 12185, 45719, 171531, 643550, 2414454, 9058467, 33985227, 127504505, 478366600, 794717734, 733354121, 261943303, 776803305, 580025381, 51688048, 44657419, 737209731, 604119499, 159693437, 858533109, 639056669, 549054109, 996291083, 531294469, 23314687, 783022045, 855462856, 649970414, 68697295, 409213624, 604356692, 88638656, 978442997, 534833116, 763737161, 785892908, 123883652, 639213333, 181836645, 998121103, 124885216, 501575626, 39816123, 113468411, 799008836, 775465589, 256852905, 664630886, 971550783, 751629411, 51018086, 702530485, 725438992, 696683714, 792638194, 221791721, 149602322, 414054379, 986519078, 981760191, 305799096, 515140586, 406959393, 975058685, 245601370, 324759692, 673385295, 191483611, 570246669, 427196161, 781042769, 569725155, 842176273, 25328739, 847501730, 206282374, 353770801, 323137024, 371653459, 940737264, 123820509, 915711339, 847205021, 252858375, 718889563, 866398347, 738390145, 133009077, 333099663, 170591295, 329869205, 616680192, 597534442, 388130742};
    int n;
    cin >> n;
    cout << ans[n] << endl;
    return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec d = ivec(n);
    int ans = 0;
    For(i, 0, n - 1) { For(j, i + 1, n - 1) ans += d[i] * d[j]; }
    print(ans);

    return 0;
}


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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int maxN = 1e16;
const int oo = 1e18;
const int mod  = 998244353;
const int base = 26;
const double PI = 3.14159265358979323846;

int ans[N];

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("spm.out", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    FOR(i, 1, n - 1) {
        int x; cin >> x;
        ans[x] ++;
    }
    FOR(i ,1, n) cout << ans[i] << '\n';
}


Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100000
int n,m;
vector<int> G[MAX_N];
bool visited[MAX_N];

bool dfs(int pos,int prev){
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(prev==to)continue;
    if(visited[to])return true;
    visited[to]=true;
    if(dfs(to,pos))return true;
  }
  return false;
}

bool solve(){
  for(int i=0;i<n;i++){
    if(G[i].size()>2)return false;
    if(visited[i])continue;
    visited[i]=true;
    if(dfs(i,-1))return false;
  }

  return true;
}

void init(){
  for(int i=0;i<MAX_N;i++){
    G[i].clear();
    visited[i]=false;
  }
}

int main(){
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0)break;
    init();
    for(int i=0;i<m;i++){
      int a,b;
      scanf("%d %d",&a,&b);
      a--,b--;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    printf(solve()?"yes\n":"no\n");
  }
  return 0;
}

Measured memory_bytes: 7132
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;
#define int ll

int typeA(int H, int W) {
    int m = min(H, W);
    int M = max(H, W);

    if (H % 3 == 0 || W % 3 == 0) {
        return 0;
    }
    else {
        return m;
    }
}

int typeB(int H, int W) {
    int area = H * W;
    int res = 10e11;
    int s1, s2, s3;
    for (int i = 1; i < H; i++) {
        s1 = W * i;
        int offset = W % 2;
        s2 = (H - i) * (W / 2);
        s3 = (H - i) * (W / 2 + offset);

        res = min(res, max({ s1,s2,s3 }) - min({ s1,s2,s3 }));
    }

    for (int i = 1; i < W; i++) {
        s1 = H * i;
        int offset = H % 2;
        s2 = (W - i) * (H / 2);
        s3 = (W - i) * (H / 2 + offset);

        res = min(res, max({ s1,s2,s3 }) - min({ s1,s2,s3 }));
    }
    return res;
}
signed main() {
    int H, W; cin >> H >> W;

    int ans = 10e11;
    ans = min(ans, typeA(H, W));
    ans = min(ans, typeB(H, W));

    cout << ans << endl;
}

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

vector<vector<int>> t(200005,vector<int>());
vector<int> ans(200005);

void dfs(int v,int p){
    for(int u:t[v]){
        if(u==p) continue;
        ans[u]+=ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p,x;
        cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    dfs(0,-1);
    for(int i=0;i<n;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 23424
import java.io.*;
import java.io.InputStreamReader;
import java.util.*;
public class Main
{
    static long dist[][];
    static long ans;
    static void solve(int array[], int start, int end) {
        if (start == end) {
            long temp = 0;
            for (int i = 1; i < array.length - 1; i++)
                temp += dist[array[i]][array[i + 1]];
            ans = Math.min(ans, temp);
            return;
        }
        for (int i = start; i <= end; i++) {
            swap(array, start, i);
            solve(array, start + 1, end);
            swap(array, start, i);
        }
    }
    static void swap(int array[], int start, int idx){
        int temp = array[start];
        array[start] = array[idx];
        array[idx] = temp;
    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int r = Integer.parseInt(st.nextToken());
        int array[] = new int[r + 1];
        st = new StringTokenizer(br.readLine());
        for (int i = 1; i < array.length; i++)
            array[i] = Integer.parseInt(st.nextToken());
        dist = new long[n + 1][n + 1];
        for(int i = 1;i <= n;i++)
            Arrays.fill(dist[i], Long.MAX_VALUE / 2);
        for (int i = 1; i <= m; i++) {
            st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            int c = Integer.parseInt(st.nextToken());
            dist[a][b] = dist[b][a] = c;
        }
        for (int k = 1; k <= n; k++) {
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++)
                    dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
        ans = Long.MAX_VALUE;
        solve(array, 1, r);
        System.out.print(ans);
    }

}

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


int main(){
    int c5 = 0,c7 = 0;
    int in;
    for(int i=0;i<3;i++){
        cin >> in;
        if(in==5)c5++;
        else if(in==7)c7++;
    }
    if(c5==2&&c7==1)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int x;
    cin >> x;
    if(x==0) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3564
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(String.format("%d %d %f", a/b, a%b, (double)a/b));
		}
	}
}


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

int main(){
    int n, k;
    long long ans = 0;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    sort(h.begin(), h.end());
    for(int i = n - 1; i >= 0; i--){
        if(k > 0){
            k--;
            h[i] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        ans += h[i];
    }

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

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int n, a;
	char *ans;
	ans = "APPROVED";
	scanf("%d",&n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a % 2 == 0)
			if (a % 5 != 0 && a % 3 != 0)
				ans = "DENIED";
	}
	printf("%s",ans);
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	const int MAX = 30;
	vector<vector<ll>> b(n, vector<ll>(MAX));
	vector<int> cnt(MAX);
	rep(i, n) {
		int now = a[i];
		rep(j, MAX) {
			b[i][j] = now%2;
			if(b[i][j]) cnt[j] ^= 1;
			now /= 2;
		}
	}
	rep(i, n) {
		ll ans = 0;
		vector<ll> ch;
		ll tmp = 1;
		rep(j, MAX) {
			if (b[i][j] != cnt[j]) {
				ch.push_back(tmp);
			}
			tmp *= 2;
		}
		for(auto t: ch) {
			ans ^= t;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
    ll a,h,n,w,i,j;
    cin>>a;
    for(i=1;i<=3500;i++)
        for(j=i;j<=3500;j++){
            h=i;
            n=j;
            w=4*h*n-a*n-a*h;
            if(w>0&&a*h*n%w==0)
            {
                w=a*h*n/w;
                printf("%lld %lld %lld\n",h,n,w);
                return 0;
                //break;
            }
        }
    return 0;
}

Measured memory_bytes: 256
(function(stdin) {
  var lines = stdin.trim().split('\n');
  while(1) {
    var line = lines.shift();
    if (line == '0') {
      break;
    }
    var n = Number(line);
    var a = 0, b = 0;
    for (var i = 0; i < n; i++) {
      var numbers = lines.shift().split(' ').map(Number);
      if (numbers[0] == numbers[1]) {
        a += numbers[0];
        b += numbers[0];
      } else if (numbers[0] > numbers[1]) {
        a += numbers[0] + numbers[1];
      } else {
      	b += numbers[0] + numbers[1];
      }
    }
    console.log([a, b].join(' '));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21360
#include <stdio.h>
int main(){
  int n,a,i;
  scanf("%d",&n);
  int ans[n];
  for(i=0;i<n;i++){
    scanf("%d",&a);
    ans[a-1]=i+1;
  }
  for(i=0;i<n;i++){
    printf("%d\n",ans[i]);
  }
}

Measured memory_bytes: 1152
// https://atcoder.jp/contests/abc144/tasks/abc144_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        a: i32, b: i32, s: i32
    };

    let mut rad = ((2*a*a*b-2*s) as f64).atan2((a*a*a) as f64);
    if (a as f64) * rad.tan() > (b as f64) {
        rad = ((a*b*b) as f64).atan2((2*s) as f64);
    }

    println!("{:.12}", rad * 180.0 / std::f64::consts::PI);
}


Measured memory_bytes: 4352
n = int(input())
c = 0
for p in range(2, int(n**0.5)+1): #nが合成数
  e = 0
  while n%p == 0:
    n //= p
    e += 1
  i = 1
  while e >= i:
    e -= i
    c += 1
    i += 1
if n != 1: #nが素数 or nがn^0.5より大きい素数を因数に持つ合成数
  c += 1
print(c)

Measured memory_bytes: 63648
#include <stdio.h>
#include <math.h>
int hantei(int);
int main(){
  int n,a[10000],i,j,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    cnt+=hantei(a[i]);
  }
  printf("%d\n",cnt);
  return 0;
}

int hantei(int a){
  if(a<=1)return 0;
  else if(a==2)return 1;
  else if(a%2==0)return 0;
  double sq=pow(a,0.5);
  int i;
  for(i=3;i<=sq;i+=2){
    if(a%i==0)return 0;
  }
  return 1;
}



Measured memory_bytes: 2064
def run():
  N = int(input())
  abc_li = [tuple(map(int, input().split())) for n in range(N)]
  dp = [[0]*3 for n in range(N)]
  dp[0] = abc_li[0]
  for n in range(1, N):
    for pre_i in range(3):
      for i in range(3):
        if pre_i == i: continue
        dp[n][i] = max(dp[n][i], dp[n-1][pre_i] + abc_li[n][i])
  print(max(dp[-1]))
  
if __name__ == '__main__':
  run()

Measured memory_bytes: 40236
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a;
    double b;
    cin>>a>>b;
    int bb=round(b*100);
    cout<<a*bb/100<<endl;
}

Measured memory_bytes: 3784
/**
 *  Kaiwen Zhou,
 *  CUHK
**/
#include <bits/stdc++.h>
using namespace std;
#define INS ios::sync_with_stdio(false);cin.tie(0)
typedef long long LINT;
#define INF 1000000000000
#define MODU 1000000007

int main(void) {
    INS;
    int H, W;
    cin >> H >> W;
    int dp[H][W];
    for(int i = 0; i < H; i ++)
        for(int j = 0; j < W; j ++) {
            dp[i][j] = 1;
            char c;
            cin >> c;
            if(c == '.') {
                int temp = 0;
                if(i > 0)
                    temp += (dp[i - 1][j]) % MODU;
                if(j > 0)
                    temp += (dp[i][j - 1] ) % MODU;
                if(i > 0 || j >  0)
                    dp[i][j] = temp;
            }
            else dp[i][j] = 0;
        }
    cout << dp[H - 1][W - 1] % MODU << '\n';
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  bool is_lucky = false;
  if(N%10 == 7) is_lucky = true;
  if(N/100 == 7) is_lucky = true;
  if(N/10 - (N/100)*10 == 7) is_lucky = true;
  if(is_lucky) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3632
// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int k,q; cin>>k>>q;
  vector<ll> D(k); for (auto& v : D) cin>>v;

  for (int i = 0; i < q; i++) {
    ll n,x,m; cin>>n>>x>>m;

    x %= m;
    ll zeros = 0;
    ll sum = x;
    for (int i = 0; i < k; i++) {
      auto d = D[i]%m;
      ll times = (n-1)/k + ((n-1)%k>i);
      if (d == 0) {
        zeros += times;
      } else {
        sum += d*times;
      }
    }
    ll ans = n-1-(sum/m+zeros);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int a; char s[30];
	scanf("%d%s", &a, s);
	if (a >= 3200){
		printf("%s", s);
	}
	else{
		printf("red");
	}

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    int n;
    cin >> n;
    
    while(n){
        double mn = 1e9, mx = 0, sum = 0;
        REP(i, n){
            double t;
            cin >> t;
            sum += t;
            mx = max(mx, t);
            mn = min(mn, t);
        }
        cout << (int)((sum - mx - mn) / (n - 2)) << '\n';
        
        cin >> n;
    }
}


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

int main() {
	for(int i=0;i<4;i++){
		int t,n;
		cin>>t>>n;
		switch (t){
			case 1: cout<<6000*n<<endl;
					break;
			case 2: cout<<4000*n<<endl;
					break;
			case 3: cout<<3000*n<<endl;
					break;
			case 4: cout<<2000*n<<endl;
					break;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)998244353, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    char a;

    scanf("%c", &a);

    if (a < 'a') {
        printf("A\n");
    }
    else {
        printf("a\n");
    }

    return 0;
}

Measured memory_bytes: 3760
s=input()
x,y=map(int,input().split())
D=map(len,s.split('T'))
X,Y={next(D)},{0}
for i,d in enumerate(D,1):
  if i%2==0:
    X={x+d for x in X}|{x-d for x in X}
  else:
    Y={y+d for y in Y}|{y-d for y in Y}
if x in X and y in Y:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 4968
#include <stdio.h>

int main(void)
{
	char n[11];
	int s[10];
	int i, j;
	
	while (scanf("%s", n) != EOF){
		for (i = 0; i < 10; i++){
			s[i] = n[i] - '0';
		}
		for (i = 9; 0 <= i; i--){
			for (j = 0; j < i; j++){
				s[j] = (s[j] + s[j + 1]) % 10;
			}
		}
		printf("%d\n", s[0]);
	}
	
	return (0);
}

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

int main() {
	int r,g,b;cin >> r >> g >> b;
	int x = 100 * r + 10 * g + b;
	if (x % 4 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#[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 main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      k: usize,
      t: usize,
      mut aa: [usize; t],
    }
    aa.sort();
    let max_a: usize = *aa.iter().max().unwrap();
    let sum: usize = aa.iter().sum::<usize>() - max_a;

    // debug!(max_a, sum);
    if sum >= max_a - 1 {
        puts!("{}\n", 0);
    } else {
        puts!("{}\n", max_a-1-sum);
    }
}


Measured memory_bytes: 4352
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/

ll n, m;
vvi g;
vi visit, dp;

void dfs(ll u)
{
    visit[u] = 1;
    ll maxi = 0;
    for (auto it: g[u])
    {
        if (visit[it] == 0)
            dfs(it);
        maxi = max(dp[it] + 1, maxi);
    }
    dp[u] = maxi;
}

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

    cin >> n >> m;
    g.resize(n), visit.resize(n, 0), dp.resize(n);

    for (int i = 0; i < m; i++)
    {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        
        g[x].pb(y);
    }

    ll maxi = 0;
    for (int i = 0; i < n; i++)
        if (visit[i] == 0)
            dfs(i), maxi = max(dp[i], maxi);

    cout << maxi << "\n";
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=3500;i++)
		for(int j=1;j<=3500;j++)
		{
			if (4*i*j-(i+j)*n>0 && 1ll*i*n*j%(4*i*j-(i+j)*n)==0){
				printf("%d %d %lld\n",i,j,1ll*i*n*j/(4*i*j-(i+j)*n));
				return 0;
			}
		}
	assert(0);
	return 0;
}

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

int gcd(int a, int b){
  if(!a) return b;
  return gcd(b%a,a);
}

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  
  vector<int> L(N+1);
  for( int i = 0; i < N; i++ ){
    L.at(i+1) = gcd( L.at(i), A.at(i) );
  }
  
  vector<int> R(N+1);
  for( int i = N-1; i >= 0; i-- ){
    R.at(i) = gcd( R.at(i+1), A.at(i) );
  }
  
  int ans = 1;
  int M;
  for( int i = 0; i < N; i++ ){
    M = gcd( L.at(i), R.at(i+1) );
    if( M > ans ) ans = M;
  }
  cout << ans << endl;

}


Measured memory_bytes: 2560
n, *v = map(int, open(0).read().split())

a, b = [[[i,0]for i in range(100010)]for i in range(2)]
for i in range(n):
        if i%2: b[v[i]][1] += 1
        else: a[v[i]][1] += 1

a.sort(key=lambda x:-x[1])
b.sort(key=lambda x:-x[1])

if a[0][0]!=b[0][0]: print(n-a[0][1]-b[0][1])
else: print(n-max(a[0][1]+b[1][1], a[1][1]+b[0][1]))

Measured memory_bytes: 35044
from heapq import heappush,heappop
N,M,s,t=map(int,input().split())
table=[[] for i in range(N)]
rtable=[[] for i in range(N)]
for i in range(M):
    u,v,a,b=map(int,input().split())
    table[u-1].append((a,v-1))
    table[v-1].append((a,u-1))
    rtable[u-1].append((b,v-1))
    rtable[v-1].append((b,u-1))
dij=[]
heappush(dij,(0,s-1))
val=[10**16]*N
val[s-1]=0
while dij:
    q,x=heappop(dij)
    if val[x]<q:
        continue
    for d,y in table[x]:
        if val[y]>val[x]+d:
            val[y]=val[x]+d
            heappush(dij,(val[y],y))
rdij=[]
heappush(rdij,(0,t-1))
rval=[10**16]*N
rval[t-1]=0
while rdij:
    q,x=heappop(rdij)
    if rval[x]<q:
        continue
    for d,y in rtable[x]:
        if rval[y]>rval[x]+d:
            rval[y]=rval[x]+d
            heappush(rdij,(rval[y],y))
ans=[]
t=val[N-1]+rval[N-1]
mod=pow(10,15)
ans.append(mod-t)
for i in range(N-2,-1,-1):
    t=min(t,val[i]+rval[i])
    ans.append(mod-t)
ans=ans[::-1]
for a in ans:
    print(a)



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  int alice = 0, bob = 0;
  rep(i, n) {
    if(i%2) bob += a[i];
    else alice += a[i];
  }
  cout << alice-bob << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    int d = Integer.parseInt(str[3]);
    System.out.println(Math.min(b,d)-Math.max(a,c)>0?
                       Math.min(b,d)-Math.max(a,c):0);
  }
}

Measured memory_bytes: 32628
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
 
using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ld long double 
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
ll mod =1000*1000*1000 + 7 ;
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
#define rigsh(a,b) a>>b 
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count()) ;
		bool sortbysec(const pair<int,int> &a, 
		      const pair<int,int> &b) 
		{ 
		    return (a.second < b.second); 
		} 	   
		
		  ll power(ll a,ll n)
		{
		ll ans=1;
		while(n)
		{
		if(n&1) ans=(ans*a)%mod;
		a=(a*a)%mod ;
		n=n>>1;
		 }
		 return ans;
		}
		ll power2(ll a,ll n)
		{
		ll ans =1 ;
		while(n)
		{
			if(n&1) ans =(ans*a) ;
			n =n>>1 ;
			a = (a*a) ;
		  }
		  return ans ;
		}
		ll lcm(ll a, ll b)
		{
		       return a / __gcd(a, b) * b;
		}
#define N 1000005
#define M 400060
         vll dir({{1, 0}, {-1, 0}, {0, 1}, {0, -1}}) ;
     
      ll dp[N][3] ;
	  void solve() 
	  {
	  ll n ;cin>>n ;
	  if(n ==1 ) 
	  {
	  	cout<<0<<endl ;return ;
	  }
	  f(i,0,n+1) 
	  {
	  	dp[i][0] =dp[i][1] =dp[i][2] =0 ;
	  }
	  dp[0][0] =1 ;
	  f(i,0,n)
	  {
	  	dp[i+1][0] = (8*dp[i][0])%mod ;
	  	dp[i+1][1] = (dp[i][1]*9 +dp[i][0]*2)%mod ;
	  	dp[i+1][2] = (dp[i][1] + dp[i][2]*10)%mod ;
	  }
	  cout<<dp[n][2]<<endl ;
	  }
		  
		int main() 
	  	{
	    SPEED
	   	 ll t =1 ;
	   	 while(t--) solve() ;
		  
	    
	    }

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

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 (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
	return 0;
}

Measured memory_bytes: 256