akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	ll h, w;
	cin >> h >> w;

	ll ans = min(h,w);
	if(h % 3 == 0 || w % 3 == 0)
	{
		ans = 0;
		cout << ans << endl;
		return 0;
	}
	rep(i,2){
		for(ll tate = 1; tate < h; tate++){
			ll one = tate * w; ll two, three;

			two = (h - tate) * (w/2);
			three = (h - tate) * ((w+1)/2);
			if(two < one){
				three = max(one,three);
				one = two;
			}
			chmin(ans,three-one);
		}
		swap(h,w);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#define int long long
using namespace std;
int n;
int p[114514],q[114514];
signed main(){
	int i,j;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>p[i];
		p[i]--;
	}
	int ans=0;
	for(i=0;i<n;i++)
		if(p[i]==i){
			ans++;
			if(i<n-1&&p[i+1]==i+1)
				i++;
		}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        boolean[][] cards = new boolean[4][13];
        for (int i = 0; i < n; i++) {
            String mark = input.next();
            int no = input.nextInt();
            char c = mark.charAt(0);
            if (c == 'S')
                cards[0][no - 1] = true;
            else if (c == 'H')
                cards[1][no - 1] = true;
            else if (c == 'C')
                cards[2][no - 1] = true;
            else if (c == 'D')
                cards[3][no - 1] = true;
        }
        for (int i = 0; i < 4; i++) {
            char mark = 0;
            if (i == 0) mark = 'S';
            else if (i == 1) mark = 'H';
            else if (i == 2) mark = 'C';
            else if (i == 3) mark = 'D';
            for (int j = 0; j < 13; j++) {
                if (cards[i][j] == false) {
                    System.out.println(String.format("%c %d", mark, j + 1));
                }
            }
        }
    }
}

Measured memory_bytes: 18160
N = gets.strip.to_i
A = gets.split.map(&:to_i)
res = Array.new
puts A.join(' ')
for i in 1..(A.length-1)
  key = A[i]
  j = i - 1
  while j >= 0 and A[j] > key
    A[j+1] = A[j]
    j=j-1
  end
  A[j+1] = key
  res << A.join(' ') + "\n"
end
print res.join

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

int rate = 380000;

int main(){
    int n;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);

    for (int i=0;i<n;i++){
        double xi;
        string ui;
        cin >> xi >> ui;
        x[i] = xi;
        u[i] = ui;
    }

    double sum = 0;
    for(int i=0;i<n;i++){
        if(u[i]=="JPY") sum += x[i];
        else sum += x[i]*rate;
    }
    cout << sum <<endl;
    return 0;
}

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

// Shortcut

#define int long long
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << ' ';
#define PrintVl(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << endl;
#define PrintA(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a));
#define mmset(a) memset(a, 0x3f, sizeof(a));
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, inf = 1e9 + 7;

int n, a, b, c, d;
string s;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> a >> b >> c >> d >> s;
    a--;
    b--;
    c--;
    d--;
    ForE(i, a + 1, c){
        if (s[i] == '#' && s[i - 1] == '#') Ptest("No");
    }
    ForE(i, b + 1, d){
        if (s[i] == '#' && s[i - 1] == '#') Ptest("No");
    }
    if (d < c){
        bool ck = 1;
        ForE(i, max(2ll, b + 1), min((int)s.length() - 1, d + 1)){
            if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') ck = 0;
        }
        if (ck) Ptest("No");
    }
    cout << "Yes";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 592
n = int(input())
A = list(map(int,input().split()))
abs_A = [abs(i) for i in A]
zero = 0
minus = 0
for i in A:
    if i < 0:
        minus += 1
    elif i == 0:
        zero += 1  
if minus % 2 == 0 or (zero in A):
    print(sum(abs_A))
else:
    print(sum(abs_A) - min(abs_A)*2)

Measured memory_bytes: 14412
import kotlin.math.max

