akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;



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

	stack<int> s;
	string a;
	int x, y;
	while (cin>>a) {
		if (a[0] == '+') {
			y = s.top();
			s.pop();
			x = s.top();
			s.pop();

			s.push(x + y);
		}
		else if (a[0] == '-') {
			y = s.top();
			s.pop();
			x = s.top();
			s.pop();

			s.push(x - y);
		}
		else if (a[0] == '*') {
			y = s.top();
			s.pop();
			x = s.top();
			s.pop();

			s.push(x * y);
		}
		else {
			int z = a[0] - '0';
			for (int i = 1; i < a.size(); i++) {
				z *= 10;
				z += a[i] - '0';
			}
			s.push(z);
		}
	}
	cout << s.top() << endl;
}


Measured memory_bytes: 3204
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

    int maxh = 0;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int h; cin >> h;
        if (maxh <= h) cnt++;
        maxh = max(maxh, h);
    }

    cout << cnt << endl;

    return 0;
}


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

int main() {
  ll a, b, c, k, sum = 0;
  cin >> a >> b >> c >> k;
  if(a < k){
    sum += a;
    k -= a;
  }else if(a >= k){
    sum += k;
    k = 0;
  }

  if(b < k){
    k -= b;
  }else if(b >= k){
    k = 0;
  }

  cout << sum - k << endl;

  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int n, m;
    int a[101][101], b[101];
    scanf("%d %d", &n, &m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(int i = 0; i < m; i++){
        scanf("%d", &b[i]);
    }
    for(int i = 0; i < n; i++){
        int c = 0;
        for(int j = 0; j < m; j++){
            c += a[i][j] * b[j];
        }
        printf("%d\n", c);
    }
    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll pre[n+1]={0};
    for(int i=1;i<=n;i++)
        pre[i]=pre[i-1]+a[i-1];
    for(int i=0;i<=n;i++)
        pre[i]=(pre[i]-i+k)%k;
    map<ll,ll>cnt;
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        if(i-k>=0)cnt[pre[i-k]]--;
        ans+=cnt[pre[i]];
        cnt[pre[i]]++;
    }
    cout<<ans;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;



int main(){
    IOS
    ll n ,m;
    cin >>n>>m;
    priority_queue<int,vector<int>,greater<int>> qq;
    for (int a, i = 0; i <n ; ++i) {
        cin >>a;
        qq.push(a);
        
    }
    
    vpi vec2;
    
    for (int a ,b, j = 0; j <m ; ++j) {
            cin >>a>>b;
            vec2.pb({b,a});
    }
    
    sort(BEND(vec2));

    for (int l = vec2.size()-1; l >=0 ; --l) {
        int t =10;

        while (t > 0){


            if(vec2[l].first <= qq.top())break;

            t = vec2[l].second;



            qq.pop();
            qq.push(vec2[l].first);
            if(vec2[l].second == 0){
              break;
            }
            vec2[l].second--;
            t--;
        }

        if(vec2[l].first < qq.top())break;
    }
    ll sum = 0;
    for (int k = 0; k <n ; ++k) {
        //cout << qq.top() <<" ";
        sum +=qq.top();
        qq.pop();
    }
    cout << sum;

    return 0;
}



Measured memory_bytes: 1784
n,m = gets.chomp.split(' ').map(&:to_i)
roads = m.times.map{gets.split(' ').map(&:to_i)}

(1..n).each do |i|
  count = 0
  (0...m).each do |j|
    count += 1 if roads[j][0] == i || roads[j][1] == i
  end
  puts count
end



Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main(){
	int a, b, c;

	cin >> a;
	cin >> b;
	cin >> c;

	int count = 0;

	for ( int i = a; i <= b; i++ ) {
		if ( c % i == 0 ) {
			count++;

		}
	}

	cout << count << endl;

}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b,h; cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

ll n, z, w;
vector<ll> a;
int main(void) {
	cin >> n >> z >> w;
	rep(i, n) {
		ll x; cin >> x;
		a.pb(x);
	}
	if (n == 1) {
		cout << abs(a[0] - w) << endl;
	}
	else {
		cout << max(abs(a[n-2]-a[n-1]), abs(a[n-1]-w)) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int n, x, y;

int main(){
	scanf(" %d %d %d", &n, &x, &y);
	if(x + y <= n) printf("%d 0\n", min(x, y));
	else printf("%d %d\n", min(x, y), x + y - n);
}

Measured memory_bytes: 760
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;

typedef int INT;
set <INT> S;
bool H[16777216];

inline INT get( char c ) {
    char T[5] = "ACGT";
    for ( INT i = 0; i < 4; ++ i ) {
        if ( c == T[i] ) return i + 1;
    }
    return 0;
}

inline INT get( char *s ) {
    INT n = strlen( s );
    INT sum = 0;
    INT t = 1;
    for ( INT i = 0; i < n; ++ i ) {
        sum += get( s[i] ) * t;
        t *= 4;
    }
    return sum;
}

inline void insert( char *s ) {
    S.insert( get( s ) );
}

inline bool find( char *s ) {
    return S.count( get( s ) ) > 0;
}

int main() {
    INT n, sum, t, c;
    while ( scanf("%d", &n) != EOF ) {
        while ( getchar() != '\n' );
        S.clear();
        for ( register INT i = 0; i < n; ++ i ) {
            sum = 0;
            t = 1;
            bool flag = getchar() == 'i';
            while ( ( c = getchar() ) != ' ' );
            while ( ( c = get( getchar() ) ) != 0 ) {
                sum += c * t;
                t *= 4;
            }
            if ( flag ) {
                S.insert( sum );
            } else {
                puts( S.count( sum ) ? "yes" : "no" );
            }
        }
    }
    return 0;
}

Measured memory_bytes: 7244
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int n, m, i1, i2, i3, i4;
typedef pair<int, int>P;
vector<P>v[34];
int dijkstra(int p, int key) {
	priority_queue<P, vector<P>, greater<P>>pq;
	pq.push(make_pair(0, p));
	int a[123456]; for (int i = 0; i < 123456; i++)a[i] = -1;
	while (pq.size()) {
		P p1 = pq.top(); pq.pop();
		if (p1.second == key)return p1.first;
		if (a[p1.second] == -1) {
			a[p1.second] = p1.first;
			for (P i : v[p1.second])
				if (a[i.first] == -1)pq.push(make_pair(p1.first + i.second, i.first));
		}
	}
}
int input() {
	string s; cin >> s;
	s += ',';
	int cnt = 0, k = 0;
	for (char ch : s) {
		if (ch == ',') {
			if (cnt == 0)i1 = k;
			if (cnt == 1)i2 = k;
			if (cnt == 2)i3 = k;
			if (cnt == 3)i4 = k;
			k = 0; cnt++;
		}
		else {
			k *= 10; k += ch - '0';
		}
	}
}
signed main() {
	cin >> n >> m;
	for1(i, m) {
		input();
		v[i1].push_back(mp(i2, i3));
		v[i2].push_back(mp(i1, i4));
	}
	input();
	cout << i3 - i4 - dijkstra(i1, i2) - dijkstra(i2, i1) << "\n";
}


Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(),v.end()

int main() {
    int n,m;
    cin >> n >> m;
    vector<bool> from1(200000), toN(200000);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        if (a == 1) {
            from1[b-1] = true;
        } else if (b == n) {
            toN[a-1] = true;
        }
    }
    rep(i,from1.size()) {
        if (from1[i] && toN[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }        
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using namespace std;

const int N = 2006;

int fq[N / 2], l[N];

int f(int val) {
    int ans(0);
    for (int i = 1; i <= val; ++i)
        ans += fq[i];
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> l[i];
    sort(l + 1, l + n + 1);
    long long ans(0);
    for (int i = 1; i <= n; ++i) {
        ans += (i - 1) * (i - 2) / 2 - f(l[i]);
        for (int j = 1; j < i && l[i] + l[j] < N / 2; ++j)
            fq[l[i] + l[j]]++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc134/tasks/abc134_e
import sys
read = sys.stdin.readline


def read_a_int():
    return int(read())


from bisect import bisect_left, bisect_right, insort_left
from array import array


class BinarySearchTree:
    def __init__(self, ls: list = []):
        '''
        C++でいうsetを実装する。二分探索木をガチで実装しようとすると大変なので、ここでは配列二分法を用いる。
        pythonの標準ライブラリがヨイショに抱っこしてくれるおかげで楽に実装できる。
        https://docs.python.org/ja/3/library/bisect.html


        ls ... 渡す初期配列
        '''
        self.bst = array('q', sorted(
            ls))  # insertを爆速にするためにarray型にします。signed long long 前提です

    # def __repr__(self):
    #     return f'BST:{self.bst}'

    def __len__(self):
        return len(self.bst)

    def __getitem__(self, idx):
        return self.bst[idx]

    def size(self):
        return len(self.bst)

    def insert(self, x):
        # idx = self.bisect_left(x)
        # self.bst.insert(idx,x)
        insort_left(self.bst, x)

    def pop_left(self):
        x = self.bst[0]
        del self.bst[0]
        return x

    def pop_right(self):
        x = self.bst[-1]
        del self.bst[-1]
        return x

    def remove(self, x):
        '''
        xを取り除く。xがself.bstに存在することを保証してください。
        同一のものが存在した場合は左から消していく
        '''
        del self.bst[self.find(x)]

    def bisect_left(self, x):
        '''
        ソートされた順序を保ったまま x を self.bst に挿入できる点を探し当てます。
        lower_bound in C++
        '''
        return bisect_left(self.bst, x)

    def bisect_right(self, x):
        '''
        bisect_left() と似ていますが、 self.bst に含まれる x のうち、どのエントリーよりも後ろ(右)にくるような挿入点を返します。
        upper_bound in C++
        '''
        return bisect_right(self.bst, x)

    def find(self, x):
        '''
        xのidxを探索
        '''
        idx = bisect_left(self.bst, x)
        if idx != len(self.bst) and self.bst[idx] == x:
            return idx
        raise ValueError

    def insert_replace_left(self, x):
        '''
        xを挿入して、xの左の数字(次に小さい)を削除する。idxがはみ出す場合は挿入だけ
        '''
        idx_del = self.bisect_left(x) - 1
        if idx_del + 1 == 0:  # xがどの要素よりも小さい
            self.insert(x)
        if idx_del < len(self.bst):
            self.insert(x)
            del self.bst[idx_del]

    def insert_replace_right(self, x):
        '''
        xを挿入して、xの右の数字(次に大きい)を削除する。idxがはみ出す場合は挿入だけ
        '''
        idx_del = self.bisect_right(x) + 1  # xと同じ大きさも削除したいならbisect_left
        if idx_del - 1 == len(self.bst):  # xがどの要素よりも大きい
            self.insert(x)
        else:
            self.insert(x)
            del self.bst[idx_del]


N = read_a_int()
bst = BinarySearchTree([-1])
for n in range(N):
    a = read_a_int()
    # すべてより小さかったら、新しく追加
    if bst.bst[0] >= a:
        bst.insert(a)
    else:
        # bstのなかで、aより小さく且つ一番大きい要素をaに書き換えていく
        idx = bst.bisect_left(a) - 1
        bst.bst[idx] = a

print(len(bst))


Measured memory_bytes: 4408
#include<iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if (a < b){
		cout << "a < b"<< endl;
	}
	else if (a>b){
		cout << "a > b"<< endl;
	}
	else cout << "a == b" << endl;
	return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*(a+b);
        System.out.println(area +" "+ length);
        sc.close();
    }
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

struct S {
  int lowest, change;
  bool operator<(const S& s) const { return lowest > s.lowest; }
};

template <typename T>
bool Setmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  in(int, n);
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  vector<S> left, right;
  for (const string& si : s) {
    int lowest = 0, change = 0;
    for (char c : si) {
      change += c == '(' ? 1 : -1;
      Setmin(lowest, change);
    }
    if (change >= 0) {
      left.push_back({lowest, change});
      continue;
    }
    lowest = 0, change = 0;
    for (int i = si.size() - 1; i >= 0; --i) {
      change += si[i] == ')' ? 1 : -1;
      Setmin(lowest, change);
    }
    right.push_back({lowest, change});
  }
  sort(all(left));
  sort(all(right));
  auto height = [&](const vector<S>& v) -> optional<int> {
    int curr = 0;
    for (const auto& s : v) {
      if (curr + s.lowest < 0) {
        return nullopt;
      }
      curr += s.change;
    }
    return curr;
  };
  optional<int> l = height(left), r = height(right);
  if (l && r && *l == *r) {
    out("Yes");
  } else {
    out("No");
  }
}


Measured memory_bytes: 42388
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var chars = ReadLine().ToList();

            while (true)
            {
                chars.RemoveAt(chars.Count - 1);
                bool flag = true;
                if (chars.Count % 2 == 0)
                {

                    for (int i = 0; i < chars.Count / 2; i++)
                    {
                        if (chars[i] != chars[chars.Count / 2 + i])
                        {
                            flag = false;
                            break;
                        }
                    }
                }
                else
                {
                    flag = false;
                }
                if (flag)
                {
                    WriteLine(chars.Count);
                    break;
                }
            }
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 11220
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<string, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum[5000][5000], a[210000], b[210000];
string str;
bool f;
char c[1100][1100];
void dfs(LL cur, LL par) {
	rep(i, g[cur].size()) {
		LL v = g[cur][i].to;
		if (v == par)continue;
		if (g[cur][i].cost % 2 == 0)
			a[v] = a[cur];
		else
			a[v] = a[cur] ^ 1;
		dfs(v, cur);
	}
}
int main() {
	cin >> n;
	g.resize(n);
	rep(i, n - 1) {
		LL x, y, z;
		cin >> x >> y >> z;
		x--, y--;
		g[x].push_back(Edge{ y,z });
		g[y].push_back(Edge{ x,z });
	}
	dfs(0, -1);
	rep(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 11392
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

void solve() {
    int A, B;
    cin >> A >> B;
    cout << (A + B - 3) / (A - 1);
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
    int N,ba[10],B,C,ju;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        ju=0;
        B=0;
        C=-1;
        for(int j=0;j<10;j++)
        {
            scanf("%d",&ba[j]);
        }
        for(int j=0;j<10;j++)
        {
            if(ba[j]>B&&ba[j]>C)
            {
                if(B>C)B=ba[j];
                else C=ba[j];
            }
            else if(ba[j]>B)B=ba[j];
            else if(ba[j]>C)C=ba[j];
            else ju++;
        }
        if(ju==0)printf("YES\n");
        if(ju>=1)printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1008
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  bool f = false;
  string s;
  cin >> s;
  if(s[0] == '9' || s[1] == '9') f = true;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 500010;

lint dp[110][1<<16];

int main(){
    int n, bit[30][30];
    For(i, 6, 22)For(j, i+1, 23){
        bit[i][j] = 0;
        For(k, i, j) bit[i][j] |= 1 << (k-6);
    }

    while(scanf("%d", &n) && n){
        int m[n], b[n]; lint L[n];
        rep(i, n){
            scanf("%d%lld", &m[i], &L[i]);
            b[i] = 0;
            rep(j, m[i]){
                int l, r;
                scanf("%d%d", &l, &r);
                b[i] |= bit[l][r];
            }
        }

        rep(i, n+1)rep(S, 1<<16) dp[i][S] = -1;
        dp[0][0] = 0;
        rep(i, n)rep(S, 1<<16)if(dp[i][S] >= 0){
            chmax(dp[i+1][S], dp[i][S]);
            if(!(S & b[i])){
                chmax(dp[i+1][S|b[i]], dp[i][S] + L[i]);
            }
        }
        lint ans = 0;
        rep(S, 1<<16) chmax(ans, dp[n][S]);
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 54936
s=list(input())
t=list(input())
c=0
for i in range(len(s)):
  u=[s[j] for j in range(i,len(s))]
  if i>0:
    for k in range(0,i):
      u.append(s[k])
  if t==u:
    c=1
    break
if c==1:print('Yes')
else:print('No')

Measured memory_bytes: 3060
sx,sy, tx,ty = map(int, input().split())

ans = ""

ans += "R"*(tx - sx)
ans += "U"*(ty - sy)
ans += "L"*(tx - sx)
ans += "D"*(ty - sy + 1)

ans += "R"*(tx - sx + 1)
ans += "U"*(ty - sy + 1)
ans += "L"
ans += "U"
ans += "L"*(tx - sx + 1)
ans += "D"*(ty - sy + 1)
ans += "R"

print(ans)



Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,a[N],b[N];ll w[N],tot;
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),w[i]=a[i]+b[i],tot-=b[i];
	sort(w+1,w+n+1);
	for(register int i=n;i>=1;i-=2)tot+=w[i];
	printf("%lld\n",tot);
	return 0;
}

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

#define INF 10000001

#define MOD 1000000007

typedef long long ll;

void chmin(ll *a,ll b){ //第二引数のほうが第一引数より小さければ、第一引数に代入
  if(*a > b){
    *a = b;
  }
}

void chmax(ll *a,ll b){ //第二引数のほうが第一引数より大きければ、第一引数に代入
  if(*a < b){
    *a = b;
  }
}

int main(void){
  int n;
  std::cin >> n;

  ll a[n][3],dp[n+1][3];
  for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
      std::cin >> a[i][j];
      dp[i][j] = 0;
    }
  }
  for(int i=0; i<3; i++) dp[n][i] = 0;


  for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(j != k) chmax(&dp[i+1][k],dp[i][j] + a[i][k]);
      }
    }
  }

  ll ans = 0;
  for(int i=0; i<3; i++) chmax(&ans,dp[n][i]);
  std::cout << ans << std::endl;
  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
 /* ll t;cin>>t;
    while(t--)
    {*/
      ll x,y,z;cin>>x>>y>>z;
     
      swap(x,y);
      
      swap(x,z);
      cout<<x<<" "<<y<<" "<<z;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n,m,dis[N],pre[N];
const int inf=1e9;
vector<int>v[N];
void dfs(int x){
	priority_queue<pair<int,int>>q;
	q.push({0,1});
	for(int i=2;i<=n;i++)dis[i]=inf;
	while(!q.empty()){
		auto x=q.top();
		q.pop();
		for(auto k:v[x.se]){
			if(dis[k]>dis[x.se]+1){
				dis[k]=dis[x.se]+1;
				pre[k]=x.se;
				//cout<<x.se<<' '<<k<<endl;
				q.push({-dis[k],k});
			}
		}
	}
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;
  for(int i=1;i<=m;i++){
  	int s,t;
  	cin>>s>>t;
  	v[s].pb(t);
  	v[t].pb(s);
  }
  dfs(1);
  for(int i=2;i<=n;i++){
  	if(dis[i]==inf)return cout<<"No\n",0;
  }
  cout<<"Yes\n";
  for(int i=2;i<=n;i++)cout<<pre[i]<<'\n';
 	return 0;
}

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;


int main(){
    string S;
    cin>>S;
    if (S[0]==S[1]&&S[0]==S[2]) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

#define fi  first
#define se  second
#define mp  make_pair
#define pb  push_back
#define ll  long long
#define mod 1000000007
#define pie 2.0*acos(0.0)
#define pii pair<int, int>

int main() {
    ll x, y, i = 2;
    cin >> x >> y;

    if (x % y == 0) {
        cout << -1 << endl;
        return 0;
    }

    while (true) {
        if ((x * i) % y) {
            cout << x * i << endl;
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Integer a[] = {1,3,5,7,8,10,12};
    Integer b[] = {4,6,9,11};
    Integer c[] = {2};
    Scanner scan = new Scanner(System.in);
    Integer x = scan.nextInt();
    Integer y = scan.nextInt();
    Integer g1 = 0;
    Integer g2 = 0;
    if(Arrays.asList(a).contains(x)) {
      g1 = 1;
    }else if(Arrays.asList(b).contains(x)){
      g1 = 2;
    }else{
      g1 = 3;
    }
    if(Arrays.asList(a).contains(y)) {
      g2 = 1;
    }else if(Arrays.asList(b).contains(y)){
      g2 = 2;
    }else{
      g2 = 3;
    }
    if(g1==g2){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

  

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

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

    if ( c <= (a + b) ){
        cout << "No" << endl;
    }else{
        ll ans = a * a + b * b + c * c - 2 * (a * b + b * c + c * a);
        if (ans > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    // if (sqrt(a) + sqrt(b) < sqrt(c)){
    //     cout << "Yes" << endl;
    // }else{
    //     cout << "No" << endl;
    // }

    return 0;
}

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

int main() {
  long H,W;
  cin >> H >> W;
  long S;
  if(H%3==0 || W%3==0)S=0;
  else S=min(H,W);
  long S1,S2,S3,s;
  for(int i=1;i<H;i++){
    S1=i*W;
    S2=(H-i)*(W/2);
    S3=(H-i)*(W-W/2);
    s=max({S1,S2,S3})-min({S1,S2,S3});
    S=min(S,s);
  }
  for(int i=1;i<W;i++){
    S1=i*H;
    S2=(W-i)*(H/2);
    S3=(W-i)*(H-H/2);
    s=max({S1,S2,S3})-min({S1,S2,S3});
    S=min(S,s);
  }
  cout << S;
}



Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N,M,T;
vi A;
vi L;
int ans;

signed main(){

    in(N,M,T);
    A.resize(N);
    L.resize(T+10010);
    rep(i,N){
        in(A[i]);
        A[i];
    }

    for(auto e:A){
        REP(i,e-M,e+M){
            L[i]=1;
        }
    }

    show(L);

    rep(i,T) if(L[i]!=1) ans++;

    out(ans);

    return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;


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

    ll L;
    int N;

    cin >> L >> N;

    vll X(N);
    for(int i=0;i<N;i++) cin >> X[i];

    sort(X.begin(), X.end());
    vll Y(N);
    for(int i=0;i<N;i++) Y[i] = L - X[N-1-i];

    vll S(N+1, 0);
    vll T(N+1, 0);
    for(int i=1;i<=N;i++) {
        S[i] = S[i-1] + X[i-1];
        T[i] = T[i-1] + Y[i-1];
    }

    ll best = max(X[N-1], Y[N-1]);
    for(int n=1; n<N; n++) {
        int m = N-n;
        ll cur = 0;
        if (n > m) {
            cur = max(2*(S[n] - S[n-m]) + 2*T[m] - min(X[n-1], Y[m-1]),
                      2*(S[n] - S[n-m-1]) + 2*T[m] - X[n-1]);
        } else if (m > n) {
            cur = max(2*S[n] + 2*(T[m] - T[m-n]) - min(X[n-1], Y[m-1]),
                      2*S[n] + 2*(T[m] - T[m-n-1]) - Y[m-1]);
        } else {
            cur = 2*(S[n] + T[m]) - min(X[n-1], Y[m-1]);
        }

        // cout << n << " " << cur << endl;
        best = max(best, cur);
    }

    cout << best << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, pair<int, int> > p;
 
#define MOD 1000000007

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

    int N;
    cin >> N;

    vector<int> A(N);
    vector<int> B(N);

    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if(N % 2) {
        cout << B[N / 2] - A[N / 2] + 1 << endl;
    } else {
        int a = A[N / 2] + A[N / 2 - 1];
        int b = B[N / 2] + B[N / 2 - 1];
        cout << (b - a) + 1 << endl;
    }
}

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

int main(){
  ll n,w;
  cin >> n >> w;
  vector<ll> v(n,0),a(n,0);
  for(int i=0;i<n;i++){
    cin >> v[i] >> a[i];
  }
  ll dp[n+1][w+1];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=w;j++){
      if(i==0 or j==0){
        dp[i][j]=0;
      }
      else if(j<v[i-1]){
        dp[i][j] = dp[i-1][j];
      }
      else{
        dp[i][j] = max(dp[i-1][j],a[i-1] + dp[i-1][j-v[i-1]]);
      }
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 82420
// [Tag]
// #

#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <deque>
#include <map>
using namespace std;

#define fi     	first    
#define se     	second  

/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
typedef unsigned char           uchar;
typedef unsigned int            ui;
typedef unsigned long long int  ull;

constexpr int               inf = 2123456789;
constexpr long long 		INF = 9123456789123456789;
constexpr long long         MOD = 1000000007LL;

template<class T>
using MaxHeap = priority_queue<T>;
template<class T>
using MinHeap = priority_queue<T, vector<T>, greater<T> >;


template<class T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i];
        if (i + 1 < vec.size())os << ' ';
    }
    return os;
}
template<class T>
istream& operator >> (istream& is, vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++)is >> vec[i];
    return is;
}


/*************************************************/

ll N, K, S;
vi A;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    /*INPUT*/
    cin >> N >> K >> S;
    A.resize(N);

    if (N - K + 1 < S) {
        int period = N - K + 1;
        int each = S / period;
        int residual = S % period;
        for (int i = 0; i < N; i++) {
            if ((i + 1) % period == 0)
                A[i] = each + residual;
            else
                A[i] = each;
        }

    }
    else {
        for (int i = 0; i < N; i++) {
            if (i < K) A[i] = S;
            else A[i] = S + 1;
        }
    }

    for (auto a : A)
        cout << a << " ";

    return 0;
}

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

int main() {
  long long  n,k,p=0,cycle;
  cin >> n >> k;
  vector<int> table(n); // 入力情報
  vector<int> num(n,-1); // 初めて訪れた時刻
  vector<int> check(n,0); // 訪れたかどうかを調べる

  //初期条件の追加
  num.at(0) = 0;
  check.at(0) = 1;

  for(int i = 0; i < n; i++) {
    cin >> table.at(i);
  }
  for (int i = 1; i < n+ 10; i++) {
    p = table.at(p) - 1;
    check.at(p)++;

    if(check.at(p) == 1) {
      num.at(p) = i;
    }

    if (check.at(p) == 2) {
      cycle = i - num.at(p);
      break;
    }
  }
  long long ans;
  if (k < num.at(p)) {
    ans = k;
  }
  else 
     ans = (k-num.at(p))%cycle + num.at(p);

  for (int i = 0; i < n; i++) {
    if (ans == num.at(i)) {
      cout << i+1 << endl;
    }
  }
}

Measured memory_bytes: 5608
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

void solve(void){

    int N;
    
    cin >> N;
    
 	if(N%2==1){
      cout << N/2+1 << endl;
    }
    else
    {
      cout << N/2 << endl;
    }



  return;
}

int main(int argc, const char * argv[]) {


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
#全ての勇者に対して，どれだけの敵を倒すか決めていく．
for i in range(n):
    if b[i] <= a[i]:
        ans += b[i]
    else:
        ans += a[i]
        b[i] -= a[i]
        if b[i] <= a[i+1]:
            ans += b[i]
            a[i+1] -= b[i]
        else:
            ans += a[i+1]
            a[i+1] = 0

print(ans)


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

int main(void){
    int N;
    cin >> N;
    int house[N];
    for(int i = 0; i < N ; i++){
        cin >> house[i];
    }
    int max = house[0];
    int min = house[0];
    for(int i = 0; i < N ; i++){
        if(max < house[i]) max = house[i];
        if(min > house[i]) min = house[i];
    }
    cout << max - min << endl;
    return 0;
}

Measured memory_bytes: 3136
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int H1=sc.nextInt();
		int M1=sc.nextInt();
		int H2=sc.nextInt();
		int M2=sc.nextInt();
		int K=sc.nextInt();

		System.out.println(H2*60+M2-H1*60-M1-K);

	}
}


Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint H, W, N;
  cin >> H >> W >> N;
  map<pair<int, int>, lint> mp;
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    REP(j, 3) {
      if(a <= 0 || a >= H-1) {
        a--; continue;
      }
      int bb = b;
      REP(k, 3) {
        if(bb <= 0 || bb >= W-1) {
          bb--; continue;
        }
        mp[make_pair(a, bb)]++;
        bb--;
      }
      a--;
    }
  }
  vector<lint> ans(10);
  for(auto itr = mp.begin(); itr != mp.end(); itr = next(itr)) {
    ans[itr->second]++;
  }
  ans[0] = (H-2)*(W-2);
  FOR(i, 1, 10) ans[0] -= ans[i];
  REP(i, 10) cout << ans[i] << "\n";
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

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

bool comp1(pii a, pii b){
	return a.first < b.first;  
}

bool comp2(pii a, pii b){
	return a.second < b.second;  
}


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

	int n;
	cin >> n;

	vector<pii> r;
	rep(i, n){
		int x,y;
		cin >> x >> y;
		r.push_back((pii){x, y});
	}

	vector<pii> b;
	rep(i, n){
		int x,y;
		cin >> x >> y;
		b.push_back((pii){x, y});
	}

	// 青い点のx座標が小さい順にマッチングを考える
	// マッチさせる赤い点はy座標が最も大きいもの
	sort(b.begin(), b.end());
	sort(r.begin(), r.end());

	int ans = 0;
	rep(i, n){
		pii bi = b[i];
		// cout << bi.first << " " << bi.second << endl;

		auto itx = upper_bound(r.begin(), r.end(), bi, comp1);
		if(itx == r.begin()) continue;

		sort(r.begin(), itx, comp2);

		auto ity = upper_bound(r.begin(), itx, bi, comp2);
		if(ity == r.begin()) continue;

		ans++;
		r.erase(ity - 1);

		/*
		rep(i,r.size()) cout << r[i].first << " ";
		cout << endl;
		rep(i,r.size()) cout << r[i].second << " ";
		cout << endl;
		*/
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int num,h,m,s;
	scanf("%d",&num);
	h=num/3600;
	num-=h*3600;
	m=num/60;
	num-=m*60;
	s=num;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>

#define INF 2000001

typedef struct node{
  int key;
  int parent;
  int left;
  int right;
}Node;

Node N[251];



int main() {
  int n,i,j,par,m=0;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&N[i].key);
  }
  for(i=1;i<=n;i++){
    N[i].left =N[2*i].key;
    N[i].right = N[2*i+1].key;
    if(i!=1){
      N[i].parent = N[i/2].key;
    }
  }

  for(i=1;i<=n;i++){
    if(i==1){
      printf("node %d: key = %d, left key = %d, right key = %d, \n",i,N[i].key,N[i].left,N[i].right);
    }
    else if(2*i==n){
      printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,N[i].key,N[i].parent,N[i].left);
    }
    else if(2*i+1<=n){
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,N[i].key,N[i].parent,N[i].left,N[i].right);
    }

      else{
	printf("node %d: key = %d, parent key = %d, \n",i,N[i].key,N[i].parent);

      }
  }

  return 0;
}
	
      
      




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

