akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000000;

int x, y, a, b, c;
int pa[100000],pb[100000],pc[100000];
ll ans = 0;
int main(){
  cin >> x >> y >> a >> b >> c;
  rep(i, a) cin>>pa[i];
  rep(i, b) cin>>pb[i];
  rep(i, c) cin>>pc[i];
  sort(pa, pa+a);
  reverse(pa, pa+a);
  sort(pb, pb+b);
  reverse(pb, pb+b);
  sort(pc, pc+c);
  reverse(pc, pc+c);
  
  int list[300000];
  rep(i, x) list[i] = pa[i];
  rep(i, y) list[x+i] = pb[i];
  rep(i, c) list[x+y+i] = pc[i];
  sort(list, list + x+y+c);
  reverse(list, list+x+y+c);
  rep(i, x+y) ans += list[i];
  cout << ans <<endl;
}

Measured memory_bytes: 2560
def main():
    N = int(input())
    *a, = map(int, input().split())

    d = [0] * (N + 1)
    for x in a:
        d[x] += 1

    b = 0
    for x in d:
        b += x * (x - 1) // 2

    for x in a:
        t = b - (d[x] - 1)

        print(t)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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


//int* g;
vector<int> g;
long long int_pow(long long a, long long b, const int& mod) {
    long long ans(1);
    while (b) {
        if (b % 2) ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}

void pre_calc(const int& n) {
    //bool* is_c = new bool[n + 1];
  vector<bool> is_c(n + 1);
    vector<int> p;
    //vector<int> g(n + 1);
    //g = new int[n + 1];
  g.resize(n + 1);
    g[1] = 1;

    for (int i = 2; i <= n; ++i) {
        if (!is_c[i]) {
            p.push_back(i);
            // phi: i-1, mu: -1, lcm: i - i * i
            g[i] = i - 1;
        }
        
        for (int j = 0; j < p.size() && p[j] * i <= n; ++j) {
            is_c[i * p[j]] = true;
            // for mobius function: 
            // g[i] * (i % p[j] ? g[p[j]] : 0)
            g[i * p[j]] = g[i] * (i % p[j] ? g[p[j]] : p[j]);
            if (i % p[j] == 0) break;
        }
    }

    //delete[] is_c;
}

int main() {
    // time :k log(n)
    // space k
    int n, k;
    cin >> n >> k;
    const int mod(1000000007);
    long long ans(0);
    pre_calc(k);
    //for (int i = 0; i <= n; ++i) cout << g[i] << ' ';

    //cout << endl;
    for (int i = 1; i <= k; ++i)
        ans = (ans + int_pow(k / i, n, mod) * g[i] % mod) % mod;
    //delete[] g;
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int k;
    cin >> k;
    priority_queue<ll, vector<ll>, greater<ll>> que;

    for (int i = 1; i < 10; ++i) {
        que.push(i);
    }

    ll run;
    while(1){
        run = que.top();
        que.pop();
        k--;
        if (k == 0){
            cout << run << endl;
            return 0;
        }
        que.push(run * 10 + run % 10);
        if (run % 10 > 0) que.push(run * 10 + run % 10 - 1);
        if (run % 10 < 9) que.push(run * 10 + run % 10 + 1);
    }
}

Measured memory_bytes: 5296
#include <stdio.h>

int main(){
	int a, b, c, temp;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if(a > b){
		temp = a;
		a = b;
		b = temp;	
	}
	
	if(b > c){
		temp = b;
		b = c;
		c = temp;	
	}
	
	if(a > b){
		temp = a;
		a = b;
		b = temp;	
	}
		
	printf("%d %d %d\n",a, b, c);
	
	
	return 0;
}

Measured memory_bytes: 596
# coding: utf-8

g1 = ["1", "3", "5", "7", "8", "10", "12"]
g2 = ["4", "6", "9", "11"]
g3 = ["2"]

x, y = raw_input().split()

if x in g1 and y in g1:
    print "Yes"
elif x in g2 and y in g2:
    print "Yes"
elif x in g3 and y in g3:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define F first                                                                                         
#define S second
#define mp make_pair
#define pb push_back
#define y1 variable
#define matrix vector<vector<double> > 

using namespace std;

const int MIN = 2e3 + 2;                                                                                                                                  
const int MXN = 2e6 + 3;
const int MMM = 1e6 + 3;
const int INF = 1e9 + 7;                                                                                                       
const int base = 1e9;
const ll LINF = 1e18 + 15;
const double EPS = 1e-15;                                                                                                                 

int n, a, b;

int main(){
	ios_base::sync_with_stdio(0);              
	cin.tie(0);             
	cout.tie(0);
   	#ifdef Pissoir              	
		//freopen("input.txt", "r", stdin);                                                                                                              
		//freopen("output.txt", "w", stdout);                       
	#else                                                                                           
		//freopen("mushrooms.in", "r", stdin);
  		//freopen("mushrooms.out", "w", stdout);			
    #endif
    cin >> n >> a >> b;
    if (abs(a - b) % 2) cout << "Borys";
    else cout << "Alice";
	return 0;	
}

Measured memory_bytes: 256
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
k = inint()
X = inintl()

ans = 0

for x in X:
    ans += 2*min(x,abs(x-k))

print(ans)

Measured memory_bytes: 61884
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s := r.nextString()

	ans:=0
	for i:=0;i<len(s)/2;i++{
		if s[i] != s[len(s)-1-i] {
			ans++
		}
	}
	fmt.Fprintln(stdout, ans)
}


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

