akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;


struct RMQ{
    int size;
    LL sum;
    vector<LL> data;
    RMQ(int n){
        size = 1;
        while(size < n)size *= 2;
        data.assign(2*size-1, 1LL<<60);
        sum = 0;
    }
    void update(int pos, LL val){
        pos += size-1;
        data[pos] = val - sum;
        while(pos>0){
            pos = (pos-1)>>1;
            data[pos] = min(data[2*pos+1], data[2*pos+2]);
        }
    }
    LL query(int a, int b, int k, int l, int r){
        if(b<=l || r<=a)return 1LL<<60;
        if(a<=l && r<=b)return data[k];
        int mid = (l+r)>>1;
        return min(query(a,b,2*k+1,l,mid), query(a,b,2*k+2,mid,r));
    }
    LL query(int left, int right){
        return query(left, right, 0, 0, size) + sum;
    }
    void add(LL val){
        sum += val;
    }
};

void update(RMQ &minus, RMQ &plus, int pos, LL val){
    minus.update(pos, val-pos);
    plus.update(pos, val+pos);
}

void add(RMQ &minus, RMQ &plus, LL val){
    minus.add(val);
    plus.add(val);
}

LL search(RMQ &minus, int N){
    LL res = 1LL<<62;
    REP(i, N){
        res = min(res, minus.query(i, i+1) + i);
    }
    return res;
}

int main(){
    int N, Q, A, B;
    cin >> N >> Q >> A >> B;
    A--;
    B--;
    RMQ minus = RMQ(N);
    RMQ plus = RMQ(N);
    int prev = B;
    update(minus, plus, A, 0);
    REP(i, Q){
        int x;
        cin >> x;
        x--;
        LL res = min(minus.query(0, x+1)+x, plus.query(x, N)-x);
        add(minus, plus, abs(prev-x));
        update(minus, plus, prev, res);
        prev = x;
    }
    cout << search(minus, N) << endl;
    return 0;
}


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

char maze[101][101];

