akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int k,a,b,f=0;
  cin>>k;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0)f=1;
  }

  if(f==1)cout<<"OK";
  else cout<<"NG";
  return 0;
}


Measured memory_bytes: 3624
use std::fmt::Debug;
use std::str::FromStr;

// std input(line)
fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn sub() -> bool
{
    let lines = read_line();
    let n = lines[0];
    let k = lines[1];

    if n == 0 && k == 0 {
        return false;
    }

    let stocks:Vec<u32> = read_line();
    assert!(stocks.len() == k);

    let mut wants = Vec::new();
    for _i in 0..k {
        wants.push(Vec::new());
    }

    for _i in 0..n {
        let lines = read_line();
        assert!(lines.len() == k);
        for j in 0..k {
            wants[j].push(lines[j]);
        }
    }

    let mut over = false;
    for i in 0..k {
        let sum = wants[i].iter().fold(0u32, |sum, v| sum + v);
        if stocks[i] < sum {
            over = true;
            break;
        }
    }

    if over {
        println!("No");
    }
    else {
        println!("Yes");
    }

    return true;
}

fn main()
{
    while sub() {}
}


Measured memory_bytes: 5056
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>

static void B_CanYouSolveThis();
static void C_EnergyDrink();

int main()
{
	C_EnergyDrink();

	fflush(stdout);
	return 0;
}

typedef struct PriceAndBottle {
	unsigned long long price;
	unsigned long long bottle;
	//	unsigned long long sumPrice;
};

static int cmpr(const void* a, const void* b)
{
	int ret = 1;
	if (((struct PriceAndBottle*)a)->price < ((struct PriceAndBottle*)b)->price) {
		ret = -1;
	}
	else if (((struct PriceAndBottle*)a)->price == ((struct PriceAndBottle*)b)->price) {
		ret = 0;
	}
	return ret;
}

static void C_EnergyDrink()
{
	int N = 0, M = 0;
	static struct PriceAndBottle sPnB[100000] = { 0 };

	scanf(" %d %d", &N, &M);

	for (int i = 0; i < N; i++) {
		scanf(" %llu %llu", &(sPnB[i].price), &(sPnB[i].bottle));
//		sPnB[i].sumPrice = sPnB[i].price * sPnB[i].bottle;
	}

	qsort(sPnB, N, sizeof(sPnB[0]), cmpr);

	bool comp = false;
	unsigned long long sumBottles = 0;
	unsigned long long sumPrice = 0;
	unsigned long long surplus = 0;
	for(int n = 0; (n < N) && (!comp); n++) {
		sumBottles += sPnB[n].bottle;

		surplus = 0;
		if (sumBottles >= M) {
			surplus = sumBottles - M;
			comp = true;
		}
		sumPrice += (sPnB[n].bottle - surplus) * sPnB[n].price;
	}

	printf("%llu\n", sumPrice);

}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  string win;
  if ((b - a) % 2) win = "Borys";
  else win = "Alice";

  cout << win << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
int dp[11];

int main(void){
	scanf("%d%d",&n,&k);
	dp[0]=1;
	for(int i=0;i<n;i++){
		dp[i+1]=dp[i]*2;
		dp[i+1]=min(dp[i+1],dp[i]+k);
	}
	printf("%d\n",dp[n]);
	return 0;
}

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

int main(){
    int a, b, c, K;
    bool flag = false;
    cin >> a >> b >> c >> K;
    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            for(int k = 0; k <= K; k++){
                int x = a*(1 << i), y = b*(1 << j), z =  c*(1 << k);
                if(i + j + k <= K && x < y && y < z){
                    flag = true;
                }
            }
        }
    }

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

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] ant = new int[5];
			for (int i = 0; i < 5; i++) {
				ant[i] = int.Parse(Console.ReadLine());
			}
			int k = int.Parse(Console.ReadLine());

			int ans = 0;
			for (int i = 0; i < 4; i++) {
				for (int j = i; j < 5; j++) {
					if (ant[j] - ant[i] > k) {
						Console.WriteLine(":(");
						return;
					}
				}
			}
			Console.WriteLine("Yay!");
		}
	}
}

Measured memory_bytes: 11092
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

void drop(string s) {
    printf("%s\n", s.c_str());
    exit(0);
}