int main() {
  int n, h, w, s = 0;
  cin >> n >> h >> w;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    if(a >= h && b >= w) ++s;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma optimize("Ofast")
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int len[2005];
char s[2005][10005];
bitset<10005> can[2005];
pair<int,int> dp[2][20005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		scanf("%s",s[i]);
		len[i]=strlen(s[i]);
	}
	for(int i=0;i<n;i++){
		can[i].reset();
	}
	can[n]=1;
	for(int i=n-1;i>=0;i--){
		can[i]=can[i+1]|(can[i+1]<<len[i]);
	}
	int cnt=0,ii=0;
	for(int i=0;i<n;i++){
		if(can[i+1][k-len[i]]) dp[0][cnt++]=make_pair(i,0);
	}
	string res;
	pair<int,int> *a=dp[0],*b=dp[1];
	for(int i=1;i<=k;i++){
		char mi='z';
		int cnt2=0;
		pair<int,int> *c=a;
		for(int j=0;j<cnt;j++,c++){
			mi=min(s[(*c).first][(*c).second],mi);
		}
		res+=mi;
		int miid=1e9;
		c=a;
		char mii='z'; 
		for(int j=0;j<cnt;j++,c++){
			int fi=(*c).first,se=(*c).second;
			if(s[fi][se]==mi){
				if(se+1==len[fi]) miid=min(miid,fi);
				else{
					if(s[fi][se+1]<=mii)b[cnt2++]=make_pair(fi,se+1),mii=s[fi][se+1];
				}
			}
		}
		for(int j=miid+1;j<n;j++){
			if(k-len[j]-i>=0&&can[j+1][k-len[j]-i]&&s[j][0]<=mii) b[cnt2++]=make_pair(j,0),mii=s[j][0];
		}
		swap(a,b);
		cnt=cnt2;
	}
	cout<<res;
}


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

using namespace std;

int main() {

    int n, p;

    while(cin >> n >> p, n | p) {

        int bowl = p;
        int stone[n];

        fill(stone, stone + n, 0);

        int i = -1;
        do {
            i = (i + 1) % n;
            if(bowl > 0) {
                --bowl;
                ++stone[i];
            } else {
                bowl += stone[i];
                stone[i] = 0;
            }
        } while(stone[i] != p);

        cout << i << endl;

    }

}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, K, S; cin >> N >> K >> S;
  
  //main
  if(S!=1e9){
    for(int i=0; i<K; i++){
      cout << S << " "; 
    }
    for(int i=K; i<N; i++){
      cout << S+1 << " "; 
    }
  }else{
    for(int i=0; i<K; i++){
      cout << S << " "; 
    }
    for(int i=K; i<N; i++){
      cout << 1 << " "; 
    }
  }
  
  // output

  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

int n;
bool f = 1;
string s;
vector <pair <int, int> > v1, v2;

bool cmp(pair <int, int> x, pair <int, int> y) { return (x.second > y.second); }