int main(){
  int white, black;
  cin >> white >> black;
  white--;
  black--;
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 100; j++) {
      maze[i][j] = '.';
    }
  }
  for (int i = 50; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      maze[i][j] = '#';
    }
  }
  for (int i = 0; i < 50; i += 2) {
    for (int j = 0; j < 100; j += 2) {
      if (black > 0) {
        maze[i][j] = '#';
        black--;
      } else {
        break;
      }
    }
  }
  for (int i = 51; i < 100; i += 2) {
    for (int j = 0; j < 100; j += 2) {
      if (white > 0) {
        white--;
        maze[i][j] = '.';
      } else {
        break;
      }
    }
  }
  cout << "100 100" << endl;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      cout << maze[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) {
      cin >> h.at(i);
    }
    int ans = 0;

    for (int a : h) {
        if (k <= a) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
    }

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll n,a,b,c,d;
int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	d-=c;
	rep(i,0,n){
		//減らすのをi回
		ll kihon=(n-1-2*i)*c;
		ll upper=d*(n-1-i);
		ll lower=-d*i;
		if(kihon+lower<=b-a&&b-a<=kihon+upper){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
X = [int(i) for i in input().split()]
if X[1]==0:
    print(X[0])
else:
        
    P = [int(i) for i in input().split()]
    N=sorted(P)
    # print(N)
    s=0
    flag=0
    
    for i in range(100):
        if (X[0]-i) in N:
            s=1
        else:
            flag=1
            
        if (X[0]+i) in N:
            s=s+1
        else:
            if flag!=1:
                flag=2
        
        if flag==1:
            
            print(X[0]-i)
            break
    
        if flag==2:
            print(X[0]+i)
            break

Measured memory_bytes: 9224
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	// 繰り上げ金額の単位(円)
	private static final int ROUND_UNIT = 1000;

	// 利子
	private static final double LOAN_INTEREST = 1.05;

	/**
	 * 返済額計算実行
	 */
	public static void main(String[] args) throws Exception {

		// 標準入力
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		// 返済額の計算
		new Main().calcAmountRepaid(Integer.parseInt(reader.readLine()));
	}

	/**
	 * 返済額計算
	 */
	private void calcAmountRepaid(int weekNum) {

		// 借金10万円を初期値とする
		int debt = 100000;

		// 週単位で返済額を計算
		for (int i = 0; i < weekNum; i++) {

			// 利子込みの返済額を計算
			debt *= LOAN_INTEREST;

			// 計算結果から1000円未満を切り上げ
			if (debt % ROUND_UNIT != 0) {
				debt = ROUND_UNIT * (debt / ROUND_UNIT + 1);
			} else {
				debt = ROUND_UNIT * (debt / ROUND_UNIT);
			}

		}

		// 結果出力
		System.out.println(debt);

	}

}

Measured memory_bytes: 16856
#include <stdio.h>

int main(void)
{
	int a = 0,b = 0,c = 0;
	scanf("%d%d%d",&a,&b,&c);
	
	if(a >= b && a >= c && a == b + c){
		printf("Yes\n");
	}else if(b >= a && b >= c && b == a + c)
		printf("Yes\n");
	else if(c >= a && c >= b && c == a + b)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#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 <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//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)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int n,a,b,c;
int main(int argc, char const *argv[])
{
	cin >> n;
	a = n*800;
	b = 200*(n/15);

	cout << a-b  << endl;

	return 0;
}

Measured memory_bytes: 764
import math
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
C = A - B

def judge(t):
    count = 0
    Bt = B * t
    for i in range(N):
        numerator = h[i] - Bt
        count += max(math.ceil(numerator / C), 0)
    return count <= t

left = 0
right = math.ceil(10**9 // B) + 1
mid = (left + right) // 2
while right - left > 1:
    if judge(mid):
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right)


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


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

    string s;
    cin >> s;

    if(n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    string former = "";

    for(int i = 0; i < n / 2; i++){
        former += s.at(i);
    }

   string ans = former + former;

   if(s == ans){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
cumsum = [0]
cumsumx = [0]
for i in range(N):
  cumsum.append(cumsum[i] + A[i])
  cumsumx.append(cumsumx[i] ^ A[i])
res = 0
"""
for i in range(1, N + 1):
  for j in range(i, N + 1):
    #print(i, j, cumsum[j - 1] - cumsum[i], cumsumx[j] ^ cumsumx[i - 1])
    if cumsum[j] - cumsum[i - 1] == cumsumx[j] ^ cumsumx[i - 1]:
      res += 1
"""   
for i in range(1, N + 1):
  l = i
  r = N
  j = (l + r) / 2

  while True:
    j = (l + r) // 2
    if r - l < 2:
      #print(i, j, l, r)
      break
    if cumsum[j] - cumsum[i - 1] == cumsumx[j] ^ cumsumx[i - 1]:
      l = j
    else:
      r = j
  #print(i, j)
  if j < N:
    if cumsum[j + 1] - cumsum[i - 1] == cumsumx[j + 1] ^ cumsumx[i - 1]:
        j += 1
  res += j - i + 1
    
print(res)
#print(cumsum)
#print(cumsumx)


Measured memory_bytes: 100300
x = int(input())

testa = 0
while True:
    testb = int((abs((testa**5)-x))**(0.2))
    if testa**5 - x < 0:
        testb *= -1
    if (testa**5-testb**5) == x:
        print(testa,testb)
        exit()
    testa += 1


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define INF (INT_MAX>>2)


template<class PAIR_T, class DIST_T>
bool dijkstra(const vector<vector<PAIR_T>>& graph, int start, vector<DIST_T>& dist, vector<int>& prev) {
    int n = graph.size();
    dist.resize(n);
    prev.resize(n); fill(prev.begin(), prev.end(), -1);
    fill(dist.begin(), dist.end(), INF);
    vector<bool> done(n, false);
    priority_queue<pair<DIST_T, int>, vector<pair<DIST_T, int>>, greater<pair<DIST_T, int>>> q;
    dist[start] = 0;
    q.emplace(0, start);
    while (!q.empty()) {
        auto p = q.top(); q.pop();
        const auto& v = p.second, d = p.first;
        if (d > dist[v]) continue;
        dist[v] = d;
        done[v] = true;
        for (const auto& e : graph[v]) {
            const auto& ev = e.second, ed = e.first;
            if (done[ev]) continue;
            if (dist[v] + ed < dist[ev]) {
                dist[ev] = dist[v] + ed;
                prev[ev] = v;
                q.emplace(dist[ev], ev);
            }
        }
    }
    return true;
}

int main()
{
    int N, M; cin >> N >> M;
    vector<vector<pii>> g(N+1);

    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        g[a].emplace_back(1, b);
        g[b].emplace_back(1, a);
    }
    vector<int> dist;
    vector<int> prev;

    dijkstra(g, 1, dist, prev);

    bool yes = true;

    if (yes) {
        cout << "Yes" << endl;
        for (int i = 2; i <= N; i++) {
            cout << prev[i] << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


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

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

    if(a > b) {
        rep(i, a) {
            cout << b;
        }
        cout << endl;
    } else {
        rep(i, b) {
            cout << a;
        }
        cout << endl;
    }

    return 0;
}

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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int h,w,memo = 0;
    
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        rep(i,0,h){
            rep(j,0,w){
                if(i % 2 == 0 && j % 2 == 0) cout << "#";
                else if(i % 2 != 0 && j % 2 != 0) cout << "#";
                else cout << '.';
                memo++;
                
            }
            cout << endl;
        }
        cout << endl;
    
    }
    
    
    return 0;
}


Measured memory_bytes: 3156
import numpy as np

N, W = map(int, input().split())

dp = np.zeros((N+1, W+1), dtype =int)

for i in range(1, N+1):
    w, v = map(int, input().split())
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.maximum( dp[i-1, w:], dp[i-1, :W+1-w] + v )

print(dp[N,:].max())

Measured memory_bytes: 92344
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

int inf = 1e9+7;
int path[107][107],ind[107][107];
int main(){
	int n,m;
	int u,v,w;
	
	cin >> n >> m;
	
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=n;j++){
			path[i][j] = inf;
			ind[i][j] = inf;
		}
	}
	while(m--){
		cin >> u >> v >> w;
		path[u][v] = w;
		path[v][u] = w;
		ind[u][v] = w;
		ind[v][u] = w;
	}
	
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=n;j++){
			for(int k = 1;k<=n;k++){
				path[j][k] = min(path[j][k],path[j][i]+path[i][k]);
			}
		}
	}
	int ans = 0;
	for(int i = 1;i<=n;i++){
		for(int j = i+1;j<=n;j++){
			if(ind[i][j]!=inf&&ind[i][j]>path[i][j]) ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cctype>

using namespace std;

const int MAX = 9;
const int TOP = 0;
const int RIGHT = 1;
const int BOTTOM = 2;
const int LEFT = 3;

bool used[MAX];
string puz[MAX];
string tmp[MAX];
int ans;

void rotate(int n){
  string s = "";
  s = puz[n].substr(1);
  s += puz[n][0];
  puz[n] = s;
}

bool able(int n){
  //top
  if(n >= 3){
    char c1 = tmp[n-3][BOTTOM];
    char c2 = tmp[n][TOP];
    if(c1 == c2 || tolower(c1) != tolower(c2)) return false;
  }

  //left
  if(n % 3){
    char c1 = tmp[n-1][RIGHT];
    char c2 = tmp[n][LEFT];
    if(c1 == c2 || tolower(c1) != tolower(c2)) return false;
  }
  return true;
}

void solve(int n){
  //  cout << n << endl;
  if(n == 9){
    ans++;
    return;
  }

  for(int i = 0; i < 9; i++){
    if(used[i]) continue;
    
    for(int j = 0; j < 4; j++){
      rotate(i);
      tmp[n] = puz[i];
      used[i] = true;
      if(able(n)) solve(n+1);
      used[i] = false;
    }
  }
}

int main(){

  int n;
  cin >> n;
  while(n--){
    for(int i = 0; i < 9; i++) cin >> puz[i];
    ans = 0;
    solve(0);
    cout << ans << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
#define Graph vector<vector<int>>
using namespace std;

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

        map<int,int> m;
        rep(i,n)
        {
                int a; cin>>a;
                m[a]++;
        }

        long ans=0;
        each(it,m)
        {
                if(it.second==it.first)continue;
                if(it.second>it.first)ans+=it.second-it.first;
                else ans+=it.second;
        }

        cout<<ans<<endl;
}

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

int main(){
  int x, y;
  cin >> x >> y;
  if (x < y)
    swap(x, y);

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



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a=0,b=0,c=0,x,y,t;
  for(int i=n;i>0;i--){
    cin>>t>>x>>y;
    if(t-c<abs(a-x)+abs(b-y)||(t-c)%2!=(abs(a-x)+abs(b-y))%2){
      cout << "No";
      return 0;
    }
    a=x;
    b=y;
    c=t;
  }
  cout << "Yes";
}


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

using ll = long long;

int main() {
	int H, W; cin >> W >> H;
	ll res = 0;
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> q;
	for (int i = 0; i < W; i++) {
		ll x; cin >> x; q.emplace(x, 0);
	}
	for (int i = 0; i < H; i++) {
		ll x; cin >> x; q.emplace(x, 1);
	}
	vector<ll> cnt{H+1, W+1};
	while (q.size()) {
		auto p = q.top(); q.pop();
		ll x = p.first; int i = p.second;
		res += x * cnt[i];
		cnt[1-i]--;
	}
	cout << res << endl;
}

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

using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

void discount_fare()
{
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << "\n";
}


void A_114()
{
  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES\n";
  else cout << "NO\n";
}


void christmas_eve_eve_eve()
{
  int d;
  cin >> d;

  if (d == 25) cout << "Christmas\n";
  else if (d == 24) cout << "Christmas Eve\n";
  if (d == 23) cout << "Christmas Eve Eve\n";
  if (d == 22) cout << "Christmas Eve Eve Eve\n";
}


void right_triangle()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << a * b / 2 << "\n";
}


void entrance_examination()
{
  int t, x;
  cin >> t >> x;

  cout << (double)t / (double)x << "\n";
}


void A_118()
{
  int a, b;
  cin >> a >> b;

  if (b % a == 0) cout << a + b << "\n";
  else cout << b - a << "\n";
}


void still_TBD()
{
  string s;
  cin >> s;

  if (s[5] == '1' || s[6] >= '5') cout << "TBD\n";
  else cout << "Heisei\n";
}


void favorite_sound()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << min(b / a, c) << "\n";
}


void atcoder_beginner_contest111()
{
  int n;
  cin >> n;

  if (n % 111 == 0) cout << n << "\n";
  else
  {
    int a = n / 111;
    ++a;
    cout << a * 111 << "\n";
  }
}


int main()
{
  //atcoder_beginner_contest999();
  //programming_education();
  //discount_fare();
  //A_114();
  //christmas_eve_eve_eve();
  //right_triangle();
  //entrance_examination();
  //A_118();
  //still_TBD();
  //favorite_sound();

  atcoder_beginner_contest111();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint x,y;std::cin>>x>>y;
    std::cout<<(x*(x-1)/2+y*(y-1)/2)<<'\n';
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] V = new int[N];
        for (int i = 0; i < N; i++) {
            V[i] = sc.nextInt();
        }

        List<Integer> sums = new ArrayList<>();
        for (int countA = 0; countA <= K; countA++) {
            for (int countB = 0; countB <= (K - countA); countB++) {
                int countCD = K - countA - countB;

                // 持っている宝石の価値のリスト
                List<Integer> havings = new ArrayList<>();

                // キューを作成
                Deque<Integer> queue = new ArrayDeque();
                for (int i = 0; i < N; i++) {
                    queue.addLast(V[i]);
                }

                // 操作A
                for (int i = countA; i > 0; i--) {
                    Integer tmp = queue.pollFirst();
                    if (tmp == null) {
                        break;
                    }
                    havings.add(tmp);
                }

                // 操作B
                for (int i = countB; i > 0; i--) {
                    Integer tmp = queue.pollLast();
                    if (tmp == null) {
                        break;
                    }
                    havings.add(tmp);
                }
                // 操作CD
                // List<Integer> finalHaving = new ArrayList<>();
                Collections.sort(havings);
                List<Integer> removeList = new ArrayList<>();
                for (Integer having : havings) {
                    if (having < 0 && countCD > 0) {
                        removeList.add(having);
                    } else {
                        break;
                    }
                    countCD--;
                }
                int sum = 0;
                for (Integer having : havings) {
                    if (!removeList.contains(having)) {
                        sum += having;
                    }
                }
                sums.add(sum);
            } // 内 for
        } // 外 for

        Collections.sort(sums, Collections.reverseOrder());
        System.out.print(sums.get(0));
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 39484
import sys

input = sys.stdin.readline


def main():
    n = int(input())

    fib = [1] * 46
    for i in range(2, 46):
        fib[i] = fib[i - 1] + fib[i - 2]

    ans = fib[n]
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5600
n = int(input())
 
def aa(str, chrMax):
  if len(str) == n:
    print(str)
    return
  for i in range(ord("a"), ord(chrMax)+2):
    if i > ord(chrMax):
      aa(str+chr(i), chr(i))
    else:
      aa(str+chr(i), chrMax)
 
aa("a", "a")

Measured memory_bytes: 4404
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scanf("%d", &A)
	fmt.Scanf("%d", &B)

	for i := 0; i < 3; i++ {
		if A-1 == i || B-1 == i {
			continue
		} else {
			fmt.Println(i + 1)
		}
	}
}


