akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   while (true) {
      int D;
      cin >> D;
      if (D == 0) break;
      int n, m;
      cin >> n >> m;
      vector<int> d(n + 1);
      d[0] = 0;
      rep(i, 1, n) cin >> d[i];
      d[n] = D;
      sort(d.begin(), d.end());
      int ans = 0;
      rep(i, 0, m) {
         int k;
         cin >> k;
         auto it = lower_bound(d.begin(), d.end(), k);
         int res = D + 1;
         if (it != d.begin()) res = min(res, k - *prev(it));
         res = min(res, *it - k);
         ans += res;
      }
      cout << ans << endl;
   }
   return 0;
}


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

int main() {
 string str ;
  cin >> str ;
  int count=0 ;
  if(str.at(0)=='A')
    count++ ;
  int C=0 ;
  for(int i=2 ; i<str.size()-1 ; i++){
    if(str.at(i)=='C'){
      C++ ;
    }
  }
  if(C==1){
    count++ ;
  }
  int a=0 ;
  for(int i=0 ; i<str.size() ; i++){
    if(str.at(i)=='A'||str.at(i)=='B'||str.at(i)=='C'||str.at(i)=='D'||str.at(i)=='E'||
       str.at(i)=='F'||str.at(i)=='G'||str.at(i)=='H'||str.at(i)=='I'||str.at(i)=='J'||
       str.at(i)=='K'||str.at(i)=='L'||str.at(i)=='M'||str.at(i)=='N'||str.at(i)=='O'||
       str.at(i)=='P'||str.at(i)=='Q'||str.at(i)=='R'||str.at(i)=='S'||str.at(i)=='T'
       ||str.at(i)=='U'||str.at(i)=='V'||str.at(i)=='W'||str.at(i)=='X'||str.at(i)=='Y'||
       str.at(i)=='Z'){
a++ ;
    }
  }
   if(a==2)
     count++ ;
  if(count==3)
    cout<< "AC" << endl ;
  if(count!=3)
    cout<<"WA"<< endl ;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int
typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  double n, k;
  cin >> n >> k;
  vector<int> v(n, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
  }
  cout << ceil((n-k) / (k-1) + 1) << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {

    static long ans;
    static int[] k_list;

    public static void main(String[] args) {
        var scaner = new Scanner(System.in);
        
        var s = scaner.next();
        var end = s.toCharArray()[s.length()-1];
        var num = Integer.parseInt(String.valueOf(end));

        String ans;

        if (num == 3) {
            ans = "bon";
        } else if (num == 2 || num == 4 || num == 5|| num == 7 || num == 9) {
            ans = "hon";
        } else {
            ans = "pon";
        }

        System.out.println(ans);

        scaner.close();
    }

}


Measured memory_bytes: 35664
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int s = Integer.parseInt(sc.next());
		int L = s / 100;
		int R = s % 100;
		if (1 <= L && L <= 12) {
			if (1 <= R && R <= 12)
				System.out.println("AMBIGUOUS");
			else
				System.out.println("MMYY");
		} else {
			if (1 <= R && R <= 12)
				System.out.println("YYMM");
			else
				System.out.println("NA");
		}
		sc.close();
	}
}

Measured memory_bytes: 21588
n = int(input())
s = [input() for i in range(n)]
s.sort()
max = 0
count = 1
for i in range(1,n):
    if s[i] == s[i-1]:
        count+=1
    else:
        if max < count:
            max = count
            count=1
        else:
            count=1
if max < count:
    max = count
count = 1
ans = []
for i in range(1,n):
    if s[i] == s[i-1]:
        count+=1
    else:
        if max == count:
            ans.append(s[i-1])
            count = 1
        else:
            count = 1
if max == count:
    ans.append(s[n-1])
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 20676
#include<set>
#include<iostream>
#include<ctime>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<string.h>
#include<limits.h>
using namespace std;

signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b < c)puts("NA");
	else cout << max(0, c - a) << endl;
}

Measured memory_bytes: 3080
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>
//#include<iostream>
//using namespace std;

int main() {
	
	int N, ans, tmp;
	scanf("%d", &N);
	for (int i = 0; i < 1000000; i++) {
		tmp = i * i;
		if (tmp > N) {
			break;
		}
		ans = tmp;
	}
	printf("%d", ans);
	return(0);
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	// Code for B - Red or Blue
	var N int
	fmt.Scanf("%d", &N)

	var S string
	fmt.Scanf("%s", &S)

	ans := make(map[string]int, N)
	for i := 0; i < len(S); i++ {
		ans[S[i:i+1]]++
	}

	if ans["R"] > ans["B"] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

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

   int ans = (1000 - n % 1000) % 1000;
   cout << ans << "\n";
}