int main() {
    fast_io;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        int m = int(s.size()), a = 0, b = 0, q = 0;

        for (int j = 0; j < m; ++j)
            if (s[j] == ')') {
                if (q > 0) --q;
                    else ++a;
            } else ++q;

        b = q;
        if (a < b) v1.push_back(make_pair(a, b));
            else v2.push_back(make_pair(a, b));
    }

    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end(), cmp);

    int q = 0;

    for (auto i : v1) {
        q -= i.first;
        if (q < 0)
            f = 0;
        q += i.second;
    }

    for (auto i : v2) {
        q -= i.first;
        if (q < 0)
            f = 0;
        q += i.second;
    }
    if (q != 0)
        f = 0;

    cout << (f ? "Yes\n" : "No\n");
}


Measured memory_bytes: 11220
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long N ; cin >> N ;
	long res;

	res = (int)sqrt(N);

	res = res * res;

	cout << res << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int x,y,z;
	cin >> x >> y >> z;
	swap(x,y);
	swap(x,z);
	cout << x << ' ' << y << ' ' << z << '\n';
}


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

int main(){
  int A, B, j;
  cin >> A >> B;
  int ans = 0;

  for(int i =A; i <= B; i++){
    j = i;
    if(j/10000 == j%10){
      j %= 10000;
      j /= 10;
      if(j/100 == j%10){
        ans += 1;
      }
    }
  }
  cout << ans << endl;
     
    


}


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

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            List<Long> numbers = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                numbers.add(scanner.nextLong());
            }
            System.out.println(numbers.stream().mapToLong(it -> it).min().getAsLong() + " " + numbers.stream().mapToLong(it -> it).max().getAsLong() + " " + numbers.stream().mapToLong(it -> it).sum());
        }
    }
}

Measured memory_bytes: 45384
import collections
N, K = map(int, input().split())
arr = list(map(int,input().split()))
M = len(list(set(arr))) - K #減らさなきゃいけない種類
ans = 0

#操作不要の場合は、そのままゼロ出して終わる
if K >= len(list(set(arr))):
    print(0)
    exit()

#与えられた数列のKeyとValueをvalueの昇順でリスト化する
c = collections.Counter(arr)
cnt_arr = list(sorted(c.items(), key=lambda x:x[1]))
for i in range(M):
    ans += cnt_arr[i][1]
print(ans)

Measured memory_bytes: 55732
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int x,n;
    cin>>x>>n;
    int p;
    vector<bool> ol(101,false);
    
    for(int i=0;i<n;i++) {
        cin>>p;
        ol[p--]=true;
    }
    
    int m=-1;
    for(int i=0;i<=x;i++){
        if(ol[i]==false) {
            m = i;
        }
    }
    
    
    
    int mm=101;
    for(int i=101;i>=x;i--){
        if(ol[i]==false) {
            mm = i;
        }
    }
    
    if(abs(x-m) <= abs(x-mm)) cout<<m<<endl;
    else cout<<mm<<endl;
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N; N%=10;
    if (N==3) cout << "bon" << '\n';
    else if (N==0||N==1||N==6||N==8) cout << "pon" << '\n';
    else cout << "hon" << '\n';
}

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
s = [0]
for i in range(n):
    s.append(s[-1] + a[i])
s.sort()
result = 0

count = 1
for i in range(n):
    if s[i] == s[i+1]:
        count += 1
    else:
        result += count * (count - 1) // 2
        count = 1
result += count * (count - 1) // 2

print(result)


Measured memory_bytes: 25976
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int Ans = 0, n;cin >> n;
	int r = n - 1;
