akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

struct SegTree {
    int size;
    vector<int> seg;

    // This function is used in query
    int f(int a, int b) {
        return max(a,b);
    }

    // This function is used in update
    int g(int a, int b) {
        return a + b;
    }

    SegTree(const vector<int>& v) {
        size = 1;
        while (size < v.size()) size <<= 1;
        seg.resize(2 * size);
        for (int i = 0; i < v.size(); i++) {
            seg[i + size] = v[i];
        }
        for (int i = size - 1; i > 0; i--) {
            seg[i] = f(seg[2 * i], seg[2 * i + 1]);
        }
    }

    SegTree(int n) : SegTree(vector<int>(n)) {}

    void update(int k, int x) {
        k += size;
        seg[k] = g(seg[k],x);
        k /= 2;
        for (; k > 0; k /= 2) {
            seg[k] = f(seg[2 * k], seg[2 * k + 1]);
        }
    }

    int query(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) return seg[k];
        int x = query(a,b,2 * k,l,(l + r) / 2);
        int y = query(a,b,2 * k + 1,(l + r) / 2,r);
        return f(x,y);
    }

    int query(int a, int b) {
        return query(a,b,1,0,size);
    }
};

pair<int,int> XY[200000];

constexpr double pi = 2 * acos(0);

int main(void) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    if (x1 > x2) {
        swap(x1,x2);
        swap(y1,y2);
    }
    bool rev = false;
    if (y1 > y2) {
        swap(y1,y2);
        rev = true;
    }

    int i, N;
    scanf("%d",&N);
    REP (i,N) scanf("%d%d",&XY[i].first,&XY[i].second);
    sort(XY,XY+N);

    unordered_map<int,int> coX, coY;
    set<int> st;
    REP (i,N) st.insert(XY[i].first);
    st.insert(x1);
    st.insert(x2);
    i = 0;
    for (auto x: st) coX[x] = i++;
    st.clear();
    REP (i,N) st.insert(XY[i].second);
    st.insert(y1);
    st.insert(y2);
    i = 0;
    for (auto y: st) coY[y] = i++;

    SegTree s(coY.size());
    REP (i,N) if (x1 <= XY[i].first && XY[i].first <= x2 && y1 <= XY[i].second && XY[i].second <= y2) {
        int mx;
        if (!rev) mx = s.query(0,coY[XY[i].second]);
        else mx = s.query(coY[XY[i].second]+1,coY.size());
        s.update(coY[XY[i].second],mx + 1);
    }
    int fountains = s.query(0,coY.size());

    double ans = (double) (x2 - x1 + y2 - y1) * 100;
    ans += fountains * (pi * 5 - 20);
    if (fountains == min(x2 - x1 + 1, y2 - y1 + 1)) ans += pi * 5;
    printf("%.12f\n",ans);
    return 0;
}

Measured memory_bytes: 30536
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;
const int mod=1e9+7; 

int findMaxGCD(vi arr, int n) 
{ 
    int high = 0; 
    for (int i = 0; i < n; i++) 
        high = max(high, arr[i]); 
    int count[high + 1] = {0}; 
    for (int i = 0; i < n; i++) 
        count[arr[i]]++; 
    int counter = 0; 
    for (int i = high; i >= 1; i--) 
    { 
        int j = i; 
       counter = 0; 
        while (j <= high) 
        {  
  
            if(count[j] >=2) 
               return j; 
  
           else if (count[j] == 1)          
                counter++;          
  
            j += i; 
            if (counter == 2)          
                return i; 
        } 
    } 
}
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    vi a(n);
    f(i,n)cin>>a[i];
    int ans=findMaxGCD(a, n); 
    if(ans==1)cout<<"pairwise coprime";
    else 
    {
        int g=a[0];
        for(int i=1;i<n;i++)
        {
            g=gcd(g,a[i]);
        }
        if(g==1)
        {
            cout<<"setwise coprime";
        }
        else
        {
            cout<<"not coprime";
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 26688
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

vector<int> v(100000+2,0);
int root(int x){
    if(v[x]==x)return x;
    return v[x]=root(v[x]);
}
void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx==ry)return ;
    v[rx] = ry;
}

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

    rep(i,n+2){
        v[i]=i;
    }
    vector<int> cll(n+2,0);
    int cl = 1;
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        if(v[x]==0&&v[y]==0){
            v[x]=cl;
            v[y]=cl;
            cll[cl]=cl;
            cl++;
        }else if(v[x]==0||v[y]==0){
            v[x]=max(v[x],v[y]);
            v[y]=max(v[x],v[y]);
        }else{
            int nx =  root(v[x]);
            int ny = root(v[y]);
            v[ny]=nx;
        }
    }
    int ans = 0;
    int cla = 0;
    for(int i=1;i<=n;i++){
        if(v[i]==0)ans++;
        if(v[i]==i)cla++;
    }

    cout<<ans+cla<<endl;


    
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N;i++)
    {
        sum += i;
    }
    cout << sum - N << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long long N, M;
    cin >> N >> M;
    
    if(N == 1 && M == 1){
        cout << 1 << endl;
    }
    else if(N == 1 && M != 1){
        cout << M - 2 << endl;
    }
    else if(M == 1 && N != 1){
        cout << N - 2 << endl;
    }
    else{
        long long m = (N - 2) * (M - 2);
        cout << m << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n) cout<<fixed<<setprecision(n);