fun main(args: Array<String>) {
    val (n, k) = readIntList()
    val p = readIntList().map { it - 1 }
    val c = readLongList()

    var ans = Long.MIN_VALUE
    for (i in 0 until n) {
        val score = mutableListOf<Long>()
        var tmp = 0L
        var next = p[i]
        do {
            tmp += c[next]
            score.add(tmp)
            next = p[next]
        } while (next != i)
        tmp += c[next]
        score.add(tmp)

        var tmpAns = if (score.last() > 0) score.last() * (k / score.size - 1) else 0
        next = i
        repeat((k % score.size + score.size).toInt()) {
            next = p[next]
            tmpAns += c[next]
            ans = max(ans, tmpAns)
        }
    }

    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,ans;
	cin>>n;
	(n%1000==0)?ans = 0: ans = 1000 - n%1000;
	cout<<ans<<"\n";
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""



Measured memory_bytes: 3680
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
#define P 1000000007
long long l, r;
int dp[65][2][2], ans; // 0 >= l 1 < l / 0 <= r 1 > r
void upd(int &x, int y){
	(x += y) >= P ? x -= P : 0;
}
int main(){
	scanf("%lld%lld", &l, &r);
	dp[0][0][0] = 1;
	for (register int i = 0; i <= 59; ++i){
		// 00
		upd(dp[i + 1][l >> i & 1][0], dp[i][0][0]);
		upd(dp[i + 1][l >> i & 1][!(r >> i & 1)], dp[i][0][1]);
		upd(dp[i + 1][1][0], dp[i][1][0]);
		upd(dp[i + 1][1][!(r >> i & 1)], dp[i][1][1]);
		// 11
		upd(dp[i + 1][0][!(r >> i & 1)], dp[i][0][0]);
		upd(dp[i + 1][l >> i & 1][!(r >> i & 1)], dp[i][1][0]);
		upd(dp[i + 1][0][1], dp[i][0][1]);
		upd(dp[i + 1][l >> i & 1][1], dp[i][1][1]);
		// 01
		upd(dp[i + 1][l >> i & 1][!(r >> i & 1)], dp[i][0][0]);
		upd(dp[i + 1][l >> i & 1][1], dp[i][0][1]);
		upd(dp[i + 1][1][!(r >> i & 1)], dp[i][1][0]);
		upd(dp[i + 1][1][1], dp[i][1][1]);
	}
	int kl = 60, kr = 60;
	while (!(l >> kl & 1)) --kl;
	while (!(r >> kr & 1)) --kr;
	if (kl == kr) ans = dp[kl][0][0];
	else{
		upd(ans, dp[kr][0][0]), upd(ans, dp[kr][1][0]);
		upd(ans, dp[kl][0][0]), upd(ans, dp[kl][0][1]);
		for (register int i = kr - 1; i > kl; --i)
			upd(ans, dp[i][0][0]), upd(ans, dp[i][0][1]), upd(ans, dp[i][1][0]), upd(ans, dp[i][1][1]);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  ll n,k;cin>>n>>k;
  pair<int,int> p[100000];rep(i,n)cin>>p[i].first>>p[i].second;
  sort(p,p+n);
  ll a[100000];a[0] = p[0].second;
  repd(i,1,n)a[i] = a[i-1] + p[i].second;

  auto itr = lower_bound(a,a+n,k);
  cout << p[distance(a,itr)].first << endl;
}




Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c) dunk("Yes");
    else if(a == c && a != b) dunk("Yes");
    else if(b == c && a != b) dunk("Yes");
    else dunk("No");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

    int pat[4] = {1, 9, 7, 4};
    int n[4] = {0};
    int count = 0;
    int flg = 0;

    cin >> n[0] >> n[1] >> n[2] >> n[3];

    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            if(pat[i] == n[j] && flg != 1){
                count++;
                flg = 1;
                break;
            }
        }
        flg = 0;
    }

    if(count == 4) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;

int cost[5000], idou[5000], mincost[5000];
vector<int>rinsetu[5000];
bool operator <(P a, P b) {
	return a.first < b.first;
}
signed main()
{
	int a, b;
	cin >> a >> b;
	fill(mincost + 1, mincost + a, 1<<29);
	for (int c = 0; c<a; c++) { scanf("%d%d", &cost[c], &idou[c]); }
	for (int d = 0; d<b; d++) {
		int e, f;
		scanf("%d%d", &e, &f);
		e--; f--;
		rinsetu[e].push_back(f);
		rinsetu[f].push_back(e);
	}
	priority_queue <P>Q;
	Q.push(P(0, 0));
	while (Q.size()) {
		P g = Q.top(); Q.pop();
		if (mincost[g.first]<g.second)continue;
		int h[5000];
		memset(h, -1, sizeof(h));
		h[g.first] = 0;
		queue<P>que;
		que.push(P(g.first, 0));
		while (que.size()) {
			P o = que.front(); que.pop();
			if (o.second>idou[g.first])break;
			for (int r = 0; r<rinsetu[o.first].size(); r++) {
				if (h[rinsetu[o.first][r]] == -1) { que.push(P(rinsetu[o.first][r], o.second + 1)); h[rinsetu[o.first][r]] = o.second + 1; }
			}
		}
		for (int i = 0; i<a; i++) {
			if (h[i]!=-1&&h[i] <= idou[g.first] && mincost[i]>g.second + cost[g.first]) { mincost[i] = g.second + cost[g.first]; Q.push(P(i, mincost[i])); }
		}
	}
	cout << mincost[a - 1] << endl;
}