int main() {
    int N, M; cin >> N >> M;
    vector<int> deg(N);
    vector< vector<int> > G(N);
    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
        deg[u]++, deg[v]++;
    }

    // 奇数があるなら NG
    int deg6 = 0, deg4 = 0, deg2 = 0;
    for(int i=0; i<N; i++) {
        if(deg[i] % 2) drop("No");
        else if(deg[i] == 2) deg2++;
        else if(deg[i] == 4) deg4++;
        else deg6++;
    }
    fprintf(stderr, "# %d %d %d\n", deg6, deg4, deg2);

    // 次数 >= 6 なら 3 つ以上に分割可能
    // 次数 == 4 が 1 個以下なら無理
    // 次数 == 4 が 3 個以上なら OK
    if(deg6 >= 1 or deg4 >= 3) drop("Yes");
    if(deg4 <= 1) drop("No");
    
    // 次数 == 4 が 2 個の場合のみ
    {
        int s = -1, t = -1;
        for(int i=0; i<N; i++) {
            if(deg[i] == 4) {
                if(s < 0) s = i;
                else t = i;
            }
        }

        int cnt = 0;
        for(auto v : G[s]) {
            int cur = v, pre = s;
            while(cur != s and cur != t) {
                for(auto to : G[cur]) {
                    if(to == pre) continue;
                    pre = cur;
                    cur = to;
                    break;
                }
            }
            if(cur == t) cnt++;
        }

        printf("%s\n", cnt == 4 ? "No" : "Yes");
    }
    return 0;
}


Measured memory_bytes: 6144
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, M, C;
vec b, a[30];

signed main() {
  cin >> N >> M >> C;
  for (int i = 0; i < M; i++) {
    int tmp;
    cin >> tmp;
    b.pb(tmp);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      int tmp;
      cin >> tmp;
      a[i].pb(tmp);
    }
  }

  int cont = 0;
  for (int i = 0; i < N; i++) {
    int sum = C;
    for (int j = 0; j < M; j++) {
      sum += a[i][j] * b[j];
    }
    if (sum > 0) cont++;
  }

  cout << cont << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100 + 5;

int main()
{
	ll n,m;
	cin >> n >> m;
	ll z = n % m;
	ll a = abs(z-m);
	cout << min(z,a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
using namespace std;
 
int main()
{
  long long a,b,c;
  cin>>a>>b;
  if(a==1&&b==2||a==2&&b==1)
    cout<<3<<endl;
    else if(a==2&&b==3||a==3&&b==2)
    cout<<1<<endl;
  else if(a==1&&b==3||a==3&&b==1)
    cout<<2<<endl;
}

Measured memory_bytes: 3568
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int op(int a,int b){
    return max(a,b);
}

int e(){
    return 0;
}

int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cout << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);

    // n=300000;
    // vector<int> a(n);
    // k=3000;
    // rep(i,n) a[i]=i;

    int max_k=300001;
    segtree<int,op,e> sg(max_k);
    int x;
    rep(i,n){
        x=sg.prod(max(0,a[i]-k),min(max_k,a[i]+k+1));
        sg.set(a[i],x+1);
    }
    cout<<sg.all_prod()<<endl;
}/*
./problem.exe
*/

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 2e5 + 10;
int n, A[maxn], ans[maxn];

vector <int> E[maxn];

int len, val[maxn];

void dfs(int u,int f){
  ans[u]=len;
  for(int v:E[u])if(v!=f){
    int pos=lower_bound(val+1,val+len+1,A[v])-val;
    int lst=val[pos];
    val[pos]=A[v];
    bool flg=pos>len;
    if(flg)len++;
    dfs(v,u);
    val[pos]=lst,len-=flg;
  }
}

