akhauriyash/Code-Regression huggingface dataset:
// abc171_a
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#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() {
  char c;
  cin >> c;
  if (c >= 'A' && c <= 'Z')
    cout << 'A' << endl;
  else
    cout << 'a' << endl;
  return 0;
}


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

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

	vector<int> d(n);

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


	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += d[i] * d[j];
		} 
	}

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

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define M 1000000007

#define pb push_back
#define fs first
#define se second
using namespace std;
// ll changeI(ll a)
// {
//     ll k=1;
//     ll st=0;
//     while(a)
//     {
//         st=(st%D+((a%10)*(k%D))%D)%D;
//         a/=10;
//         k*=100;
//     }
//     return st;
// }
 
long long powe(ll a, ll p , ll r)
{
    if(p==0)
        return 1;
    else if(p==1)
        return a;
    ll q=powe(a,p/2,r)%r;
    q= ((q%r)*(q%r))%r;
    if(p%2 == 1)
    {
        q = ((q%r)*(a%r))%r;
    }
    return q;
 
}
ll modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        ll q = a / m; 
        ll t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
pair<pair<ll,ll>,ll> maxSubArraySum(vector<ll>a, int size) 
{ 
    ll max_so_far = LLONG_MIN, max_ending_here = 0, 
       start =0, end = 0, s=0; 
    ll p=0;
    for (ll i=0; i< size; i++ ) 
    { 
        max_ending_here += a[i]; 
  
        if (max_so_far < max_ending_here) 
        { 
            max_so_far = max_ending_here; 
            start = s; 
            end = i; 
        } 
  
        if (max_ending_here < 0) 
        { 
            max_ending_here = 0; 
            s = i + 1; 
        } 
    } 
      
    return {{max_so_far,end},(end - start + 1)}; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //  #ifndef ONLINE_JUDGE
    //     freopen("mengawasi_sample_1.in", "r", stdin);
    //     freopen("mengawasi_sample_1.out", "w", stdout);
    // #endif
    ll n;
    cin>>n;
    vector<ll>mons(n+1);
    for(ll i=0;i<=n;i++)
        cin>>mons[i];
    vector<ll>her(n);
    for(ll i=0;i<n;i++)
        cin>>her[i];
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(mons[i]>=her[i])
        {
            ans+=her[i];
            mons[i]-=her[i];
            her[i]=0;
        }
        else
        {
            ans+=mons[i];
            her[i]-=mons[i];
        }
        if(her[i]>0)
        {
            ll t=min(her[i],mons[i+1]);
            ans+=t;
            mons[i+1]-=t;
            her[i]-=t;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	int cnt[200000] = {};
	
	int ans = 0;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		if(num > N){
			ans++;
		}else{
			cnt[num]++;
		}
	}
	
	for(int i = 1; i <= N; i++){
		if(cnt[i] >= i){
			ans += cnt[i] - i;
		}else{
			ans += cnt[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
Ti = [list(map(int, input().split())) for _ in range(N)]

last_x = 0
last_y = 0
last_t = 0
for t in Ti:
    dt = t[0] - last_t
    dx = abs(t[1] - last_x)
    dy = abs(t[2] - last_y)
    d = dx + dy
    if dt < d or dt % 2 != d % 2:
        print("No")
        exit()

    last_t = t[0]
    last_x = t[1]
    last_y = t[2]

print("Yes")

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

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

char str[20];
int dp[20][3];

int solve (int pos, int eq, int len)
{
	if (pos == len)
		return 0;
		
	int &ret = dp[pos][eq];
	
	if (ret == -1)
	{
		int mx = 9;
		
		if (eq)
			mx = str[pos]-'0';
			
		ret = 0;
		for (int i = 0; i <= mx; i += 1)
		{
			ret = max(ret,solve(pos+1,eq && i == mx, len) + i);
		}
	}
	
	return ret;
}

int main (int argc, char const* argv[])
{
	scanf("%s",str);
	
	int len = strlen(str);
	
	memset(dp,-1,sizeof dp);
	printf("%d\n",solve(0,1,len));
		
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
    ll n,i,s=0;
    cin >> n ;
    vector<ll>v(n-1);
    for(auto &it:v)
        cin >> it ;
    if(n==2)
        cout << v[0] + v[0] << "\n";
    else
    {
        for(i=0 ; i <n-2 ; i++)
        {
            s+=min(v[i],v[i+1]);
        }
        s+=v[0];
        s+=v[n-2];
        cout << s << "\n";
    }


}


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

string s;
vector<string> anses;

void dfs(string ans, int sum, int i)
{
    int num = s.at(i) - '0';
    if(ans.length() == 0) sum += num;
    if(ans.back() == '+') sum += num;
    if(ans.back() == '-') sum -= num;
    ans += s.at(i);
    if(i == s.length() - 1)
    {
        ans += "=7";
        if(sum == 7) anses.push_back(ans);
        return;
    }
    // if +
    dfs(ans + '+', sum, i+1);
    // if -
    dfs(ans + '-', sum, i+1);
}

int main()
{
    cin >> s;
    dfs("", 0, 0);
    cout << anses.at(0) << endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    if(n<105) cout<<0<<endl;
    else if(n>=105 && n<135) cout<<1<<endl;
    else if(n>=135 && n<165) cout<<2<<endl;
    else if(n>=165 && n<189) cout<<3<<endl;
    else if(n>=189 && n<195) cout<<4<<endl;
    else cout<<5<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <set>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    set<int> s;

    for (int i = 0; i < N; i++)
    {
        int A;
        if (scanf("%d", &A) < 1) return 0;
        s.insert(A);
    }

    printf("%lu\n", s.size() % 2 ? s.size() : s.size() - 1);
    return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	//long long n, A[1000000000];
	string s;
	cin >> s;
	cin >> a;
	for ( b = 0; b < s.length(); b++)
	{
		cout << s[b] ;

		b += a - 1;
	}

	//cout <<  << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int a[6];
int main()
{
	cin>>n;
	a[1] = n/100;
	a[2]= (n-a[1]*100) /10;
	a[3] = n - a[1]*100 - a[2]*10;
	for(int i=1;i<=3;i++)
	    {
		
		if(a[i]==9) {
		a[i]=1;continue;}
	    if(a[i]==1) a[i]=9;
	    }
	    cout<<a[1]<<a[2]<<a[3]; 
	    return 0;
} 

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    while(true) {
      val h, w = scanner.nextInt
      if((h == 0) && (w == 0)) System.exit(0)

      for(y <- 1 to h) {
        for(x <- 1 to w) {
          print(if(((x + y) % 2) == 0) "#" else ".")
        }
        println()
      }
      println()
    }
  }
}


Measured memory_bytes: 52940
#include<iostream>
#include<vector>
#include<unordered_set>
#include<deque>
using namespace std;

int N, M, K;
vector<vector<int>> friends;
vector<vector<int>> enemies;
vector<unordered_set<int>> clusters;


int main() {
    cin >> N >> M >> K;

    friends.resize(N);
    enemies.resize(N);
    clusters.resize(N);

    //friend
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        friends[a].push_back(b);
        friends[b].push_back(a);
    }

    //enemy
    for (int i = 0; i < K; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        enemies[a].push_back(b);
        enemies[b].push_back(a);
    }

    // bfs 
    vector<int> searched(N);
    deque<int> bfs_q;
    int cluster_id = 0;
    vector<int> cluster_ids(N);

    for (int i = 0; i < N; ++i) {

        // bfs
        if (searched[i] == false) {
            bfs_q.push_back(i);
            cluster_ids[i] = cluster_id;
            clusters[cluster_id].insert(i);

            while (!bfs_q.empty()) {
                int now = bfs_q.front();
                bfs_q.pop_front();

                for (auto itr = friends[now].begin(); itr != friends[now].end(); itr++) {
                    int next = *itr;
                    if (searched[next] == false){
                        bfs_q.push_back(next);
                        cluster_ids[next] = cluster_id;
                        clusters[cluster_id].insert(next);
                    }
                }
                searched[now] = true;
            }
            cluster_id++;
        }  
    }

    //ans
    for (int i = 0; i < N; ++i) {
        int base = clusters[cluster_ids[i]].size();
        int ans = base - (1 + friends[i].size());
        for (auto itr = enemies[i].begin(); itr != enemies[i].end(); itr++) {
            int enemy = *itr;
            if (cluster_ids[i] == cluster_ids[enemy]) ans--;
        }
        cout << ans << endl;
    }

    // // debug clusters
    // for (int i = 0; i < cluster_id; i++){
    //     cout << "id:" << i << endl;
    //     for (auto itr = clusters[i].begin(); itr != clusters[i].end(); itr++){
    //         cout << *itr << " ";
    //     }
    //     cout << endl;
    // }

    return 0;
}

Measured memory_bytes: 22544
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
  	ll X, Y;
  	cin >> X >> Y;
  	for (int x = 0; x <= X; x ++) {
  		if (2 * x + (X - x) * 4 == Y) {
  			cout << "Yes";
  			exit(0);
		  }
	  }
	  cout << "No";
}

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

int main() {
    vector<long long> vec(3);
    for(int i = 0; i < 3; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    
    long long a = vec.at(0);
    long long b = vec.at(1);
    long long c = vec.at(2);
    
    long long result;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        result = 0;
    } else {
        result = (a * b);
    }
    
    cout << result << endl;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    int sum = 0;
    for (auto aa : a)
        sum += aa;
    if(sum<=n)
        cout << n - sum << endl;
        else
            cout << "-1" << endl;

    return 0;
}

Measured memory_bytes: 3640
N,D=map(int, input().split())
X=[list(map(int,input().split())) for i in range(N)]
from itertools import permutations, combinations,combinations_with_replacement,product

def dist(X,Y,D):
  ans = 0
  for i in range(D):
    ans += (X[i]-Y[i])**2
  ans = ans ** 0.5
  return ans

L = combinations(range(N), 2)
cnt = 0
for i in L:
  if (dist(X[i[0]],X[i[1]],D)).is_integer():
    cnt +=1
print(cnt)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int q;cin>>q;
  rep(i,q){
    ll a,b;cin>>a>>b;
    if(a>b)swap(a,b);

    ll result = 2*(a-1);
    ll l=0, r=1<<30, num;
    while(r-l>1){
      num=(l+r)/2;
      if(a+num>b){
        r=num;
        num=(l+r)/2;
        continue;
      }
      bool ng=false;
      for(ll x = num/2-1; x<=num/2+1 ;x++){
        if(x>num || x<=0)continue;
        if((a+x)*(a+num-x)>=a*b){
          ng=true;
        }
      }
      if(ng)r=num;
      else l=num;
      num=(l+r)/2;
//cout<<num<<' '<<l<<' '<<r<<endl;
    }
    cout<<result + num<<endl;
//    cout<<result<<' '<<num<<' '<<result + num<<endl<<endl;

  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n;
    cin >> n;
    ll a[n+1],b[n+1],c[n+1];
    rep(i,1,n+1)cin >> a[i] >> b[i] >> c[i];

    ll dp[n+1][3] = {};
    
    rep(i,1,n+1){
	dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
	dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
	dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
    }

    P(max(max(dp[n][0],dp[n][1]),dp[n][2]));
    return  0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define debug(x) cout<<x<<'\n'
#define pii pair<ll,pair<ll,ll> >
using namespace std;
const int inf = 0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans;
}
ll mul(ll a,ll b){//大数取模乘法防止溢出
    ll ans=0;
    a%=mod,b%=mod;
    while(b) { if(b&1) ans = (ans+a)%mod; a = (a*2)%mod; b >>= 1; }
    return ans;
}
//(b/a)%p=b*a^(p-2)%p
int pr(ll num){//判断素数
     if(num == 1) return 0;
     if(num ==2|| num==3 ) return 1 ;
     if(num %6!= 1&&num %6!= 5) return 0 ;
     int tmp =sqrt( num);
     for(int i= 5;i <=tmp; i+=6 )
          if(num %i== 0||num %(i+ 2)==0 )return 0 ;
     return 1 ;
}
int Day(int y,int m, int d){
    if(m==1||m==2) { m+=12; y--; }
    int w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
    return w+1;
}
inline int read() {
    int c = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        c = c * 10 + ch - '0';
        ch = getchar();
    }
    return c * f;
}