Measured memory_bytes: 3640
N = int(input())
*L, = map(int,input().split())

import bisect
L.sort()
ans = 0
bl = bisect.bisect_left
br = bisect.bisect_right
for i,a in enumerate(L):
    for j,b in enumerate(L[i+1:],i+1):
        m = b-a+1
        M = b+a-1
        ans += br(L,M,j+1) - bl(L,m,j+1)
print(ans)

Measured memory_bytes: 49500
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;
 
const int Inf = 1000000007;
const long long mod = 998244353;//1000000007;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m, k;
long long ans = 0;
long long F[400005];

long long BinPow(long long a, long long b)
{
	if(b == 0)
	{
		return 1;
	}
	long long t = BinPow(a, b / 2);
	if(b % 2 == 1)
	{
		return t * t % mod * a % mod;
	}
	else
	{
		return t * t % mod;
	}
}

long long C(long long n, long long k)
{
	return F[n] * BinPow(F[k], mod - 2) % mod * BinPow(F[n - k], mod - 2) % mod;
}

void Solve()
{
	cin >> n >> m >> k;
	F[0] = 1;
	for(int i = 1; i <= n * 2; i++)
	{
		F[i] = (F[i - 1] * 1ll * i) % mod;
	}
	for(int i = n - k; i <= n; i++)
	{
		ans += (C(n - 1, i - 1)) * m % mod * BinPow(m - 1, i - 1) % mod;
		ans %= mod;
	}
	cout << ans;
}
 
int main()
{	
	Fastio();
	Solve();
}

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

using namespace std;

const long long MOD=998244353;

long long add_mod(long long x,long long y){
	return (x+y)%MOD;
}

long long sub_mod(long long x,long long y){
	return (x-y+MOD)%MOD;
}

long long mul_mod(long long x,long long y){
	return x*y%MOD;
}

int n,s;
long long c[3001][3001];

void solve(){
    int i,j;
    string str;
    cin >> n >> s;
    vector<long long> a(n);
    for(i = 0;i < n;i++) cin >> a[i];
    long long ans = 0;
    for(i = 0;i < n;i++){
        for(j = 0;j <= s;j++){
            c[i+1][j] = c[i][j];
        }
        c[i+1][0] = add_mod(c[i+1][0],1);
        for(j = s-a[i];j >= 0;j--){
            c[i+1][j+a[i]] = add_mod(c[i+1][j+a[i]],c[i+1][j]);
        }
        ans = add_mod(ans,mul_mod(c[i+1][s],n-i));
        c[i+1][s] = 0;
    }
    cout << ans << endl;
}

int main(){
    solve();
}


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

int main(){
  string S,T;
  cin >> S >> T ;
  int x = T.size();
  S = S + T.at(x-1);
  if(S == T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

struct node{
    bool ex;
    ll NEXT[2];
    
    node():ex(false){NEXT[0]=NEXT[1]=-1;}
};

ll n,l;
vector<node> A(1,node());
ll ans=0;


ll cul(ll a){
    //cout<<a<<endl;
    return a^(a&(a-1));
}

void add_string(string s){
    ll w=0;
    for(auto &I:s){
        if(A[w].NEXT[I-'0']==-1){A[w].NEXT[I-'0']=A.size(); A.push_back(node());}
        w=A[w].NEXT[I-'0'];
    }
    A[w].ex=true;
}

void search(ll w,ll d){
    if(A[w].ex){return;}
    for(int i=0;i<2;i++){
        if(A[w].NEXT[i]!=-1){search(A[w].NEXT[i],d+1);}
        else{ans^=cul(l-d);}
    }
}


int main(){
    cin>>n>>l;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        add_string(s);
    }
    search(0,0);
    cout<<(ans==0?"Bob":"Alice")<<endl;
    
    
    return 0;
}


Measured memory_bytes: 7688
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 300000;
int mod = 1e9 + 7;
int a[N], f[N];
string s;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    int inv = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++){
        for (int j = i + 1; j <= n; j++){
            if (a[j] < a[i]) inv++;
        }
    }
    for (int i = 1; i <= n; i++){
        int c = 0;
        for (int j = 1; j <= n; j++){
            if (a[j] < a[i]) c++;
        }
        int x = k * (k - 1) / 2 % mod;
        ans = (ans + c * x) % mod;
    }
    ans = (ans + k * inv) % mod;
    cout << ans;
}


