akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------

int N;
int a[101010];
int m2, m4, odd;

int main() {
  cin >> N;
  rep(i, 0, N) {
    cin >> a[i];
    if (a[i] % 4 == 0) {
      ++m4;
    } else if (a[i] % 2 == 0) {
      ++m2;
    } else {
      ++odd;
    }
  }

  if (m2 == 0) {
    if (odd <= m4 + 1) {
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  } else {
    if (odd <= m4) {
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
}


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

using namespace std;

int main()
{
	int n, flg=0;
	cin>>n;
	map<int, int> mp;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin>>a;
		mp[a]++;
		if(mp[a]>1) flg=1;
	}
	if(flg) cout<<"NO";
	else cout<<"YES";
	cout<<endl;


	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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

void myswap(int *a, int *b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d,n;
    cin >> n;
    string s;
    cin >> a >> b >> c >> d;
    cin >> s;
    s += "####";
    a--,b--,c--,d--;
    if( (a < b && c < d) || (a > b && c > d)){
      //b is big
      if(a > b){
        myswap(&a,&b);
        myswap(&c,&d);

      }
      if(s[d] == '#' || s[c] == '#'){
        cout << "No" << "\n";
        return 0;
      }
      FOR(i,b+1,d+1){
        if(s[i-1] == '#' && s[i] == '#'){
          cout << "No" << "\n";
          return 0;
        }
      }
      FOR(i,a+1,c+1){
        if(s[i-1] == '#' && s[i] == '#'){
          cout << "No" << "\n";
          return 0;
        }
      }
      cout << "Yes" << "\n";
      return 0;
    }else{
      if(a > b){
        myswap(&a,&b);
        myswap(&c,&d);
      }
      // bのが前
      if(s[d] == '#' || s[c] == '#'){
        cout << "No" << "\n";
        return 0;
      }
      FOR(i,b+1,d+1){
        if(s[i-1] == '#' && s[i] == '#'){
          cout << "No" << "\n";
          return 0;
        }
      }
      FOR(i,a+1,c+1){
        if(s[i-1] == '#' && s[i] == '#'){
          cout << "No" << "\n";
          return 0;
        }
      }
      bool flag = false;
      FOR(i,b,d+1){
        if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') flag = true;
      }

      if(flag) cout << "Yes" << "\n";
      else cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200010];
map<int,bool> mp;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    if(mp[a[i]])
    {
        cout<<"NO"<<endl;
        return 0;
    }
    else mp[a[i]]=1;
    cout<<"YES"<<endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<char> c(100,' ');
	int i=0;
	while(n!=0)
	{
		int am=abs(n%2);
		int n2=n;
		if(am==1)
		{
			c.at(i)='1';
		}
		else
		{
			c.at(i)='0';
		}
		i++;
		n /= (-2);
		if(am==1&&n>0)
		{
			n++;
		}
		if(n==0&&n2==-1)
		{
			c.at(i)='1';
			i++;
		}
	}
	for(int j=0;j<i;j++)
	{
		cout << c.at(i-j-1);
	}
	if(c.at(0)==' ')
	{
		cout << '0';
	}
    cout << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  vector<string> c(2);
  rep(i, 2) cin >> c[i];
  if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll y,z,n,p,m=0,k,h,w,sum=0,sum_a=0,sum_b=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u,v;
    bool ok=true;
    cin >> n;
    VL a(n),b(n+1);
    bool c[n];
    b[0] = 0;
    rep(i,n){
        cin >> a[i];
        c[i] = false;
    }
    sort(ALL(a));
    c[n-1]=true;
    for(int i=1;i<n;i++){
        b[i] = a[i-1] + b[i-1];
    }
    for(int i=n-2; i>=0; i--){
        if(2*(b[i]+a[i]) >= a[i+1]){
            if(c[i+1]==true){
                ans++;
                c[i] = true;
            }
        }
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 1920
S = list(map(int, list(input())))
min_n = 10**4
for i in range(len(S) - 2):
    a, b, c = S[i], S[i+1], S[i+2]
    n = abs(100 * a + 10 * b + c - 753)
    min_n = min(min_n, n)
print(min_n)


Measured memory_bytes: 9060
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

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

ll mod = 1e9 + 7;

int main(){	
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ull> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	vector<int> cnt(100 , 0);
	for(int i = 0; i < n; i++){
		for(int bit = 0; bit < 60; bit++){
			if(a[i] & (1LL << bit))cnt[bit]++;
		}
	}
	
	ull ans = 0;
	ull t = 1;
	ull x = 0;
	for(int bit = 0; bit < 60; bit++){
		x = (ull)cnt[bit]*(n - cnt[bit]);
		x %= mod;
		ans += (t * x)%mod;
		ans %= mod;
		t *= 2;
		t %= mod;
	}
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 5568
#include <stdio.h>
 
int ChkRightTriangle(int a,int b,int c){
    if((a*a==b*b+c*c)||(b*b==a*a+c*c)||(c*c==a*a+b*b)){
//    if(a<b+c&&b<a+c&&c<a+b){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}
 
 
int main(void) {
    int i,datano;
    int a,b,c;
    scanf("%d",&datano);
    for(i=0;i<datano;i++){
        scanf("%d %d %d",&a,&b,&c);
        ChkRightTriangle(a,b,c);
    }
 
        return 0;
}

Measured memory_bytes: 576
#include <stdio.h> 
long long a[100010]; 
int main (){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    int zero =0;
    for(int i=0;i<n;i++)
        if(a[i]==0) zero++; 
    if(zero >0){
        // a[i] contains 0
        printf("0\n");
        return 0; 
    }
    long long prod =1; 
    for(int i=0;i<n;i++){
        if(a[i]<=1000000000000000000/prod){
        // This condition is equivalent to prod*a[i]<=10ˆ18 
            prod*=a[i];
        }else{ printf("-1\n");
        return 0; }
    }
    printf("%lld\n",prod); 
}

Measured memory_bytes: 2484
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=1e5+5;

int n,k;
int h[MAX_N];
int dp[MAX_N];

int main()
{
	memset(dp,0x7F,sizeof(dp));
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	dp[1]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=k&&i+j<=n;j++)
			dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
	printf("%d\n",dp[n]);
	return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define endl '\n'
#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define ld long double
#define PI 3.14159265359

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t = 1;
	// cin >> t;
	while (t--) {
		string s;
		cin >> s;
		ull b = 0, ans = 0;
		for (auto i : s) {
			if (i == 'B')
				b++;
			if (i == 'W')
				ans += b;
		}
		cout << ans;
	}
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define sorta(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.begin(),v.end(),greater<>())
#define mkp make_pair
#define endl "\n"
#define tab " "
#define pb push_back
#define ff first
#define ss second
#define gcd __gcd
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define ff first
#define ss second
#define tc ll T;cin>>T;while(T--)
#define inf (long long)9e18
const ll mod = 1e9 + 7;
ll powm(ll x, ll y, ll p)  {  ll res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }
ll lcm(ll x,ll y){return (x*y*1LL)/gcd(x,y);}
ll pow(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); y = y >> 1; x = ((x) * (x)); } return res; }
void solve()
{
    ll n,we,i,j;
    cin>>n>>we;
    vll v(n,0),w(n,0);
    for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
    ll t[n+1][we+1];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=we;j++)
        t[i][j]=0;
    }
    //  for(i=0;i<n;i++)
    // {
    //     for(j=0;j<=we;j++)
    //     {
    //         cout<<t[i][j]<<tab;
    //     }cout<<endl;
    // }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=we;j++)
        {
            if(j<w[i-1])
            t[i][j]=t[i-1][j];
            else
            {
                t[i][j]=max(t[i-1][j],v[i-1]+t[i-1][j-w[i-1]]);
            }
            
        }
    }
    //  for(i=0;i<=n;i++)
    // {
    //     for(j=0;j<=we;j++)
    //     {
    //         cout<<t[i][j]<<tab;
    //     }cout<<endl;
    // }

    cout<<t[n][we];
}		
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif
	fast
	//tc
	solve();
}

Measured memory_bytes: 82528
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var nums = chunk.split(" ");
    for(var i = 0; i < nums.length; i ++){
        nums[i] = Number(nums[i]);
    }
    var rec = new Array(nums[0], nums[1]);
    var cir = new Array(nums[2], nums[3], nums[4]); // point x, point y, r
    
    var output = "No";
    if ((cir[0] - cir[2] >= 0) && (cir[0] + cir[2] <= rec[0])){
        if((cir[1] - cir[2] >= 0) && (cir[1] + cir[2] <= rec[1])){
            output = "Yes";
        }
    }
    console.log(output);
});