Measured memory_bytes: 1832
#include <iostream> 

using namespace std;

int main(int argc, char *argv[]) {
	int A, B, C;
	cin >> A >> B >> C;

	int ans = 0;
	int M = max(A, max(B, C));

	while (M - A >= 2) { A += 2; ans++; }
	while (M - B >= 2) { B += 2; ans++; }
	while (M - C >= 2) { C += 2; ans++; }

	int m = min(A, min(B, C));
	if (m < A) { A--; ans++; }
	if (m < B) { B--; ans++; }
	if (m < C) { C--; ans++; }

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

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

void solve(long long A, long long B, long long T)
{
    long long n = 0;
    n = floor((T + 0.5) / A);
    long long sum = 0;
    sum = (n * B);
    cout << sum << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long T;
    scanf("%lld", &T);
    solve(A, B, T);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = list(input())
one_two_pair = (["S", "S"], ["S", "W"], ["W", "S"], ["W", "W"])
for one_two in one_two_pair:
    ans = one_two
    for i in range(1, N - 1):
        left = ans[i - 1]
        now = ans[i]
        ox = s[i]
        if now == "S":
            if ox == "o":
                if left == "S":
                    ans.append("S")
                else:
                    ans.append("W")
            else:
                if left == "S":
                    ans.append("W")
                else:
                    ans.append("S")
        elif now == "W":
            if ox == "o":
                if left == "S":
                    ans.append("W")
                else:
                    ans.append("S")
            else:
                if left == "S":
                    ans.append("S")
                else:
                    ans.append("W")
    first, last = False, False
    left = ans[-1]
    now = ans[0]
    right = ans[1]
    if now == "S":
        if s[0] == "o":
            first = (left == right)
        else:
            first = (left != right)
    else:
        if s[0] == "o":
            first = (left != right)
        else:
            first = (left == right)

    left = ans[-2]
    now = ans[-1]
    right = ans[0]
    if now == "S":
        if s[-1] == "o":
            last = (left == right)
        else:
            last = (left != right)
    else:
        if s[-1] == "o":
            last = (left != right)
        else:
            last = (left == right)

    if first and last:
        print("".join(ans))
        break

else:
    print(-1)


Measured memory_bytes: 7340
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	cout << a[2] * 10 + a[1] + a[0] << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    ll k,n; cin>>k>>n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    
    int min = 1e9;
    
    min = a[n-1]-a[0];
    rep(i,n-1){
        if(k-(a[i+1]-a[i]) < min) min = k-(a[i+1]-a[i]);
    }
    cout << min << ln;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int x; 
    cin >> x;
    if(x==0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

const int MAXN = 310, MOD = 1e9 + 7;
inline int mul(int x, int y) { return 1LL * x * y % MOD; }
inline void Add(int &x, int y) { (x += y) >= MOD && (x -= MOD); }
inline void Mul(int &x, int y) { x = 1LL * x * y % MOD; }

int n, m, tot, QAQ;
int a[MAXN * 2], b[MAXN * 2], c[MAXN * 2], dp[MAXN * 2][MAXN][MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n * 2; ++i) scanf("%d", a + i);
	for (int i = 1; i <= n * 2; i += 2)
		if (a[i] == -1 || a[i + 1] == -1) {
			++m;
			if (~a[i]) b[a[i]] = 1;
			else if (~a[i + 1]) b[a[i + 1]] = 1;
			else ++QAQ;
		} else b[a[i]] = b[a[i + 1]] = -1;
	for (int i = 1; i <= n * 2; ++i) if (~b[i]) c[++tot] = b[i];
	dp[m * 2 + 1][0][0] = 1;
	for (int i = 1; i <= QAQ; ++i) Mul(dp[m * 2 + 1][0][0], i);
	for (int i = m * 2; i; --i)
		for (int j = 0; j <= m; ++j)
			for (int k = 0; j + k <= m; ++k) if (c[i]) {
				if (j + k < m) Add(dp[i][j + 1][k], dp[i + 1][j][k]);
				if (k) Add(dp[i][j][k - 1], dp[i + 1][j][k]);
			} else {
				if (j + k < m) Add(dp[i][j][k + 1], dp[i + 1][j][k]);
				if (j) Add(dp[i][j - 1][k], mul(dp[i + 1][j][k], j));
				if (k) Add(dp[i][j][k - 1], dp[i + 1][j][k]);
			}
	printf("%d\n", dp[1][0][0]);
	return 0;
}

Measured memory_bytes: 227200
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int h[]=new int[n];
    int b[]=new int[n];
    int c=0;
    for(int i=0;i<n;i++)
    {
      h[i]=sc.nextInt();
     b[i]=0;
    }
    int x,z;
    for(int i=0;i<m;i++)
    {
      x=sc.nextInt();
      z=sc.nextInt();
      b[x-1]=Math.max(b[x-1],h[z-1]);
        b[z-1]=Math.max(b[z-1],h[x-1]);
    }
    
     for(int i=0;i<n;i++)
     {
       if(h[i]>b[i])
       {
        // System.out.println(i+1);
         c++;
       }
         
       
     }
    
    
     System.out.println(c);
    
  }
}