Measured memory_bytes: 2304
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map(String::toInt)
    var arr = IntArray(10e5.toInt() + 1,{0})
    (0..n-1).map{i->
        if(a[i] != 0) arr[a[i]-1]++
        arr[a[i]]++
        arr[a[i]+1]++
    }
    println(arr.max()!!)
        
}

Measured memory_bytes: 60056
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = [INT() for _ in range(N)]
print("second" if all(x%2==0 for x in a) else "first")


Measured memory_bytes: 9196
a, b = map(int, input().split())
if (a > 0 and b > 0) or (a < 0 and b < 0 and (b - a - 1) % 2 == 0):
  print('Positive')
elif a * b <= 0:
  print('Zero')
elif (a < 0 and b < 0 and (b - a - 1) % 2 == 1):
  print('Negative')

Measured memory_bytes: 3060
//ほぼstandard answer
#include<iostream>
using namespace std;

class Cube{
public:
  int f[6];
  Cube(){} //コンストラクタなし
  void roll_y(){ roll(0, 2, 5, 3);} //サイコロの番号は+1
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
  void move(char ch){
    if ( ch == 'W' ) roll_y();
    if ( ch == 'N' ) roll_x();
    if ( ch == 'E' ) for ( int i = 0; i < 3; i++ ) roll_y();
    if ( ch == 'S' ) for ( int i = 0; i < 3; i++ ) roll_x();
  }
};

int main(){
  Cube c; //上でCube型 define
  string com;
  
  for ( int i = 0; i < 6; i++ ) cin >> c.f[i]; //define each face 
  cin >> com; //string
  
  for ( int i = 0; i < com.size(); i++ ) c.move(com[i]);
  
  cout << c.f[0] << endl;
  
  return 0;
}



Measured memory_bytes: 3232
#include <iostream>

int main (){
  int h, w;
  std::cin >> h >> w;

  while ((h!=0)&&(w!=0))
    {
      for (int i=0; i<h; i++)
        {
          for (int j=0; j<w; j++)
            std::cout << '#';
          std::cout << std::endl;
        }
      std::cout << std::endl;
      std::cin >> h >> w;
    }
}



Measured memory_bytes: 3116
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) a[i] = in();
    int ans = 0;
    FOR(i,1,n-2){
        ans += ((a[i] - a[i - 1]) * (a[i] - a[i + 1]) < 0);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.test();
    }
    
    int n;
    private void test() {
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        long[][] us = new long[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                us[i][j] = Integer.MAX_VALUE;
            }
            int u = input.nextInt();
            int k = input.nextInt();
            for (int j = 0; j < k; j++) {
                int v = input.nextInt();
                int c = input.nextInt();
                us[u][v] = c;
            }
        }
        us[0][0] = 0;
        
        long[] vs = new long[n+1];
        Arrays.fill(vs, Integer.MAX_VALUE);
        vs[0] = 0;
        for (int m = 0; m < n; m++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    vs[j] = Math.min(vs[j], vs[i] + us[i][j]);
                }
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.println(String.format("%d %d", i, vs[i]));
        }
    }
}

class Scanner {
    BufferedReader r;
    StreamTokenizer st;
    
    public Scanner(InputStream in) {
        r = new BufferedReader(new InputStreamReader(in));
        st = new StreamTokenizer(r);
    }
    
    public String next() {
        nextToken();
        return st.sval;
    }
    
    public Integer nextInt() {
        nextToken();
        return (int)st.nval;
    }
    