Measured memory_bytes: 7648
//#include<iostream>
#include<cstdio>
using namespace std;

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    //cin >> a >> b;
    //c = a + b;
    //cout << a << " + " << b << " = " << c << '\n';
    printf("%d %d\n", a * b, 2 * (a + b));

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;

int matrix[50][50];

void init(){
	for(int i = 0; i < 50; i ++){
		for(int j = 0; j < 50; j++){
			matrix[i][j] = 0;
		}
	}
}

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i = 0; i < m; i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		matrix[a][b]++;
		matrix[b][a]++;
	}
	for(int i = 0; i < n; i++){
		int ans = 0;
		for(int j = 0; j < n; j++){
			ans += matrix[i][j];
		}
		cout<<ans<<endl;
	}
	return 0;
}



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

typedef long long ll;

const int MAXN = 102, MAXV = 1000;
ll dp[MAXN*MAXV], v[MAXN], w[MAXN], n, W;

int main(){
    // freopen(".in", "r", stdin);

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n >> W;
    for(int i=0; i<n; i++)
        cin >> w[i] >> v[i];

    fill(dp, dp + MAXN*MAXV, -1);
    dp[0] = 0;

    for(int i=0; i<n; i++){
        for(int j=n*MAXV; j>=v[i]; j--)
            if(dp[j - v[i]] != -1)
                dp[j] = (dp[j] == -1 ? dp[j-v[i]] + w[i] : min(dp[j], dp[j-v[i]] + w[i]));
    }

    for(int i = n*MAXV; i>=0; i--){
        if(dp[i] != -1 && dp[i] <= W){
            cout << i << '\n';
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S = null;
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	int N = 0;
//	int K = 0;
//	char[] c = null;
	int[] A = null;
	int ans = 0;
	
	public void input() throws IOException {
		N = in.nextInt();
		A = in.nextInt(new int[2*N]);
	}
	
	private int idx(int i, int j) {
		return i*N + j;
	}
	
	public void solve() throws IOException {
		int[] A1 = new int[N];
		int[] A2 = new int[N];
		A1[0] = A[idx(0,0)];
		A2[N-1] = A[idx(1,N-1)];
		for (int j=1; j<N; j++) {
			A1[j] += A1[j-1] + A[idx(0,j)];
			A2[N-j-1] += A2[N-j] + A[idx(1,N-j-1)];
		}
		ans = -1;
		for (int j=0; j<N; j++) {
			ans = Math.max(ans, A1[j]+A2[j]);
		}
	}
	
	public void output() {
		out.println(ans);
		out.flush();
	}
}

//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int a[90];
void solve()
{
	int n,i,j;
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	
	ll ans=1000;
	for(i=1;i<n;)
	{
		ll stocks=0;
		for(j=i;j<n;j++)
		if(a[j]<a[j+1])
		{
			stocks=ans/a[j];
			ans%=a[j];
			j++;
			break;
		}
		if(stocks==0)
		{
			i=j;
			continue;
		}
		for(;j<=n;j++)
		if(j==n || (a[j]>a[j+1]))
		{
			ans+=stocks*a[j];
			break;
		}
		
		i=j; 
	}
	cout<<ans<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3644
N, T = map(int, raw_input().split())
small_c = 10000
for i in range(N):
  c, t = map(int, raw_input().split())
  if t <= T:
    if c < small_c:
      small_c = c
if small_c > 1000:
  print('TLE')
else:
  print(small_c)


Measured memory_bytes: 2568
function main(input){
    args = input.split("\n");
    n = args[0]
    a = args[1].split(" ").map((n)=>parseInt(n, 10))
    a.sort(function(a,b){return (a < b)? 1:-1})
    c = 0;
    for (var i=0; i < a.length ; i+=2){
        if ((i + 1) < a.length ){
            c+= a[i] - a[i+1] 
        }else{
            c+= a[i] 
        }
        
    }
    console.log(c);

}
main(require('fs').readFileSync('/dev/stdin', {encoding:'utf8'}))


Measured memory_bytes: 7500
<?php
  while($line=trim(fgets(STDIN))){
    $abcdef=explode(" ",$line);
    $x=(double)($abcdef[2]*$abcdef[4]-$abcdef[1]*$abcdef[5])/(double)($abcdef[0]*$abcdef[4]-$abcdef[3]*$abcdef[1]);
    $y=(double)($abcdef[0]*$abcdef[5]-$abcdef[2]*$abcdef[3])/(double)($abcdef[0]*$abcdef[4]-$abcdef[1]*$abcdef[3]);
    echo sprintf("%.3f",round($x,3))." ";
    echo sprintf("%.3f",round($y,3))."\n";

  }

Measured memory_bytes: 15416
R, C, K = map(int, input().split())
V = [[0]*C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[r-1][c-1] = v
dp = [[0]*4 for _ in range(C+1)]
for j in range(C):
    for k in range(1, 4):
        dp[j+1][k] = max(dp[j][k-1]+V[0][j], dp[j][k])
for i in range(1, R):
    newdp = [[0]*4 for _ in range(C+1)]
    for j in range(C):
        newdp[j+1][0] = max(max(dp[j+1]), newdp[j][0])
        newdp[j+1][1] = max(max(max(dp[j+1]), newdp[j][0])+V[i][j], newdp[j][1])
        for k in range(2, 4):
            newdp[j+1][k] = max(newdp[j][k-1]+V[i][j], newdp[j][k])
    dp = newdp
print(max(dp[-1]))

Measured memory_bytes: 210552
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
//#include<bits/stdc++.h>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	long long count = 0;
	for (int i = 0; i < N; ++i) {
		long long a;
		cin >> a;
		
		while (a % 2 == 0) {
			a /= 2;
			++count;
		}
	}

	cout << count << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string s;
    cin >> k >> s;
    if(s.size()<=k) cout << s << "\n";
    else{
        for(int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << "\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
    
    int n;cin>>n;
    vector<pair<int,int>> vp;

    int u,v;
    for(int i=0;i<n;i++){
        cin>>u>>v;
        vp.pb({u,v});
    }

    sort(all(vp),[](pair<int,int> a,pair<int,int> b){

        if(a.S==b.S)
            return a.F < b.F;
        return a.S < b.S;
    });

    int sum=0;
    bool ok=true;
    for(int i=0;i<n;i++){

        if(sum+vp[i].F <= vp[i].S){
            sum+=vp[i].F;
        }
        else
        {
            cout<<"No"<<endl;
            ok=false;
            break;
        }
    }

    if(ok)
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 7428
#include <iostream>
#define MAX_NM 400000
using namespace std;
int max(int a, int b){
  return a > b ? a : b;
}
int min(int a, int b){
  return a < b ? a : b;
}
int main(void){
  int n, m;
  cin >> n >> m;
  int edge1[n+1] = {0};
  int edge2[n+1] = {0};
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    int ma, mi;
    ma = max(a, b);
    mi = min(a, b);
    if(mi == 1) edge1[ma] = 1;
    if(ma == n) edge2[mi] = 1;
  }
  for(int i = 1; i < n; i++){
    if(edge1[i] && edge2[i]) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int lnt;
int main()
{
	lnt a,b,c;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0) puts("0");
	else{
		printf("%lld\n",min(min(a*b,c*a),b*c));
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll x;
    cin>>x;
    ll ans=(x/11)*2;
    x=x%11;
    if(x>6)ans+=2;
    else if(x>=1&&x<=6)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)
const int maxn = 1e5 + 10;
int a[maxn], b[maxn];
int32_t main(){
	IOS;
	int n, x;
	cin >> n >> x;
	for(int i=0; i<n; i++)
		cin >> a[i];
	sort(a, a+n);
	memset(b, -1, sizeof b);
	for(int i=0; i<n; i++){
		if(i == n-1){
			b[i] = x;
			continue;
		}
		if(x >= a[i]){
			b[i] = a[i];
			x -= a[i];
		}
		else{
			break;
		}
	}
	x = 0;
	for(int i=0; i<n; i++)
		x += (a[i] == b[i]);
	cout << x << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ss second
#define ff first
#define N 10003
#define inf 1000000009
#define ll long long
#define pii pair<int,int>
#define sz(a) int(a.size())
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int n,m,a[N],b[N],pos;
int dp[1<<14];
int v[N],x;
vector <int> E[14];

void f(int st){
	pos = log2(st & ~(st-1));
	int now,ans = inf;
	for(auto i : E[pos]){
		now = st - (st & v[i]);
		if(dp[now] == inf) f(now);
		if(dp[now] == -1)  continue;
		ans = min(ans,a[i] + dp[now]);
	}
	if(ans == inf) dp[st] = -1;
	else dp[st] = ans;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i++){
		scanf("%d%d",&a[i],&b[i]);
		for(int j = 0;j < b[i];j++){
			scanf("%d",&x),E[x].pb(i);
			v[i] += (1<<x);
		}
	}
	for(int i = 1;i <= (1<<(n+1))-1;i++) dp[i] = inf;
	f((1<<(n+1))-2);
	printf("%d",dp[(1<<(n+1))-2]);
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    VI b_cnt(n + 1, 0), w_cnt(n + 1, 0);
    REP(i, n) {
        if (s[i] == '#') {
            b_cnt[i + 1] = b_cnt[i] + 1;
            w_cnt[i + 1] = w_cnt[i];
        } else {
            b_cnt[i + 1] = b_cnt[i];
            w_cnt[i + 1] = w_cnt[i] + 1;
        }
    }

    int ans = n;
    FOR(i, 0, n) ans = min(ans, b_cnt[i] + w_cnt[n] - w_cnt[i]);
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 2196
#include<stdio.h>

int A[20];
int n1;

int Solve(int i, int b){//A中に足してBになるものあるか？
  //あったら
  int result=0;
  
  if (b == 0)return 1;
  if (i >= n1)return 0;
  if(Solve(i + 1, b) || Solve(i + 1, b - A[i])){
    return 1; 
  }
  return 0;
}


int main(){
  int n2;
  int i;
  int b;
  
  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&b);
    if(Solve(0,b))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2004
import numpy as np
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp=np.zeros(n,dtype=int)
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    if i-k>0:
        dp[i]=min(dp[i-k:i]+abs(h[i]-h[i-k:i]))
    elif 0>=i-k:
        dp[i]=min(dp[0:i]+abs(h[i]-h[0:i]))
print(dp[n-1])

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

int main(){
  int n,m;
  int s[6],c[6];
  int a[4]={0,0,0,0};
  
  cin >> n >> m;
  for(int i=1; i<=m; i++)
    cin >> s[i] >> c[i];
  
  for(int j=1;j<=m;j++){
    for(int k=1; k<=m; k++){
      if(s[j]==s[k]&&c[j]!=c[k]){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if(n==1){
    cout << c[1] << endl;
  }
  else {
    a[1]=1;
    for(int p=1; p<=m; p++){
      if(s[p]==1)
        a[1]=c[p];
      else if(s[p]==2)
        a[2]=c[p];
      else if(s[p]==3)
        a[3]=c[p];
    }
    if(a[1]==0)
      cout << -1 << endl;
    else if(n==2)
      cout << a[1]*10+a[2] << endl;
    else if(n==3)
      cout << a[1]*100+a[2]*10+a[3] << endl;
  }
    
    return 0;
}
      

Measured memory_bytes: 256
import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
answer_list = []
pair = N if N&1 else N+1
for i in range(1, N):
    for j in range(i+1, N+1):
        if i+j == pair:
            continue
        else:
            answer_list.append((i, j))

print(len(answer_list))
for x in answer_list:
    print(*x)


Measured memory_bytes: 3956
//
// Created by corol
//
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int l,p,d;
    cin >> l >> p >>d;
    int cnt=0;
    for (int i=l;i<=p;i++) {
        if (i%d==0) {
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

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

int main(){
	for(int i=0; i<1000; ++i){
		string s;
		cin >> s;
		bool ans=true;
		int p=0;
		while(p<s.size()-1){
			if(s[p]=='A'){
				if(s[p+1]=='B' || s[p+1]=='D');
				else ans=false;
			}
			else if(s[p]=='B'){
				if(s[p+1]=='A' || s[p+1]=='C' || s[p+1]=='E');
				else ans=false;
			}
			else if(s[p]=='C'){
				if(s[p+1]=='B' || s[p+1]=='F');
				else ans=false;
			}
			else if(s[p]=='D'){
				if(s[p+1]=='A' || s[p+1]=='E' || s[p+1]=='G');
				else ans=false;
			}
			else if(s[p]=='E'){
				if(s[p+1]=='B' || s[p+1]=='D' || s[p+1]=='F' || s[p+1]=='H');
				else ans=false;
			}
			else if(s[p]=='F'){
				if(s[p+1]=='C' || s[p+1]=='E' || s[p+1]=='I');
				else ans=false;
			}
			else if(s[p]=='G'){
				if(s[p+1]=='D' || s[p+1]=='H');
				else ans=false;
			}
			else if(s[p]=='H'){
				if(s[p+1]=='E' || s[p+1]=='G' || s[p+1]=='I');
				else ans=false;
			}
			else if(s[p]=='I'){
				if(s[p+1]=='F' || s[p+1]=='H');
				else ans=false;
			}
				
			if(!ans) break;
			++p;
		}
		
		if(ans) cout << s << endl;
	}	
}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

#define KIT 4

int main() {
        int n, i, j;
        int d[KIT*KIT];
        int dd[10002];
        int count = 0;
        int aria = KIT;
        string s1, s2;

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

        sort(dd, dd + n);
        if (n < KIT) {
                aria = n;
        }
        for (i = 0; i < aria; i++) {
                s1 = to_string(dd[i]);
                for (j = 0; j < aria; j++) {
                        if (i != j) {
                                s2 = to_string(dd[j]);
                                s2 = s1 + s2;
                                d[count] = stoi(s2);
                                count++;
                        }
                }
        }
        sort(d, d + count);
        cout << d[2] << endl;

        /*
        for (i = 0; i < count; i++) {
                cout << d[i] << endl;
        }
        */



        // sort dd
//      cout << dd[2] << endl;
        return 0;
}



Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define ff first
#define ss second
#define int long long 
#define endl "\n"
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
int a[N] ;
int n , k;

void solve(){
	cin >> n >> k;
	
	int sum  = 0;
	if(n+1==k)
	{	cout << "1" <<endl; return;}
	
	
	int lminsum = k*(k-1)/2;
	int rmaxsum = n*(n+1)/2   - (n-k)*(n-k+1)/2;
	int addr = n-k;
		
	sum = ( rmaxsum - lminsum + 1 ) % MOD;
	for(int i = k ; i<=n ; i++){
		lminsum += i;
		rmaxsum += addr;
		
		sum +=( rmaxsum - lminsum + 1 ) % MOD;
		addr --;
	}
	
	cout << sum % MOD <<endl;
}

int32_t main(){
	FAST;
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3648
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, t; cin >> n >> t;
    vector<int> a(n), b(n);
    vector<int> zeroshop;
    vector<P> shop(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
        shop[i] = make_pair(a[i], b[i]);
        if(a[i] == 0) zeroshop.pb(b[i] + 1);
    }
    sort(all(shop), [&](P x, P y){ return (x.sc + 1) * y.fr < (y.sc + 1) * x.fr;});
    sort(all(zeroshop));
    static int dp[200200][40];
    rep(i, 200200) {
        rep(j, 40) {
            dp[i][j] = t + 1;
        }
        dp[i][0] = 0;
    }
    rep(i, n) {
        for(int j = 1; j < 40; ++j) {
            //cerr << shop[i].fr << " " << shop[i].sc << endl;
            chmin(dp[i + 1][j], dp[i][j]);
            if(shop[i].fr != 0 && (shop[i].fr + 1) * (dp[i][j - 1] + 1) + shop[i].sc <= t) chmin(dp[i + 1][j], (shop[i].fr + 1) * (dp[i][j - 1] + 1) + shop[i].sc);
        }
    }
    // vector<int> sum((int)zeroshop.size() + 1, 0);
    // rep(i, (int)zeroshop.size()) {
    //     sum[i + 1] = sum[i] + zeroshop[i];
    // }
    int ans = 0;
    for(int j = 0; j < 40; ++j) {
        cerr << j << " " << dp[n][j] << endl;
        if(dp[n][j] > t) continue;
        int cnt = j, ti = dp[n][j], i = 0;
        while(i < (int)zeroshop.size() && ti + zeroshop[i] <= t) {
            ti += zeroshop[i];
            ++ i;
            ++ cnt;
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 70768
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=1e6+10;
bool vis[M];
int p[1005];
int m;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
bool divide(int n)
{
    m=0;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            p[++m]=i;
            while(n%i==0) n/=i;
        }
    }
    if(n>1)///n是质数
        p[++m]=n;
    for(int i=1;i<=m;i++)
    {
        if(vis[p[i]]) return 0;
        vis[p[i]]=1;
    }
    return 1;
}
int a[M];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    bool f1=1;
    for(int i=1;i<=n;i++)
    {
        if(divide(a[i])==0)
        {
            f1=0;
            break;
        }
    }
    if(f1)
    {
        puts("pairwise coprime");
        return 0;
    }
    ll ans=a[1];
    for(int i=2;i<=n;i++)
    {
        ans=gcd(ans,a[i]);
    }
    if(ans!=1)
    {
        puts("not coprime");
    }
    else puts("setwise coprime");
    return 0;
}


Measured memory_bytes: 7512
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val mp = IntArray(n+1){0}
    val ap = LongArray(n+1)
    val minusp = LongArray(n+1)
    val aArr = IntArray(n)

    var sum = 0L
    repeat(n) {
        val a = sc.nextInt()
        aArr[it] = a
        if (mp[a] != 0) {
            mp[a] = mp[a] + 1
            if (mp[a] == 2) {
                ap[a] = 1
                minusp[a] = 1
                sum += 1
            } else {
                val oldap = ap[a]
                val newap = ap[a] * mp[a] / (mp[a]-2)
                ap[a] = newap
                minusp[a] = newap - oldap
                sum += newap - oldap
            }
        } else {
            mp[a] = 1
            ap[a] = 0
            minusp[a] = 0
        }
    }

    repeat(n) { cnt ->
        val k = aArr[cnt]
        println(sum - minusp[k])
    }
}


Measured memory_bytes: 89896
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    int ha,ma,hb,mb,k,d,ans;
    cin>>ha>>ma>>hb>>mb>>k;
    ma+=ha*60;
    mb+=hb*60;
    d=mb-ma;
    ans=d-k;
    if(ans>=0){
        cout<<ans<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 3564
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    if (a * a * b > 2 * x) {
        ans = atan(a * b * b / 2 / x);
    } else {
        ans = atan(2 * (a * a * b - x) / a / a / a);
    }
    cout << setprecision(10) << ans / M_PI * 180 << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>=(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = 0; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a));

    // 対称
    if((n%2)==0) {
        rep(i, n/2) {
            ans += 2*a[n-1-i];
            if(i == (n/2-1)) {
                ans -= a[n-1-i];
            }
        }
        rep(i, n/2) {
            ans -= 2*a[i];
            if(i == (n/2-1)) {
                ans += a[i];
            }
        }
    }
    else {
        ll tmp = 0;
        rep(i, n/2) {
            ans += 2*a[n-1-i];
        }
        rep(i, (n+1)/2) {
            ans -= 2*a[i];
            if(i == (n+1)/2-2 || i == (n+1)/2-1) {
                ans += a[i];
            }
        }
        rep(i, (n+1)/2) {
            tmp += 2*a[n-1-i];
            if(i == (n+1)/2-2 || i == (n+1)/2-1) {
                tmp -= a[n-1-i];
            }
        }
        rep(i, n/2) {
            tmp -= 2*a[i];
        }
        if(ans < tmp) ans = tmp;
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    const i64 mod = 1'000'000'007;

    string K;
    i64 D;
    cin >> K >> D;

    const i64 max_digit=10010;
    const i64 max_d=100;
    static i64 memo[max_digit][2][max_d];
    static bool done[max_digit][2][max_d];
    fill_n((i64*)memo,max_digit*2*max_d,0);
    fill_n((bool*)done,max_digit*2*max_d,false);

    assert(K.size()<max_digit);

    reverse(begin(K),end(K));
    while(K.size()<max_digit) K+='0';
    vector<i64> val(max_digit);
    rep(i,0,max_digit){
        val[i]=K[i]-'0';
    }

    function<i64(i64,i64,i64)> rec=[&](i64 d,i64 b,i64 r){
        if(d==-1){
            return i64(r==0?1:0);
        }

        auto& res=memo[d][b][r];
        if(done[d][b][r]) return res;
        done[d][b][r]=true;

        if(b==0){
            rep(i,0,10){
                res+=rec(d-1,0,(r+i)%D);
                res%=mod;
            }
        }else{
            rep(i,0,val[d]){
                res+=rec(d-1,0,(r+i)%D);
                res%=mod;
            }
            res+=rec(d-1,1,(r+val[d])%D);
            res%=mod;
        }

        return res;
    };

    // rec(max_digit-1,1,0)がmodの倍数のケースに注意
    cout << (rec(max_digit-1, 1, 0)-1+mod)%mod << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 19584
program measure
  implicit none
  character(3) :: s
  read(*,*) s
  if (len_trim(s) == 2) then
    write(*,'(a)') trim(s)
    stop
  end if
  write(*,'(a,a,a)') s(3:3), s(2:2), s(1:1)
end program measure

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int q;
  cin>>q;
  REP(i,q) {
    ll a,b;
    cin>>a>>b;
    if (a<b) swap(a, b);
    ll s = sqrt(a*b);
    while (s*s < a*b) ++s;
    while (s*s >= a*b) --s;
    ll ans = 2*s;
    if (s*(s+1) >= a*b) --ans;
    if (b <= s) --ans;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl

use warnings;
my $int = 0;
$line = <STDIN>;
my @words = split/ /, $line; 
my $red = $words[0];
my $green = $words[1];
my $blue = $words[2];

$line = <STDIN>;
chomp $line;
my $k = $line;
my $i = 0;
while ($i < $k) {
    if ($green <= $red) {
        $green = $green * 2;
    } elsif ($blue <= $red || $blue <= $green) {
        $blue = $blue * 2;
    } 
    $i++;
}
if ($red < $green && $green < $blue) {
    print "Yes\n";
} else {
    print "No\n";
}


Measured memory_bytes: 5104
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int i,n,reg1,reg2,sum1,sum2;
        for(;;){ 
        	n=sc.nextInt();
        	if(n==0){
        		break;
        	}else{
        		sum1=0;
        		sum2=0;
        		for(i=0;i<n;i++){
        			reg1=sc.nextInt();
        			reg2=sc.nextInt();
        			if(reg1>reg2){
        				sum1+=reg1+reg2;
        			}else if(reg1<reg2){
        				sum2+=reg1+reg2;
        			}else{
        				sum1+=reg1;
        				sum2+=reg2;
        			}
        		}
        		System.out.println(sum1+" "+sum2);
        	}
        }
    } 
}


Measured memory_bytes: 56928
import sys
import  math
import fractions
from collections import defaultdict
import copy
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

K=int(input())
mod_l=[0]*(K*10)
mod_l[0]=7%K
mod_k=7%K
ans=1
for i in range(10*K-1):
    if(mod_l[i]==0):
        print(ans)
        sys.exit(0)
    mod_k=(mod_k*10)%K  
    if(mod_k==0):
        print("-1")
        sys.exit(0)
    mod_l[i+1]=(mod_l[i]+mod_k)%K
    ans+=1

print("-1")


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a > c){
    swap(a, c);
    swap(b, d);
  }
  int ans;
  if(b <= c) ans = 0;
  else ans = min(b, d) - c;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a%b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}


ll X,Y;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> X >> Y;
	
	if (X%Y==0) cout << -1 << "\n";
	else cout << X << "\n";
	
	return 0;
}



Measured memory_bytes: 256