void solve() {
  cin>>n;
  rep(i,1,n)A[i]=read();
  rep(i,2,n){
    int u=read(),v=read();
    E[u].push_back(v),E[v].push_back(u);
  }
  val[len=1]=A[1];
  dfs(1,0);
  rep(i,1,n)printf("%d\n",ans[i]);
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 30408
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    long long n,sum=0;
    cin>>n;
    int a[n+1];
    a[0]=0;
    for(long long i=1;i<1+n;i++)
        cin>>a[i];
    for(int i=1;i<n+1;i++)
        sum+=abs(a[i]-a[i-1]);
    sum+=abs(a[n]);
    for(long long i=1;i<n+1;i++)
    {
        int p,q,k;
        if(i==n)
        {
           p=abs(a[i]-a[i-1]);
            q=abs(a[i]);
            k=abs(a[i-1]);
            cout<<sum-p-q+k<<endl;
        }
        else
        {
            p=abs(a[i]-a[i-1]);
            q=abs(a[i]-a[i+1]);
            k=abs(a[i-1]-a[i+1]);
            cout<<sum-p-q+k<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
     
int main(void){
     
  int a[3];
  int change;
  register int i,s;
 
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  if(a[0] > a[1]){
    change = a[0];
    a[0] = a[1];
    a[1] = change;
  }
  if(a[1] > a[2]){
    change = a[1];
    a[1] = a[2];
    a[2] = change;
  }
  if(a[0] > a[1]){
    change = a[0];
    a[0] = a[1];
    a[1] = change;
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int dp[101][4][4];
int main(void)
{
	int n,d;
	int a,b;
	int pa[101];
	int s=0;
	int i,j,k,l;
	
	scanf("%d %d",&n,&d);
	for(i=1;i<=n;i++){
		pa[i]=0;
		for(j=1;j<=3;j++){
			for(k=1;k<=3;k++){
				dp[i][j][k]=0;
			}
		}
	}
	for(i=1;i<=d;i++){
		scanf("%d %d",&a,&b);
		pa[a]=b;
	}
	if(pa[1]==0){
		for(i=1;i<=3;i++){
			dp[1][i][1]=1;
		}
	}
	else {
		dp[1][pa[1]][1]=1;
	}
	for(i=1;i<=3;i++){
		if(pa[1]==i || pa[1]==0){
			for(j=1;j<=3;j++){
				if(pa[2]==j || pa[2]==0){
					dp[2][j][i]+=1;
				}
			}
		}
	}
	for(i=2;i<n;i++){
		for(j=1;j<=3;j++){
			if(pa[i]==j || pa[i]==0){
				for(k=1;k<=3;k++){
					for(l=1;l<=3;l++){
						if(pa[i+1]==l || pa[i+1]==0){
							if(!(j==k && l==j)){
								dp[i+1][l][j]+=dp[i][j][k];
								dp[i+1][l][j]=dp[i+1][l][j]%10000;
							}
						}
					}
				}
			}
		}
	}
	
/*	for(i=1;i<=n;i++){
		for(j=1;j<=3;j++){
			for(k=1;k<=3;k++){
				printf(" %d",dp[i][j][k]);
			}
			printf(" |");
		}
		printf("\n");
	}*/
	for(i=1;i<=3;i++){
		for(j=1;j<=3;j++){
			s+=dp[n][i][j];
			s=s%10000;
		}
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    string s;
    cin >> s;
    char S[4];
    rep(i, 4) S[i] = s[i];
    sort(S, S + 4);
    if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
	string n;
	cin >> n;
	for(int i; i < 3; i++) {
		if(n.at(i) == '1') n.at(i) = '9';
		else n.at(i) ='1';
	}
	cout << n << endl;
}


Measured memory_bytes: 256
for _ in range(int(input())):
	input()
	*a, = map(int,input().split())
	s = input()
	b=[]
	ans=0
	for x,p in zip(a[::-1],s[::-1]):
		for y in b:
			x=min(x,x^y)
		if x:
			if p=="1":
				ans=1
				break
			b.append(x)
	print(ans)


Measured memory_bytes: 9156
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writeln(int x){
	write(x);puts("");
}
int nedge=0,p[200010],nex[200010],head[200010],n,m;
int s[200010],d[200010],dfn[200010],low[200010],cnt=0,top;
bool b[200010];
inline void addedge(int a,int b){
	p[++nedge]=b;nex[nedge]=head[a];head[a]=nedge;
}
inline void dfs(int x,int fa){
	dfn[x]=low[x]=++cnt;
	b[x]=1;s[++top]=x;
	for(int k=head[x];k;k=nex[k]){
		if(!dfn[p[k]])dfs(p[k],x),low[x]=min(low[x],low[p[k]]);
		else if(p[k]!=fa&&b[p[k]])low[x]=min(low[x],dfn[p[k]]);
	}
	if(low[x]==dfn[x]){
		d[0]++;d[d[0]]=1;
		while(s[top]!=x)top--;
		top--;
	}
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		addedge(x,y);addedge(y,x);
	}
	dfs(1,0);
	writeln(d[0]-1);
	return 0;
}

Measured memory_bytes: 2304
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
		long startCpuTime = threadMXBean.getCurrentThreadCpuTime();

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\0541-input.txt"));

		while (scan.hasNext()) {

			int h = scan.nextInt();
			if (h == 0)
				break;
			int w = scan.nextInt();
			int n = scan.nextInt();
			Walk walk = new Walk(h, w);
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++)
					walk.set(i, j, scan.nextInt());
			int r = walk.end(n);
			if (r > 0)
				System.out.println((h + 1) + " " + r);
			else
				System.out.println((-1 * r) + " " + (w + 1));
		}

		scan.close();
		long stopCpuTime = threadMXBean.getCurrentThreadCpuTime();
		// System.out.println("CPU=" + (stopCpuTime - startCpuTime) / 1000000);

		System.exit(0);
	}
}

class Walk {
	int[][] cr;
	int[][] tm;

	public Walk(int h, int w) {
		cr = new int[h][w];
		tm = new int[h + 1][w + 1];
	}

	public int end(int n) {
		tm[0][0] = n - 1;
		for (int h = 0; h < tm.length - 1; h++)
			for (int w = 0; w < tm[0].length - 1; w++) {
				tm[h + 1][w] += tm[h][w] / 2;
				tm[h][w + 1] += tm[h][w] / 2;
				if (tm[h][w] % 2 == 1) {
					if (cr[h][w] == 0)
						tm[h + 1][w]++;
					else
						tm[h][w + 1]++;
					cr[h][w] ^= 1;
				}
			}

		return this.move(0, 0);
	}

	private int move(int h, int w) {
		if (h >= cr.length)
			return (w + 1);
		if (w >= cr[0].length)
			return (-1 * (h + 1));
		if (cr[h][w] == 0) {
			cr[h][w] = 1;
			return move(h + 1, w);
		} else {
			cr[h][w] = 0;
			return move(h, w + 1);
		}
	}

	public void set(int h, int w, int d) {
		cr[h][w] = d;
	}
}

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

bool check(string s) {
  int n = s.size() / 2;
  rep(i, n) {
    if(s[i] != s[n+i]) return false;
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  if(s.size()%2==0) s.erase(s.size()-2, 2);
  else s.erase(s.size()-1, 1);
  
  while(!check(s)) {
    s.erase(s.size()-2, 2);
  }
  
  cout << s.size() << endl;
  
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
static const int N = 1000;
int main(){
  int n,i,j,k,len,com,whereplus[N];
  string str[N];
  while(1){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> str[i];
    }
    for(i=0;i<n;i++){
      len=str[i].size();
      if(str[i][0]=='.'){
	for(j=0;j<len-1;j++){
	  if(str[i][j+1]!='.'){
	    whereplus[i]=j;
	    str[i][j]='+';
	    break;
	  }
	}
      }
      else whereplus[i]=-1;
    }
    for(i=0;i<n;i++){
      com=whereplus[i];
      for(j=i+1;j<n;j++){
	if(whereplus[j]<com) break;
	if(com==whereplus[j]){
	  for(k=i+1;k<j;k++){
	    str[k][com]='|';
	  }
	  break;
	}
      }
    }
    for(i=0;i<n;i++){
      len=str[i].size();
      for(j=0;j<len;j++){
	if(str[i][j]=='.') str[i][j]=' ';
      }
    }
    for(i=0;i<n;i++){
      cout << str[i] << endl;
    }
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b; cin>>a>>b;
	if (a<10 && b<10){
		cout << a*b << "\n";
	}else{
		cout << "-1\n";
	}
	return 0;
}

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

using namespace std;
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'

int main(){
    FAST
    int a,b;
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    int cnt=a;
    int tap=1;
    while(cnt<b){
        cnt+=a-1;
        tap++;
    }
    cout<<tap<<endl;
}

Measured memory_bytes: 3612
import java.util.*;
 
public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		if(N >= 10) {
			System.out.println(R);
		}else {
			System.out.println(R + (100 * (10 - N)));
		}
	}
}

Measured memory_bytes: 35748
package main

import (
	"fmt"
	"sort"
)


func main() {

	// input size
	var n int
	fmt.Scan(&n)
	slist := make([]string, n)

	// make input value list
	for i := 0; i < n; i++ {
		fmt.Scan(&slist[i])
	}

	// make word count map
	wcMap := make(map[string]int)
	for k := 0; k < len(slist); k++ {
		_, exists := wcMap[slist[k]]
		if exists {
			wcMap[slist[k]]++
		} else {
			wcMap[slist[k]] = 1
		}
	}

	// take countMax
	max := 0
	maxMap := make(map[string]int)
	for key, value := range wcMap {

		if value > max {
			max = value
			maxMap = make(map[string]int)
			maxMap[key] = value
		} else if value == max {
			maxMap[key] = value
		}
	}

	results := make([]string, len(maxMap))
	index := 0
	for key := range maxMap {
		results[index] = key
		index++
	}
	sort.Strings(results)

	for _, l := range results {
		fmt.Println(l)
	}
}


Measured memory_bytes: 36096
def main():
    *a, = map(int, input().split())

    a.sort()
    ma = a[-1]

    if (a[0] - a[1]) % 2 == 1:
        # 収束値がmaになるには
        # ma以外の2要素の偶奇が一致していなければならない
        # ma in oddsの場合だと
        # odds=[ma],evens=[a0,a1]
        # odds=[ma,a0,a1],evens=[]
        # の2パターン
        ma += 1
    ans = (ma * 3 - sum(a)) // 2

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

int main(){
  string a,b;
  cin >> a >> b;
  if(a.at(0)==b.at(2) && a.at(1)==b.at(1) && a.at(2)==b.at(0)){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

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

vector<int64_t> lucdp(100);

int64_t lucas(int n) {
  if (n == 0) return 2;
  if (n == 1) return 1;
  if (lucdp.at(n) != 0) return lucdp.at(n);
  return lucdp.at(n) = lucas(n - 1) + lucas(n - 2);
}

int main() {
  int n;
  cin >> n;
  int64_t ans = 0;
  ans = lucas(n);
  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int x, y, kame, tsuru;
    scanf ("%d %d", &x, &y);
    kame = x;
    tsuru = 0;
    while (1) {
        if (kame * 4 + tsuru * 2 == y) {
            printf ("Yes\n");
            return 0;
        }
        if (kame == 0) break;
        kame--;
        tsuru++;
    }
    printf ("No\n");
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  cin >> n;
  map<ll,int> s,t;
  vector<int> v(n);
  rep(i,n){
    ll tmp;
    cin >> tmp;
    v[i] = tmp;
    if(i > 0) t[i+1-tmp]++; 
  }
  ll ans = 0LL;
  for (int i = 0;i < n;i++){
    ans += t[(ll)v[i]+i+1];
    t[i+1-(ll)v[i]]--;
  }
  
  cout << ans << endl;


  return 0; 
}



Measured memory_bytes: 26528
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int dx = tx-sx, dy = ty-sy;

    cout<< string(dy,'U') << string(dx,'R');
    cout<< string(dy,'D') << string(dx,'L');
    cout<< 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
    cout<< 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
    cout<<endl;
}

Measured memory_bytes: 256
n, c, k = map(int, input().split()); a = [int(input()) for _ in range(n)]
a.sort(); t = a[0]+k; m = 0; x = 1
for i in range(n):
    if a[i] > t or m == c: t = a[i]+k; m = 1; x += 1
    else: m += 1
print(x)

Measured memory_bytes: 13120
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		 BigDecimal aa = new BigDecimal(n);
		int k = scan.nextInt();
		BigDecimal ab = new BigDecimal(k);
		BigDecimal a1 = new BigDecimal(1);
		int a =2;

		double result = 0;

		for(int i=1; i<=n; i++){
			a=2;

			if(i<=k-1) {
				while(a*i<k) {
					a= a*2;


				}
//				BigDecimal aaa = new BigDecimal(a);
//				double b1 = a1.divide(aa, 15, BigDecimal.ROUND_HALF_UP).doubleValue();
//				BigDecimal ab1 = new BigDecimal(b1);
//				double b2 = ab1.divide(aaa, 15, BigDecimal.ROUND_HALF_UP).doubleValue();
//				//System.out.println(b2);
				double b2 = (double)1/n/a;
				result += b2;
			}else {
				double b1 = a1.divide(aa, 15, BigDecimal.ROUND_HALF_UP).doubleValue();
				result += b1;
			}
			// System.out.println(result); 
		}
		System.out.println(result); 
	}
}

Measured memory_bytes: 24020
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> p;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;

int main(){
    int n,m;cin>>n>>m;
    int c[m];
    for(int i=0;i<m;++i) cin>>c[i];
    vector<vector<int> > dp(m+1,vector<int>(n+1,INF));
    dp[0][0]=0;
    for(int i=0;i<m;++i){
        for(int j=0;j<=n;++j){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            if(j>=c[i]) dp[i+1][j]=min(dp[i+1][j],dp[i+1][j-c[i]]+1);
        }
    }
    cout<<dp[m][n]<<endl;
    return 0;
}


Measured memory_bytes: 7136
def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    AB = []
    for a in A:
        for b in B:
            AB.append(a + b)

    AB.sort(reverse=True)
    C.sort(reverse=True)
    ans = []
    for i in range(min(K,X*Y)):
        for j in range(min(K,Z)):
            ans.append(AB[i] + C[j])

    ans.sort(reverse=True)
    for k in range(K):
        print(ans[k])



if __name__ == "__main__":
    main()

Measured memory_bytes: 147884
#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++)

int main(){
    ll n, d;
    cin >> n >> d;
    ll ans = (n + 2*d)/(2 * d + 1);
    cout << ans << endl;
    return 0;
}

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

int main() {
  //←インデント
  int K, A, B; cin >> K;
  cin >> A >> B;
  if(A/K < B/K || A%K == 0)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()

namespace mp = boost::multiprecision;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  mp::cpp_dec_float_100 a, b, c;
  cin >> a >> b >> c;
  mp::cpp_dec_float_100 A = mp::sqrt(a);
  mp::cpp_dec_float_100 B = mp::sqrt(b);
  mp::cpp_dec_float_100 C = mp::sqrt(c);
  
  cout << (A + B < C ?"Yes" :"No") << "\n";

}


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

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<ii, int>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int N = 1e5 + 10;
const int M = 1e4 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;

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

string s;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.txt", "r" , stdin);
    cin >> s;
    FOR(i, 0, 3)
        cout << s[i];
    cout << ' ';
    FOR(i, 4, 11)
        cout << s[i];
    cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b=0,c=0,x=1,i,z;
cin>>a;
z=a;
while(a>0)
{
a/=10;
b++;
}
if(b&1)
{
for(i=1;i<b;i++)
x*=10;
c+=(z-x);
c++;
b-=2;
}
else if(b%2==0)
b--;
while(b>0)
{
c+=9*pow(10,b-1);
b-=2;
}
cout<<c<<"\n";
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.ComponentModel;

class Program
{
    static void Main(string[] args)
    {
        var alice = new Magatro();
        alice.Scan();
        alice.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner() : this(Console.OpenStandardInput())
    {
        Index = 0;
        S = new string[0];
    }
    public Scanner(Stream source)
    {
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public T Next<T>()
    {
        var converter = TypeDescriptor.GetConverter(typeof(T));
        return (T)converter.ConvertFromString(Next());

    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private int X;
    public void Scan()
    {
        Scanner cin = new Scanner();
        X = cin.NextInt();
    }

    public void Solve()
    {
        int sum = 0;
        for (int i = 1; i < 100000; i++)
        {
            sum += i;
            if (X <= sum)
            {
                Console.WriteLine(i);
                return;
            }
        }
    }

}



Measured memory_bytes: 13140
N, A, B = gets.split(' ').map(&:to_i)
result_a = []
for i in 1..N do
  i_a = i.to_s.split('')
  i_s = i_a.inject(0) {|sum, n| sum + n.to_i}
  if i_s >= A && i_s <= B
    result_a.push(i)
  end
end
p result_a.inject(:+)

Measured memory_bytes: 4092
#include<stdio.h>
int main()
{
  int a,b;
  int x = 0;
  
  scanf("%d %d",&a, &b);

  if(a >= b){
    x = x + a;
    a = a - 1;
  }else{
    x = x + b;
    b = b - 1;
  }
  
  if(a >= b){
    x = x + a;
    a = a - 1;
  }else{
    x = x + b;
    b = b - 1;
  }
    
  printf("%d",x);
    
  return 0;
}

Measured memory_bytes: 128
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n =  int(sys.stdin.readline())
a =  list(map(int, sys.stdin.readline().split()))
b =  list(map(int, sys.stdin.readline().split()))
c =  list(map(int, sys.stdin.readline().split()))

ans=0
a0=a[0]-1

# print(a)
# print(b)
# print(c)

ans+=b[a0]
# print(ans)
for i in range(1,n):
    ai=a[i]
    if a[i] == a[i-1]+1:
        ans+=b[ai-1]+c[ai-2]
    else:
        ans+=b[ai-1]
print(ans)

Measured memory_bytes: 5588
s = input()
R = ["R","U","D"]
L = ["L","U","D"]
for i in range(len(s)):
    if i%2 == 0:
        if (s[i] in R):
            flag = True
        else:
            flag = False
            break
    if i%2 == 1:
        if (s[i] in L):
            flag = True
        else:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    long long n;
    cin >> n;
    vector <char> ans;
    
    while(n>0){
        --n;
        ans.push_back(static_cast <char> (n%26)+'a');
        n = n / 26;
    }
    //cout << ans.size();
    for(int i=0; i<ans.size(); i++){
        //cout << "hoge";
        cout << ans[ans.size()-i-1];
    }
    
    return 0;
}

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

const ll MX = 1e18;

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  bool ng = false;
  rep(i,n) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || __int128(ans)*a > MX) {
      ng = true;
    }
    ans *= a;
  }
  if (ng) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>

int main()
{   char me[10000];
   
 gets(me);
   
 if((me[(strlen(me)-1)])!='s')
    {
        printf("%ss\n", me);
    }
    else 

if((me[(strlen(me)-1)])=='s')
    {
        printf("%ses\n", me);
    }


    return 0;
}

Measured memory_bytes: 1648
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int q = sc.nextInt();
      char[] c = sc.next().toCharArray();
      int[] l = new int[q];
      int[] r = new int[q];
      for(int i = 0;i < q;i++){
      	l[i]=sc.nextInt();
        r[i]=sc.nextInt();
      }
      int[] cnt = new int[n+1];
      for(int i=1;i<n;i++){
        if(c[i-1]=='A'&&c[i]=='C')cnt[i+1]++;
      	cnt[i+1]+=cnt[i];
      }
      for(int i = 0;i < q;i++)System.out.println(cnt[r[i]]-cnt[l[i]]);
    }
}