Measured memory_bytes: 3656
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
   int N;
   cin >> N;
   double count = 0;
   for(int i = 0; i < N; i++){
       double a;
       string b;
       cin >> a >> b;
       if(b == "JPY"){
           count += a;
       }
       else{
           count += a * 380000;
       }
   }
   cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) 				for(int i=0; i<(n); ++i)
#define all(c) 					(c).begin(),(c).end()
#define sortall(x)              sort(all(x))
#define tr(c,i) 				for( typeof( (c).begin() ) i = (c).begin();  i != (c).end(); ++i)
#define pb 						push_back
#define sz(a) 					int((a).size())
#define mp                      make_pair
#define ll                      long long
#define F                       first
#define S                       second
#define PI                      3.1415926535897932384626
// Input macros
#define s(n)                    scanf("%d",&n)
#define sc(n)                   scanf("%c",&n)
#define sl(n)                   scanf("%lld",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                   scanf("%s",n)

// Others
#define test(t) 				int t; cin>>t; while(t--)
#define endl 					"\n"

using namespace std;

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

// const int mod = 1000000007;
// const int INF = 1e9+5;

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

     string s;
     cin>>s;
     
     ll ans = 0;
     for(char c : s){
		int x = c-'0';
		ans+=x;
	 }
	 
	 if(ans%9 == 0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		 

}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
const LL inf=(LL)1e15;
int n,a[N];
char op[N][2];
LL f[N][3];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<n;i++) scanf("%d%s",&a[i],op[i]);
    scanf("%d",&a[n]);
    f[1][0]=a[1];f[1][1]=f[1][2]=-inf;
    for (int i=2;i<=n;i++)
        if (op[i-1][0]=='+')
        {
            f[i][0]=max(f[i-1][0],f[i-1][1])+a[i];
            f[i][1]=f[i-1][1]-a[i];
            f[i][2]=f[i-1][2]+a[i];
        }
        else
        {
            f[i][0]=-inf;
            f[i][1]=max(f[i-1][0],f[i-1][1])-a[i];
            f[i][2]=max(f[i-1][1],f[i-1][2])+a[i];
        }
    printf("%lld",max(f[n][0],max(f[n][1],f[n][2])));
    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <math.h>
#define N 10000

void search_prime_number(int a[]) { // 素数探索
    int i, j;
    
    for(i=0; i<N; i++) {
        a[N] = 0;
    }

    for(i=2; i<N; i++) {
        if( a[i]==0 ) {
            for(j=i*2; j<N; j+=i) {
                a[j] = 1;
            }
        }
    }

    return;
}

int soe(int a[], int z) { // エラトステネスの篩
    int i;
    for(i=2; i<=sqrt(z); i++) {
        if( a[i] == 0 ) {
            if( z%i == 0 ) return 0;
        }
    }

    return 1;
}