Measured memory_bytes: 60252
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x,t;
    cin>>x>>t;



    cout<<((x-t)>=0 ? x-t:0 )<<endl;
   
    return 0;
}

Measured memory_bytes: 256
def est_time(sta,N,csf_list):
  SUM = 0
  for i in range(sta,N):
    if i == sta:
      SUM += csf_list[i-1][0] + csf_list[i-1][1]
    else:
      if SUM >= csf_list[i-1][1]:
        SUM = ((SUM+csf_list[i-1][2]-1) // csf_list[i-1][2])*csf_list[i-1][2]
        SUM += csf_list[i-1][0]
      else:
        SUM = csf_list[i-1][1]
        SUM += csf_list[i-1][0]
  return SUM

N=int(input())
csf_list=[tuple(map(int,input().split())) for _ in range(N-1)]

for i in range(N):
  print(est_time(i+1,N,csf_list))

Measured memory_bytes: 9240
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();

        int[][] c = new int[n][m+1];

        int ans = Integer.MAX_VALUE;

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


        outer:
        for (int i=0; i<(int)Math.pow(2, n); i++) {
            int cost = 0;
            int[] arr = new int[m];
            String tmp = Integer.toBinaryString(i);
            if (tmp.length() < n) {
                while (tmp.length() < n) {
                    tmp = "0" + tmp;
                }
            }

//            System.out.println(tmp);

            for (int j=0; j<tmp.length(); j++) {
                if (tmp.charAt(j) == '1') {
                    cost += c[j][0];
                    for (int k=0; k<m; k++) {
                        arr[k] += c[j][k+1];
                    }
                }
            }

            for (int j=0; j<m; j++) {
                if (arr[j] < x) continue outer;
            }

            ans = Math.min(ans, cost);

        }

        if (ans == Integer.MAX_VALUE) {
            System.out.println(-1);
            return;
        }

        System.out.println(ans);


    }

    void dfs() {

    }