    private int nextToken() {
        int token = st.TT_EOF;
        try {
            token = st.nextToken();
        } catch (IOException e) {
        }
        return token;
    }
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

string s;

int main()
{
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
S = gets.chomp.chars
T = gets.chomp.chars

t_to_s = {}
s_to_t = {}
T.each.with_index do |t_ch, i|
  s_ch = S[i]
  t_to_s[t_ch] = s_ch unless t_to_s[t_ch]
  s_to_t[s_ch] = t_ch unless s_to_t[s_ch]
  if t_to_s[t_ch] != s_ch || s_to_t[s_ch] != t_ch
    puts 'No'
    exit 0
  end
end
puts 'Yes'


Measured memory_bytes: 22780
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using ll =long long;
using namespace std;
int ans = -1;

int main(){
	int  a, b;
	cin >> a >> b;
	int na, nb;
	na = a / 0.08;
	nb = b / 0.1;
	auto f = [&](int na, int nb) {
		for (int i = na; i <= nb; i++) {
			int ans = -1;
			if ((int)(i * 0.1) == b && (int)(i * 0.08) == a) {
				return i;
			}
		}
		return ans;
	};
	if (na >= nb)cout << f(nb, na+1);
	else cout << f(na, nb);
	return 0;

}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")

#define MAX_NODE 100005

/*

	node[     0] --> n0, n1, n2, ... 
	 ...
	node[100005] --> n0, n1, n2, ...

*/
vector<int> node[MAX_NODE];
int N;

vector<int> dist;

/*
	s : current node
	d : distance from source
	p : previous node
*/
void resolveDFS(int v, int d = 0, int p = -1) {
	// save distance to v
	dist[v] = d;
	for (int u : node[v]) {
		// bidirectional controll
		if (u == p) continue;

		resolveDFS(u, d + 1, v);
	}
}

vector<int> calcDistance(int s) {
	// initialize vector that represent distance from node s to each nodes
	dist = vector<int>(N);
	// calculate distance by DFS (Depth-First Search) 
	resolveDFS(s);
	
	return dist;
}

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

	// number of tree node
	cin >> N;

	// node index where Takahashi start as s, and Aoki as t
	int s, t;
	cin >> s >> t;
	s--;
	t--;

	// edge in tree
	int a, b;
	for (int i = 0; i < N-1; i++)
	{
		cin >> a >> b;
		a--;
		b--;
		node[a].push_back(b);
		node[b].push_back(a);
	}

	// distance from Takahashi
	vector<int> distS = calcDistance(s);
	// distance from Aoki
	vector<int> distT = calcDistance(t);

	int m = 0;
	for (int i = 0; i < N; i++) {
		/*
			If Aoki can arrive at node i faster than Takahashi, save the distance from Takahashi
		*/
		if (distS[i] < distT[i]) {
			m = max(m, distT[i]);
		}
	}

	/*
		Game exactly finishes one node before the leaf
	*/
	cout << (m - 1) << endl;

	return 0;
}


Measured memory_bytes: 10744
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <numeric>

int main(){
  long int N;
  std::cin>>N;
  std::vector<int> B(N);
  std::copy_n(std::istream_iterator<int>(std::cin),N,B.begin());
  std::vector<int> Index(N);
  std::iota(Index.begin(), Index.end(), 0);
  for(int i = 0 ; i < N ; i++){
    if( Index[i] + 1 < B[i] ){
      std::cout<<-1<<std::endl;
      return 0;
    }
  }
  int max=0;
  std::vector<int> result;
  for(int i = 0 ; i < N ; i++ ){
    for(int k = 0 ; k < N - i ; k++ ){
      if(Index[k] + 1 == B[k]) max = Index[k];
    }
    result.push_back(B[max]);
    B.erase(B.begin() + max );
    Index.erase(Index.begin() + max );
    for(int k = max ; k < N - i - 1 ; k++ ){
      Index[k] -= 1;
    }
    max = 0;
  }
  for(int i = N - 1 ; i >= 0 ; i-- ){
    std::cout<<result[i]<<std::endl;
  } 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> on(n, 0);
    vector<int> p(n, 0);
    vector<int> q(n, 0);
    for(int i = 0; i < n; ++i) cin >> p.at(i);
    for(int i = 0; i < n; ++i) cin >> q.at(i);
    for(int i = 0; i < n; ++i) {
        on.at(i) = i+1;
    }

    int a = 0, b = 0;
    int cnt = 1;
    do{
        bool pb = true;
        bool qb = true;
        for(int i = 0; i < n; ++i) {
            if(on.at(i) != p.at(i)) pb = false;
            if(on.at(i) != q.at(i)) qb = false;
        }
        if(pb) a = cnt;
        if(qb) b = cnt;
        cnt++;
    }while(next_permutation(on.begin(), on.end()));
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint p(int n) {
  if (n == 1) {
    return 2;
  }
  if ( n % 2 == 0 ) {
    mint ans = p(n/2);
    return ans * ans;
  } else {
    mint ans = p(n/2);
    ans *= ans;
    ans *= 2;
    return ans;
  }
} 

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

  mint ans = p(n);
  ans -= 1;

  mint mina = 1, minb = 1;
  rep(i,a) mina *= n-i;
  rep(i,a) mina /= a-i;
  rep(i,b) minb *= n-i;
  rep(i,b) minb /= b-i;
  ans -= mina;
  ans -= minb;
  cout << ans.x << endl;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int edge[10][10]={};

int bitdp(int N,int n,int mask,int last){
  if(n==N){
    return 1;
  }
  int i;
  int ans = 0;
  for(i=0;i<N;i++){
    if(mask & 1<<i && ( edge[last][i] || edge[i][last] )){
      ans += bitdp(N,n+1,mask - (1<<i),i);
    }
  }
  return ans;
}


int main()
{
  int n,m;
  cin >> n >> m;
  int i;
  for(i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    edge[a-1][b-1]=1;
    edge[a-1][b-1]=1;
  }

  int ans = bitdp(n,1,(1<<n) - 1 - 1,0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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() {
    ll X; cin >> X;

    ll a, b;

    for(int i=-1000; i<=1000; i++){
        for(int j=-1000; j<1000; j++){
            ll x = pow(i, 5);
            ll y = pow(j, 5);
            if(x - y == X){
                a = i, b = j;
                break;
            }
        }
    }
    cout << a << " " << b << ln;
  
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n;
    cin >> n;
    double sum = 0;
    for (int i = 0; i < n; ++i) {
        double val;
        cin >> val;
        sum += 1/val;
    }
    printf("%.10lf", 1 / sum);// << endl;
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

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

typedef long long ll;
typedef tuple<ll, int, int> tlii;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define all(obj) (obj).begin(), (obj).end()
#define pb push_back
#define str to_string
#define mkp make_pair
#define mkt make_tuple
// #define print(out) cout << (out) << endl
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

template<typename Any>
void print(Any out) {
    cout << out << '\n';
}

void print(vector<ll> A) {
    rep(i, 0, A.size()) {
        cout << A[i];
        cout << (i == A.size()-1 ? '\n' : ' ');
    }
}

ll max(vector<ll> A) {
    ll res = -INF;
    for (ll a: A) chmax(res, a);
    return res;
}

ll min(vector<ll> A) {
    ll res = INF;
    for (ll a: A) chmin(res, a);
    return res;
}

ll max(ll A[], int len) {
    ll res = -INF;
    rep(i, 0, len) chmax(res, A[i]);
    return res;
}

ll min(ll A[], int len) {
    ll res = INF;
    rep(i, 0, len) chmin(res, A[i]);
    return res;
}

int N, a, b, c;
ll cnt;
vector<int> A;

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

    cin >> N;
    A.resize(N);
    rep(i, 0, N) cin >> A[i];
    cnt = 0;
    sort(all(A));

    rep(i, 0, N) {
        a = A[i];
        rep(j, i+1, N) {
            b = A[j];
            rep(k, j+1, N) {
                c = A[k];
                // 枝刈り
                if (c >= a + b) break;
                if (a < b + c && b < c + a && c < a + b) {
                    cnt++;
                }
            }
        }
    }

    print(cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll n;
  vector<ll> a(5);  
  rep(i, 0, 5) {
    cin >> a[i];
    if(a[i]==0) {
      cout << i+1 << "\n";
      return 0;
    }
  }
  
  //cout << (  ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 3652
def dfs_traverse(adj, visited, u=0):
  visited[u] = True
  for v in adj[u]:
    if not visited[v]:
      dfs_traverse(adj, visited, v)


def calc_num_of_bridges(edges, adj):
  n = len(adj)
  bridge_cnt = 0
  for a, b in edges:
    adj[a].remove(b)
    adj[b].remove(a)
    # check
    visited = [False] * n
    dfs_traverse(adj, visited)
    if not all(visited):
      bridge_cnt += 1
    # restore
    adj[a].append(b)
    adj[b].append(a)
  return bridge_cnt


n, m = map(int, input().split())
adj = [[] for _ in range(n)]
edges = []
for _ in range(m):
  a, b = map(lambda x: int(x)-1, input().split())
  edges.append((a, b))
  adj[a].append(b)
  adj[b].append(a)

print(calc_num_of_bridges(edges, adj))


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

string make(ll x, ll y){
    stringstream ss1;
    ss1 << x;
    string s1 = ss1.str();
    while(s1.size() < 6)s1 = "0" + s1;
    stringstream ss2;
    ss2 << y;
    string s2 = ss2.str();
    while(s2.size() < 6)s2 = "0" + s2;
    return s1 + s2;
}

int main(){

    ll N, M;
    cin >> N >> M;
    vector<PP>v(M, PP(P(0, 0), P(0, 0)));
    for(ll i = 0; i < M; i++){
        cin >> v[i].first.second >> v[i].first.first;
        v[i].second.first = i;
    }
    sort(v.begin(), v.end());
    vector<ll>cnt(101010, 0);
    vector<string>ans(101010);
    for(ll i = 0; i < M; i++){
        ll p = v[i].first.second;
        ll idx = v[i].second.first;
        cnt[p]++;
        ans[idx] = make(p, cnt[p]);
    }
    for(ll i = 0; i < M; i++)cout << ans[i] << endl;


    return 0;
}

Measured memory_bytes: 10880
s = input()

if s[0] == s[1] == s[2] == "R":
    ans = 3
elif s[0] ==s[1] =="R" or s[1] ==s[2] =="R":
    ans = 2
elif "R" in s:
    ans = 1
else:
    ans = 0

print(ans)

Measured memory_bytes: 9036
N = int(input())
S = []
for i in range(N):
  Ss = input()
  S.append(Ss)
E = [set() for i in range(N)]
D = [[100000]*N for i in range(N)]
for i in range(N):
  D[i][i] = 0
  for j in range(i+1, N):
    if S[i][j] == "1":
      #print(i, j)
      E[i].add(j)
      E[j].add(i)
      D[i][j] = 1
      D[j][i] = 1
ok = True
V = [-1]*N
c = 0
V[0] = 0
q = [0]
while q:
  c = q.pop()
  ns = E[c]
  for n in ns:
    if V[n] == V[c]:
      ok = False
    if not V[n] < 0:
      continue
    V[n] = 1 if V[c] == 0 else 0
    q.append(n)
if not ok:
  print(-1)
  exit()
for k in range(N):
  for i in range(N):
    for j in range(N):
      D[i][j] = min(D[i][j], D[i][k]+D[k][j])
#print(D)
r = max([max(Ds) for Ds in D])+1
print(r)


Measured memory_bytes: 44652
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
vector<int> a;
long MAX=7368791;

int main(){
  int m,n;
  long long k;
  scanf ("%d %d",&m,&n);
  while(n){
    k=m;
    a.assign(MAX+1,1);
    for(int t=0;t<n;t++){
      while(a[k]==0){
        ++k;
      }
      for(int p=2*k;p<=MAX;p=p+k){
        a[p]=0;
      }
      ++k;
    }
    while(a[k]==0){
      ++k;
    }

    printf("%lld\n",k);
    scanf ("%d %d",&m,&n);
  }
}



Measured memory_bytes: 31612
#include <stdio.h>
int main(void){
	long a;
	long b;
	long n;
	scanf("%ld", &a);
	scanf("%ld", &b);
	scanf("%ld", &n);
	if(n/b < 1){
		printf("%ld\n", (a*n/b));
	}
	else{
		printf("%ld\n", (a*(b-1)/b));
	}
	return 0;
}

Measured memory_bytes: 1684
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;
const int inf = 1000000000;

/*
void show(vector<vector<int> > &array){
	for(int i = 0; i < array.size(); i++){
		for(int j = 0; j < array[i].size(); j++) {
			cout << array[i][j] << "\t";
		}
		cout << endl;
	}
}
*/

int main(){
	int n, m;
	cin >> n >> m;
	vector<vector<int> > cost(n + 1, vector<int>(n + 1, inf));
	int town_a, town_b, from_a_to_b, from_b_to_a;
	for(int i = 0; i < m; i++){
		scanf("%d,%d,%d,%d", &town_a, &town_b, &from_a_to_b, &from_b_to_a);
		cost[town_a][town_b] = from_a_to_b;
		cost[town_b][town_a] = from_b_to_a;
	}
	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	
	for(int k = 1; k <= n; k++)
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				if(cost[i][j] > cost[i][k] + cost[k][j])
					cost[i][j] = cost[i][k] + cost[k][j];
	cout << y1 - cost[x1][x2] - cost[x2][x1] - y2 << endl;
}

Measured memory_bytes: 1260
#include <cstdio>
 
const int MAXN = 1e5 + 5;
 
int n, cnt, sum;
int arr[MAXN], ans[MAXN];
 
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
        sum += arr[i];
        if (i & 1) 
            cnt += (arr[i] << 1);
    }
    ans[1] = cnt - sum;
    for (int i = 1; i < n; ++i) {
        ans[i + 1] = (arr[i] << 1) - ans[i];
    }
    for (int i = 1; i <= n; ++i) {
        printf("%d ", ans[i]);
    }
    return 0;
}

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

int main(){
  int s, w;
  cin >> s >> w;
  if(w>=s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}

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

int main()
{
	string s,t;
	int ss,ts;
	cin>>s>>t;
	cin>>ss>>ts;
	string st;
	cin>>st;
	
	if(st==s)
		cout<<ss-1<<' '<<ts<< endl;
	else if(st==t)
		cout<<ss<<' '<<ts-1<< endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <memory>
using namespace std;
using ll=long long;


int main(){
    ll N;
    cin >> N;
    ll mod=1000000007;
    vector<ll> A(N);
    vector<ll> sums(N+1);
    for(ll i=0;i<N;i++){
        cin >> A[i];
        sums[i+1]=(sums[i]+A[i])%mod;
    }
    ll res=0;
    for(ll i=0;i<N-1;i++){
        ll sum;
        if(sums[N]-sums[i+1]<0){
            sum=sums[N]-sums[i+1]+mod;
        }else{
            sum=sums[N]-sums[i+1];
        }
        res+=(A[i]*sum)%mod;
    }
    cout << res%mod << endl;
}

Measured memory_bytes: 6400
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll n, s;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>s;
    if(s>n){
        cout1(-1);
        return 0;
    }
    if(n==s){
        cout1(n+1);
        return 0;
    }
    
    set<ll> ans;
    for(ll b=2;b*b<=n;b++){
        ll tmp=n, sum=0;
        while(tmp){
            sum+=tmp%b;
            tmp/=b;
        }
        if(sum==s){
            ans.insert(b);
            break;
        }
    }
    
    for(ll p=1;p*p<n&&p<=s;p++){
        ll m=s-p;
        if(n-m>=0 && (n-m)%p==0){
            ll b=(n-m)/p;
            if(b>p&&b>m) ans.insert((n-m)/p);
        }
    }
    
    if(ans.size()){
        cout1(*ans.begin());
    }else{
        cout1(-1);
    }
    
}

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

int main() {

    int n,k;

    cin >> n >> k;

    map<int,int> m;

    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        m[a]++;
    }

    int ans = 0;

    vector<int> balls;

    for(auto a : m){
        balls.push_back(a.second);
    }

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

    for(int i=m.size(); i>k; i--){
        ans += balls[m.size()-i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10748
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000000000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int q = 0; q < n; q++){
        cin >> a[q];
        string s;
        int w = a[q];
        while (w > 0){
            s += (w & 1)+'0';
            w >>= 1;
        }
        //reverse(s.begin(), s.end());
        //cout << s << endl;
    }
    int x = 0, y = a[0]+a[1];
    for (int q = 2; q < n; q++){
        x ^= a[q];
    }
    int dif = y-x;
    if (y < x || (y & 1) != (x & 1)){
        cout << -1 << endl;
        return 0;
    }
    for (int q = 1; q < 40; q++){
        if (((dif >> q) & 1) && ((x >> (q-1)) & 1)){
            cout << -1 << endl;
            return 0;
        }
    }
    dif >>= 1;
    if (dif > a[0]){
        cout << -1 << endl;
        return 0;
    }
    int need = a[0]-dif;
    for (int q = 39; q > -1; q--){
        if (((x >> q) & 1) && (1LL << q) <= need){
            need -= (1LL << q);
        }
    }
    if (need == a[0]){
        cout << -1 << endl;
    }else{
        cout << need << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;




public class Main{
	static class MyScanner {
	    BufferedReader br;
	    StringTokenizer st;

	    public MyScanner() {
	       br = new BufferedReader(new InputStreamReader(System.in));
	    }

	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try {
	                st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    } 

	    int nextInt() { return Integer.parseInt(next());}

	    long nextLong() {return Long.parseLong(next());}

	    double nextDouble() {return Double.parseDouble(next());}

	    String nextLine(){
	        String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	    }
	}
		
	
		 public static void main(String[] args) throws IOException {
			 	PrintWriter out = new PrintWriter(System.out);
			    MyScanner sc = new MyScanner();
			 	Main solver = new Main();
				solver.solve(out, sc);
				out.flush();
				out.close();
			
		 }
	
		
		 
		 
		
 		void solve(PrintWriter out, MyScanner sc) throws IOException{	
 			
 				int a = sc.nextInt();
 				int b = sc.nextInt();
 				int res = a - 1 + ((a <= b)?1:0);
 				out.print(res);
 				
 			
 			
 			
 		
 		}
 		
 		

 	
		
	
			
		
		
		
		
		
		
		
		
	
	
}



Measured memory_bytes: 23124