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

struct Edge {
	int to;

	int64_t cost;
	int64_t capacity;
	int rev_i;
};

using EdgeVec = std::vector<Edge>;
using EdgeLists = std::vector<EdgeVec>;

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここからコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////


///////////////
// 最小費用流 //
///////////////

class MinCostFlow {
private:
	const int64_t inf_{LLONG_MAX};

	EdgeLists edges;
	const int source_, sink_;

public:
	MinCostFlow(const int node_num, const int source, const int sink)
		: edges(node_num), source_(source), sink_(sink) {}
	
	void addEdge(const int from, const int to, const int64_t cost, const int capacity)
	{
		edges[from].push_back({to, cost, capacity, (int)edges[to].size()});
		edges[to].push_back({from, -cost, 0, (int)edges[from].size() - 1});
	}

	int64_t operator()(const int64_t flow)
	{
		int64_t min_cost{};
		for (int64_t flow_rest{flow}; flow_rest > 0;)
		{
			std::vector<int64_t> distance(edges.size(), inf_);
			distance[source_] = 0;
			std::vector<int> revEdges(edges.size());
			std::queue<std::pair<int, int64_t>> que;
			que.push({source_, 0});
			while (!que.empty())
			{
				auto now{que.front()};
				que.pop();
				if (now.second > distance[now.first]) continue;
				for (Edge& edge: edges[now.first])
					if (edge.capacity > 0 && distance[now.first] + edge.cost < distance[edge.to])
					{
						distance[edge.to] = distance[now.first] + edge.cost;
						que.push({edge.to, distance[edge.to]});
						revEdges[edge.to] = edge.rev_i;
					}
			}
			if (distance[sink_] == inf_) return inf_;
			int64_t additional_flow{flow_rest};
			for (int index{sink_}; index != source_; index = edges[index][revEdges[index]].to)
			{
				Edge& revEdge{edges[index][revEdges[index]]};
				additional_flow = std::min(additional_flow, edges[revEdge.to][revEdge.rev_i].capacity);
			}
			for (int index{sink_}; index != source_; index = edges[index][revEdges[index]].to)
			{
				Edge& revEdge{edges[index][revEdges[index]]};
				edges[revEdge.to][revEdge.rev_i].capacity -= additional_flow;
				revEdge.capacity += additional_flow;
			}
			flow_rest -= additional_flow;
			min_cost += additional_flow * distance[sink_];
		}
		return min_cost;
	}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// ここまでコピペ ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp
int main()
{
	int V, E;
	int64_t F;
	scanf("%d%d%lld", &V, &E, &F);
	MinCostFlow minCostFlow(V, 0, V - 1);
	for (int e_i{}; e_i < E; e_i++)
	{
		int u, v;
		int64_t c, d;
		scanf("%d%d%lld%lld", &u, &v, &c, &d);
		minCostFlow.addEdge(u, v, d, c);
	}
	int64_t cost{minCostFlow(F)};
	if (cost == LLONG_MAX) puts("-1");
	else printf("%lld\n", cost);

	return 0;
}


Measured memory_bytes: 3384
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=5e5+5;
int mod=1e9+7;

ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}


int main()
{
    FIO
    int n;
    cin>>n;
    int co=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(x!=i)
        co++;
    }
    if(co<=2)
        cout<<"YES";
    else
        cout<<"NO";



    return 0;
}



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

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  if (N == 1 || N == 2) {
    cout << ans << endl;
    return 0;
  }
  ll sqrt_n = sqrt(N);
  for (int i = 1; i <= sqrt_n; i++) {
    if (N % i == 0) {
      ll small_divisor = i;
      ll big_divisor = (ll)(N / i);
      // cout << "i : " << i << ", s : " << small_divisor << ", b : " << big_divisor << endl;
      if (big_divisor - small_divisor > 1) ans += (big_divisor - 1);
    }
  }

  cout << ans << endl;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



char maze[25][25];
int N, M;
int sx, sy;//start
int gx, gy;//goal

