akhauriyash/Code-Regression huggingface dataset:
// Author--> darklight13
#define _CRT_SECURE_NO_DEPRECATE
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mod (int)1e9+7
int32_t main()
{
	int h,w;cin>>h>>w;
	char a[h+1][w+1];
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
		}
	}
	int dp[h+1][w+1];
	memset(dp,0,sizeof dp);
	dp[1][1]=1;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(i==1&&j==1){
				continue;
			}
			if(a[i][j]=='#'){
				continue;
			}else{
				dp[i][j] = dp[i-1][j]+dp[i][j-1];
				dp[i][j]%=mod;
			}
		}
	}
	// for(int i=0;i<=h;i++)
	// {
	// 	for(int j=0;j<=w;j++)
	// 	{
	// 		cout<<dp[i][j]<<' ';
	// 	}cout<<'\n';
	// }
	cout<<dp[h][w];
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b;
    cin>>S;
  if(S[0]==S[1]&&S[1]==S[2]) cout<<"No";
  else cout<<"Yes";
}
 
 
signed main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-6
#define inf 1e14

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

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 101;
const int mod = 1e9 + 7;
const int maxa = 2 * 1e5;

int maxs(int &a, int b) { return a = max(a, b);}
int mins(int &a, int b) { return a = min(a, b);}
int mul(int a, int b) { return a * 1LL * b % mod;}
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b;}
int sub(int a, int b) { return a >= b ? a - b : a - b + mod;}
int pow(int a, int k)
{
    int res = 1;
    while (k)
    {
        if (k % 2) res = mul(res, a);
        a = mul(a, a);
        k /= 2;
    }

    return res;
}

int inv(int a)
{
    return pow(a, mod - 2);
}

int n, k, A[maxn], dp[maxa];

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

    for (int i = 0; i <= k; ++i)
        for (int j = 0; j < n; ++j)
            if (i >= A[j] && !dp[i - A[j]])
                dp[i] = true;

    cout << (dp[k] ? "First" : "Second");
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

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

  ll ans = 0;
  ll prev = a[0];
  for (ll i = 1; i < n; ++i) {
    ll sum = prev + a[i];
    ll sub = sum - x;

    if (sub > 0) {
      ans += sub;
      a[i] -= sub;
      if (a[i] < 0) {
        a[i] = 0;
        a[i-1] = max(0ll, a[i-1]-sub);
      }
    }
    prev = a[i];
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	string a, b;
	cin >> a >> b;
	if(a.size() > b.size()) printf("GREATER\n");
	else if(a.size() < b.size()) printf("LESS\n");
	else{
		if(a == b) printf("EQUAL\n");
		else if(a < b) printf("LESS\n");
		else printf("GREATER\n");
	}
}