//	cout << 
	for(int i = 1; i <= n; i++) {
		int j;
		for(j = 1; j <= r; j++) {
			if(i * j >= n)break;
		}
//		cout << "j:" << j << endl;
		Ans += j - 1;
//		cout << Ans << endl;
		r = j - 1; 
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 3632
import sys
import bisect
input = sys.stdin.readline
n, d, a = map(int, input().split())
xh = sorted([tuple(map(int, input().split()))for _ in range(n)])
x_list = [x for x, h in xh]

damage = [0]*(n+1)
ans = 0
for i in range(n):
    x, h = xh[i]
    h -= damage[i]
    if h <= 0:
        damage[i+1] += damage[i]
        continue
    cnt = -(-h//a)
    ans += cnt
    damage[i] += cnt*a
    end_idx = bisect.bisect_right(x_list, x+2*d)
    damage[end_idx] -= cnt*a
    damage[i+1] += damage[i]

print(ans)

Measured memory_bytes: 40936
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.stream.Stream;
import java.util.Collection;
import java.util.Scanner;
import java.util.Optional;
import java.util.Comparator;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long N = in.nextLong();
            long A = in.nextLong();
            long B = in.nextLong();
            long C = in.nextLong();
            long D = in.nextLong();
            long E = in.nextLong();

            long min = Arrays.asList(A, B, C, D, E).stream().min(Comparator.naturalOrder()).get();
            out.println(4L + (long) Math.ceil((double) N / min));
        }

    }
}



Measured memory_bytes: 28500
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	ll a;
	double b;
	while(scanf("%lld%lf", &a, &b)==2)
	{
		ll ans=(a*(int)(b*100+1e-6))/100;
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1748
function main(input){
  input = input.split("\n");
  const a = parseInt(input[0]);
  const s = input[1];
//  const AB = input[0].split(" ").map(x => parseInt(x))
//  console.log(a + s);
 
  if(a >= 3200){
    console.log(s);
  }else{
    console.log("red");
  }
 
 
}
  
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vector<string> str = {
    "SUN","MON","TUE","WED","THU","FRI","SAT"
  };
  string s;
  cin >> s;
  rep(i, 7) {
    if (str[i] == s) {
      cout << 7 - i << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    cin >> s;
    
    int res = 0;
    int counter = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            counter++;
        } else {
            res = max(res, counter);
            counter = 0;
        }
    }
    res = max(res, counter);
    cout << res << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 10000000000;
const ll MOD = 1000000007;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	long long g = gcd(a, b);
	return a / g * b;
}

int main() {
	int n, a, b; cin >> n >> a >> b;
	string s; cin >> s;

	int cnt = 0;
	int ac = 0;
	int bc = 0;

	vector<string>ans(n);

	rep(i, n) {
		if (s[i] == 'a' && cnt < a + b) {
			ans[i] = "Yes";
			cnt++;
		}
		else if (s[i] == 'b' && bc < b && cnt < a + b) {
			ans[i] = "Yes";
			cnt++;
			bc++;
		}
		else {
			ans[i] = "No";
		}
	}
	rep(i, n)cout << ans[i] << "\n";
}


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

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

  int n;
  cin >> n;
  int c = 31;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    int tmp = 0;
    while (a % 2 == 0) {
      a /= 2;
      tmp++;
    }
    c = min(c, tmp);
  }
  cout << c << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double n,m,d;
int main(){
	scanf("%lf%lf%lf",&n,&m,&d);
	printf("%.10lf\n",((d<1?1:2))*(n-d)/(n*n)*(m-1));
	return 0;
}


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

using namespace std;

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

    char c;
    cin >> c;
    if (islower(c)) {
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }

    return 0;
}

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

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        int k = int.Parse(Console.ReadLine());
        int n = s.Length;
        Dictionary<string, int> dic = new Dictionary<string, int>();

        for (int i = 0; i < n; i++)
        {
            for(int j = 1; i + j <= n && j <= 5; j++)
            {
                dic[s.Substring(i, j)] = 0;
            }
        }
        string[] keys = dic.Keys.ToArray();
        Array.Sort(keys);

        Console.WriteLine(keys[k - 1]);
    }
}

Measured memory_bytes: 14560
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (200000)
#define SIZE_BUF (30)

using namespace std;

enum Dir { L, R, U, D };