int d[100][100];//各pointまでの最短距離

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


int bfs(){
    queue<i_i> que;
    rep(i,N) rep(j,M) d[i][j] = INF;//初期化
    que.push(i_i(sx,sy));  //que->start
    d[sx][sy] = 0; //startは距離0

    //queが空になるまでloop
    while(que.size()){
        //queの先頭を取りだす
        i_i p = que.front(); que.pop();
        //getがgoalならend
        if(p.fs == gx and p.sc == gy) break;

        rep(i,4) {
            int nx = p.fs + dx[i];
            int ny = p.sc + dy[i];
            if(0 <= nx and nx < N and 0 <= ny and ny < M){
                if(maze[nx][ny] == '#') continue;
                if(d[nx][ny] != INF) continue;

                //それ以外なら移動可能
                que.push(i_i(nx,ny));
                d[nx][ny] = d[p.fs][p.sc] + 1;
            }
        } 
    }
    return d[gx][gy];
}

//AGC033A

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

    cin >> N >> M;
    rep(i,N) rep(j,M) {
        cin >> maze[i][j];
    }
	int ans = 0;
	rep(i,N) rep(j,M) {
		if(maze[i][j] == '.') {
			sx = i;
			sy = j;
			rep(k,N) rep(l,M) {
				if(maze[k][l] == '.') {
					gx = k;
					gy = l;
					chmax(ans, bfs());
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<int,int> mp;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto& x:mp){
        if(x.second>=x.first) ans += x.second-x.first;
        else ans += x.second;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4736
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
    double a, b, x; cin >> a >> b >> x;
    double p, theta;
    if(x*2 < a*a*b){
        p = 2*x/(a*b);
        theta = atan(b/p);
    }else{
        p = 2*(b - (x/(a*a)));
        theta = atan(p/a);
    }
    const double pi = acos(-1);
    cout << fixed << setprecision(10) << 180 * theta / pi << endl;
    return 0;
}

Measured memory_bytes: 4048
using System;

public class Hello
{
    public static int MOD = 1000000007;
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var s = Console.ReadLine().Trim();
        line = s.Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var count = 0;
        for (int i = 0; i < n - 1; i++)
            for (int j = i + 1; j < n; j++)
                if (a[i] > a[j]) count++;
        line = (s + " " + s).Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        var count2 = 0;
        for (int i = 0; i < n; i++)
            for (int j = n; j < 2 * n; j++)
                if (b[i] > b[j]) count2++;
        var ans = count * (long)k % MOD;
        var ans2 = count2 * (long)k % MOD;
        ans2 *= k - 1;
        ans2 %= MOD;
        var Inv2 = getInv(2, MOD);
        ans2 = ans2 * Inv2 % MOD;
        ans += ans2;
        ans %= MOD;
        Console.WriteLine(ans);
    }
    public static long getInv(int a, int m)
    {
        var x = 0L; var y = 1L; var gcd = (long)m;
        var px = 1L; var py = 0L; var pgcd = (long)a;
        var temp = 0L;

        while (gcd > 0)
        {
            var quotient = pgcd / gcd;

            temp = x;
            x = px - quotient * temp;
            px = temp;

            temp = y;
            y = py - quotient * temp;
            py = temp;

            temp = gcd;
            gcd = pgcd - quotient * temp;
            pgcd = temp;
        }

        return px < 0 ? px + m : px;
    }

}

Measured memory_bytes: 13236
#include<bits/stdc++.h>
#define db(x) cout<<#x<<"="<<x<<endl;
using namespace std;
int n,d,ans;
int x[11][11];
int main() {
	scanf("%d%d",&n,&d);
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=d; j++)scanf("%d",&x[i][j]);
		for(int j=1;j<i;j++){
			int sum=0;
			for(int k=1;k<=d;k++)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			int s=sqrt(sum);
			if(s*s==sum)ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc090_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int A, B;
  cin >> A >> B;

  ll ans = 0;
  repi(i, A, B + 1) { string s = to_string(i);
    if (s[0] == s[4] && s[1] == s[3]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

const int MAX_H = 100;
const int MAX_W = 100;

//输入
int H, W;
char g[MAX_H][MAX_W + 1];

int d[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};        //方向

//深度优先遍历g[i][j]同类局域
void dfs(int x, int y, int c){
    for(int i = 0; i < 4; i ++){
        int nx = x + d[i][0], ny = y + d[i][1];
        if(0 <= nx && nx < H && 0 <= ny && ny < W && g[nx][ny] == c){
            g[nx][ny] = '1';
            dfs(nx, ny, c);
        }
    }
}

void solve(){
    //遍历果园，每到一个新位置，遍历该位置能到达的地方
    int ans = 0;
    for(int i = 0; i < H; i ++){
        for(int j = 0; j < W; j ++){
            if(g[i][j] != '1'){
                ans ++;
                char c = g[i][j];
                g[i][j] = '1';
                dfs(i, j, c);
            }
        }
    }
    printf("%d\n", ans);
}

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

    while(scanf("%d %d", &H, &W)){
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i ++){
            scanf("%s", g[i]);
        }
        solve();
    }

    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}

int n,m,q;
int a[55],b[55],c[55],d[55];

int ans = 0;
void dfs(vector<int>& v, int p, int ma){
    if(p!=n)for(int i=ma;i<=m;i++){
        v[p] = i;
        dfs(v,p+1,i);
    }
    else{
        int ret = 0;
        for(int i=0;i<q;i++){
            if(v[b[i]]-v[a[i]] == c[i])ret+=d[i];
        }
        chmax(ans,ret);
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--,b[i]--;
    }
    vector<int> v(n);
    dfs(v,0,1);
    cout << ans << endl;
}

Measured memory_bytes: 3656
#!python3.4.3

n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
# a_list.sort()

b = [abs(i) for i in range(-n+1, n, 2)]
b.sort()
if a==b:
    result = 2**(n//2)%(10**9+7)
else:
    result = 0
print(result)



Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(max(a,b)>c&&min(a,b)<c) cout << "Yes" << endl;
    else cout << "No" << endl;
}
   


Measured memory_bytes: 3608
n,y=map(int,input().split())
flag=False
for a in range(n+1):
    for b in range(n-a+1):
        if y-10000*a-5000*b==1000*(n-a-b) and n-a-b>=0:
            print(a,b,n-b-a)
            flag=True
            break
    if flag: break
if flag==False: print("-1 -1 -1")

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b, c;
  cin >> a >> b >> c;
  if(a == '7' || b == '7'){
    cout << "Yes" << endl;
  }
  else if(c == '7'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll k=in(),x=in();
    for(ll i=x-(k-1);i<=x+(k-1);++i){
        if(i!=x-(k-1))cout<<' ';
        cout<<i;
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* nichijou */
template<class T,class U>
bool cmax(T & a, const U & b) {return a < b ? a = b, 1 : 0;}
template<class T,class U>
bool cmin(T & a, const U & b) {return b < a ? a = b, 1 : 0;}
/* data type */
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second
/* STL container */
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back
/* I gave you my heart and then you turned around. */
void _BG(const char * s) {cerr<<s<<endl;}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
    for (size_t c = 0; *s && (c || *s != ','); cerr << *s++)
        c += count(ALL("([{"),*s) - count(ALL(")]}"),*s);
    cerr << " = " << a;
    if (*s) {
        cerr << ", ";
        ++s;
    }
    _BG(s,b...);
}
#ifdef PR3PONY
#define BG(...) do { \
    cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
    _BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)
#else
#define BG(...)
#endif
/* Good Luck && Have Fun ! */
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll T;
    cin >> n >> T;
    vector<pll> p;
    vector<ll> vs = {0};
    for (int i = 0; i < n; ++i) {
        pll a;
        cin >> a.F >> a.S;
        if (a.F == 0)
            vs.push_back(a.S + 1);
        else
            p.push_back(a);
    }
    sort(ALL(p), [] (pll a, pll c) {
        ll d = c.F * (a.S + 1) - a.F * (c.S + 1);
        if (d) return d < 0;
        return a < c;
    });
    sort(ALL(vs));
    for (int i = 1; i < vs.size(); ++i)
        vs[i] += vs[i - 1];
    n = p.size();
//    for (int i = 0; i < n; ++i) BG(i, p[i].F, p[i].S, p[i].F / (p[i].S + 1.));
    auto f = [] (pll a, ll x) {return (x + 1) * (a.F + 1) + a.S;};
    vector<ll> dp = {0};
    for (auto a : p) {
        dp.push_back(T + 1);
        for (int i = dp.size() - 2; i >= 0; --i)
            cmin(dp[i + 1], f(a, dp[i]));
        if (dp.back() > T)
            dp.pop_back();
    }
    int ans = 0;
    for (int i = 0; i < dp.size(); ++i)
        ans = max(ans, (int)(upper_bound(ALL(vs), T - dp[i]) - begin(vs)) - 1 + i);
    cout << ans << endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int t; cin >> t; 
    string s = "aaaabaaaaa";
    map<string,int> hash;
    while(t--) {
        char a[10];
        forn(10) {
            cin >> a[i];
        }
        sort(a, a + 10);
        for(int i = 0; i < 10; i++) {
            s[i] = a[i];
        }
        hash[s]++;
    }   
    ll res = 0;
    It(hash) {
        if(it->second != 1) {
            int n = it->second - 1;
            res += (n + pow(n,  2)) / 2;
        }
    }   
    cout << res;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	long N;
	cin >> N;
	long ans = 0;
	for(long i=1;i * i < N - i;i++){
		if(!((N - i) % i)) ans += (N - i) / i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,Q; cin>>N>>Q;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    if(N%2) A.emplace_back(-INF),++N;
    sort(ALL(A),greater<ll>());
    ll mae[N/2+1]={};
    ll usiro[N/2+1]={};
    ll kei[N/2+1]={};
    reps(i,1,N/2+1){
        mae[i]=mae[i-1]+A[i-1];
        usiro[i]=usiro[i-1]+A[N-2*i];
    }
    rep(i,N/2+1){
        kei[i]=mae[i]+usiro[N/2-i];
    }

    rep(i,Q){
        ll x; cin>>x;
        /*bis*/ ll low= 0 , high= N/2+1 ; // min-1, max+1
        while( abs(high-low)>1 ){ ll mid=(high+low)/2;
            bool ok=true;
            ll r=A[mid-1];
            if(r<=x) ok=false;
            r=x+x-r;
            if(A[2*mid-2]<r) ok=false;
            ( ok ? low : high ) = mid;
        }// if ok, okdir = mid
        cout<< kei[low] <<"\n";
    }

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int H,W;
vector <string > A;



int main()
{

	cin >> H >> W;

	A.resize(H);
	REP(i,H){
		cin >> A[i];
	}

	REP(i,H-1){
		REP(j,W-1){
			if(A[i+1][j] == '#' && A[i][j+1] == '#') {
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	cout << "Possible" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
	
	string a;

	cin>>a;

	if(sz(a)%2)return cout<<"No\n",0;

	string maybe = "";

	for(int i=0;i<sz(a)/2;i++)maybe+="hi";

	if(a==maybe)cout<<"Yes\n";
	else	cout<<"No\n";
}		


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 300005;

#define lsb(x) (x&(-x))

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

ll n;
ll b[NMAX];
// the aib is 1 indexed

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

    ll d,a;
    cin >> n >> d >> a;

    vector<pair<ll,ll> > monsters;

    for(int i =0; i < n; ++i)
    {
		ll x, h;
		cin >> x >> h;
		h = (h + a - 1) / a;
		monsters.emplace_back(x,h);
	}

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

	// segment tree or BIT to hold the health of the monsters
	// want to use smenul lui mars pt aib 

	ll ans = 0;
    ll currHp = 0;
    ll running_sum = 0;
    for(int i =0 ; i < n; ++i)
	{
		// prefix sum (0,i) din b care da elementul i
        running_sum += b[i];
        currHp = monsters[i].second - running_sum;

		if(currHp <= 0)
			continue;

		ll low = i, high = n - 1;
		ll ok = -1;

		while(low <= high)
		{
			ll mid = (low + high) / 2;
			// find the last monster still hit by a bomb starting from monster[i] location
			if(monsters[mid].first <= monsters[i].first + 2LL * d)
			{
				ok = mid;
				low = mid+1;
			}
			else
			{
				high = mid-1;
			}
		}
	
        running_sum += currHp;
		b[ok+1] -= currHp;

		ans+=currHp;
	}
	cout << ans;

    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
long long int getMax(long long int a,long long int b){
    if(a>=b)    return a;
    else        return b;
}
int main(){
long long int n,sumA=0,sumC=0,tempSumA,tempSumC,maxDif=std::numeric_limits<long long int>::min();        std::cin>>n;
n = n*3;
std::vector<long long int> arr(n);
for(long long int i=0;i<n;i++)  std::cin>>arr[i];
std::vector<long long int> a(arr.begin(),arr.begin()+n/3),b(arr.begin()+n/3,arr.begin()+2*n/3),c(arr.end()-n/3,arr.end());
for(long long int i=0;i<a.size();i++)   sumA += a[i];
for(long long int i=0;i<c.size();i++)   sumC += c[i];
std::multiset<long long int> A(a.begin(),a.end()),C(c.begin(),c.end());
std::multiset<long long int>::iterator it;
std::vector< std::pair<long long int,long long int> > D(b.size(),std::pair<long long int,long long int>(0,0));
tempSumA = sumA;
tempSumC = sumC;
for(long long int i=0;i<b.size();i++){
    if(*A.begin()<b[i]){
        tempSumA = tempSumA + b[i] - *A.begin();
        A.erase(A.begin());
        A.insert(b[i]);
    }
    D[i].first = tempSumA;
}
for(long long int i=b.size()-1;i>=0;i--){
    if(*C.rbegin()>b[i]){
        tempSumC = tempSumC - (*C.rbegin() - b[i]);
        it = C.end();
        it--;
        C.erase(it);
        C.insert(b[i]);
    }
    D[i].second = tempSumC;
}
for(long long int i=0;i<D.size()-1;i++){
    maxDif = getMax(maxDif,D[i].first-D[i+1].second);
}
maxDif = getMax(maxDif,sumA-D[0].second);
maxDif = getMax(maxDif,D.back().first-sumC);
std::cout<<maxDif<<"\n";
return 0;
}


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

int main(){
    int i,n;
    cin >> n;
    vector<tuple<string,int,int>> sp;
    for(i=0;i<n;i++){
        string a;
        int b,c;
        cin >> a >> b;
        b=200-b;
        c=i+1;
        sp.push_back(make_tuple(a,b,c));
    }
    sort(sp.begin(),sp.end());
    for(i=0;i<n;i++){
        cout << get<2>(sp[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int a, b; std::cin >> a >> b;
  if (a <= b) {
    for (int i = 0; i < b; ++i) std::cout << a;
  } else {
    for (int i = 0; i < a; ++i) std::cout << b;
  }
  std::cout << std::endl;
}


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

int main() {
  //ﾐ〝
  string s;
  cin >> s;
  bool ans=true;
  s.pop_back();
  int n=s.length()/2;
  int anum;
  for(int i=n;i>0 && ans;i--){
    for(int j=0;j<n;j++){
      if(s[j]!=s[j+i])break;
      if(j==i-1){
        ans=false;
        anum=2*i;
      }
    }
  }
  cout << anum;
}



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

int main() {
	int K,S;
	cin >> K>>S;
	
	int ans=0;
	for(int X=0; X<=K; X++){
	for(int Y=0; Y<=K; Y++){
		if(X+Y<=S && X+Y+K>=S){
			ans++;
		}
	}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
flag = False
for i in range(int(y/10000)+1):
    for j in range(int((y-i*10000)/5000)+1):
        k = n - i - j
        if i*10000 + j*5000 + k*1000 == y:
            print(i, j, k)
            flag = True
            break
    if flag:
        break
if not flag:
    print(-1, -1, -1)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string N;
    cin >> N;
    char a = N.at(0);
    char b = N.at(1);
    char c = N.at(2);
    if(a == '7'){
      cout << "Yes" << endl;
    }
    else if(b == '7'){
      cout << "Yes" << endl;
    }
    else if(c == '7'){
      cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for (i64 i = 0; i < H; i++)
    cin >> S[i];
  i64 ans = (H - 1) * (W - 1);
  bool cc = false;
  for (i64 i = 0; i < (1 << (H - 1)); i++)
  {
    i64 t = 0;
    for (i64 j = 0; j < (H - 1); j++)
      if (i & (1 << j))
        t++;
    i64 tmp = t;
    vector<i64> cnt(t + 1);
    for (i64 j = 0; j < W; j++)
    {
    con:;
      i64 tt = 0;
      for (i64 k = 0; k < H; k++)
      {
        if (S[k][j] == '1')
          cnt[tt]++;
        if (i & (1 << k))
          tt++;
      }
      for (i64 k : cnt)
        if (K < k)
        {
          tmp++;
          cnt = vector<i64>(t + 1);
          if (cc)
            goto en;
          cc = true;
          goto con;
        }
      cc = false;
    }
    ans = min(ans, tmp);
  en:;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//ABC104B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	if(s.at(0) != 'A'){
		cout << "WA" << endl;
		return 0;
	}
	int a = 0, b = 0;
	if(s.size() == 4){
		if(s.at(0) == 'A'){
			if('a' <= s.at(1) && s.at(1) <= 'z'){
				if(s.at(2) == 'C'){
					if('a' <= s.at(3) && s.at(3) <= 'z'){
						cout << "AC" << endl;
						return 0;
					}
				}
			}
		}
		cout << "WA" << endl;
		return 0;
	}else{
		for(int i=2;i<s.size()-1;i++){
		if(s.at(i) == 'C'){
			a++;
		}else if('a' <= s.at(i) && s.at(i) <= 'z'){
			b++;
		}
	}
	if(a == 1 && b == s.size()-4){
		if('a' <= s.at(1) && s.at(1) <= 'z'){
			if('a' <= s.at(s.size()-1) && s.at(s.size()-1) <= 'z'){
			cout << "AC" << endl;
			return 0;
			}
		}
	}
	cout << "WA" << endl;
	return 0;
	}
}

Measured memory_bytes: 256
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, 
                  tree_order_statistics_node_update> ordered_set;

//ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

#define PR(x) cout<<#x<<": "<<x<<"\n";
#define PR1(x,y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"  |  "<<#z<<": "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007


const int N=2e5+99;

ll count(ll A, ll B, ll M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
    return (B / M) - (A / M); 
}

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

    vector<pii> v(n);

    fr(n) cin>>v[i].S>>v[i].F;

    sort(all(v));
    ll ta=0;
    int tk=1;

    fr(n)
    {
        if(ta+v[i].S<=v[i].F) ta+=v[i].S;
        else
        {
            tk=0;
            break;
        }
    }

    if(tk) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;  

}




 


Measured memory_bytes: 1792
a = [int(input()) for i in range(5)]

b = (a[0]-1)%10

for i in range(5):
    if (a[i]-1)%10 < b:
        b=(a[i]-1)%10

b += 1

for i in range(5):
    if a[i]%10!=0:
        a[i]=((a[i]+10)//10)*10

print(sum(a)+b-10)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int[] a=new int[2];
		for(int i=0;i<3;i++) {
			if(s.substring(i, i+1).equals("A"))a[0]++;
			if(s.substring(i, i+1).equals("B"))a[1]++;
		}
		if(a[0]!=0&&a[1]!=0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define LL  long long
#define pii pair<int, int>


int main(){
    int n; cin>>n;
    vector<int> v;
    for(int i = 1; i <= 2*n; i++){
        int x; cin>>x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    int res = 0;
    for(int i = 0; i < (2*n)-1; i += 2){
        res += min(v[i], v[i+1]);
    }

    cout<<res<<'\n';
}




Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[n][m];
        int[] b = new int[m];
        int[] c = new int[n];

        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                a[i][j] = sc.nextInt();
            }
        }
        for(int i=0;i<m;i++){
            b[i] = sc.nextInt();
        }

        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                c[i] +=a[i][j]*b[j];
            }
            System.out.println(c[i]);
        }
        sc.close();
    }    
}


Measured memory_bytes: 40276
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll R, G, B, N;
ll ans;

int main()
{
  std::cin >> R >> G >> B >> N;

  rep( r, (N+R-1)/R+1 ) rep( g, (N+G-1)/G+1 )
  {
    ll rest = N-(r*R+g*G);

    if( rest >= 0 && rest % B == 0 )
    {
      ++ans;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<ll,ll>;
 
int n, t, a, b, e[2], ans;
long long dp[35], ac, INF = 1e9+7;
P s[2][200005];
 
int main(){
	scanf("%d%d", &n, &t); t++;
	rep(i,n){
		scanf("%d%d", &a, &b);
		s[!a][e[!a]++] = {a+1,b+1};
	}
	sort(s[0], s[0]+e[0], [](P &a, P &b){
		return a.second * (b.first-1) < b.second * (a.first-1);
	});// a.second * (b.first-1) < b.second * (a.first -1)
	sort(s[1], s[1]+e[1]);
	fill(dp,dp+30, INF);
	dp[0] = 1;
	rep(i,e[0]) for(int j=29; j>0; j--){
		dp[j] = min(dp[j], dp[j-1] * s[0][i].first + s[0][i].second);
	}
	rep(i,e[1]+1){
		ans = max(ans,(int)(i+upper_bound(dp, dp+30, t-ac)-dp-1));
		if(i<e[1]){
			ac += s[1][i].second;
			if(t <= ac) break;
		}
	}
	printf("%d\n", ans);
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int degree[1010];

int main(void){
	int a,b;
	while(cin >> a >> b){
		if(cin.eof())
			break;
		if(a==0&&b==0){
			bool ok=true;
			
			for(int i=1;i<=2;++i)
				if(degree[i]%2==0)
					ok=false;
			for(int i=3;i<=100;++i)
				if(degree[i]%2==1)
					ok=false;
			if(ok)
				cout << "OK" << endl;
			else
				cout << "NG" << endl;
			for(int i=1;i<=100;++i) degree[i]=0;
		}else{
			degree[a]++;
			degree[b]++;			
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.length(); i++) {
    if (t[i] == '?')
      t[i] = 'D';
  }
  cout << t << endl;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int h1, h2, m1, m2, k;

  cin >> h1 >> m1 >> h2 >> m2 >> k;

  cout << (60 * h2 + m2) - k - (60 * h1 + m1) << endl;

  return 0;
}


Measured memory_bytes: 3636
import numpy as np
n,d=map(int,input().split())
v=[]
for i in range(n):
  v.append(np.array(list(map(int,input().split()))))
  
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    dist=np.linalg.norm(v[i]-v[j], ord = 2)
    if int(dist) == dist:
      ans += 1

print(ans)

Measured memory_bytes: 12472
#include <stdio.h>

int main(void)
{
	char mark;
	int cards[4][13];
	int M,No,quant,number;
	
	for (M = 0; M < 4; M++) {
		for (number = 0; number < 13; number++) {
			cards[M][number] = 0;
		}
	}
	
	scanf("%d",&quant);
	
	for (M = 0; M < quant; M++) {
		scanf ("%s %d",&mark,&No);
	
		if (mark == 'S') {
			cards[0][No-1] = 1;
		}
		if (mark == 'H') {
			cards[1][No-1] = 1;
		}
		if (mark == 'C') {
			cards[2][No-1] = 1;
		}
		if (mark == 'D') {
			cards[3][No-1] = 1;
		}
	}
	
	for (M = 0; M < 4; M++) {
		for (number = 0; number < 13; number++) {
			if (cards[M][number] == 0) {
				if (M == 0) {
					printf ("S %d\n",number + 1);
				}
				if (M == 1) {
					printf ("H %d\n",number + 1);
				}
				if (M == 2) {
					printf ("C %d\n",number + 1);
				}
				if (M == 3) {
					printf ("D %d\n",number + 1);
				}
			}
		}
	}
	
	return 0;
}

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

int main()
{
	int N, grid[2][100], x(0), y(0), tempMax, max(0), i, j;
	cin >> N;

	for (i = 0; i < 2; i++)
		for (j = 0; j < N; j++)
			cin >> grid[i][j];

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

		for (j = 0; j <= i; j++)
			tempMax += grid[0][j];

		for (j = i; j < N; j++)
			tempMax += grid[1][j];

		max = (tempMax > max) ? tempMax : max;
	}

	cout << max << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(((W - r) >= x) && (r <= x) && ((H - r) >= y) && (r <= y)){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;

}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll res,A,B,fact[100002],MOD=1000000000+7;
  fact[0] = 1;
  REP(i,100001){
    fact[i+1] = ((i+1)*fact[i]) % MOD;
  }
  cin >> A >> B;
  if(abs(A-B) > 1){
    cout << 0 << endl;
  }else{
    res = (fact[A]*fact[B])%MOD;
    if(A == B){
      res *= 2;
    }
    cout << ((res) % MOD) << endl;
  }
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

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

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	
	vector<int> v(n + 1);
	int suma = 0,sumb = 0;
	
	for (int i = 0; i < m; ++i){
		int in;
		string s;
		cin >> in >> s;
		
		if (v[in] == -1) continue;
		
		if (s == "AC"){
			suma++;
			sumb += v[in];
			v[in] = -1;
		}
		else{
			v[in]++;
		}
	}
	cout << suma << ' ' << sumb;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int n,p,num[50],a,pp;
  while(1){
    scanf("%d %d",&n,&p);
    if(n==0&&p==0)
      break;
    for(int i=0;i<n;i++)
      num[i]=0;
    a=0;
    pp=p;
    while(1){
      if(pp==1&&num[a]==p-1)
        break;
      else if(pp>=1){
        pp--;
        num[a]++;
      }
      else{
        pp=num[a];
        num[a]=0;
      }
      a++;
      a%=n;
    }
    printf("%d\n",a);
  }
}


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n, m;
	cin >> n >> m;
	ll ans = n*m>>1ll;
	ans = max(ans, n*m-ans);
	if (n == 1 || m == 1) ans = 1;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,i,j,m,l,q,r;
	char ch[150][150];
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		getchar();
		for(i=1;i<=a;i++)
		{
		for(j=1;j<=b;j++)
		scanf("%c",&ch[i][j]);
		getchar();
	    }
		for(m=1;m<=b+2;m++)
		printf("#");
		printf("\n");
		for(l=1;l<=a;l++)
		{
			printf("#");
			for(q=1;q<=b;q++)
			printf("%c",ch[l][q]);
			printf("#");
			printf("\n");
		}
		for(r=1;r<=b+2;r++)
		printf("#");
		printf("\n");
}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int main() {
    int N;
    cin >> N;
    char c[110];
    rep(i, N)cin >> c[i];

    bool bc[110] = {};
    rep(i, N) {
        bc[c[i]] = true;
    }
    int cou = count(bc, bc + 110, true);
    if (cou == 3)cout << "Three" << endl;
    else cout << "Four" << endl;
}

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


int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    int cnt = 1;
    sort(s.begin(),s.end());
    rep(i,n-1){
        if(s[i] != s[i+1]) cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    int N;
    cin >> N;
    int sum = 0;

    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        sum += a;
    }

    cout << sum - N << endl;

    return 0;
}

Measured memory_bytes: 256