//#pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈
//stable_sort 排序不处理相同元素
//map<int,int>::reverse_iterator rit;
//for(rit=mp.rbegin();rit!=mp.rend();rit++)
//vec动态二维数组
//vector<vector<int>> g(26,vector<int>(100005));
//初始化vec里面套了n个vec

//lower_bound(begin,end,num) 有序数列中返回第一个>=num的数字的地址
//upper_bound( begin,end,num) 返回第一个>num的数字的地址

const int maxn=2e5+5;
ll a[maxn];
int main(){
    ll n;
    cin>>n;
    ll ans=0;
    map<ll,ll> mp,mmp;
    for(ll i=1;i<=n;++i) {
        cin>>a[i];
        mp[a[i]+i]++;
        mmp[i-a[i]]++;
    }
    for(auto i:mp){
        ans+=mmp[i.first]*i.second;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 39332
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

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

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop


def bellman_ford(V, Edges, start):
    dis = {}
    
    for i in range(V): dis[i] = (1 << 30)
    
    dis[start] = 0
    
    for i in range(V):
        for a, b, w in Edges:
            if dis[a] != (1 << 30) and dis[a] + w < dis[b]:
                dis[b] = dis[a] + w
    
    for a, b, w in Edges:
        if dis[a] != (1 << 30) and dis[a] + w < dis[b]:
            return ('NEGATIVE CYCLE', dis)
    
    return ('No NEGATIVE CYCLE', dis)
    
    
if __name__ == '__main__':
    line = sys.stdin.readline()
    V, E, start = line.split()
    V, E, start = int(V), int(E), int(start)
    Es = []
    for i in range(E):
        line = sys.stdin.readline()
        a, b, w = line.split()
        a, b, w = int(a), int(b), int(w)
        Es.append((a,b,w))
        
    judge, dis = bellman_ford(V, Es, start)
    
    if judge == 'NEGATIVE CYCLE':
        sys.stdout.write(judge + '\n')
    else:
        for i in range(V):
            if dis[i] == (1 << 30):
                sys.stdout.write('INF\n')
            else:
                sys.stdout.write(str(dis[i]) + '\n')

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    cin >> N;
    int T[N];
    int sum_time = 0;
    rep(i, N){
        cin >> T[i];
        sum_time += T[i];
    }
    int M;
    cin >> M;
    int P[M], X[M];
    int result[M];
    rep(i, M){
        cin >> P[i] >> X[i];
        int sub = T[P[i]-1] - X[i];
        result[i] = sum_time - sub;
    }
    rep(i, M) cout << result[i] << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine}

object Main {
  def main(args: Array[String]): Unit = {
    val n = readInt()
    val arr = Array.fill(4, 3, 10)(0)
    for (_ <- 1 to n) {
      val Array(b, f, r, v) = readLine().split(" ").map(_.toInt)
      arr(b-1)(f-1)(r-1) += v
    }
    println(arr.map(_.map(_.map(" "+_).mkString).mkString("\n")).mkString(s"\n${"#" * 20}\n"))
  }
}



Measured memory_bytes: 44088
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int N = s.size();
  string ans = "CODEFESTIVAL2016";
  
  int cnt = 0;
  for (int i=0; i<N; i++) {
    if (s[i] != ans[i]) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
class Dice():
	__S1 = 'NNNNENNNNENNNNENNNNrNNNNllNNNN'
	__leng = len(__S1)
	
	def __init__(self, label):
		self.d = label
		
	def __eq__(self, other):
		for j in range(self.__leng):
			if self.pmatch(other):
					return True
					break
			other.roll(self.__S1[j])
		else:
			return False
	
	def __ne__(self, other):
		return not self == other
		
	def pmatch(self, other):
		if (self.d[1] != other.d[1] or self.d[2] != other.d[2] or self.d[3] != other.d[3] or self.d[4] != other.d[4] or self.d[5] != other.d[5] or self.d[6] != other.d[6]):
			return False
		else:
			return True
	
	def roll(self, drt):
		if drt == 'N':
			self.d[1], self.d[2], self.d[6], self.d[5] = self.d[2], self.d[6], self.d[5], self.d[1]
		elif drt == 'E':
			self.d[1], self.d[3], self.d[6], self.d[4] = self.d[4], self.d[1], self.d[3], self.d[6]
		elif drt == 'S':
			self.d[2], self.d[6], self.d[5], self.d[1] = self.d[1], self.d[2], self.d[6], self.d[5]
		elif drt == 'W':
			self.d[4], self.d[1], self.d[3], self.d[6] = self.d[1], self.d[3], self.d[6], self.d[4]
		elif drt == 'r':
			self.d[2], self.d[3], self.d[5], self.d[4] = self.d[4], self.d[2], self.d[3], self.d[5]
		elif drt == 'l':
			self.d[4], self.d[2], self.d[3], self.d[5] = self.d[2], self.d[3], self.d[5], self.d[4]
	
	def printl(self, lct):
		print(self.d[lct])

N = int(input())
a = [0 for i in range(N)]
for i in range(N):
	b = [0]
	b.extend(list(map(int, input().split())))
	a[i] = Dice(b)

for i in range(N):
	for j in range(i+1,N):
		if a[i] == a[j]:
			print("No")
			break
	else:
		continue
	break
else:
	print("Yes")

Measured memory_bytes: 7920
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define float long double
#define pb push_back
using namespace std;
signed main()
{
    fastio;
    int n;
    cin>>n;
    float d;
    cin>>d;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        float dist=sqrt(pow(x,2)+pow(y,2));
        if(dist<=d)
        sum++;
    }      
    cout<<sum;
           
return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
#define SIZE 12
void init_v (vector <vector <bool> >& v )
{
	int size = v.size();
	int i, j;

	for (i = 0; i < size; ++i){
		v[i][0] = true;
		v[i][size - 1] = true;
	} // end for

	for (j = 0; j < size; ++j){
		v[0][j] = true;
		v[size - 1][j] = true;
	} // end for

}
	
void dfs (vector <vector <bool> >& v, vector <vector <int> > m, int row, int col )
{
	const int dir[][2] = { { 0, 1 }, { 1, 0 }, { 0, -1}, { -1, 0 } }; // ツ右ツ可コツ債カツ湘」
	int k;
	
	v[row][col] = true;

	for (k = 0; k < 4; ++k){
		if ( m[ row + dir[k][0] ][ col + dir[k][1] ] == 1 
		&&  !v[ row + dir[k][0] ][ col + dir[k][1] ] ){
			dfs (v, m, row + dir[k][0], col + dir[k][1] );
		} // end if
	} // end for
}

void disp_map (vector <vector <int> > m )
{
	int size = m.size();
	int len  = m[0].size();
	int i, j;

	for (i = 0; i < size; ++i){
		for (j = 0; j < len; ++j){
			cout << setw(2) << m[i][j] << ' ';
		} // end for
		cout << endl;
	} // end for
}

void disp_v (vector <vector <bool> > m )
{
	int size = m.size();
	int len  = m[0].size();
	int i, j;

	for (i = 0; i < size; ++i){
		for (j = 0; j < len; ++j){
			cout << setw(2) << m[i][j] << ' ';
		} // end for
		cout << endl;
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen("testcase.island", "r", stdin);
	string str = "";
	int i = 1, j;
	vector <vector<int> > Map (SIZE + 2, vector <int> (SIZE + 2, 0 ) );

	while (getline (cin, str ) ){
		if (str.empty() ){
//			Map.clear();
			i = 1;
			continue;
		} // end if

		stringstream ss(str);
		ss >> str;
		for (j = 1; j <= SIZE; ++j){
			Map[i][j] = str[j-1] - '0';
		} // end for
		++i;

		if (i <= SIZE){
			continue;
		} // end if

//		cout << "i: " << i << endl;
//		disp_map (Map);

		int res = 0;
		vector <vector<bool> > visit (SIZE + 2, vector<bool> (SIZE + 2, false ) );
		init_v (visit );
		int row, col;

		for (row = 1; row < SIZE + 2; ++row){
			for (col = 1; col < SIZE + 2; ++col){
				if ( Map[row][col] == 1 && !visit[row][col]){
					++res;
					dfs (visit, Map, row , col );
//					disp_v (visit );
//					cout << endl;
				} // end if
				if (!visit[row][col]){
					visit[row][col] = true;
				} // end if
			} // end for
		} // end for
		cout << res << endl;
	} // end loop

//	cout << res << endl;	
		
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 305;

inline void Add(int &x, int y) { x -= (x += y) >= Mod ? Mod : 0; }

int N, Z, A[MN * 2], B[MN * 2], C[MN * 2], D[MN * 2];
int f[MN][MN], g[MN][MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= 2 * N; ++i) {
		scanf("%d", &A[i]);
		if (~i & 1 && ~A[i] && ~A[i - 1]) C[A[i - 1]] = C[A[i]] = 1;
	}
	for (int i = 1; i <= 2 * N; ++i) D[i] = D[i - 1] + !C[i];
	for (int i = 1; i <= 2 * N; ++i) if (~A[i] && !C[A[i]]) B[D[A[i]]] = 1, --Z;
	Z += N = D[2 * N] / 2;
	f[0][0] = 1;
	for (int i = 1; i <= Z; ++i) f[0][0] = (LL)f[0][0] * i % Mod;
	for (int i = 2 * N; i >= 1; --i) {
		for (int j = 0; j <= N; ++j)
			for (int k = 0; k <= N - j; ++k)
				g[j][k] = 0;
		for (int j = 0; j <= N; ++j)
			for (int k = 0; j + k <= N; ++k)
				if (B[i]) {
					if (j) Add(g[j - 1][k], f[j][k]);
					if (j + k < N) Add(g[j][k + 1], f[j][k]);
				} else {
					if (j) Add(g[j - 1][k], f[j][k]);
					if (k) g[j][k - 1] = (g[j][k - 1] + (LL)f[j][k] * k) % Mod;
					if (j + k < N) Add(g[j + 1][k], f[j][k]);
				}
		std::swap(f, g);
	}
	printf("%d\n", f[0][0]);
	return 0;
}

// Luogu : PinkRabbit

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


int main(){
    string s;
    cin>>s;

    cout<< count(s.begin(), s.end(), '1')<<endl;


    return 0;

}

Measured memory_bytes: 256
n = int(input())
s = {('S',str(i)) for i in range(1,14)}
h = {('H',str(i)) for i in range(1,14)}
c = {('C',str(i)) for i in range(1,14)}
d = {('D',str(i)) for i in range(1,14)}

for i in range(n):
    t = tuple(input().split())
    if t[0] == 'S':
        s = s - {t} 
    elif t[0] == 'H':
        h = h - {t}
    elif t[0] == 'C':
        c = c - {t}
    else :
        d = d - {t}

for i in map(list,[s,h,c,d]):
    for j in sorted(i,key=lambda x:int(x[1])):
        print(" ".join(j))
        

Measured memory_bytes: 7760
mod=10**9+7
n,k=map(int,input().split())
ans=(n+1)*( (n+k+1)*(n-k+2)/2 - (n+2)*(2*n+3)/6 )+k*(k-1)*(2*k-1)/6+(n-k+2)
ans=round(ans%mod)
print(ans)

Measured memory_bytes: 79736
n,a = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
dp = Array.new(n+1){ Array.new(n+1){ Array.new(50 * n + 1, 0) } }

dp[0][0][0] = 1
(1 .. n).each do |i|
    dp[i][0][0] = 1
    (1 .. i).each do |j|
        (1 .. 50 * n).each do |k|
            if x[i - 1] <= k
                dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]]
            else
                dp[i][j][k] = dp[i - 1][j][k]
            end
        end
    end
end
puts (1..n).map {|j| dp[n][j][j * a] }.inject(0,&:+)





Measured memory_bytes: 52604
#include <cstdio>
int main() {
	int k, i, num = 1;
	scanf("%d", &k);
	long int a[100005];
	for (i = 1; i < 10; i++)
		a[num++] = i;
	i = 1;
	while (num <= k) {
		if (a[i] % 10 != 0) {
			a[num++] = a[i] * 10 + a[i] % 10 - 1;
		}
		a[num++] = a[i] * 10 + a[i] % 10;
		if (a[i] % 10 != 9) {
			a[num++] = a[i] * 10 + a[i] % 10 + 1;
		}
		i++;
	}
	printf("%ld\n", a[k]);
	return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	cout << s.substr(0, 3);
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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



public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> list = new ArrayList<>();
		String b = "";
		char al = 'A';
		for(int i=0;i<52;i++){
			if(i==26) 
				al = 'a';
			list.add(String.valueOf(al));
			al++;
			
		}
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0)break;
			
			int[] k = new int[n+1];
			for(int i=1;i<=n;i++) {
				k[i] = sc.nextInt();
			}
			String str = sc.next();
			char[] s = str.toCharArray();
			StringBuilder sb = new StringBuilder();
			
			int h = 0;
			while(h<str.length()) {
				for(int i=1;i<=n&&h<str.length();i++) {
					if(list.indexOf(String.valueOf(s[h]))-k[i] < 0) {
						b =list.get(52+(list.indexOf(String.valueOf(s[h]))-k[i]));
					}
					else
						b = list.get(list.indexOf(String.valueOf(s[h]))-k[i]);
					sb.append(b);
					h++;
				}
			}
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 33760
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

class M {
    struct R {
        int from, to;
        int length() {
            return to - from;
        }
        int countUnder(int l) {
            if (l < from) return 0;
            if (l >= to) return to - from;
            return l - from + 1;
        }
    }
    R[] rs;
    this(int from, int to) {
        rs = [R(from, to)];
    }
    int count(int p, int q, int l) {
        int ret = 0;
        split(q);
        auto a = split(p);
        foreach (r; a) {
            ret += r.countUnder(l);
        }
        return ret;
    }
    void shuffle(int x, int y) {
        auto a = split(y);
        auto b = split(x);
        auto c = rs;
        rs = a ~ b ~ c;
    }
    R[] split(int x) {
        R[] ret;
        int i = 0;
        int t = 0;
        R b;
        foreach (r; rs) {
            t += r.length;
            if (t >= x) {
                t -= r.length;
                b = r;
                break;
            }
            i++;
        }
        if (t == x) {
            ret = rs[i .. $];
            rs = rs[0 .. i];
        } else {
            ret ~= R(b.from + x - t, b.to);
            ret ~= rs[i + 1 .. $];
            rs = rs[0 .. i];
            rs ~= R(b.from, b.from + x - t);
        }
        return ret;
    }
}

void main() {
    int n; 
    while (readf("%d\n", &n), n) {
        int m; readf("%d\n", &m);
        int p, q, r; readf("%d %d %d\n", &p, &q, &r);
        M rs = new M(1, n + 1);
        foreach (i; 0 .. m) {
            int x, y; readf("%d %d\n", &x, &y);
            rs.shuffle(x, y);
        }
        rs.count(p - 1, q, r).writeln;
    }
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int h = H1 * 60 + M1;
    int h2 = H2 * 60 + M2;

    int diff = h2 - h - K;

    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int,input().split()))
C = {}
for a in A:
  if a in C:
    C[a] +=1 
  else:
    C[a] = 1
ans = 0
for k,v in C.items():
  if v > k:
    ans += v-k
  elif v < k:
    ans += v
print(ans)


Measured memory_bytes: 67240
#include<bits/stdc++.h>
// use gp_hash_table<int,int,custom_hash> m;
// in place of map
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
// This custom_hash is for unordered_map 
// use map<int, int, custom_hash> mp;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        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);
    }
};
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	ll ans=0;
	if(n%2==0){
		n/=2;
		while(n>0){
			n/=5;
			ans += n;
		}
	}	
	else{
		ll x = (n-1)/2;
		ll n2 = n;
		ll ans1=0;
		while(n>0){
			n/=5;
			ans1 += n;
		}
		// ans1 -= x;
		while(x>0){
			x/=5;
			ans1 -= x;
		}
		x = (n2-1)/2;
		while(n2>0){
			n2/=2;
			ans += n2;
		}
		ans -= x;
		while(x>0){
			x/=2;
			ans -= x;
		}
		// cout<<ans<<ans1;
		ans = min(ans,ans1);
	}
	cout<<ans;
	return 0;
}

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