int main() {
    int n, ans = 0;
    string s; cin >> n >> s;

    for (int i = 0; i < n;) {
        if (s[i] == 'O' && s[i+1] == 'X') {
            ans++;
            i += 2;
        } else if (s[i] == 'X' && s[i+1] == 'O') {
            ans++;
            i += 2;
        } else {
            i++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=998244353;
const int INF=INT_MAX/2;
const int N_MAX=100010;
const double PI=3.14159265359;

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main(){
	ll n, k;
	cin>>n>>k;
	int ans=0;
	while(myPow(k,ans,10000000000)<n){
		ans++;
	}
	if(myPow(k, ans, 10000000000)==n)ans++;
	if(n==1)ans=1;
	cout<<ans<<endl;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i64 a, b, c, k;
  cin >> a >> b >> c >> k;

  i64 na, nb, nc;
  na = min(k, a);
  nb = min(k - na, b);
  nc = k - na - nb;

  cout << na - nc << endl;

  return 0;
}


Measured memory_bytes: 3608
D, G = map(int, input().split())
Ci = [list(map(int, input().split())) for _ in range(D)]


MAX_BIT = (1 << D)
minimum = 1000000000
# 各ビットが1のとき全部解く
for patternBit in range(MAX_BIT):
    if patternBit >= MAX_BIT:
        continue
    p = patternBit
    score = 0
    ans1 = 0
    use_c = None
    for i, c in enumerate(Ci):
        s = (i + 1) * 100 #1問のスコア
        if p % 2 > 0:
            score += s * c[0] + c[1]
            ans1 += c[0]
        else:
            use_c = c + [s]
        p = p // 2
    if score < G:
        remain = G - score
        add_count = remain // use_c[2]
        if remain % use_c[2] > 0:
            add_count += 1
        if add_count > use_c[0]:
            continue
        ans1 += add_count
    minimum = min(minimum, ans1)
    
print(minimum) 

Measured memory_bytes: 3064
ipt = [int(input()) for i in range(5)]

minnum = 1000
minidx = 6
for i, con in enumerate(ipt):
    if con % 10 != 0:
        if minnum > con % 10:
            minnum = con % 10
            minidx = i

print(sum([int((con+9)/10)*10 if i != minidx and con%10 != 0 else con for i,con in enumerate(ipt)]))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

ll get_keta(ll a){
  return to_string(a).size();
  //return 1;
}
int main(int argc, char const *argv[]) {
  ll ans = 10000000000, n;std::cin >> n;
  for(ll i=1;(i*i)<=n;i++){
    if(n%i==0){
      ans = min({ans, max(get_keta(i), get_keta(n/i))});
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384