Measured memory_bytes: 77572
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if((a&&b)>=1)
	if((a&&b<=13))
	if(((a>b)||(a==1))&&(b!=1)){
		cout<<"Alice";
	}
	else if(((b>a)||(b==1))&&(a!=1)){
		cout<<"Bob";
	}	
	else if(a==b) {
	
		cout<<"Draw";
}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const ld PI = acos(-1);
ll a, b, x;

ld solve() {
    ll S = b*a*a;

    if (S >= 2*x) {
        ld w = 2.0*x/b/a;
        return atan2(b, w);
    } else {
        ld v = 2*x-S;
        ld h = b-v/a/a;
        return atan2(h, a);
    }
}

int main() {
    cin >> a >> b >> x;
    cout << fixed << setprecision(12) << solve() * 180 / PI << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	H1, M1, H2, M2, K := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	H := H2 - H1
	M := abs(M2 - M1)
	if M1 > M2 {
		H--
		M = 60 - M
	}
	fmt.Println(H*60 + M - K)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1788
#include <stdio.h>
int main(){
  int a,b,c,d,x,y;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  x=(a+b+c+d)/60;
  y=(a+b+c+d)%60;
  printf("%d\n",x);
  printf("%d\n",y);
  return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-

n = input()

l = []

for i in range(n):
    inpt = raw_input().split()
    l.append((inpt[0], int(inpt[1]), i + 1))

l.sort(key=lambda x:(x[0], -x[1]))

for i in l:
    print (i[2])



Measured memory_bytes: 2568
#include <stdio.h>

int main(void)
{
	int n, p[10], max=0, max_number, price=0;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &p[i]);
		if (p[i]>max)
		{
			max=p[i];
			max_number=i;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		if (i!=max_number)
		{
			price+=p[i];
		}
		else
		{
			price+=p[i]/2;
		}
	}
	printf("%d\n", price);
	return 0;
}	

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;


bool check(string a){
        for(int i=0; i<a.length()/2; i++){
                if(a[i] == a[a.length() - i - 1]){
                        continue;
                }else{
                        return false;
                }

        }
        return true;

}



int main(){
         ios::sync_with_stdio(false);    
        cin.tie(0);
        string s;
        cin>>s;
        int l = s.length();
        // cout<<l;
        if(check(s) && check(s.substr(0,(l-1)/2)) && check(s.substr((l+3)/2-1,(l-1)/2))){
                
                cout<<"Yes";
        }else{
                // cout<<check(s) <<check(s.substr(0,(l-1)/2-1))<< check(s.substr((l+3)/2-1,l-1));
                cout<<"No";
        }




        
        



       
                                
        


        return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  int ans=0;
  rep(i,N-1){
    if(A[i+1]==A[i]){
      ans++;
      A[i+1]=0;
    }
  }
  cout<<ans<<endl;
}

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

int gcd(int a, int b) {
    if (a == 0) {
        return b;
    }
    if (b == 0) {
        return a;
    }
    if (a < b) gcd(b, a);
    int r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {

    int N;
    cin >> N;

    vector<int> A;
    int tmp;

    for (int i=0; i<N; i++) {
        cin >> tmp;
        A.push_back(tmp);
    }

    vector<int> L, R;
    L.push_back(0);
    R.push_back(0);
    for (int i=0; i<N; i++) {
        L.push_back(gcd(L[i], A[i]));
        R.push_back(gcd(R[i], A[N-1-i]));
    }
    reverse(R.begin(), R.end());

    // cout << "L : ";
    // for (int i=0; i<=N; i++) {
    //     cout << L[i] << " ";
    // }
    // cout << endl;
    // cout << "R : ";
    // for (int i=0; i<=N; i++) {
    //     cout << R[i] << " ";
    // }
    // cout << endl;

    vector<int> M;
    for (int i=0; i<N; i++) {
        // cout << "L : " << L[i] << "  R : " << R[i+1];
        M.push_back(gcd(L[i], R[i+1]));
        // cout << "  M : " << M.back() << endl;
    }

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

    cout << M.back() << endl;

    return 0;
}


Measured memory_bytes: 2296
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    h,w = LI()
    s = SR(h)
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#":
                su = 0
                for dy,dx in d:
                    y = i+dy
                    x = j+dx
                    if 0 <= y < h and 0 <= x < w:
                        if s[y][x] == "#":
                            su += 1
                if su == 0:
                    print("No")
                    quit()
    print("Yes")
    return

#F
def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return

#G
def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 40048
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;


int main() {
	int flag = 0;
	int count = 0;
	int n, m;
	int nedan[1001] = {};
	int saidai = 0;
	int result[1000];
	for (count = 0; true; count++) {
		cin >> n;
		if (n == 0) break;
		cin >> m;
		saidai = 0;
		for (int i = 0; i < n; i++) {
			cin >> nedan[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j) continue;
				if (((nedan[i] + nedan[j]) > saidai) && (nedan[i] + nedan[j]) <= m) {
					saidai = nedan[i] + nedan[j];
				}
			}
		}
		result[count] = saidai;
	}
	for (int i = 0; i < count; i++) {
		if (result[i] == 0) {
			cout << "NONE" << endl;
		}
		else {
			cout << result[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3088
n = int(input())
a = list(map(int, input().split()))
t = int(input())
drink_list = []

for i in range(t):
    array = list(map(int, input().split()))
    drink_list.append(array)

for i in range(t):
    b = a.copy()
    b[drink_list[i][0]-1] = drink_list[i][1]
    print(sum(b))



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main()
{
    int n;
    set<string>s1;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        s1.insert(s);
    }
    cout<<s1.size()<<"\n";
}

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

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

	int a, b;
	cin >> a >> b;

	string u;
	cin >> u;

	if (u == s) {
		--a;
	} else {
		--b;
	}

	cout << a << " " << b;
	
	return 0;
}
	

Measured memory_bytes: 256
def main():
    S = list(input())
    A = []
    Z = []
    for x in range(len(S)):
        if S[x] == "A":
            A.append(x)
        elif S[x] == "Z":
            Z.append(x)

    print(max(Z) - min(A) + 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 12824