Dir char_to_dir(char c) {
  switch (c) {
    case 'L':
      return L;
    case 'R':
      return R;
    case 'U':
      return U;
    case 'D':
      return D;
    default:
      printf("Something is wrong...\n");
      return L;
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  int H, W, N, sr, sc;
  char S[MAX_N + 1], T[MAX_N + 1], buf[SIZE_BUF];
  scanf("%d %d %d %d %d", &H, &W, &N, &sr, &sc);
  scanf("%s", S);
  scanf("%s", T);
  sr--;  // NOTE : modified input
  sc--;  // NOTE : modified input
  // printf("%s\n", S);
  // printf("%s\n", T);

  // maximum steps in each direction
  int max_steps[4];
  max_steps[L] = sc;
  max_steps[R] = W - sc - 1;
  max_steps[U] = sr;
  max_steps[D] = H - sr - 1;
  // printf("max_steps:");
  // for (int dir = 0; dir < 4; dir++) {
  //   printf(" %d", max_steps[dir]);
  // }
  // printf("\n");

  // solve dp
  int ans = 1;
  int dpss[MAX_N + 1][4];
  Dir dirs[] = {L, R, U, D};
  Dir opps[] = {R, L, D, U};
  // initialize
  for (int dir = 0; dir < 4; dir++) {
    dpss[0][dir] = 0;
  }
  // update
  for (int i = 0; i < N; i++) {
    const Dir dt = char_to_dir(S[i]), da = char_to_dir(T[i]);
    // printf("i = %d, dt = %d, da = %d\n", i, dt, da);
    for (int dir = 0; dir < 4; dir++) {
      Dir d = dirs[dir], dop = opps[dir];
      dpss[i + 1][d] = dpss[i][d] + (dt == d ? 1 : 0);
      if (dpss[i + 1][d] > max_steps[d]) {
        ans = 0;
        break;
      }
      dpss[i + 1][d] += (da == dop ? -1 : 0);
      dpss[i + 1][d] = max(dpss[i + 1][d], -max_steps[dop]);
    }
    if (!ans) {
      break;
    }
    // print
    // printf("i + 1 = %d:", i + 1);
    // for (int dir = 0; dir < 4; dir++) {
    //   printf(" %d", dpss[i + 1][dir]);
    // }
    // printf("\n");
  }

  // print answer
  if (ans) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 3712
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

A_rest = A % 10
B_rest = B % 10
C_rest = C % 10
D_rest = D % 10
E_rest = E % 10

A_diff = 0
B_diff = 0
C_diff = 0
D_diff = 0
E_diff = 0

if A_rest != 0:
    A_diff = 10 - (A_rest)
else:
    A_rest = 10
if B_rest != 0:
    B_diff = 10 - (B_rest)
else:
    B_rest = 10
if C_rest != 0:
    C_diff = 10 - (C_rest)
else:
    C_rest = 10
if D_rest != 0:
    D_diff = 10 - (D_rest)
else:
    D_rest = 10
if E_rest != 0:
    E_diff = 10 - (E_rest)
else:
    E_rest = 10

dish_list = [A_rest,B_rest,C_rest,D_rest,E_rest]
min_rest = min(dish_list)

diff = min_rest - 10

time = A + A_diff + B + B_diff + C + C_diff + D + D_diff + E + E_diff + diff

print(time)

Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define get(A,B,C,D) (rui[B][D]-rui[A-1][D]-rui[B][C-1]+rui[A-1][C-1])
short dp[102][102][102][102];
int map[100][100];
short rui[101][101];
int main()
{
	int mx,my;
	scanf("%d%d",&mx,&my);
	int sx,sy;
	for(int i=0;i<mx;i++)
	{
		for(int j=0;j<my;j++)
		{
			char z;
			scanf(" %c",&z);
			if(z=='o')map[i][j]=1;
			if(z=='E')sx=i,sy=j;
		}
	}
	for(int i=0;i<mx;i++)for(int j=0;j<my;j++)rui[i+1][j+1]=rui[i+1][j]+rui[i][j+1]-rui[i][j]+map[i][j];
	short maxi=0;
	for(int i=1;i<=mx;i++)
	{
		for(int j=mx;j>=i-1;j--)
		{
			for(int k=1;k<=my;k++)
			{
				for(int l=my;l>=k-1;l--)
				{
					short t=dp[i][j][k][l];
					maxi=max(maxi,t);
					if(i>j||k>l)continue;
					int si=1+sx-(mx-j);
					int sj=1+sx+(i-1);
					int sk=1+sy-(my-l);
					int sl=1+sy+(k-1);
					dp[i+1][j][k][l]=max(dp[i+1][j][k][l],t);
					dp[i][j-1][k][l]=max(dp[i][j-1][k][l],t);
					dp[i][j][k+1][l]=max(dp[i][j][k+1][l],t);
					dp[i][j][k][l-1]=max(dp[i][j][k][l-1],t);
					if(si<=i)dp[i+1][j][k][l]=max(dp[i+1][j][k][l],short(t+get(i,i,max(sk,k),min(sl,l))));
					if(sj>=j)dp[i][j-1][k][l]=max(dp[i][j-1][k][l],short(t+get(j,j,max(sk,k),min(sl,l))));
					if(sk<=k)dp[i][j][k+1][l]=max(dp[i][j][k+1][l],short(t+get(max(si,i),min(sj,j),k,k)));
					if(sl>=l)dp[i][j][k][l-1]=max(dp[i][j][k][l-1],short(t+get(max(si,i),min(sj,j),l,l)));
				}
			}
		}
	}
	printf("%d\n",maxi);
}


Measured memory_bytes: 105216
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i*i <= n; ++i) {
    if (n%i != 0) continue;
    res.push_back(i);
    if (i*i != n) res.push_back(n/i);
  }
  sort(res.begin(), res.end());
  return res;
}


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

  ll ans = 0;
  for (auto & e : divisor(n)) {
    ll m = e - 1;
    if (n / e < m) ans += m;
  }
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3700
<?php
while(fscanf(STDIN,"%f %f %f %f %f %f",$a,$b,$c,$d,$e,$f)){
  $x=($e*$c-$b*$f)/($e*$a-$b*$d);
  $y=($d*$c-$a*$f)/($d*$b-$a*$e);
  printf("%.3f %.3f\n",$x,$y);
}