//    int calc() {
//
//    }
}


Measured memory_bytes: 40848
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
void marmot0814() {
    int n; cin >> n;
    vector<LL> dp(3, 0);
    while (n--) {
        LL a, b, c; cin >> a >> b >> c;
        vector<LL> tmp(3, 0);
        tmp[0] = max(dp[1] + b, dp[2] + c);
        tmp[1] = max(dp[0] + a, dp[2] + c);
        tmp[2] = max(dp[0] + a, dp[1] + b);
        dp = tmp;
    }
    cout << max({dp[0], dp[1], dp[2]}) << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 3640
num = list(map(int, input().split(' ')))
array = [list(map(int, input().split(' '))) for i in range(0, num[0])]
product_array = [[1,1,1],[-1,1,1],[1,-1,1],[1,1,-1],[-1,-1,1],[1,-1,-1],[-1,-1,-1]]
array_result = [[0 for j in range(0, num[1])] for i in range(0, len(product_array))]
for i, product in enumerate(product_array):
    s = [item[0]*product[0]+item[1]*product[1]+item[2]*product[2] for item in array]
    array_result[i]= sorted(range(len(s)), key=lambda k: s[k])[0:num[1]]
result = 0
for i, item in enumerate(array_result):
    total1 = 0
    total2 = 0
    total3 = 0
    for j in range(num[1]):
        total1 += array[item[j]][0]
        total2 += array[item[j]][1]
        total3 += array[item[j]][2]
    total = total1*(1 if total1>0 else -1)+total2*(1 if total2>0 else -1)+total3*(1 if total3>0 else -1)
    result = result if result>total else total
print(result)

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

int main(){
  int a[3];cin >> a[0] >> a[1] >> a[2];
  
  sort(a,a+3);
  
  int ans = 0;
  
  ans += (a[2] - a[0])/2;
  a[0] +=(a[2] - a[0])/2*2;
  ans += (a[2] - a[1])/2;
  a[1] +=(a[2] - a[1])/2*2;
  
  if(a[2] == a[0] && a[2] == a[1]) cout << ans;
  else if(a[0] != a[1]) cout << ans+2;
  else cout << ans+1;

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0;i<x; i++)
typedef long long  ll;
using namespace std;
int main(){
	int N,M;
  cin>>N>>M;
  int A[N];
	ll all=0;
  rep(i,N){
  	cin>>A[i];
    all+=A[i];
  }
  ll sinsa;
  if(all%(4*M)==0){
  	sinsa=all/(4*M);
  }else{
  	sinsa=all/(4*M)+1;
  }
  ll counter=0;
  rep(i,N){
  	if(A[i]>=sinsa){
    	counter++;
    }
  }
  if(counter>=M){
  	cout<<"Yes";
  }else{
  	cout<<"No";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    int N, Q;
    long long A, B, C, n;
    long long ans_tmp = 0;
    long long gap = 0;
    map<long long, long long> cont;

    std::cin >> N;

    for(int i = 0; i < N; i++){
        std::cin >> A;
        if(cont.count(A)!=0){
            cont[A] = cont[A] + 1;
        }else{
            cont[A] = 1;
        }
        ans_tmp = ans_tmp + A;
    }

    std::cin >> Q;
    vector<long long> ans(Q);

    for(int i = 0; i < Q; i++){
        std::cin >> B >> C;

        if(cont.count(B)!=0){
            n = cont[B];
            cont[B] = 0;
            if(cont.count(C)!=0){
                cont[C] = cont[C] + n;
            }else{
                cont[C] = n;
            }
            ans_tmp = ans_tmp + n * (C-B);
            ans[i] = ans_tmp;
        }else{
            ans[i] = ans_tmp;
        }

    }

    for(int i = 0; i < Q; i++){
        std::cout << ans[i] << "\n";
    }


}

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

int main() {
  int n,m;
  cin >> n >> m;
  priority_queue<ll, vector<ll>, greater<ll>> a;
  rep(i,0,n) {
    int ai;
    cin >> ai;
    a.push(ai);
  }
  priority_queue<P> card;
  rep(i,0,m) {
    int b; ll c;
    cin >> b >> c;
    card.push(P(c,b));
  }
  bool flag = false;
  rep(i,0,m) {
    P p = card.top(); card.pop();
    rep(j,0,p.second) {
      ll f = a.top();
      if (f < p.first) {
        a.pop();
        a.push(p.first);
      } else {
        flag = true;
        break;
      }
    }
    if (flag) break;
  }
  ll ans = 0;
  rep(i,0,n) {
    ans += a.top(); a.pop();
  }
  cout << ans << endl;
  return 0;
}


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

#define N 100005

char s[N];

int main() {
	scanf("%s", s);
	int n = strlen(s);
	for (int i = 0; i < n; i ++) {
		if (i + 1 < n && s[i] == s[i+1]) {
			printf("%d %d\n", i+1, i+2);
			return 0;
		}
		if (i + 2 < n && s[i] == s[i+2]) {
			printf("%d %d\n", i+1, i+3);
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

ll maxi = 1000000000000000000ll;
int N;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	vector<ll> A(N);
	for(auto &x : A)cin >> x;
	sort(all(A));
	ll res = 1;
	forn(i,0,N){
		ll x = A[i];
		if(__builtin_mul_overflow(res,x,&res)){
			res = -1;
			break;
		}
		if(res > maxi){
			res = -1;
			break;
		}
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, K;
    cin >> N >> K;
    VL a(N), f(N);
    rep(i, 0, N) cin >> a[i];
    rep(i, 0, N) cin >> f[i];
    sort(ALL(a));
    sort(ALL(f), greater<ll>());
    ll L = -1, R = 1e18;
    while(R - L > 1){
        // cerr << L << " " << R << endl; 
        bool flag = true;
        ll M = L + (R - L) / 2;
        ll k = K;
        rep(i, 0, N){
            if(a[i] * f[i] > M){
                ll rem = a[i] * f[i] - M;
                k -= (rem + f[i] - 1) / f[i];
            }
            if(k < 0){
                flag = false;
                break;
            }
        }
        if(flag) R = M;
        else L = M;
    }
    cout << max(0LL, R) << endl;
    return 0;
}

Measured memory_bytes: 6404
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <list>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

ll lcm(ll a, ll b){
  ll g = gcd(a,b);
  return a / g * b;
}

int main(void){
  int N; 
  cin >> N;
  
  ll ans = 1;
  
  for(int i = 0; i < N; ++i){
    ll T; cin >> T;
    ans = lcm(ans,T);
  }
  
  cout << ans << endl;
  
  return 0;
}


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

void show_v( vector<int> v ){
    for(vector<int>::iterator it=v.begin(); it!=v.end(); it++){
        cout << *it << ' ';
    }
    cout << endl;
}

int main(){
    int n, r, i, j, p, c;
    while( cin >> n >> r, n||r ){
        vector<int> card(n);
        for(i = 0; i < n; i++){
            card[i] = n-i;
        }
        while( r-- > 0 ){
            cin >> p >> c;
            vector<int> tmp;
            tmp.assign( card.begin()+p-1, card.begin()+p+c-1 );
            card.erase( card.begin()+p-1, card.begin()+p+c-1 );
            tmp.insert( tmp.end(), card.begin(), card.end() );
            card.assign( tmp.begin(), tmp.end() );
        }
        cout << card[0] << endl;
    }
    return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    //mapでそれぞれ位に分けて対処
    vector<ll> keta(60);
    rep(i, n)
    {
        ll a;
        cin >> a;
        //これを2進数に治せればよしなのだが,,
        bitset<60> s(a); //2^60-1までの値を表す。
        rep(i, 60)
        {
            if (s[i] == 1)
            {
                keta[i] += 1; //1の数を格納。
            }
        }
    }
    ll count = 0;
    rep(i, 60)
    {
        count = (count + (keta[i]% 1000000007 * (n - keta[i]) % 1000000007* ((ll)(pow(2, i)) % 1000000007))) % 1000000007;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    vector<vector<int>> G(n);
    vector<P> es(n-1);
    rep(i, n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
        es[i] = {x, y};
    }

    vector<bool> seen(n, false);
    seen[0] = true;
    queue<int> que;
    que.push(0);

    int maxdeg = 0;
    vector<int> used(n, 0); // 各頂点の親で使っている色
    map<P, int> mp; // 頂点{u,v} = 色
    while(!que.empty()) {
        int v = que.front(); que.pop();
        int color = 1;
        chmax(maxdeg, sz(G[v]));
        for(const auto& nv: G[v]) {
            if (seen[nv]) continue;
            seen[nv] = true;
            if (used[v]==color) color++;
            used[nv] = color;
            mp[{v, nv}] = mp[{nv, v}] = used[nv];
            color++;
            que.push(nv);
        }
    }
    cout << maxdeg << endl;
    for(const auto& e: es) cout << mp[{e.fi, e.se}] << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

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

  ll remind=(h2-h1)*60+m2-m1;
  ll ans=remind-k;
  cout<<ans<<endl;
}



Measured memory_bytes: 3608
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main(void) {
  int A, B, C;
  
  cin>>A>>B>>C;
  
  printf("%d %d %d\n",C, A, B);
  
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

string maze[1010];
string serch[2];
bool B[1010][1010];
int h, w;
string JOI = "JOI";

bool calc(int i, int j) {
	if (i < 0 || j < 0)return false;
	if (i >= h - 1 || j >= w - 1)return false;
	if (maze[i][j] == serch[0][0]
		&& maze[i][j + 1] == serch[0][1]
		&& maze[i + 1][j] == serch[1][0]
		&& maze[i + 1][j + 1] == serch[1][1])return true;
	return false;
}

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> maze[i];
	}
	for (int i = 0; i < 2; i++) {
		cin >> serch[i];
	}
	int ans = 0;
	for (int i = 0; i < h - 1; i++) {
		for (int j = 0; j < w - 1; j++) {
			if (calc(i, j)) {
				ans++;
			}
		}
	}
	int maxl = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			for (int k = 0; k < 3; k++) {
				int count = 0;
				if (maze[i][j] == JOI[k])continue;
				char copy = maze[i][j];
				maze[i][j] = JOI[k];

				count += calc(i - 1, j - 1) + calc(i - 1, j) + calc(i, j - 1) + calc(i, j);
				maxl = max(count, maxl);
				maze[i][j] = copy;
			}
		}
	}
	cout << ans + maxl << endl;
}

Measured memory_bytes: 4104
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#import fractions
#S=input()
#import math
#n=int(input())

lis=list(map(int,input().split()))
ans=lis[0]*3+lis[1]
ans=ans-ans%2
ans=int(ans/2)

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define rep(i,n) for (int i=0; i<(n); ++i)
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

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

    if(4*a*b < (c-a-b)*(c-a-b) && c-a-b >0){
        cout << "Yes";
    }
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
// ybmj
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;

int main() {
    /*
    #ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
    freopen("1.out","w",stdout);
    #endif
    */
    std::ios::sync_with_stdio(false);
    char a, b;
    while (cin >> a >> b) {
        if (a < b)
            cout << '<' << endl;
        else if (a > b)
            cout << '>' << endl;
        else
            cout << '=' << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 998244353;
const int N = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a; cin >> a;
    string s; cin >> s;
    if (a < 3200) cout << "red";
    else cout << s;


    return 0;
}



Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            String row;
            while(!(row = scn.nextLine()).equals(".")) {
                row = row.replaceAll("[^\\(\\)\\[\\]]", "");
                while(row.indexOf("()") >= 0 || row.indexOf("[]") >= 0) {
                    row = row.replaceAll("(\\(\\))|(\\[\\])", "");
                }
                System.out.println(row.length() > 0 ? "no" : "yes");
            }
        }
    }
}

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

int main(int argc, char const *argv[]){
	int n;
	cin >> n;
	while(n >= 4){
		if(n % 4 == 0 || n % 7 == 0){
			cout << "Yes" << endl;
			return 0;
		}
		else if(n > 4)	n -= 4;
		else if(n > 7)	n -= 7;
	}
	cout << "No" << endl;
	return 0;
}


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

long long gcd(long long a, long long b) {
    long long r = a % b;
    if(r == 0) return b;
    else return gcd(b, r);
}

int main() {
    long long n, x, *array, *distance;

    scanf("%lld %lld", &n, &x);

    array = new long long[n];
    distance = new long long[n];

    for(int i = 0; i < n; i++) {
        scanf("%lld", &array[i]);
    }

    for(int i = 0; i < n; i++) {
        distance[i] = abs(x - array[i]);
    }

    if(n == 1) {
        cout << abs(array[0] - x) << endl;
        return 0;
    }
    else{
        long long ans = gcd(distance[0], distance[1]);

        for(int i = 2; i < n; i++) {
            ans = gcd(ans, distance[i]);
        }

        printf("%lld\n", ans);
    }

    delete [] array;
    delete [] distance;

    return 0;
}


Measured memory_bytes: 1792