#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

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

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  string s; cin >> s;
  set<char> sr;
  sr.insert(s[0]);
  sr.insert(s[1]);
  sr.insert(s[2]);

  if (sr.size() == 2)
    Yes()
  else
    No()
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

int main() {
	char ch[26];
	string str;
	for (int i=0; i<26; i++)
		ch[i] = 0;

	getline(cin, str);
	for (int i=0; i<str.length(); i++) {
		if (str[i]-'a' >= 0 && str[i]-'a' < 26)
			ch[str[i]-'a']++;
	}
	bool found = true;
	for (int i=0; i<26 && found; i++) {
		if (ch[i]%2!=0) found = false;
	}
	if (found) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int h,w;
    char s[100][100];
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",s[i]);
    }

    int cnt[100][100]={};

    /*
    for(int i=0;i<h;i++){
        if(i==0){
            if(s[i][1]=='#'){
                cnt[i][0]++;
            }
            if(s[i+1][1]=='#'){
                cnt[i][0]++;
            }
            if(s[i+1][0]=='#'){
                cnt[i][0]++
            }
        }

    }


    for(int i=1;i<h-1;i++){
        for(int j=1;j<w-1;j++){
            if(s[i][j]=='#'){
                cnt[i][j]=0;
            }else{
                if(s[i-1][j-1]=='#'){
                    cnt[i][j]++;
                }
                if(s[i-1][j]=='#'){
                    cnt[i][j]++;
                }
                if(s[i-1][j]=='#'){
                    cnt[i][j]++;
                }
                if(s[i][j-1]=='#'){
                    cnt[i][j]++;
                }
                if(s[i][j+1]=='#'){
                    cnt[i][j]++;
                }
                if(s[i+1][j-1]=='#'){
                    cnt[i][j]++;
                }
                if(s[i+1][j]=='#'){
                    cnt[i][j]++;
                }
                if(s[i+1][j+1]=='#'){
                    cnt[i][j]++;
                }
            }
        }
    }
    */


    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                cnt[i][j]=0;
            }
            else{
                if(s[i-1][j-1]=='#'){
                    cnt[i][j]++;
                }

                if(s[i-1][j]=='#'){
                    cnt[i][j]++;
                }
                if(s[i-1][j+1]=='#'){
                    cnt[i][j]++;
                }
                if(s[i][j-1]=='#'){
                    cnt[i][j]++;
                }
                if(s[i][j+1]=='#'){
                    cnt[i][j]++;
                }
                if(s[i+1][j-1]=='#'){
                    cnt[i][j]++;
                }
                if(s[i+1][j]=='#'){
                    cnt[i][j]++;
                }
                if(s[i+1][j+1]=='#'){
                    cnt[i][j]++;
                }
                if(cnt[i][j]==0&&s[i][j]=='.'){
                    cnt[i][j]=100;
                }

            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(cnt[i][j]==100){
                 if(j==w-1){
                    printf("0\n");
                }else{
                    printf("0");
                }
            }
            else if(cnt[i][j]==0){
                if(j==w-1){
                    printf("#\n");
                }else{
                    printf("#");
                }
            }else{
                if(j==w-1){
                    printf("%d\n",cnt[i][j]);
                }else{
                    printf("%d",cnt[i][j]);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] C = new String[H];
        String[] ans = new String[2 * H];

        for(int i=0; i<H; i++){
            C[i] = sc.next();
        }

        for(int i=0; i<2*H; i++){
            ans[i] = "";
            for(int j=0; j<W; j++){
                ans[i] += String.valueOf(C[(i+2)/2-1].charAt(j));
            }
            System.out.println(ans[i]);
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    for(int i = 6; i >= 0; i--) {
        if((1<<i) <= n) {
            cout << (1<<i) << '\n';
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

// A B C
// D E F
// G H I

int main(){
  int A , B , C , D , E , F , G , H , I;
  cin >> A >> B >> E;
  G = A + B - E;
  F = A + G - E;
  C = A + E - F;
  H = A + E - G;
  I = B + E - G;
  D = B + H - F;
  printf("%d %d %d\n",A,B,C);
  printf("%d %d %d\n",D,E,F);
  printf("%d %d %d\n",G,H,I);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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 (b<a) { a=b; return 1; } return 0; }

int cnt;
string S;

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin>>S;
    rep(i,S.length()){
        if(S[i]=='o')cnt++;
    }
    if(cnt+(15-S.length())>=8)out("YES");
    else out("NO");
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int i,j,c,a,b;
  char number[100];

  i = 0;
  while((c = getchar()) != EOF) {
    if(c == ' ') {
      a = atoi(number);
      for(j = 0; j < i; j++) {
	number[j] = '\0';
      }
      i = 0;
    }
    number[i] = c;
    i++;
  }
  b = atoi(number);

  if(a < b) {
    printf("a < b\n");
  }else if(a > b) {
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
  
  return 0;
}

Measured memory_bytes: 524
# coding: utf-8

import sys
import numpy as np

N, M = map(int, sys.stdin.readline().split(" ", 2))

L = 0
R = M + N
for line in sys.stdin:
    l, r = map(int, line.split(" ", 2))
    if l > L:
        L = l
    if r < R:
        R = r
print(max(0, R - L + 1))
    # L.append(l)
    # R.append(r)

    


Measured memory_bytes: 12392
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        maxc = l[i]+l[j] #短い2辺の和
        index = bisect.bisect_left(l, maxc)
        if index > j:
            count += index-j-1
print(count)

Measured memory_bytes: 3188
N, M = map(int, input().split())
MAX_N = 10 ** 5 + 2000
factors, MOD = {}, 10 ** 9 + 7
fact, fact_inv = [1] * (MAX_N+1), [1] * (MAX_N+1)


def prime_factorization(n):
    i = 2
    while i * i <= n:
        while not n % i:
            factors[i] = factors.get(i, 0) + 1
            n //= i
        i += 1

    if n != 1:
        factors[n] = 1


def combination(n, r):
    return fact[n] * fact_inv[r] * fact_inv[n-r] % MOD


def main():
    prime_factorization(M)

    for i in range(1, N+2001):
        fact[i] = fact[i-1] * i % MOD

    fact_inv[N+2000] = pow(fact[N+2000], MOD-2, MOD)
    for i in range(N+1999, -1, -1):
        fact_inv[i] = fact_inv[i+1] * (i+1) % MOD

    ans = 1
    for i, j in factors.items():
        ans = ans * combination(j+N-1, j) % MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11124
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    a,b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0
    
    print(-(-a//b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

using State = pair<PII, vector<string>>;

int H, W;
vector<string> A;
bool inside(int nh, int nw) {
    return 0 <= nh && nh < H && 0 <= nw && nw < W;
}
int dh[] = {0, 1};
int dw[] = {1, 0};
bool check(vector<string> v) {
    FORE(el, v)FORE(e, el) {
        if (e == '#') return false;
    }
    return true;
}
int main(void) {
    cin >> H >> W;
    A.resize(H);
    for_each(ALL(A), [](string &e){cin >> e;});
    queue<State> q;
    A[0][0] = '.';
    q.push(MP(MP(0, 0), A));
    vector<vector<string>> goal;
    while (!q.empty()) {
        State now = q.front(); q.pop();
        if (now.first == MP(H - 1, W - 1)) {
            goal.EB(now.second);
        }
        int h = now.first.first;
        int w = now.first.second;
        auto mp = now.second;
        REP(i, 2) {
            auto cpmp = mp;
            int nh = h + dh[i], nw = w + dw[i];
            if (!inside(nh, nw)) continue;
            if (cpmp[nh][nw] != '#') continue;
            cpmp[nh][nw] = '.';
            q.push(MP(MP(nh, nw), cpmp));
        }
    }
    FORE(el, goal) {
        if (check(el)) {
            cout << "Possible" << endl;
            return 0;
        }
    }
    cout << "Impossible" << endl;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N, L;
    scanf("%d%d", &N, &L);
    int min = 1000;
    int ans = 0;
    for(int i = 0; i < N; i++){
            if(abs(L + i) < abs(min)){
                min = L+i;
            }
        ans += L+i;
    }
    printf("%d\n", ans - min);
    return 0; 
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  vector<ll> v(n);
  REP(i, n) {
    cin >> v[i];
  }

  FOR(i, k, n - 1) {
    if (v[i - k] < v[i]) {
      ANS("Yes");
    } else {
      ANS("No");
    }
  }
  return 0;
}


Measured memory_bytes: 4776
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = long.Parse(inputs[0]);
            var b = long.Parse(inputs[1]);
            var c = long.Parse(inputs[2]);
            var d = long.Parse(inputs[3]);

            var result = calc(b, c, d) - calc(a - 1, c, d);
            Console.WriteLine(result);
        }

        static long calc(long n, long c, long d)
        {
            var result = n;
            var l = lcm(c, d);
            result -= (n / c + n / d - n / l);
            return result;
        }

        // 最大公約数
        // ユークリッドの互除法を利用
        static long gcd(long a, long b)
        {
            if (b > a)
            {
                var tmp = a;
                a = b;
                b = tmp;
            }

            if (b == 0)
            {
                return a;
            }

            return gcd(b, a % b);
        }

        // 最小公倍数
        static long lcm(long a, long b)
        {
            return a / gcd(a, b) * b;
        }
    }
}


Measured memory_bytes: 27516
import sys
sys.setrecursionlimit(10**9)
l=list(input())
n=len(l)
p=10**9+7
ans=0
d=0
def f(n,k,q):
    if k==0:
        return 1
    elif k%2==0:
        return ((f(n,k//2,q))**2)%q
    else:
        return (n*f(n,k-1,q))%q

for i in range(n):
    if l[i]=="1":
        x=n-i-1
        ans+=(f(3,x,p)*f(2,d,p))%p
        d+=1
    else:
        continue

ans+=f(2,d,p)
print(ans%p)


Measured memory_bytes: 80476
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




int main() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> t;
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        t.push_back({a, i});
        t.push_back({b, n + i});
    }
    sort(t.begin(), t.end());
    vector<bool> flag(2 * n);
    ll sum = 0;
    REP(i, n){
        sum += t[i].first;
        flag[t[i].second] = true;
    }
    bool f1 = true, f2 = false;
    REP(i, n){
        if(flag[0] != flag[i]){
            f1 = false;
        }
        if(flag[i] && flag[n + i]){
            f2 = true;
        }
    }
    if(!(f1 || f2)){
        ll t1 = t[n - 1].second, t2 = t[n].second;
        if(t1 > t2) swap(t1, t2);
        if(t1 + n != t2){
            sum += -t[n - 1].first + t[n].first;
        }
        else{
            sum = min(sum - t[n - 1].first + t[n + 1].first, sum - t[n - 2].first + t[n].first);
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 6384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
typedef long long ll;

using namespace std;

inline int input(){
    int a;
    cin >> a;
    return a;
}

template <typename T>
inline void output(T a, int p) {
    if(p){
        cout << fixed << setprecision(p)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

// end of template

// goal, capacity, index of reverse edge
struct edge {
    int to, cap, rev;
};

// O(EV^2)
class Dinic{
public:
    int V;
    vector<vector<edge>> G;
    vector<int> L;
    vector<int> I;
    
    Dinic(int v){
        G.resize(v), L.resize(v), I.resize(v);
        V = v;
    }
    
    // add edge
    void add(int from, int to, int cap){
        G[from].push_back((edge){to, cap, (int)G[to].size()});
        G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
    }
    
    // label dist from s
    void bfs(int s){
        L.assign(V, -1);
        queue<int> q;
        L[s] = 0;
        q.push(s);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            rep(i, G[v].size()){
                edge &e = G[v][i];
                if (e.cap > 0 && L[e.to] < 0) {
                    L[e.to] = L[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }
    
    // search positive path
    int dfs(int v, int t, int f){
        if (v == t) return f;
        for (int &i = I[v]; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && L[v] < L[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    
    // calc max flow
    int max_flow(int s, int t){
        int flow = 0;
        for (;;) {
            bfs(s);
            if (L[t] < 0) return flow;
            I.assign(V, 0);
            int f;
            while ((f = dfs(s, t, inf)) > 0) {
                flow += f;
            }
        }
    }
};

int main() {
    cin.tie(0);
    // source code
    int V = input();
    int E = input();
    Dinic D(V);
    rep(i, E){
        int s, t, c;
        cin >> s >> t >> c;
        D.add(s, t, c);
    }
    cout << D.max_flow(0, V - 1) << endl;
    
    return 0;
}

Measured memory_bytes: 3168
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    int A = 0; // num of apples
    int P = 0; // num of pieces. apple -> 3 pieces
    cin >> A >> P;
    
    int pieces = P + A * 3;
    int pies = pieces/2; // num of pies. 2 pieces -> 1 pie
    cout << pies << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys 
a=input()
a=a[::-1]
b=input()
b=b[::-1]
c=input()
c=c[::-1]
i=len(a)-1
j=len(b)-1
k=len(c)-1
cur=0
while True:
    if cur==0:
        if i<0:
            print('A')
            sys.exit()
        cur=ord(a[i])-ord('a')
        i-=1
    elif cur==1:
        if j<0:
            print('B')
            sys.exit()
        cur=ord(b[j])-ord('a')
        j-=1
    else:
        if k<0:
            print('C')
            sys.exit()
        cur=ord(c[k])-ord('a')
        k-=1




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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    if (s[i] != s[i+1]) {
      ans++;
    }
  }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define tc int t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff(i,a,b) for(i=a;i<b;i++)
#define fb(i,b,a) for(i=b;i>a;i--)
#define ffi(i,a,b,c) for(i=a;i<b;i+=c)
#define fbi(i,b,a,c) for(i=b;i>a;i-=c)
#define clin(s) getline(cin,s)
#define MOD 1e9+7
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ub upper_bound
#define lb lower_bound
int main() {
	fio;
	ll n,W,i,j;
	cin>>n>>W;
	vector<pair<ll,ll>> item(n);

	ff(i,0,n){
		ll w,v;
		cin>>w>>v;
		item[i]=mp(w,v);
	}
	//sort(all(item));

	ll dp[n][W+1];

	//dp[i][j] = the max. value for items from 0 to i for weight j

	ff(i,0,n)ff(j,0,W+1)dp[i][j]=0;

	ff(i,item[0].first,W+1){
		dp[0][i]=item[0].second;
	}

	ff(i,1,n){
		ff(j,1,W+1){
			//cout<<"v["<<i<<"]="<<v[i]<<"\n";

			ll w = item[i].first;
			ll v = item[i].second;

			if(w<=j)
				dp[i][j]=max(v+dp[i-1][j-w] , dp[i-1][j]);
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	/*ff(i,0,n){
		ff(j,0,W+1){
			cout<<dp[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	cout<<dp[n-1][W]<<"\n";
	return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    ll n,m;
    cin>>n>>m;
    ll get[n+2];

    rep(i,n+2)get[i]=0;
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        get[a]++;
        get[b+1]--;

    }

    for(int i=0;i<n+1;i++){
        get[i+1]+=get[i];
    }

    ll ans=0;

    rep(i,n+1){
        if(get[i]==m)ans++;

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


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

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}


int main(){
    int n;
    cin >> n;
    int a[n+5],x[n+5][n+5],y[n+5][n+5];

    rep(i,n){

        cin >> a[i];

        rep(j,a[i]){
           cin >> x[i][j] >> y[i][j];
        }
    }

    int ans = 0;

    for(int bit =1; bit < (1 << n);bit++){
        bool ok = true;
        rep(i,n){
            if(!(bit & (1<<i))){
                continue;
            }
            rep(j,a[i]){
                if(((bit >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
                
            }
        }
        if(ok){
            ans = max(counter(bit),ans);
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

using vqi=vector<queue<int>>;

using vqi=vector<queue<int>>;
using bs=bitset<60>;
using vbi=vector<bs>;
constexpr ll MOD = 1e9 + 7;


int main() {
    int N;
    cin >> N;
    string s, t;

    cin >> s >> t;

    for (int i = 0; i < N; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

struct COM {
    vector<ll> inv, fac, finv;
    COM(int N) : inv(N), fac(N), finv(N) {
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        for (int i = 2; i < N; ++i) {
            inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
            fac[i] = fac[i - 1] * i % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    ll calc(int a, int b) {
        return (fac[a] * finv[b] % MOD) * finv[a - b] % MOD;
    }
};

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

    int X;
    cin >> X;

    for (int i = 1; i <= 360; ++i) {
        if (X * i % 360 == 0) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


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

int main(){
    int x,y,z;
    while(1){
        cin >> x >> y;
        if (x == 0 && y == 0)break;
        if (x > y){
            z = x;
            x = y;
            y = z;
        }
        else if (x < y){
            x = x;
            y = y;
        }
        cout << x << " " << y << '\n';
    }
    return 0;
}



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

int gcd(int x, int y) {
    if (y > x) {
        swap(x, y);
    }

    int r;
    while (y > 0) {
        r = x % y;
        x = y;
        y = r; 
    }

    return x;
}

int main() {
    int x, y;
    cin >> x >> y;

    cout << gcd(x, y) << endl;

    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=1,anss=0,a,b,c,d,e,f,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0,mizu,satou;
double gendo,noudo,cmpnoudo;
string s;

vector<int> z;

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

       cin >> a >> b >> c >> d >> e >> f;
      // gendo=(double)(100*e)/(100+e);
      // Cout(gendo);
       for(int i=0;100*a*i<=f;i++){
           for(int j=0;100*a*i+100*b*j<=f;j++){
               for(int k=0;100*a*i+100*b*j+c*k<=f;k++){
                   for(int l=0;100*a*i+100*b*j+c*k+d*l<=f;l++){
               mizu=(i*a+j*b)*100;
               satou=c*k+d*l;
             //  cout << mizu << " " << satou << endl;
               
              // if(satou==0){
                //   noudo=0;
               //}
              // else{
               noudo=(double)(100*satou)/(mizu+satou);
               //}
               //Cout(noudo);
               //Cout(satou);
               if(mizu!=0 && mizu+satou<=f &&  1.0*100*satou/mizu<=e){
                   if(noudo>100){
                       continue;
                   }
                   else{
                   if(cmpnoudo<=noudo){
                       cmpnoudo=noudo;
                      ans=satou+mizu;
                      anss=satou;
                     //cout << ans << " " << anss << endl;
                   }
                   }
               }
           }
       }
           }
       }
       cout << ans << " " << anss << endl;
return 0;
}


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

public class Main{
	public static void main(String[] args){
		int i,j;
		Scanner scan = new Scanner(System.in);

		while(scan.hasNext()){
			int ans = -1;
			String[] s = scan.next().split("[\\+=]");
			BigInteger[] bi = new BigInteger[3];

			for(i=0;ans==-1 && i<=9;i++){
				if(i == 0){
					if((s[0].charAt(0)=='X' && s[0].length()==1 || s[0].charAt(0)!='X') &&
						 (s[1].charAt(0)=='X' && s[1].length()==1 || s[1].charAt(0)!='X') &&
						 (s[2].charAt(0)=='X' && s[2].length()==1 || s[2].charAt(0)!='X')){
						for(j=0;j<3;j++) bi[j] = new BigInteger(s[j].replaceAll("X","0"));
						if(bi[2].equals(bi[0].add(bi[1]))) ans = 0;
					}
				}
				else{
					for(j=0;j<3;j++) bi[j] = new BigInteger(s[j].replaceAll("X",Integer.toString(i)));
					if(bi[2].equals(bi[0].add(bi[1]))) ans = i;
				}
			}

			if(ans == -1) System.out.println("NA");
			else System.out.println(ans);
		}
	}
}

Measured memory_bytes: 13000
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
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(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 998244353

int main() {
	string str;
	LL k;
	cin >> str >> k;
	REP(i, str.length()) {
		if (str[i] != '1') {
			if (k > i) {
				cout << str[i] << endl;
			}
			else {
				cout << '1' << endl;
			}
			return 0;
		}
	}
	cout << '1' << endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //入力を受け取る
          int N = int.Parse(Console.ReadLine());
          var AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          int[] Rain = new int[N+1];
          //1の山に降った洪水の量を求める(奇数だから可能)
          Rain[1] = AB[0];
          for(int i = 1;i < N ; i++){
            Rain[1] = AB[i]-Rain[1]; 
          }
          //Console.Write(Rain[1]);
          
          //2以降の各山に降った雨の量を求める
          for(int i = 2;i < N+1 ; i++){
            Rain[i] = 2*AB[i-2]-Rain[i-1]; 
          }
          for(int i = 1;i < N ; i++){
            Console.Write(Rain[i]+" ");
          }
          Console.Write(Rain[N]);
        }
 }

Measured memory_bytes: 31960
N = int(input())
B = list(map(int,input().split()))
A = [0 for _ in range(N)]
A[0] = B[0]
A[-1] = B[-1]

for i in range(1,N-1):
  A[i] = min(B[i-1], B[i])
  
print(sum(A))

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

int main(){
int N,M;
  cin>>N>>M;
  int a[50],b[50],c[50],d[50];
  for(int i=0; i<N; i++){ cin>>a[i]>>b[i]; }
  for(int i=0; i<M; i++){ cin>>c[i]>>d[i]; }
 
  for(int i=0; i<N; i++){
      int checkpoint=0;
      int min_dist=abs(a[i]-c[0])+abs(b[i]-d[0]);
     for(int j=0; j<M; j++){
       int ma=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(min_dist>ma){
        min_dist=ma;
        checkpoint=j;  }
     } // マンハッタン距離が最小の時のチェックポイントの座標jが出る
    cout<<checkpoint+1<<endl;
  }
  
}


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

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

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

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

    list<string> li;
    int maxCount = 0;
    int counter = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if (p[i] == p[i + 1]) {
            counter++;
        }
        else {
            if (counter == maxCount) {
                li.push_back(p[i]);
            }
            else if (counter > maxCount) {
                maxCount = counter;
                li.clear();
                li.push_back(p[i]);
            }
            counter = 1;
        }
    }
    
    if (counter == maxCount) {
        li.push_back(p[n - 1]);
    }
    else if (counter > maxCount) {
        maxCount = counter;
        li.clear();
        li.push_back(p[n - 1]);
    }

    for (auto &&val : li)
    {
        cout << val << endl;
    }
}

Measured memory_bytes: 20480
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
	int z,x,c=0;
	string s;
	cin>>s;
	z=s.find("A");
	x=s.rfind("Z");
	c=(x-z)+1;
	cout<<c;
	return 0;
}


Measured memory_bytes: 640
from collections import deque
n, m = map(int, input().split(' '))
c = [[] for i in range(n)]
r = [0] * n
q = deque()
for i in range(m):
    a, b = map(int, input().split(' '))
    c[a - 1].append(b - 1)
    c[b - 1].append(a - 1)
q.append(0)
while len(q) > 0:
    ix = q.popleft()
    for i in c[ix]:
        if r[i] == 0:
            r[i] = ix + 1
            q.append(i)

jg = 'Yes' if r.pop(0) > 0 else 'No'
print(jg)
for i in r:
    print(i)

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

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

}



Measured memory_bytes: 3652
n = int(input())
maxda = -10**18
minda = 10**18
maxdb = -10**18
mindb = 10**18
for i in range(n):
	x,y = map(int,input().split())
	maxda = max(maxda, x-y)
	minda = min(minda, x-y)
	maxdb = max(maxdb, x+y)
	mindb = min(mindb, y+x)
print(max(maxda-minda, maxdb-mindb))

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

int main(){
    string s; cin >> s;
    if(s.size()%2 != 0){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0; i<s.size(); i+=2){
        if(s[i]=='h' && s[i+1]=='i'){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

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

using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    int ans = 0, cont = 0;
    for(char c: s) {
        if(c == 'R') {
            cont++;
            ans = max(ans, cont);
        }
        else if(c == 'S') cont = 0;
    }

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

    return 0;
}

Measured memory_bytes: 3704
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string S; cin >> S;
    vl cnt(26,0);
    REP(i, S.size()) cnt[S[i]-'a']++;
    if(S.size()!=26){
        REP(i, 26){
            if(cnt[i] == 1) continue;
            cout << S + (char)(i + 'a') << endl; return 0;
        }
        
    }
    else{
        string T = S;
        if(next_permutation(T.begin(), T.end())){
            ll idx = LINF;
            REP(i, T.size()){
                if(T[i]!=S[i]){
                    idx = i; break;
                }
            }
            cout << T.substr(0, idx+1) << endl;
        }
        else{
            cout << -1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int X, Y;
	cin >> X >> Y;
	if (X == Y) {
		cout << X + Y << endl;
	}
	else if (X > Y) {
		cout << X + (X - 1) << endl;
	}
	else {
		cout << Y + (Y - 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 256