Measured memory_bytes: 15064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main() {
  int n;
  cin>>n;
  double a,b=0;
  for (int i=0; i<n; i++) {
    cin>>a;
    b+=1/a;
  } 
  printf("%.15lf\n",1/b);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll M = 1e9 + 7;
#define MOD_MUL(n, m) ((((n)%M)*((m)%M))%M)
ll pw(ll n, ll m)
{
    if(m <= 0) return 1;
    if(m == 1) return n;
    if(m & 1) return MOD_MUL(pw(n, m-1), n);
    ll k = pw(n, m/2);
    return MOD_MUL(k, k);
}
ll P(ll n, ll m)
{
    ll k = 1;
    for(ll i = n; i > n - m; i--) {
        k = MOD_MUL(k, i);
    }
    return k;
}
int main()
{
    ll n, a, b, k;
    cin >> n >> a >> b;
    k = pw(2, n) - 1;
    k -= MOD_MUL(P(n, a), pw(P(a, a), M-2));
    k -= MOD_MUL(P(n, b), pw(P(b, b), M-2));
    while(k < 0) k += M;
    cout << k << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int S,h,m,s;
	cin>>S;
	 h=S/3600;
	 m=(S%3600)/60;
	 s=(S%3600)%60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}

Measured memory_bytes: 3080
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

ll N, M;

void solve() {
    ll ans = 0;
    REPR(i, M / N + 1) {
        if (M % i == 0) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> M;
    solve();
    return 0;
}

Measured memory_bytes: 256
s = str(input())

yy = int(s[0:2])
mm = int(s[2:4])

mf1 = False
mf2 = False

if 0 < yy < 13 :
    mf1 = True
if 0 < mm < 13 :
    mf2 = True

if mf1 and mf2 :
    print('AMBIGUOUS')
elif mf1 and not mf2 :
    print('MMYY')
elif not mf1 and mf2 :
    print('YYMM')
elif not mf1 and not mf2 :
    print('NA')

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

int main(){
  int n,m;
  cin>>n>>m;
  char a[n][n+1],b[m][m+1];
  for(int i=0;i<n;i++)
      cin>>a[i];
  for(int i=0;i<m;i++)
      cin>>b[i];
  
  bool can=0;
  for(int i=0;i<n-m+1 &&!can;i++)
    for(int j=0;j<n-m+1&&!can;j++){
      bool still=1;
      for(int k=0;k<m&&still;k++)
        for(int l=0;l<m&& still;l++)
          if(a[i+k][j+l]!=b[k][l]) still=0;
      can=still;
    }
  cout<<(can?"Yes\n":"No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  int n;
  int ans=0;
  cin>>s;
  n = s.length() - 1;
  int m = n/2 + 1;
  rep(i,m){
      if(s.at(i) != s.at(n-i)){
          ans++; 
      }
  }
  cout<<ans<<endl;
}

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

template <class M> class segment_tree{
public:
	typedef typename M::value_type value_type;
	size_t n;
	vector<value_type> v;
	value_type e = M::unit();
	segment_tree(size_t size){
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		for(size_t i=1; i<n+size; ++i) v[i] = e;
	}
	segment_tree(vector<value_type> a){
		size_t size = a.size();
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		for(size_t i=0; i<size; ++i) v[n+i] = a[i];
		for(size_t i=n-1; i>0; --i) v[i] = M::operate(v[2*i], v[2*i+1]);
	}
	void point_update(size_t k, value_type val){
		k += n;
		v[k] = val;
		k >>= 1;
		while(k > 0){
			v[k] = M::operate(v[2*k], v[2*k+1]);
			k >>= 1;
		}
	}
	void point_operate(size_t k, value_type lval){
		k += n;
		v[k] = M::operate(lval, v[k]);
		k >>= 1;
		while(k > 0){
			v[k] = M::operate(v[2*k], v[2*k+1]);
			k >>= 1;
		}
	}
	value_type range_get(size_t l, size_t r){ // [l, r)
		value_type lres = e;
		value_type rres = e;
		l += n;
		r += n;
		while(l < r){
			if(l & 1){
				lres = M::operate(lres, v[l]);
				++l;
			}
			if(r & 1){
				--r;
				rres = M::operate(v[r], rres);
			}
			l >>= 1;
			r >>= 1;
		}
		return M::operate(lres, rres);
	}
	value_type operator[](size_t k){
		return v[k+n];
	}
};
struct plus_monoid{
	using value_type = Int;
	static value_type unit(){
		return 0;
	}
	static value_type operate(value_type l, value_type r){
		return l + r;
	}
};
struct min_monoid{
	using value_type = Int;
	static value_type unit(){
		return (1ll<<31)-1;
	}
	static value_type operate(value_type l, value_type r){
		return min(l, r);
	}
};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, q; cin >> n >> q;
	vector<Int> c(n);
	for(auto &i:c){
		cin >> i;
		--i;
	}

	using P = pair<Int, Int>;
	using PP = pair<P, P>;
	vector<PP> query;
	for(Int i=0; i<q; ++i){
		Int l, r; cin >> l >> r; --l; --r;
		query.push_back(PP(P(i, -1), P(l, r)));
	}
	sort(query.begin(), query.end(), [](PP x, PP y){
		return x.second < y.second;
	});

	vector<Int> next(n, n);
	vector<Int> last(n, n);
	for(Int i=n-1; i>=0; --i){
		next[i] = last[c[i]];
		last[c[i]] = i;
	}

	vector<Int> v(n);
	vector<Int> f(n);
	for(Int i=0; i<n; ++i){
		if(f[c[i]] == 0) v[i] = 1;
		f[c[i]] = 1;
	}

	segment_tree<plus_monoid> st(v);
//	for(Int i=0; i<n; ++i)
//		cout << i << " " << st[i] << "\n";

	Int pres = 0;
	for(Int i=0; i<q; ++i){
		while(pres < query[i].second.first){
			st.point_operate(pres, -1);
			st.point_operate(next[pres], 1);
			++pres;
		}
		query[i].first.second = st.range_get(pres, query[i].second.second+1);
	}

	sort(query.begin(), query.end());
	for(auto i:query)
		cout << i.first.second << "\n";
}

Measured memory_bytes: 51128
import java.util.PriorityQueue;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		Dijkstra dk = new Dijkstra(n);
		for (int i = 0;i<m;++i) {
			String[] route = sc.next().split(",");
			dk.addRoute(Integer.parseInt(route[0]),Integer.parseInt(route[1]),Integer.parseInt(route[2]));
			dk.addRoute(Integer.parseInt(route[1]),Integer.parseInt(route[0]),Integer.parseInt(route[3]));
 		}
		String[] str = sc.next().split(",");
		System.out.println(dk.solve(Integer.parseInt(str[0]),Integer.parseInt(str[1]),Integer.parseInt(str[2]),Integer.parseInt(str[3])));
		
	}
	
	static class Dijkstra {
		int[][] route;
		int cityNum;
		public Dijkstra (int n) {
			cityNum = n;
			route = new int[cityNum+1][cityNum+1];
			for (int[] r : route) {
				Arrays.fill(r, -1);
			}
		}
		public void addRoute(int from, int to, int cost) {
			route[from][to] = cost;
		}
		public int solve (int start, int goal, int money, int pay) {
			money = money - solve(start,goal);
			money = money - pay;
			money = money - solve(goal,start);
			return money;
		}
		public int solve(int start, int goal) {
			
			PriorityQueue<int[]> q = new PriorityQueue<int[]>(cityNum+1,new Comparator<int[]>() {
				@Override
				public int compare(int[] i1, int[] i2) {
					return i1[1] - i2[1];
				}
			});
			
			boolean[] b = new boolean[cityNum+1];
			Arrays.fill(b,false);
			int[] d = new int[cityNum+1];
			Arrays.fill(d, Integer.MAX_VALUE);
			
			q.add(new int[]{start,0});
			
			while (!q.isEmpty()) {
				int[] r = q.poll();
				int pos = r[0];
				int cost = r[1];
				
				if (pos == goal) {
					return cost;
				}
				b[pos] = true;
				d[pos] = cost;
				
				for (int i=1;i<=cityNum;++i) {
					if (route[pos][i]+cost < d[i] && route[pos][i]!=-1) {
						q.remove(new int[]{i,d[i]});
						d[i] = route[pos][i]+cost;
						q.add(new int[]{i,d[i]});
					}
				}
			}
			
			return -1;
		}
		
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin>>N>>S;
  int ans=0;
  for(int i=0;i<1000;i++){
    int v[3]={i/100,(i/10)%10,i%10};
    int k=0;
    for(int j=0;j<N;j++){
      if(S.at(j)==('0'+v[k]))k++;
      if(k==3)break;
    }
    if(k==3)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# import sys
# sys.recursionlimit(10**7)
from functools import reduce


def solve(a,b):
    if a <= 8 and b <= 8:
        return "Yay!"
    else:
        return ":("

def main():
    a,b = map(int,input().split())
    print('{}'.format(solve(a,b)))




if __name__ == '__main__':
  main()


Measured memory_bytes: 9508
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
/*
vector<set<int> >adj;
//vector<set<int> >indegree;
vector<int>ans;
vector<int>visited;
int n,m;
int dfs(int x){
  visited[x]=1;
  if(x==4){
      ans[x]=1;
      //visited[x]=2;
  }else{
    for(int i : adj[x]){
      if(visited[i]==-1){
        dfs(i);
      }
       ans[x]+=ans[i];
       ans[x]%=mod;
    }
  }
 // visited[x]=2;
  return ans[x];
}
*/

int main(){
    boost;
    int TESTS=1;
   // cin>>TESTS;
    while(TESTS--){
      int n,m;
      cin>>n>>m;
      vector<pi>close(n);
      vector<int>open(n+1);
      for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        open[i+1]=x;
        close[i].first=y;
        close[i].second=i+1;
      }
      sort(all(close));
      int x=open[close[0].second];
      int y=close[0].first;
      int ans=0;
     // cout<<x<<" "<<y<<endl;
      for(int i=1;i<n;i++){
        auto p=close[i];
        int t=p.first;
        int j=p.second;
        int temp=open[j];
        if(temp>y){
          x=0,y=-1;
          break;
        }
        x=max(x,temp);
      }
      //cout<<x<<" "<<y<<endl;
      ans=y-x+1;
      cout<<ans<<endl;
    }
}











Measured memory_bytes: 4512
#include<iostream>
#include<stack>
#include<string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#define fast(); ios_base::sync_with_stdio(0);cin.tie(0);
#define rep(i, n) for(int i= 0; i < n; ++i)
using namespace std;

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


int main() {
	fast();


	string s; cin >> s;
	for (int i =0 ; i < s.size(); i += 2) {
		cout << s[i];
	}

	return 0;
}


Measured memory_bytes: 3724