Measured memory_bytes: 256
/*input
1 2
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=1e7+5;
const ll maxlg=__lg(maxn)+2;
int main(){
    int x,y;
    cin>>x>>y;
    int b=(y-2*x)/2;
    int a=(x-b);
    if(a>=0 and b>=0 and a*2+4*b==y){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N, T;
  cin>>N>>T;
  int c[1000], t[1000];
  int ans = 1000000000;
  for(int i = 0; i < N; i++){
    cin>>c[i]>>t[i];
  }
  for(int i = 0; i < N; i++){
    if(t[i] <= T){
      ans = min(ans, c[i]);
    }
  }
  if(ans==1000000000){
    cout<<"TLE"<<endl;
  }else{
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int ans = 0;
	string S; cin >> S;
	REP(i, S.size()) {
		FOR(j, i, S.size()) {
			string str = S.substr(i, j - i + 1);
			bool ok = true;
			REP(k, str.size()) {
				if (str[k] != 'A'&&str[k] != 'T'&&str[k] != 'G'&&str[k] != 'C')ok = false;
			}
			if (ok)ans = max(ans, j - i + 1);
		}
	}
	print(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        final String week = "SUNMONTUEWEDTHUFRISAT"; 

        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            int result = week.indexOf(S);
            if (result == 0) {
                System.out.println(7);
            } else {
                result = 7 - (result / 3);
                System.out.println(result);
            }
        }
    }
}

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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if (map.containsKey(a[i]) == true) {
				map.put(a[i], map.get(a[i])+1);
			} else {
				map.put(a[i], 1);
			}
		}
		int count = 0;
		for (int key : map.keySet()) {
			if (key > map.get(key)) {
				count += map.get(key);
			} else if (key < map.get(key)) {
				count += (map.get(key) - key);
			}
		}
		System.out.println(count);
	}
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int a, b, c;
	cin >> a >> b >> c;

	if( b-a == c-b ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

int main(){
	int hanafuda[51]{0};
	int tmpp[51]{0};
	vector<int> ansvec;

	for (;;){
		int n, r;
		cin >> n >> r;
		if (n == 0) break;

		for (int i = n; i >= 1; i--){
			hanafuda[i] = i;
		}

		for (int i = 0; i < r; i++){
			int p, c;
			cin >> p >> c;
			for (int j = 0; j < p - 1; j++){
				tmpp[p - 1 - j] = hanafuda[n - j];
			}
			for (int j = 0; j < c ; j++){
				hanafuda[n - j] = hanafuda[n - (p - 1) - j];
			}
			for (int j = 0; j < p - 1; j++){
				hanafuda[n - c - j] = tmpp[p - 1 - j];
			}
		}
		ansvec.push_back(hanafuda[n]);
	}

	for (int ans : ansvec){
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
package main

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

var sc = bufio.NewScanner(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

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

func main() {
    sc.Split(bufio.ScanWords)
    defer w.Flush()

    n := nextInt()
    m := nextInt()
    x := nextInt()

    books := make([][]int, n)

    for i := range books {
        books[i] = make([]int, m+1)
        for j := range books[i] {
            books[i][j] = nextInt()
        }
    }

    max := -1
    for b := 0; b < (1 << n); b++ {
        cost := 0
        skills := make([]int, m)
        for i := 0; i < n; i++ {
            if (b>>i)&1 == 1 {
                cost += books[i][0]
                for j := 0; j < m; j++ {
                    skills[j] += books[i][j+1]
                }
            }
        }
        ok := true
        for i := range skills {
            if skills[i] < x {
                ok = false
            }
        }

        // fmt.Fprintln(w, ok)
        // fmt.Fprintln(w, max)
        // fmt.Fprintln(w, cost)
        // fmt.Fprintln(w, "----")
        if ok {
            if (max == -1) || (max > cost) {
                max = cost
            }
        }
    }
    fmt.Fprintln(w, max)
}


Measured memory_bytes: 2164
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

int f(int y,int m,int d){
	return (y*365+y/4-y/100+y/400+m*28+(m+1)*26/10+d-400);
}

int main(void){

  int d[6];
	while(!cin.eof()){
		rep(i,6) cin >> d[i];
		rep(i,6) if(d[i]<0) goto endd;
		
		if(d[1]<3){ d[1] +=12; d[0]--;}
		if(d[4]<3){ d[4] +=12; d[3]--;}
		cout << (f(d[3],d[4],d[5]) - f(d[0],d[1],d[2])) << endl;
	}
  endd:
	return 0;
	
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
using namespace std;
int D[11];
bool check(int x)
{
    int i,j;
    while(x)
    {
        int p=x%10;x=x/10;
        if(D[p])return false;
    }
    return true;
}
int main()
{
    int N,K;
    scanf("%d%d",&N,&K);
    int i;
    for(i=1;i<=K;i++)
    {
        int x;
        scanf("%d",&x);
        D[x]=1;
    }
    for(i=N;i<=1000000;i++)
    {
        if(check(i))
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
def resolve():
    import numpy as np
    N = int(input())
    A = np.array([list(map(int, input().split())) for __ in range(N)])
    l = A[np.argsort(A[:, 1])]

    t = 0
    for i in l:
        t += i[0]
        if t > i[1]:
            print('No')
            return
    print('Yes')

resolve()

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

#define MAX 4001

int dp[MAX][MAX];

int main(void) {
  string s, t;
  while (cin >> s >> t) {
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
	if (s[i] == t[j]) {
	  dp[i][j] = 1;
	} else {
	  dp[i][j] = 0;
	}
      }
    }

    for (int i = 1; i < s.size(); i++) {
      for (int j = 1; j < t.size(); j++) {
	if (dp[i][j] == 0) continue;
	dp[i][j] += dp[i - 1][j - 1];
      }
    }

    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
	ans = max(ans, dp[i][j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 65692
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<n;i++)
#define reps(i,s,n) for(long long i=s;i<n;i++)
#define vec vector
#define inf (1LL<<60)
using namespace std;
using ll = long long;
vec<ll> h;
vec<ll> dp;
ll k;

ll cost(ll n) {
	if (n == 0) return 0;
	if (n < 0) return inf;
	if (dp[n] != inf ) return dp[n];
	ll tmp = inf;
	reps(i, 1, k + 1) {
		if (n - i < 0) break;
		tmp = min(tmp, cost(n - i) + abs(h[n] - h[n - i]));
	}
	return dp[n] = tmp;
}

int main(void) {
	ll n;
	cin >> n >> k;
	h = vec<ll>(n);
	dp = vec<ll>(n, inf);
	rep(i, n) cin >> h[i];
	cout << cost(n - 1) << endl;
}


Measured memory_bytes: 6528
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)] #親
        self.rank = [0 for _ in range(n)] #根の深さ

    #xの属する木の根を求める
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    #xとyの属する集合のマージ
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]

uf = UnionFind(N)
for i in range(M):
    uf.unite(L[i][0]-1, L[i][1]-1)

team = {}
for i in range(N):
    tmp = uf.find(i)
    if tmp not in team:
        team[tmp] = 1
    else:
        team[tmp] += 1

ans = 0
for k, v in team.items():
    ans = max(ans, v)

print(ans)




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

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    int a, prev = -2;

    for(int i = 0; i< n;++i){
        cin >> a;
        if(a < prev){
            cout << "No";
            return 0;
        }
        if(a - 1 >= prev)
            prev = a - 1;
        else
            prev = a;
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

conti = True
while conti:
    try:
        conti = False
        for count, char in enumerate(s):
            if (count - 1) >= 0 and s[count] == s[count - 1]:
                s = s[:count] + s[count + 1:]
                conti = True
    except IndexError:
        pass

print(len(s))

Measured memory_bytes: 3572
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<VV> VVV;


int main() {
	int n,v[100000],c,y=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c;
		if ((v[i] - c) > 0)y += v[i] - c;
	}
	cout << y << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char t,c;
	int abc[52],a,b,d;
	for(a=0;a<52;a++){
		abc[a]=0;
	}
	scanf("%d",&a);
	for(b=0;b<=a;b++){
		scanf("%c %d%c",&t,&d,&c);
		switch(t){
			case 'S':
				abc[d-1]=1;
				break;
			case 'H':
				abc[d+12]=1;
				break;
			case 'C':
				abc[d+25]=1;
				break;
			case 'D':
				abc[d+38]=1;
				break;
		}
	}
	for(a=0;a<52;a++){
		if(abc[a]!=1){
			switch(a/13){
				case 0:
					printf("S %d\n",a%13+1);
					break;
				case 1:
					printf("H %d\n",a%13+1);
					break;
				case 2:
					printf("C %d\n",a%13+1);
					break;
				case 3:
					printf("D %d\n",a%13+1);
					break;
			}
		}
	}
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<int> a(N), b(N);

    for(int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));

    if(N % 2 == 1) {
        cout << b[N / 2] - a[N / 2] + 1 << endl;
    } else {
        LL am, bm;
        am = a[N / 2] + a[N / 2 - 1];
        bm = b[N / 2] + b[N / 2 - 1];
        cout << bm - am + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 4796
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>
#include <cstdint>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define M_PI 3.14159265358979323846

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
pair <int, int> vu[8] = { {0,1}, {1,0} , {1,-1},{0,-1},{-1,0},{-1,1},{0,1}, {1,0} }; // EWSN

const int max_v = 1e5 + 7;
const int INF = 1e7 + 7;

int dp[47];
LL n;
unordered_map <int, int> xhash;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);	
	fa(i, 1, 41)
	{
		fa(j, 1, 10)
		{
			if (i < (j * (j + 1)) / 2)
			{
				dp[i] = j - 1;
				break;
			}
		}
	}

	ci(n);
	for (LL i = 2; i < (LL)sqrt(n) + 1; ++i)
	{
		while (!(n % i))
		{
			if (xhash.find(i) == xhash.end())
			{
				xhash.insert({ i,1 });
			}
			else ++xhash[i];

			n /= i;
		}
	}
	if (n > 1)
	{
		if (xhash.find(n) == xhash.end())
		{
			xhash.insert({ n,1 });
		}
		else ++xhash[n];
	}

	LL ans = 0;

	for (auto x : xhash)
	{
		ans += dp[x.second];
	}

	co(ans);

	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int k;
    cin >> k;
    int tv = n;
    int fv = 0;
    while (tv - fv > 1){
      int mv = (tv + fv) / 2;
      if (a[mv] > k){
        tv = mv;
      } else {
        fv = mv;
      }
    }
    if (a[fv] == k){
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    ll n,m,ans=0,score; cin>>n;
    map<string,ll> s,t;
    string tmp;
    rep(i,n) cin>>tmp, s[tmp]++;
    cin>>m;
    rep(i,m) cin>>tmp, t[tmp]++;
    for(auto p:s){
        score=p.second;
        if(t.count(p.first)) score-=t[p.first];
        ans=max(ans,score);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
use strict;

my ($a,$b) = split(/ /,<STDIN>);
$a = 14 if ($a == 1);
$b = 14 if ($b == 1);

if($a > $b){
	print "Alice\n";
}
elsif($a < $b){
	print "Bob\n";
}
else{
	print "Draw\n";
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lnglng = long long;

void fnInput(lnglng& rnNumA, double& rnNumB)
{
  cin >> rnNumA >> rnNumB;
}

lnglng fnMultiple(lnglng nNumA, double nNumB)
{
  int nNumIB = nNumB * 100 + 0.5;
  return nNumA * nNumIB / 100;
}
  
int main()
{
  lnglng nNumA;
  double nNumB;

  fnInput(nNumA, nNumB);
  cout << fnMultiple(nNumA, nNumB) << endl;

  return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = (int) (1e9 + 7);

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

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

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  string S, T;
  cin >> S >> T;
  vector< int > x(26), y(26);
  for(auto &c : S) x[c - 'a']++;
  for(auto &c : T) y[c - 'a']++;
  for(int i = 0; i < 26; i++) {
    if(y[i] > 0 && x[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  set< int > be[26];
  for(int i = 0; i < S.size(); i++) {
    be[S[i] - 'a'].emplace(i);
  }
  int cur = 0;
  int64 add = 0;
  for(auto &c : T) {
    auto nxt = be[c - 'a'].lower_bound(cur);
    if(nxt == be[c - 'a'].end()) {
      add += (int) S.size();
      nxt = be[c - 'a'].begin();
    }
    cur = *nxt + 1;
  }
  cout << add + cur << endl;
}

Measured memory_bytes: 5200
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a[] = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }

        for (int i = n-1; i>=0; i--) {
            if(i<n-1){
                    System.out.print(" ");
            }
            System.out.print(a[i]);
            
        }
        System.out.println("");
    }
}


Measured memory_bytes: 26360
#include<cstdio>
#include<algorithm>
using namespace std;
int ans;
int main() {
	int a[4];
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	while(a[1]!=a[2]||a[2]!=a[3]||a[1]!=a[3]) {
		sort(a+1,a+4);
		ans++;
		if(a[2]-a[1]>=2) {
			a[1]+=2;
		}
		else {
			a[1]++;
			a[2]++;
		}
		
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long n,p;
    string s;
    cin >> n >> p >> s;
    if(p == 2 || p == 5){
        long ans = 0;
        rep(i,n){
            long tmp = s.at(i) - '0';
            if(tmp % p == 0) ans += i+1;
        }
        cout << ans << endl;
        return 0;
    }
    vector<long> data(n+1,0);
    long keta = 1;
    for(int i=n-1;i>=0;i--){
        int now = s.at(i) - '0';
        data.at(i) = ( now * keta + data.at(i+1) ) % p;
        keta *= 10;
        keta %= p;
    }
    vector<long> cnt(p,0);
    rep(i,n+1){
        cnt.at(data.at(i))++;
    }
    long ans = 0;
    rep(i,p){
        long tmp = cnt.at(i);
        ans += (tmp*(tmp-1))/2;
    }
    cout << ans << endl;
}

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

using namespace std;

int digit[11];

int main() {
	
	int n;int k; cin >> n >> k;
	
	while(k--) {
		int v; cin >> v;
		digit[v] = 1;
	}
	
	while(true) {
		int ans = n;
		bool flag = true;
		
		while(n && flag) {
			if(digit[n % 10]) {
				flag = false;
				break;
			}
			n /= 10;
		}
		
		if(flag) {
			cout << ans << '\n';
			return 0;
		}
		
		n = ans + 1;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
const long long md=1e9+7;
const int maxn=200100;
struct node{
	int c,w;
}a[maxn];
bool cmp(const node &A,const node &B){
	if(A.c==B.c) return A.w<B.w;
	return A.c<B.c;
}
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
long long fac[maxn],inv[maxn];
int cnt[maxn];
int n,X,Y;
long long C(int x,int y){
	if(y>x) return 0;
	return fac[x]*inv[y]%md*inv[x-y]%md;
}
int val[maxn];
int main(){
//	freopen("D.in","r",stdin);
//	freopen("D.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<=200000;i++)
		fac[i]=fac[i-1]*i%md;
	inv[200000]=powd(fac[200000],md-2);
	for(int i=200000;i>=1;i--)
		inv[i-1]=inv[i]*i%md;

	scanf("%d%d%d",&n,&X,&Y);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].c,&a[i].w);
	sort(a+1,a+n+1,cmp);
	node st=a[1];
	for(int i=1;i<=n;i++)
		if(a[i].w<st.w)
			st=a[i];
	int w=st.w;


	int v;
	for(int i=1;i<=n;i++)
	{
		if(val[a[i].c]) continue;
		if(a[i].c!=st.c)
			val[a[i].c]=w;
		else
		{
			v=1000000111;
			for(int j=1;j<=n;j++)
				if(a[j].c!=st.c&&a[j].w<v)
					v=a[j].w;
			val[st.c]=v;
		}
	}
	int l=1,r;
	for(int i=1;i<=n;i=l+1)
	{
		l=i;
		while(l<n&&a[l+1].c==a[l].c) l++;
		for(int j=i;j<=l;j++)
			if((a[j].w+val[a[i].c]<=Y)||(a[j].w+a[i].w<=X&&a[i].w+val[a[i].c]<=Y))
				cnt[j]=1;
	}
	for(int i=n;i>=1;i--)
		cnt[i]=cnt[i]+cnt[i+1];

	l=1;
	long long ans=1,sum;
	for(int i=1;i<=n;i=l+1){
		l=i;
		while(l<n&&a[l+1].c==a[l].c) l++;
		r=i;
		while(r<=l&&(a[r].w+val[a[i].c]<=Y||a[r].w+a[i].w<=X)) r++;
		if(a[i].w+w>Y) continue;
		sum=0;
		for(int j=0;j<=r-i;j++)
			sum=(sum+C(r-i,j)*C(cnt[l+1],j))%md;
		ans=ans*sum%md;
	}
	printf("%lld\n",ans);

	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int xr = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        xr ^= a[i];
    }
    for (auto e : a) {
        cout << (xr ^ e) << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 3968
def main():
    S = input()
    N = len(S)
    from collections import deque

    def solve(S):
        cur = deque([S[0]])
        ans = 1
        i = 1
        plus = 1
        while i < N:
            if i+plus > N:
                break
            if S[i:i+plus] in cur:
                plus += 1
            else:
                cur.pop()
                cur.append(S[i:i+plus])
                i = i+plus
                plus = 1
                ans += 1
        return ans
    print(solve(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 42460
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define endl "\n"
#define ff first
#define ss second

void solve()
{
	int arr[5];
	int ans = 1;
	for (int i = 0; i < 5; i++)
	{
		cin >> arr[i];
		if (arr[i] == 0)
			ans = i + 1;
	}
	cout << ans;
}


signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


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

int main() {
  int n;
  unsigned long long mul=1, buf;
  cin >> n;
  vector<unsigned long long> a(n);
  rep(i,n){
    cin >> buf;
    a[i] = buf;
    if(a[i]==0){
      cout << "0";
      return 0;
    }
  }
  rep(i,n){
    if(mul>1000000000000000000/a[i]){
      cout << "-1";
      return 0;
    }
    mul*=a[i];
  }
  cout << mul;
  return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MAX_V 10000000
#define INF 100000000

struct pos{
    int x;
    int y;
};

int main(){
    int n; cin >> n;
    vector<pos> r;
    vector<pos> b;
    for(int i = 0; i < n; i++){
        int ax, by; cin >> ax >> by;
        pos e = {ax, by};
        r.push_back(e);
    }
    for(int i = 0; i < n; i++){
        int ax, by; cin >> ax >> by;
        pos e = {ax, by};
        b.push_back(e);
    }
    sort(b.begin(), b.end(), [](const pos& c, const pos& d){return c.x < d.x;});
    /*for(int i = 0; i < n; i++){
        cout << b[i].x << endl;
    }*/
    int ans = 0;
    for(int i = 0; i < n; i++){
        int min = -1;
        int lmin = -1;
        for(int l = 0; l < r.size(); l++){
            if(b[i].x > r[l].x){
                if(b[i].y > r[l].y &&min < r[l].y){
                    min = r[l].y;
                    lmin = l;
              }
            }
        }
        if(lmin != -1){
            ans++;
            r.erase(r.begin() + lmin);
        }
        //cout<< r.size()<< endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main (void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (S.size() <= N) {
        cout << S;
    } else {
        rep(i, N) cout << S.at(i);
        cout << "..." << endl;
    }
    
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, C, K;
int T[110000];
signed main() {
    cin >> N >> C >> K;
    rep(i, N) { cin >> T[i]; }
    sort(T, T + N);
    int j = T[0], cur = 1, ans = 1;
    reps(i, N - 1) {
        if (T[i] - j > K || cur == C) { j = T[i], cur = 1, ans++; }
        else { cur++; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4356
import sys

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

max_b = max(b)
ans = []
flag = 0

while len(b) != 0:
    for i in range(min(max_b-1,len(b)-1),-1,-1):
        if b[i] == i+1:
            flag = 1
            b.pop(i)
            ans.append(i+1)
            break
    if flag == 0:
        print(-1)
        sys.exit()
    flag = 0

for i in reversed(ans):
    print(i)


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
    int i, j, n, a, res=0;

    scanf("%d", &n);

    for(i=0; i<n; i++){

        scanf("%d", &a);

        for(j=2; j*j<=a; j++){
            if(a==1){
                a=0; 
                break;
            }else if(a==2){
                break;
            }else if(a%j==0){
                a=0;
                break;
            }
        }

        if(a!=0) res++;
        
    }

    printf("%d\n", res);

    return 0;
}



Measured memory_bytes: 2064
N=int(input())
D,X=list(map(int,input().split()))
A=[]
for i in range(N):
    A.append(int(input()))
ans=N+X
for i in range(N):
    if(D%A[i]==0):
        ans += int(D/A[i])
        ans-= 1
    else:ans += int(D/A[i])
print(ans)

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

using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 3;
int a[N];
long long dp[N], col[N];

void MOD(long long &x)
{
    if (x >= mod)
        x -= mod;
}

int main()
{
    int i, n, x;
    cin >> n;
    vector<int> a = {-1};

    for (i = 1; i <= n; i++)
    {
        cin >> x;
        if (x == *a.rbegin())
            continue;
        a.push_back(x);
    }

    n = a.size();
    dp[0] = 1;

    for (i = 1; i <= n; i++)
    {
        MOD(dp[i] = dp[i - 1] + col[a[i]]);
        MOD(col[a[i]] += dp[i - 1]);
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4340
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
#include <array>

using namespace std;

struct Edge{
  int to;
  int cost;
};

typedef pair<int, int> P; // min distance, vertex id

const int kMaxVertex = 21;
const int kInf = 1 << 30;
vector<Edge> G[kMaxVertex];
int d[kMaxVertex];

void Dijkstra(int start, int num_vertex){
  priority_queue<P, vector<P>, greater<P> > q;
  fill(d, d + num_vertex + 1, kInf);
  d[start] = 0;
  q.push(P(0, start));

  while(q.size()){
	P p = q.top();
	q.pop();
	int from = p.second;
	if(d[from] < p.first){
	  continue;
	}

	for(int i=0; i<G[from].size(); i++){
	  Edge e = G[from][i];
	  // new route requires less cost
	  if(d[e.to] > d[from] + e.cost){
		d[e.to] = d[from] + e.cost;
		q.push(P(d[e.to], e.to));
	  }
	}
  }
}


int main(){
  int num_vertex, num_road;
  scanf("%d ", &num_vertex);
  scanf("%d ", &num_road);
  for(int i=0; i<num_road; i++){
	int a, b, c, d;
	scanf("%d,%d,%d,%d",&a,&b,&c,&d);
	G[a].push_back({b, c});
	G[b].push_back({a, d});
  }
  int start, goal, money, cost;
  scanf("%d,%d,%d,%d",&start,&goal,&money,&cost);
  Dijkstra(start, num_vertex);
  cost += d[goal];
  Dijkstra(goal, num_vertex);
  cost += d[start];

  printf("%d\n", money - cost);
}

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

int main(void){
	const int ofDay = 10;
	const int MAXN = 30;
	const int TOBIN = 3;
	const int YEAR = 365;
	int dp[MAXN+1];
	
	// init
	for(int i=1; i<=MAXN; i++)
		dp[i] = 0;
	dp[0] = 1;

	// 全通り計算
	for(int i=0; i<=MAXN; i++){
		for(int j=1; j<=TOBIN; j++){
			if( i+j <= MAXN )
				dp[i+j] += dp[i];
		}
	}

	// 年数計算
	for(int i=1; i<=MAXN; i++){
		dp[i] = dp[i] / ofDay + (dp[i] % ofDay ? 1 : 0);
		dp[i] = dp[i] / YEAR + (dp[i] % YEAR ? 1 : 0);
	}

	// 対話
	while( true ){
		int n;
		cin >> n;
		if( n == 0 )
			break;

		cout << dp[n] << endl;
	}

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    bool ok = true;
    rep(i, N) {
        ll a = A[i];
        if (a % 2 ==0 ) {
            if (a % 3  == 0 || a%5 ==0) {
                continue;
            }else{
                ok = false;
            }
        }
    }
    if (ok) {
        cout << "APPROVED" << '\n';
    }else{
        cout << "DENIED" << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int n, m, a[103];
long long ans = 2000000007;
 
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i+=1)
		cin >> a[i];
	for (int i = 1; i <= 100; i+=1)
	{
		long long sum = 0;
		for (int j = 1; j <= n; j+=1)
		{
			sum += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}





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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        v: [usize; n+1]
    }
    let d = 1000000007;
    let mut stairs: Vec<usize> = (1..n+2).scan(1, |ac, x| {*ac = *ac * x % d; Some(*ac)}).collect();
    stairs.insert(0,1);
    let stairs_i: Vec<usize> = stairs.clone().iter().map(|&x| inv_m(x,d)).collect();
    let mut w = vec![n+1; n+1];
    let mut a = 0;
    let mut c = 0;
    for i in 0..n {
        if w[v[i]] == n + 1 {
            w[v[i]] = i;
        } else {
            a = w[v[i]];
            c = n - i;
        }
    }
    for k in 1..n+2 {
        let mut ans = stairs[n+1] * stairs_i[n+1-k] % d * stairs_i[k] % d;
        if a + c >= k - 1 {
            ans = (ans + d - stairs[a+c] * stairs_i[a+c+1-k] % d * stairs_i[k-1] % d) % d
        }
        println!("{}", ans);
    }
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    int i;
    long long int sum = 0;
    vector<long long int> H(N);

    for(i=0;i<N;i++){
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    reverse(H.begin(), H.end());

    if(N <= K){
        cout << 0;
    }else{
        for(i = K;i < N; i++){
            sum += H.at(i);
        }
        cout << sum;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) <<endl;
    return 0;
}

Measured memory_bytes: 3636