typedef long long ll;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

void DP_82(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<((n/(a+b))*a)+min(n%(a+b),a);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    DP_82();
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}

	public int[] month = new int[]{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while((line = in.readLine()) != null){
			String[] tmp = line.split(" ");
			int y1 = Integer.parseInt(tmp[0]);
			int m1 = Integer.parseInt(tmp[1]);
			int d1 = Integer.parseInt(tmp[2]);
			int y2 = Integer.parseInt(tmp[3]);
			int m2 = Integer.parseInt(tmp[4]);
			int d2 = Integer.parseInt(tmp[5]);

			if(y1<0 || m1<0 || d1<0 || y2<0 || m2<0 || d2<0){
				break;
			}

			int n1 = date_to_num(y1, m1, d1);
			int n2 = date_to_num(y2, m2, d2);
			System.out.println(n2 - n1);
		}
	}

	public int date_to_num(int y, int m, int d){
		int yy = y-1;
		int n = yy*365;
		for(int i=0; i<m-1; i++){
			n += month[i];
		}
		n += d;
		n += yy/4 - yy/100 + yy/400;
		if(m>=3 && ((y%4==0 && y%100!=0) || y%400==0)){
			n++;
		}

		return n;
	}
}

Measured memory_bytes: 9308
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,a,m,b,mm,t;
    string s;
    cin>>a>>m>>b>>mm>>t;
    a=a*60+m;
    b=b*60+mm;
    cout<<max(0LL,abs(b-a)-t)<<endl;



    return 0;
}