int main(void) {
    int i, n, cnt, z, a[N];
    i = 0;
    cnt = 0;

    search_prime_number(a);

    do {
        scanf("%d", &n);
    } while( 1>n || n>10000);

    while( i<n ) {
        scanf("%d", &z);

        if( 2<=z && z<=100000000 ) {
            if( soe(a, z) == 1 ) {
                cnt++;
            }
            i++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 2040
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define LARGE_PRIME_NUM 1000000007
using ll = long long;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>
using namespace std;

int main() {
	int r, d, x;
	cin >> r >> d >> x;
	
	rep(i, 10) {
		cout << r * x - d << endl;
		x = r * x - d;
	}
	return 0;
}

Measured memory_bytes: 256
// 2005à\IB Red and Black

#include <iostream>
#include <string>
#include <queue>

using namespace std;

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

int main(){
	int w, h;
	string b[20];
	while(cin >> w >> h, w){
		for(int i=0;i<h;i++) cin >> b[i];
		int sx, sy;
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				if(b[i][j]=='@') sx = i, sy = j;
		queue< pair<int, int> > qu; qu.push(make_pair(sx,sy));
		int res = 0;
		while(!qu.empty()){
			pair<int, int> pr = qu.front(); qu.pop();
			int x = pr.first, y = pr.second;
			res++;
			for(int i=0;i<4;i++){
				int nx = x+dx[i], ny = y+dy[i];
				if(nx<0||h<=nx||ny<0||w<=ny||b[nx][ny]!='.') continue;
				b[nx][ny] = '#';
				qu.push(make_pair(nx,ny));
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  
  vector<vector<int>> to(n+1,vector<int>(0));
  
  rep1(i,n-1){
    to[i].push_back(i+1);
    to[i+1].push_back(i);
  }
  to[x].push_back(y);
  to[y].push_back(x);
  
  vector<int> ans(n,0);
  
  rep1(i,n){
      
    //こっからBFS
    int INF = 1000000000;
    vector<int> d(n+1,INF);
    vector<bool> seen(n+1,false);
    queue<int> q;
    q.push(i);
    d[i] = 0;
    while(!q.empty()){
      int now = q.front();
      q.pop();
      if(seen[now]) continue;
      seen[now] = true;
      for(int next : to[now]){
        d[next] = min(d[now]+1,d[next]);
        q.push(next);
      }
    }//while
    
    rep1(j,n) ans[d[j]] ++;
  }//i
  
  rep1(i,n-1) cout << ans[i]/2 << endl;
}


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

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    ll tmp = 0;
    rep(i, N) {
        cin >> A[i];
        tmp += A[i];
    }

    ll loop = 1;
    ll ans = 0;
    ll sum = 0;

    while (loop <= K) {
        loop <<= 1;
    }

    rep(i, N) {
        ll loop_t = loop;
        while (loop_t <= A[i]) {
            if ((A[i] & loop_t) == loop_t) {
                ans += loop_t;
            }
            loop_t <<= 1;
        }
    }

    loop >>= 1;

    while (loop >= 1) {
        ll cnt = 0;
        rep(i, N) {
            if ((A[i] & loop) == loop) {
                cnt++;
                //cout << A[i] << ":" << loop << ":" << (A[i] & loop) << endl;
            }
        }
        if ((cnt < N / 2.0) && ((sum + loop) <= K)) {
            sum += loop;
            cnt = N - cnt;
        }
        //cout << loop << ":" << cnt << endl;
        ans += (loop * cnt);
        loop >>= 1;
    }

    cout << max(tmp, ans) << endl;
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int maxn = 1e6 + 7;

int gcd(int x,int y) {
    if(y == 0) return x;
    else return gcd(y,x%y);
}

int vis[maxn];
int flag;

void solve(int x) {
    for(int i = 2 ; i * i <= x ; i++) {
        if(x % i == 0) {
            vis[i]++;
            if(vis[i] >= 2) {
                flag = 2;
                break;
            }
            while(x % i == 0) {
                x /= i;
            }
        }
    }
    if(x != 1 && flag != 2) {
        vis[x]++;
        if(vis[x] >= 2) flag = 2;
    }
}

int a[maxn];

int main() {
    int n;
    sd(n);
    int GCD = 0;
    flag = 0;
    rep(i,1,n) {
        sd(a[i]);
        if(flag == 0) solve(a[i]);
        if(i == 1) GCD = a[i];
        else GCD = gcd(GCD,a[i]);
    }
    if(GCD == 1) {
        if(flag == 2) puts("setwise coprime");
        else puts("pairwise coprime");
    } else puts("not coprime");
    return 0;
}

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL =  unsigned long long;
using MAT = array<array<LL, 2>, 2>;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 2005

char A[MAX_N], B[MAX_N];
int L[MAX_N], R[MAX_N];
int n;

int solve() {

    REP(i, n) {
        R[i] = 0;
        L[i] = 0;
        while(B[(i+R[i])%n] != '1') {
            R[i]++;
        }
        while(B[(i-L[i]+n)%n] != '1') {
            L[i]++;
        }
    }

    int ans = INT_MAX;
    REP(d, 0, n+1) {
        int flip_cnt = 0;
        vector<PII> tmp;
        REP(i, n) {
            if(A[(i+d) % n] != B[i]) {
                flip_cnt++;
                tmp.EB(L[i], max(R[i] - d, 0));
            }
        }
        sort(tmp.begin(), tmp.end(), greater<PII>());
        int maxy = 0, sum = INT_MAX;
        REP(i, tmp.size()) {
            int x = tmp[i].first;
            sum = min(sum, x + maxy);
            maxy = max(maxy, tmp[i].second);
        }
        sum = min(sum, maxy);
        ans = min(ans, 2 * sum + d + flip_cnt);
    }
    return ans;
}

int main()
{
    scanf("%s%s", A, B);
    n = strlen(A);
    int cnt1A = count(A, A + n, '1');
    int cnt1B = count(B, B + n, '1');
    if(cnt1B == 0) {
        if(cnt1A == 0) {
            printf("0\n");
        } else {
            printf("-1\n");
        }
        return 0;
    }
    int ans = solve();
    reverse(A, A + n);
    reverse(B, B + n);
    ans = min(ans, solve());
    printf("%d\n", ans);
    return 0;
}


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

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

// 過去問第3問ABC113Bまでdone

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

    ll sum = 0;

    for(int bit=0; bit < (1<<s.size()-1); bit++){//plusの位置の組み合わせ
        // cout << bitset<2>(bit) << endl;
        ll tmp = (s[0]-'0');
        rep(i, s.size()-1){//plusの位置にbitが立っているかどうか調べる
            if(bit&(1<<i)){
                sum += tmp;
                tmp = (s[i+1]-'0');
            }else{
                tmp = tmp*10 + (s[i+1]-'0');
            }
        }
        sum += tmp;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
M = N//2
c = Counter(A)
if N % 2 == 1 and A.count(0) == 1 and all(c[i*2+2] == 2 for i in range(M)):
    print((2 ** M) % (10**9+7))
elif N % 2 == 0 and all(c[i*2+1]==2 for i in range(M)):
    print((2 ** M) % (10**9+7))
else:
    print(0)

Measured memory_bytes: 14820
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

int n, m;
P place[100];

bool rev(const P& a, const P& b){
	if(a.first == b.first) return a.second < b.second;
	return a.first > b.first;
}

int main(){
	while(scanf("%d%d", &n, &m)){
		if(n == 0 && m == 0) break;
		for(int i = 0; i < 100; i++){
			place[i].first = 0;
			place[i].second = i+1;
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				int tmp; scanf("%d", &tmp);
				place[j].first += tmp;
			}
		}
		sort(place,place+m,rev);
		for(int i = 0; i < m; i++){
			if(i == 0) printf("%d", place[i].second);
			else printf(" %d", place[i].second);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1032
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
      		long total = 0;
      		for(int i=0; i<n; i++){ 
			 	total = total + sc.nextInt();
            }
      		System.out.println(total/(long)n);
    }
}




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

using namespace std;

// z[i] = len of lcp of s, s[i..]; lcp(longest common prefix)
vector<int> z_fn(const string& s) {
    int n = s.size();
    vector<int> z(n, 0);
    for (int i = 1, l = 0, r = 0; i < n; i++) {
        if (i <= r)
            z[i] = min(r-i+1, z[i-l]);
        while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
            z[i]++;
        }
        if (i+z[i]-1 > r) {
            l = i; r = i+z[i]-1;
        }
    }
    return z;
}

int min_period(const vector<int>& z) {
    int n = z.size();
    for (int i = 1; i <= n/2; i++) {
        if (n%i) continue;
        if (z[i] == n-i) return i;
    }
    return n;
}

void solve() {
    string s; cin >> s;
    auto z = z_fn(s);
    int n = s.size();
    int period = min_period(z);
    if (period == 1) {
        cout << n << "\n1"; return;
    }
    if (period == n) {
        cout << "1\n1"; return;
    }
    
    vector<bool> pre(n+1, true), suf(n+1, true);
    for (int p = 1; p < n; p++) {
        if (!pre[p]) continue;
        for (int k = 2; (k-1)*p <= z[p]; k++) {
            pre[k*p] = false;
        }
    }
    reverse(s.begin(), s.end());
    auto y = z_fn(s);
    for (int p = 1; p < n; p++) {
        if (!suf[p]) continue;
        for (int k = 2; (k-1)*p <= y[p]; k++) {
            suf[k*p] = false;
        }
    }
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        if (pre[i] && suf[n-i]) cnt++;
    }
    assert(cnt);
    cout << "2\n" << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

struct edge { int u, v, w; };

int main() {
    int L;
    scanf("%d", &L);
    function<pair<int, vector<edge>>(int)> solve = [&](int x) {
        if (x == 2) return make_pair(2, vector<edge>{(edge){1, 2, 0}, (edge){1, 2, 1}});
        if (x & 1) {
            auto p = solve(x - 1);
            p.second.push_back((edge){1, p.first, x - 1});
            return p;
        } else {
            auto p = solve(x >> 1); p.first++;
            for (auto &q : p.second) q.u++, q.v++, q.w <<= 1;
            p.second.push_back((edge){1, 2, 0});
            p.second.push_back((edge){1, 2, 1});
            return p;
        }
    };
    auto p = solve(L);
    printf("%d %d\n", p.first, p.second.size());
    for (auto q : p.second) printf("%d %d %d\n", q.u, q.v, q.w);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n,m;
  while(true)
    {
      cin>>n>>m;
      if(n==0)
	break;
      int sum=0;
      string num[n];
      int price[n];
      string kuzi[m];
      for(int i=0;i<n;i++)
	{
	  cin>>num[i]>>price[i];
	}
      for(int i=0;i<m;i++)
	  cin>>kuzi[i];
      for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	  {
	    for(int k=0;k<kuzi[j].size();k++)
	      {
		if(num[i][k]!=kuzi[j][k] &&num[i][k]!='*')
		  break;
		if(k==kuzi[j].size()-1)
		  sum+=price[i];
	      }
	  }
      cout<<sum<<endl;
    }
}

Measured memory_bytes: 1256
N, K = map(int,input().split())
A = [0] + list(map(int,input().split()))
#1 6 2 5 3 2 5 3 2 5 3
tmp = 1
list_tmp = [1]
set_tmp = set([1])
for n in range(K):
    #n回
    tmp = A[tmp]
    #print(tmp)
    if not tmp in set_tmp:
        set_tmp.add(tmp)
        list_tmp.append(tmp)
        ans = tmp
    else:
        
        list_loop = list_tmp[list_tmp.index(tmp):]
        
        ans = list_loop[(K-n-1)%len(list_loop)]
        break

print(ans)

Measured memory_bytes: 32376
n=int(input())
li=list(map(int,input().split()))

li.sort()
result1=li[len(li)-1]
result2=li[0]
re=[]
for i in range(1,len(li)-1):
  if li[i]<0:
    re.append([result1,li[i]])
    result1=result1-li[i]
  else:
    re.append([result2,li[i]])
    result2=result2-li[i]
               
re.append([result1,result2])
result1-=result2

print(result1)
for i in range(len(re)):
  print(re[i][0],re[i][1])

Measured memory_bytes: 22524
/* Coached by Dukkha and rainboy */
#include <stdio.h>
#include <stdlib.h>

int main() {
	int n, t_, x_, y_;

	scanf("%d", &n);
	t_ = x_ = y_ = 0;
	while (n--) {
		int t, x, y, a, b;

		scanf("%d%d%d", &t, &x, &y);
		a = t - t_;
		b = abs(x - x_) + abs(y - y_);
		if (a < b || (a ^ b) & 1) {
			printf("No\n");
			return 0;
		}
		t_ = t, x_ = x, y_ = y;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
  long long int n,i,a[100000],b[100000];
  scanf("%lld",&n);
  long long int max=0,index=0;
  for(i=0;i<n;i++){
    scanf("%lld%lld",&a[i],&b[i]);
    if(max<a[i]){
      max=a[i];
      index=i;
    }
  }
  printf("%lld",max+b[index]);
  return 0;
}

Measured memory_bytes: 1664
n=int(input())
d1={}
for i in range(n):
	a=input()
	if a in d1:
		d1[a]+=1
	else:
		d1.update({a:1})
n=int(input())
for i in range(n):
	a=input()
	if a in d1:
		d1[a]-=1
	else:
		d1.update({a:-1})
print('0'if max(d1.values())<0 else max(d1.values()))


Measured memory_bytes: 3060
//rozwiazanie wzorcowe
//Autor: Kacper Walentynowicz
//O(n + m)
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int n, m, a, b, ile[maxn + 1], cza[maxn + 1];
int main()
{
	ios_base::sync_with_stdio(0);
	cza[1] = 1;
	cin >> n >> m;
	for (int i=1; i<=n; ++i) ile[i] = 1;
	for (int i=1; i<=m; ++i)
	{
		cin >> a >> b;
		if (ile[a] > 0)
		{
			ile[a]--;
			ile[b]++;
			//wazne: nie zamienic kolejnosci ponizszych ifow
			if (cza[a]) cza[b] = 1;
			if (ile[a] == 0) cza[a] = 0;
		}
	}
	
	int res = 0;
	for (int i=1; i<=n; ++i) res += cza[i];
	cout << res;
}


Measured memory_bytes: 1024
import sys

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

H = H[::-1]

for i in range(N-1):
    if H[i+1] - H[i] > 1:
        print('No')
        sys.exit()
    elif H[i+1] - H[i] == 1:
        H[i+1] -= 1
    else:
        pass    

print('Yes')

Measured memory_bytes: 20528
n, k = map(int, input().split())
alst = list(map(int, input().split()))

if k == 0:
    print(max(alst))
    exit()

l = 1
r = max(alst)

while r != l:
    pos = (r + l) // 2
    cnt = 0
    for a in alst:
        cnt += (a - 1) // pos
    if cnt <= k:
        r = pos
    else:
        l = pos + 1
print(r)

Measured memory_bytes: 30820
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

map<ll, ll> primeFactors(ll n)  
{  
    map<ll, ll> m1;
    while (n % 2 == 0)  
    {  
        m1[2]++;
        n = n/2;  
    }  
  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            m1[i]++;
            n = n/i;  
        }  
    }  

    if (n > 2) {
        m1[n]++;
    }
    return m1;
}  

int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    map<ll, ll> m1 = primeFactors(n);

    ll ans=0;
    for (auto i = m1.begin(); i != m1.end(); ++i)
    {
        ll pow = i->S;
        ll start=1;
        while((pow-start)>=0){
            pow = pow-start;
            ans++;
            start++;
        }
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < N; i++)
#define rep2(i, x, n) for (int i = x; i < N; i++)
using ll = long long int;
int main() {
    int N=0;
    ll D=0;
    cin >> N >> D;
    D *= D;
    vector<ll> X(N);
    vector<ll> Y(N);
    int ans=0;
    rep(i, n) {
        cin >> X.at(i) >> Y.at(i);
        X.at(i) *= X.at(i);
        Y.at(i) *= Y.at(i);
        if (X.at(i) + Y.at(i) <= D) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6376
#include<iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;

signed main() {
    int N;
    cin >> N;
    vector< vector<int> > graph(N,vector<int>(N));
    for(int i=0; i<N ;i++){
        for(int j=0; j<N ; j++){
            cin >> graph[i][j];
        }
    }
    int ans=0;
    for(int i = 0; i< N-1; i++){
        for(int j= i+1 ; j<N; j++){
            ans+= min(graph[i][j],graph[j][i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3252
import sys
def input(): return sys.stdin.readline().strip()


def main():
    L = list(map(int, input().split()))
    L.sort()
    a, b, c = L[0], L[1], L[2]
    ans = c - b
    a += ans
    if (c - a) % 2 != 0:
        ans += 1
        c += 1
    print(ans + (c - a) // 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61808
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ");
int main()
{
    ll n;
    cin >> n;
    string s[n];
    vl t(n);
    rp(i, 0, n) cin >> s[i] >> t[i];
    string x;
    cin >> x;
    ll ans = 0;
    pr(i, 0, n)
    {

        if (s[i] == x)
        {
            cout << ans << endl;
            break;
        }
        else
        {
            ans += t[i];
        }
    }
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int A, B, a, b, count=0;
	
	cin >> A >> B;
	
	for(int i=A; i<=B; i++){
		a = i;
		b = 0;
		while(a != 0){
			b *= 10;
			b += a%10;
			a /= 10;
		}
		
		if(i == b)
			count++;
	}
	
	cout << count;
	
	return 0;
}

Measured memory_bytes: 256
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time

setrecursionlimit(10**6)
input=stdin.readline

class Union_find:
    
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rank=[0]*(n+1)
    
    def find_root(self,x):
    
        if self.root[x]<0: return x
        else:
            self.root[x]=self.find_root(self.root[x])
            return self.root[x]
    
    def unite(self,x,y):
    
        x,y=self.find_root(x),self.find_root(y)
    
        if x==y: return 
        elif self.rank[x]>self.rank[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if self.rank[x]==self.rank[y]: self.rank[y]+=1
    
    def same(self,x,y):
        return self.find_root(x)==self.find_root(y)
    
    def count(self,x):
        return -self.root[self.find_root(x)]

v,e=map(int,input().split())
graph=Union_find(v)

a=sorted([list(map(int,input().split())) for _ in range(e)],key=itemgetter(2))
ans=0
for i in a:
    s,t,w=i
    if not graph.same(s,t):
        graph.unite(s,t)
        ans+=w
print(ans)


Measured memory_bytes: 29208
#include<cstdio> 
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int a[10000];
	int b[10000];
	int i;
	int p = 0;
	cin >> i;
	int o = i;
	while(i--){
		cin >> a[p];
		cin >> b[p];
		p++;
	}
	int s=0;
	for(int i = 0; i < o-2; i++){
		if (a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
			s=1;
		}
	}
	if (s==1){
		cout << "Yes";
	}
	else cout << "No";
}

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

int main()
{
  std::vector<int> times(5);
  int smallestOnes = 10;
  int smallestIndex = 0;
  for(int i = 0; i < 5; ++i){
	std::cin >> times[i];
    int one = times[i] % 10;
    if(one != 0 && one < smallestOnes){
	  smallestOnes = one;
      smallestIndex = i;
    }
  }
  int minTotalTime = 0;
  for(int i = 0; i < 5; ++i){
    if(i != smallestIndex && times[i] % 10 != 0){
      int necessaryTime = times[i] + 10 - times[i] % 10;
	  minTotalTime += necessaryTime;
    }
    else{
	  minTotalTime += times[i];
    }
  }
  std::cout << minTotalTime;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}





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


  ll A , B ; cin  >> A >> B ;
  string S; cin >> S ;
  rep(i,S.size()){
    if(i==A) continue;
    if( S[i]<'0' || S[i] > '9'){
      cout << "No" << endl;
      return 0;
    }
  }

  if(S[A] == '-') cout << "Yes" << endl;
  else cout << "No" << endl; 
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#coding: utf-8                          
import numpy as np                      
                                        
ABC = [int(i) for i in input().split()] 
diff1 = max(ABC) - min(ABC)             
diff2 = max(ABC) - int(np.median(ABC))  
                                        
count = (diff1 + diff2)/2               
if not diff1 % 2 == diff2 % 2:          
  count += 2                            
                                        
print(int(count))                       


Measured memory_bytes: 12500
/*
 * Name        : e
 * Creat       : Thu Jul 11 20:58:36 CST 2019
 * Accept      : Thu Jul 11 21:10:27 CST 2019
 * Author      : landcold7
 * Motivation  : Action speaks louder more than words
 */
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define sz(x) ((int)(x).size())
#ifndef _has_trace
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
  }
  int s, t;
  cin >> s >> t;
  s--, t--;
  const int inf = (1 << 30);
  vector<vector<int>> dist(n, vector<int>(3, inf));
  deque<pair<int, int>> dq;
  dq.emplace_back(s, 0);
  dist[s][0] = 0;
  while (!dq.empty()) {
    auto u = dq.front().x;
    auto l = dq.front().y;
    dq.pop_front();
    for (auto v : g[u]) {
      int nl = (l + 1) % 3;
      if (dist[v][nl] == inf) {
        dist[v][nl] = dist[u][l] + 1;
        dq.emplace_back(v, nl);
      }
    }
  }
  trace(dist);
  cout << (dist[t][0] == inf ? -1 : dist[t][0] / 3) << "\n";
}

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


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

int a, b, c, k, f = 0;

void dfs(int A, int B, int C, int cnt) {
  if (cnt == k) {
    if (A < B && B < C) f = 1;
    return;
  }
  dfs(2 * A, B, C, cnt + 1);
  dfs(A, 2 * B, C, cnt + 1);
  dfs(A, B, 2 * C, cnt + 1);
}

int main() {
  cin >> a >> b >> c >> k;
  dfs(a, b, c, 0);
  puts(f ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K, Q; 
  cin >> N >> K >> Q;

  vector<int> point(N, K-Q);
  while(Q--){
    int a;
    cin >> a;
    point[a-1]++;
  }

  REP(i, N){
    if(point[i] > 0) Yes;
    else No;
  }

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include<stdio.h>
#define MAXSIZE 10000
#define PI 3.141592653589
using namespace std;
int main(){
  int n;
  std::cin >> n;
  int a[4][13]={0};

  
  for(int i=0;i<n;i++){
    char c;
    int x;
    std::cin >> c>>x;
    if(c=='S'){
      a[0][x-1]=1;
    }else if(c=='H'){
      a[1][x-1]=1;
    }else if(c=='C'){
      a[2][x-1]=1;
    }else if(c=='D'){
      a[3][x-1]=1;
    }
  }

  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
      if(a[i][j]==0&&i==0){
        std::cout << "S "<<j+1 << '\n';
      }else if(a[i][j]==0&&i==1){
        std::cout << "H "<<j+1 << '\n';
      }else if(a[i][j]==0&&i==2){
        std::cout << "C "<<j+1 << '\n';
      }else if(a[i][j]==0&&i==3){
        std::cout << "D "<<j+1 << '\n';
      }
    }
  }

}

Measured memory_bytes: 3100
import sys
import numpy as np

n, m, *lr = map(int, sys.stdin.read().split())
l, r = np.array(lr).reshape(-1, 2).T

def main():
    res = max(0, r.min() - l.max() + 1)
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 33608
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        a: [u64;5],
    }

    println!("{}", (a[2] * 60 + a[3]) - (a[0] * 60 + a[1]) - a[4]);
}


Measured memory_bytes: 2108
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        char c=(char)(1+sc.nextString().toCharArray()[0]);
 
        out.println(c);
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

//
//class P implements Comparable<P>{
//    int id,ds,p;
//    P(int id, int ds, int p) {
//    	this.id=id;
//    	this.ds=ds;
//    	this.p=p;
//    }
//
//    public int compareTo(P p){
//        return ds-p.ds;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23252
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
typedef long long ll;

using namespace std;

int main(){
	int N;
	cin >> N;
  	ll sum = 0;
  	sum = (ll)N*(N-1)/2;
  	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int FFTN=1<<19,N=FFTN+5,mo=924844033;
int W[N],w[N],p[N];
poly R;
int ksm(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mo){
		if(p&1) res=(ll)res*x%mo;
	}
	return res;
}
void FFTinit(){
	W[0]=1;W[1]=ksm(5,(mo-1)/FFTN);
	For(i,2,N-1) W[i]=(ll)W[i-1]*W[1]%mo;
}
int FFTinit(int n){
	int L=1;for(;L<=n;L<<=1);R.resize(L);
	For(i,0,L-1) R[i]=(R[i>>1]>>1)|((i&1)?(L>>1):0);
	return L;
}
void DFT(poly &a,int n){
	a.resize(n);For(i,0,n-1) p[R[i]]=a[i];
	for(int d=1;d<n;d<<=1){
		int len=FFTN/(d<<1);
		for(int i=0,j=0;i<d;i++,j+=len) w[i]=W[j];
		for(int i=0;i<n;i+=(d<<1)){
			For(j,0,d-1){
				int y=(ll)w[j]*p[i+j+d]%mo;
				p[i+j+d]=(p[i+j]-y+mo)%mo;
				p[i+j]=(p[i+j]+y)%mo;
			}
		}
	}
	For(i,0,n-1) a[i]=p[i];
}
void IDFT(poly &a,int n){
	DFT(a,n);reverse(a.begin()+1,a.end());
	int inv=ksm(n,mo-2);
	For(i,0,n-1) a[i]=(ll)a[i]*inv%mo;
}
int head[N],opt,f[N];
struct info{
	int to,nxt;
}e[N<<1];
void add(int x,int y){
	e[++opt]=(info){y,head[x]};head[x]=opt;
	e[++opt]=(info){x,head[y]};head[y]=opt;
}
int sz[N];
void dfs(int n,int u,int fa){
	sz[u]=1;
	for(int i=head[u];i;i=e[i].nxt){
		int k=e[i].to;
		if(k==fa) continue;
		dfs(n,k,u);sz[u]+=sz[k];
		f[sz[k]]++;
	}
	if(fa) f[n-sz[u]]++;
}
int fac[N],inv[N];
void init(int n){
	For(i,fac[0]=1,n) fac[i]=(ll)fac[i-1]*i%mo;
	inv[n]=ksm(fac[n],mo-2);
	Rep(i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
}
int C(int n,int m){
	if(n<m) return 0;
	return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
poly a,b;
poly mul(poly a,poly b){
	int n=a.size(),m=b.size(),len=FFTinit(n+m);
	DFT(a,len);DFT(b,len);
	For(i,0,len-1) a[i]=(ll)a[i]*b[i]%mo;
	IDFT(a,len);return a;
}
int main(){
	// freopen("ssw.in","r",stdin);freopen("ssw.out","w",stdout);
	init(N-1);FFTinit();
	int n=read();
	For(i,1,n-1) add(read(),read());
	dfs(n,1,0);
	a.resize(n+1);For(i,0,n) a[i]=(ll)f[i]*fac[i]%mo;
	b.resize(n+1);For(i,0,n) b[i]=inv[i];
	reverse(b.begin(),b.end());
	a=mul(a,b);
	For(i,1,n) a[n+i]=(ll)a[n+i]*inv[i]%mo;
	For(i,1,n) writeln(((ll)C(n,i)*n%mo-a[n+i]+mo)%mo);
}

Measured memory_bytes: 48180
#include<stdio.h>
int main(){
  int i,j,n,x,count,b;
  while(1){
    count=0;
    scanf("%d %d",&n,&x);
    if(n==0&&x==0){
      break;
    }
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	for(b=j+1;b<=n;b++){
	  if(i+j+b==x){
	    count++;
	  }
	}
      }
    }
    printf("%d\n",count);
  
  }
  return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+500;
char a[N]={0};
char b[N]={0};
int a1[30]={0};
int b1[30]={0};
int vis1[30]={0};
int main()
{
    scanf("%s",a);
    scanf("%s",b);
    for(int i=0;a[i];i++)
    {
        int p=a[i]-'a';
        a1[p]++;
        p=b[i]-'a';
        b1[p]++;
    }
    for(int i=0;i<26;i++)
    {
        int flag=1;
        for(int j=0;j<26&&flag;j++)
        {
            if(a1[i]==b1[j]&&!vis1[j])
            {
                flag=0;
                vis1[j]=1;
            }
        }
        if(flag)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 640