Measured memory_bytes: 3596
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

ans' :: UVector Int -> Int -> Int -> Int
ans' as acc next
	| UVector.null as = acc
	| a == next       = ans' as' acc (next + 1)
	| otherwise       = ans' as' (acc + 1) next
	where
		a   = UVector.head as
		as' = UVector.tail as

ans :: Int -> UVector Int -> Int
ans n as = if a == n then (-1) else a
	where a = ans' as 0 1

main :: IO ()
main = do
	n <- readLn
	as <- readIntToUVectorN n <$> BS.getLine
	print $ ans n as


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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a + b < c + d) cout << "Right" << endl;
	else if(a + b == c + d) cout << "Balanced" << endl;
	else cout << "Left" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define MOD 998244353
//#define MAXX 999999900000

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  string s, t;
  cin >> s >> t;
  s += s;
  if(s.find(t) != string::npos) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
#define MAXN 100010
ll par[MAXN]; // 親
ll deep[MAXN]; // 深さ
vector<ll> lo(MAXN,1);

// in要素で初期化
void init(ll in){
  for(int i=0;i<in;i++){
    par[i]=i;
    deep[i]=0;
  }
}

// 木の根を求める
ll find(ll x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

// xとyの集合を併合
void unite(ll x,ll y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(deep[x]<deep[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(deep[x]==deep[y]) deep[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool same(ll x,ll y){
  return find(x)==find(y);
}
int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll> r(m),s(m);
  for(int i=0;i<m;i++){
    cin>>r[i]>>s[i];
    r[i]--,s[i]--;
  }
  reverse(r.begin(),r.end());
  reverse(s.begin(),s.end());
  vector<ll> d(m);
  d[0]=n*(n-1)/2;
  init(n);
  for(int i=0;i<m-1;i++){
    if(same(r[i],s[i])){
      d[i+1]=d[i];
    }else{
      d[i+1]=d[i]-lo[find(r[i])]*lo[find(s[i])];
      ll e=lo[find(r[i])],f=lo[find(s[i])];
      unite(r[i],s[i]);
      lo[find(r[i])]=e+f;
    }
  }
  reverse(d.begin(),d.end());
  for(int i=0;i<m;i++){
    cout<<d[i]<<endl;
  }
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    for(int i = 0; i < H; ++i)  cin >> s[i];
    vector<vector<int>> C(H, vector<int>(W));
    for(int i = H - 1; i >= 0; --i){
        for(int j = 0; j < W; ++j){
            C[i][j] = s[H - i - 1][W - j - 1] - '0';
        }
    }

    auto update = [&](vector<vector<int>>& v){
        vector<int> idx(W, 0);
        for(int i = 0; i < H; ++i){
            for(int j = 0; j < W; ++j){
                if(v[i][j]){
                    if(idx[j] == i) ++idx[j];
                    else{
                        v[idx[j]++][j] = v[i][j];
                        v[i][j] = 0;
                    }
                }
            }
        }
        return;
    };

    int ans = 0;
    for(int x = 0; x < H; ++x){
        for(int y = 0; y < W; ++y){
            vector<vector<int>> Board = C;
            Board[x][y] = 0;
            update(Board);

            bool IsFinished = false;
            int Score = 0, Base = 1;
            while(!IsFinished){
                IsFinished = true;
                int Sum = 0;
                for(int i = 0; i < H; ++i){
                    for(int j = 0; j < W;){
                        int len = 1;
                        for(int k = j + 1; k < W; ++k){
                            if(Board[i][k] == Board[i][j])  ++len;
                            else    break;
                        }
                        if(Board[i][j] == 0){
                            j += len;
                            continue;
                        }
                        if(len >= K){
                            IsFinished = false;
                            Sum += Board[i][j] * len;
                            for(int k = 0; k < len; ++k)    Board[i][j + k] = 0;
                        }
                        j += len;
                    }
                }

                if(!IsFinished){
                    Score += Base * Sum;
                    update(Board);
                    Base <<= 1;
                }
            }
            
            chmax(ans, Score);
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 3676