akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int n,m;
int i,j;
int x,y;
int a[256][256];
int b[256];
int sum;

main(){
	scanf("%d %d",&n,&m);
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%d",&x);
			a[i][j]=x;
		}
	}
	for(i=0; i<m; i++){
		scanf("%d",&y);
		b[i]=y;
	}
	
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			sum += a[i][j]*b[j];
		}
				printf("%d\n",sum);
				sum=0;
	}
return 0;	
}

Measured memory_bytes: 704
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    String s=gs();
	    //int b=gi();
	    int m=Integer.parseInt(s.substring(5, 7));
	    //int d=Integer.parseInt(s.substring(7, 9));

        //System.out.println(t/x);
        if (m<=4) {
        	System.out.print("Heisei");
        }else {
        	System.out.print("TBD");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35516
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;

int h, w;
string s[50];
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};

signed main() {
	int i, j, dir;
	
	cin >> h >> w;
	rep(i, h) cin >> s[i];
	
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '.') continue;
			rep(dir, 4) {
				int ny = i + dy[dir];
				int nx = j + dx[dir];
				if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
				if (s[ny][nx] == '#') break;
			}
			if (dir == 4) { cout << "No" << endl; return 0; }
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main(void)
{
    int N;

    cin >> N;

    vector<int> a(N,0);
    int ans = 4000000;

    for(int i = 0; i < N; ++i)
    {
        cin >> a[i];
    }

    for(int i = -100; i <= 100; ++i)
    {
        int tmp = 0;
        for(int j = 0; j < N; ++j)
        {
            tmp += pow(a[j]-i, 2);
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    int h[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }
    sort(h, h + N);
    int m = 1000000000 + 1;
    for (int i = 0; i + K - 1 < N; i++) {
        m = min(m, h[i + K - 1] - h[i]);
    }
    printf("%d\n", m);
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
  
  int n[100], i, j;
  
  scanf("%d",&i);
  for(j = 0; j < i; j++) {
    scanf("%d",&n[j]);
  }
  for(j = i-1; j >= 0; j--) {
  printf("%d", n[j]);
  if(j == 0) break;
  printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 4050;

class Fenwick {
private:
  vector <long long> f;
public:
  void init(int n) {
    f.assign(n, 0);
  }
  void update(int pos, int delta) {
    for (; pos < sz(f); pos = (pos | (pos + 1))) {
      f[pos] += delta;
    }
  }
  long long sum(int pos) {
    long long res = 0;
    for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
      res += f[pos];
    }
    return res;
  }
  long long sum(int l, int r) {
    return sum(r) - sum(l - 1);
  }
};

int n;
int a[MAXN];
int col[MAXN];
int apos[MAXN][2];
int dp[MAXN][MAXN][2];
Fenwick f[2];
int inv[MAXN];
int sum[MAXN][MAXN];

int calc(int pos, int num, int col) {
  int& res = dp[pos][num][col];
  if (res != -1) {
    return res;
  }
  res = 0;
  int otherNum = pos + 1 - num;
  if (pos == n) {
    return res;
  }
  if (otherNum > n / 2 || num > n / 2) {
    res = 1e9;
    return res;
  }
  int curPos = apos[num][col];
  res = inv[curPos];
  res += sum[curPos][otherNum + 1];
  res += min(calc(pos + 1, num + 1, col), calc(pos + 1, otherNum + 1, 1 - col));
  return res;
}

int main() { 

  scanf("%d\n", &n);
  n *= 2;
  for (int i = 0; i < n; i++) {
    char c;
    scanf("%c %d\n", &c, &a[i]);
    col[i] = (c == 'W');
    apos[a[i]][col[i]] = i;
  }

  f[0].init(n); f[1].init(n);

  for (int i = 0; i < n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      if (col[i] == col[j] && a[j] > a[i]) {
        inv[i]++;
      }
    }
    for (int j = n / 2; j >= 1; j--) {
      sum[i][j] = (apos[j][1 - col[i]] < i ? 1 : 0);
      sum[i][j] += sum[i][j + 1];
    }
    // for (int j = 1; j <= n; j++) {
    //   sum[i][j] = f[1 - col[i]].sum(j - 1, n - 1);
    // }
    // f[col[i]].update(a[i] - 1, 1);
  }

  memset(dp, -1, sizeof(dp));

  cout << min(calc(0, 1, 0), calc(0, 1, 1)) << endl;

  return 0;
}


Measured memory_bytes: 192256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
char s[100][100];
int H, W;
void dfs(int x, int y, char f) {
  if (x < 0 || y < 0 || x >= W || y >= H)
    return;
  if (s[y][x] == f) {
    s[y][x] = 'A';
  } else
    return;
  dfs(x + 1, y, f);
  dfs(x - 1, y, f);
  dfs(x, y + 1, f);
  dfs(x, y - 1, f);
}
int main() {
  while (cin >> H >> W) {
    if (H == 0 && W == 0)
      break;
    int ans = 0;
    rep(i, H) rep(j, W) cin >> s[i][j];
    rep(i, H) rep(j, W) {
      if (s[i][j] == 'A') {
      } else {
        ans++;
        dfs(j, i, s[i][j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009],cr[500009];
int main()
{
    ll a,b,c,i,j=0,k;
    string s;
    cin>>a;
    for(i=1; i<=a; i++)
    {
        cin>>ar[i];
    }
    //ar[a+1]=0;
    //ar[0]=0;
    for(i=0;i<=a+1;i++)
    {
        j=j+abs(ar[i]-ar[i-1]);
    }
    //cout<<j<<endl;
    for(i=1; i<=a; i++)
    {
        k=j+abs(ar[i-1]-ar[i+1])-abs(ar[i-1]-ar[i])-abs(ar[i]-ar[i+1]);
        cout<<k<<endl;
    }

}



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

int main()
{
    string n;
    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n.size(); i++)
    {
        sum += (n[i]) - '0';
    }

    if (sum % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3748
/* You got a dream , you gotta protect it . */
/* Sometimes you win , sometimes you learn . */
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
int main(){
    FAST
    string s;
    cin >> s;
    for(ll i = 0; i < s.size(); i++){
        cout << "x";
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	
	int tuples = 0;
	
	for(int i=1;i<n;i++)
	{
	    for(int j=1;i*j<n;j++)
	    {
	          tuples++;
	    }
	}
	
	cout<<tuples<<"\n";
	
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>

//Memo: 90*n度回転で決まっても90*(n+1)度回転で最小になるかも
//Memo: 最後まで
//Memo: 配列の範囲

const int MAX_N = 100, MAX_M = 50, INF = 1 << 24;
int photo[MAX_N][MAX_N], part[4][MAX_M][MAX_M];//part[n][_][_]: 90*n度回転した写真の一部
int n, m;//n: 写真, m: 一部

void rotate(){
	for(int i=0;i<3;i++){
		for(int j=0;j<m;j++){
			for(int k=0;k<m;k++){
				part[i+1][m-k-1][j] = part[i][j][k];
			}
		}
	}
}

bool can(int index, int x, int y){//(x, y)を左端としてできるか
	for(int j=0;j<m;j++){
		for(int k=0;k<m;k++){
			if(photo[y+j][x+k] != part[index][j][k] && part[index][j][k] != -1)return false;
		}
	}

	return true;
}

void mostLeftTop(int index, int &x, int &y){//part[index]で-1以外の値を取る最左，上の座標をx, yに加える
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			if(part[index][i][j] != -1){
				x += j;
				y += i;
				return;
			}
		}
	}
}

int main(){
	while(std::cin >> n >> m, n){

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				std::cin >> photo[i][j];
			}
		}

		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				std::cin >> part[0][i][j];
			}
		}

		rotate();

		int x = INF, y = INF;//できたときの左端の座標(最小)

		for(int i=0;i+m<=n;i++){
			for(int j=0;j+m<=n;j++){
				for(int k=0;k<4;k++){
					if(can(k, j, i)){
						int nx = j, ny = i;
						mostLeftTop(k, nx, ny);
						if(ny < y || (ny == y && nx < x))x = nx, y = ny;
					}
				}
			}
		}

		if(x == INF)std::cout << "NA" << std::endl;
		else std::cout << (x+1) << " " << (y+1) << std::endl;
	}
}

Measured memory_bytes: 1236
//Bubble Sort

#include<stdio.h>
#define N 100

void bubble(void);
int i = 0,arr[N];
int n = 0;
int j = 0;
int temp = 0;
int k = 0;
int count = 0;

int main()
{

  //input data
  scanf("%d",&n);

  for(i=0 ; i<n ; i++)
    {
      scanf("%d",&arr[i]);
    }

  //output data
  bubble();

  printf("%d",arr[0]);

  for(k = 1; k < n; k++)
    {
      printf(" %d",arr[k]);
    }
  printf("\n");

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

  return 0;
  
}

void bubble(void)
{
  int flag = 0;

  flag = 1;
  i = 0;

  while(flag)
    {
     
      flag = 0;
      j = n - 1;
      
      for( ;j >= i+1 ; j--)
	{
	  if(arr[j] < arr[j - 1])
	    {
	     
	      temp = arr[j];
	      arr[j] = arr[j-1];
	      arr[j-1] = temp;
	      flag = 1;
	      count++;
	    }
	}
      i++;
    
    }
 
}



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

int main() {
int a,b,c,d;
cin>>a>>b;
if (a<b){cout<<"a < b"<<endl;
}else if(a>b){cout<<"a > b"<<endl;
}else if(a==b){cout<<"a == b"<<endl;

     return 0;
}
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int i,n,m,c=0;
	vector<int> a;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>m;
		a.push_back(m);
	}
	for(i=1;i<n-1;i++)
	{
		if(a[i+1]>a[i]&&a[i]>a[i-1]&&a[i+1]>a[i-1]||a[i-1]>a[i]&&a[i]>a[i+1]&&a[i-1]>a[i+1])
		{
			c++;
		}
	}
	cout<<c;
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i,N){
        cin >> X[i];
    }
    ll total = 0;
    ll ans = 100000000;
    rep(i,101){
        rep(j,N){
            total += pow(X[j]-i,2);
        }
        if(ans > total) ans = total;
        total = 0;
    }
    cout << ans << endl;
}

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

int main(){
    cout.setf(ios_base::fixed, ios_base::floatfield);
    cout.precision(12);
    constexpr double eps = 1e-15;

    double a, b, x;
    double t_ans;
    cin >> a >> b >> x;

    if(a*a*b*0.5 <= x){
        t_ans = 2.0*(a*a*b-x) / (a*a*a);
    }else{
        t_ans = a*b*b / (2.0*x);
    }

    cout << atan(t_ans) * 180.0 / M_PI << endl;
    return 0;
}

Measured memory_bytes: 384
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll H, N;
    cin >> H >> N;
    ll total = 0;
    rep(i, N)
    {
        ll a;
        cin >> a;
        total += a;
    }
    yes(total >= H);

    return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<cmath>
#define mod 1000000007
using namespace std;
long long int dp[101001][13];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a*n, b);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
static const int MAX_V = 100;
static const int MAX_K = 1000;
 
int V;
vector<int> G[MAX_V * 2];
int match[MAX_V * 2];
bool used[MAX_V * 2];
 
void add_edge(int u, int v){
  G[u].push_back(v);
  G[v].push_back(u);
}
 
bool dfs(int v){
  used[v] = true;
  for(int i = 0; i < G[v].size(); i++){
    int u = G[v][i], w = match[u];
    if(w < 0 || !used[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}
 
int bipartite_matching(){
  int res = 0;
  memset(match, -1, sizeof(match));
  for(int v = 0; v < V; v++){
    if(match[v] < 0){
      memset(used, 0, sizeof(used));
      if(dfs(v)){
    res++;
      }
    }
  }
  return res;
}

int main(){
  int X, Y, E;
  scanf("%d %d %d", &X, &Y, &E);
  V = X + Y;
  int u, v;
  for(int i = 0; i < E; i++){
    scanf("%d %d", &u, &v);
    add_edge(u, v + X);
  }
  printf("%d\n", bipartite_matching());
  return 0;
}


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


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

	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	map<ll, ll> mp;
	ll cumsum = 0;
	ll ans = 0;
	mp[0] = 1;
	for (int i = 0; i < N; i++) {
		cumsum += A[i];
		ans += mp[cumsum];
		mp[cumsum]++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ll n, a[10101], ans=0;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n;

rep(i, 1, n){
cin >> a[i];

while(a[i]%2==0){
    a[i]/=2;
    ans++;
}

}


cout << ans << endl;



return 0;}


Measured memory_bytes: 384
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
//#include <bits/stdc++.h>//atcoderでsqrtを使うときに必要
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> a;

	fi(n) {
		int temp;
		cin >> temp;
		a.push(temp);
	}

	fi(m) {
		int temp = a.top();
		a.pop();
		a.push(temp / 2);
	}

	ll res = 0;

	fi(n) {
		res += a.top();
		a.pop();
	}

	ce(res);



}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <random>
#include <climits>

using namespace std;

mt19937 mt(123);

const int H = 17;
const int N = 1 << H;
int L[N + 2], R[N + 2];

void update(int k, int v) {
  k++;
  int l = k;
  int r = k + 1;
  if (~k & 1) {
    L[r] = v;
  } else {
    R[l] = v;
  }
  for (int i = 0; i < H; i++) {
    if (~k & 1) {
      r += 1 << i;
    } else {
      l -= 1 << i;
    }
    k >>= 1;
    int m = l + r >> 1;
    if (~k & 1) {
      L[r] = min(L[m], R[m]);
    } else {
      R[l] = min(L[m], R[m]);
    }
  }
}

int query(int l, int r) {
  l++;
  r++;
  int res = INT_MAX;
  for (int i = r; i - (i & -i) >= l; i -= i & -i) {
    res = min(res, L[i]);
  }
  for (int i = l; i + (i & -i) <= r; i += i & -i) {
    res = min(res, R[i]);
  }
  return res;
}

int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++) {
    update(i, INT_MAX);
  }
  while (q--) {
    int com, x, y;
    scanf("%d %d %d", &com, &x, &y);
    if (com == 0) {
      update(x, y);
    } else {
      printf("%d\n", query(x, y + 1));
    }
  }
}

/*
int s;
int main() {
  for (int i = 0; i < 10000000; i++) {
    int l = uniform_int_distribution<int>(0, N - 1)(mt);
    int r = uniform_int_distribution<int>(0, N - 1)(mt);
    if (l > r) swap(l, r);
    s += query(l, r + 1);
  }
}
*/

/*
int main() {
  for (int i = 0; i < 5000000; i++) {
    int k = uniform_int_distribution<int>(0, N - 2)(mt);
    int v = uniform_int_distribution<int>(0, N - 1)(mt);
    update(k, v);
  }
}
*/


Measured memory_bytes: 4012
#include <stdio.h>
#include <iostream>
#include <algorithm>

#include <string>
#include <cmath>

using namespace std;

struct ans{
  int shou;
  int amari;
};

struct ans div(int n){
  int shou = n / -2;
  int amari = n % 2;

  //printf("%d\t%d\n", amari, shou);

  while(amari < 0){
    shou += 1;
    amari += 2;
  }

  //printf("%d\t%d\n", amari, shou);

  struct ans result;
  result.shou = shou;
  result.amari = amari;

  return result;
}

int main() {
  int n;

  scanf("%d", &n);

  string ans;

  if(n == 0){
    printf("0");
    return 0;
  }

  while(n != 0){
    struct ans temp = div(n);

    //printf("%d\t%d\n", temp.amari, temp.shou);

    if(temp.amari == 0){
      ans.push_back('0');
    }else{
      ans.push_back('1');
    }

    n = temp.shou;
  }

  std::reverse(ans.begin(), ans.end());

  printf("%s\n", ans.c_str());

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a+b, b+c, c+a}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, M, SM = 0, buf; cin >> N >> M;

  REP(i, M) {
    cin >> buf;
    SM += buf;
  }
  if (N-SM >= 0) {
    cout << N-SM << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <regex>
using namespace std;

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

#include <stdio.h>

int main()
{
    int N;

    scanf("%d", &N);

    int n = 1;

    for(; n <= N; n=n*2);

    cout << n/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long N;
	cin>>N;
	long long D[N];
	long long E[N];
	for(int i=0;i<N;i++){
		cin>>D[i];
		E[i]=D[i];
	}
	sort(D,D+N);
	long long mm=10*10*10*10*10*5;
	long long l[mm];
	for(int i=0;i<mm;i++){
		l[i]=0;
	}
	long long tmp=-1;
	vector<long long>jotai;
	for(int i=0;i<N;i++){
		if(tmp!=D[i]){
			jotai.push_back(D[i]);
			tmp=D[i];
		}
		l[D[i]]++;
		
	}
	long long sum=1;
	for(int i=0;i<jotai.size();i++){
		if(jotai[i]==0){
			continue;
		}
		if(E[0]!=0){
			sum=0;
			break;
		}
		for(int j=0;j<l[jotai[i]];j++){
			sum*=l[jotai[i]-1];
			if(sum>998244353){
				sum%=998244353;
			}
		}
	}
	for(int i=1;i<N;i++){
		if(D[i]==0){
			sum=0;
			break;
		}

	}
	
	cout<<sum<<endl;


	
}


Measured memory_bytes: 6904
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
void initialize();
void putQueen(int i);
void printBoard();

int Board[N][N];
int row[N],col[N],dpos[15],dneg[15];

int main(){
    int i,j,k,l;
    
    initialize();
    
    scanf("%d",&k);
    for(l=0;l<k;l++){
        scanf("%d%d",&i,&j);
        Board[i][j]=1;
    }
    putQueen(0);
    return 0;
}


void initialize(){
    int i,j;
    for(i=0;i<N;i++){
        row[i]=FREE;
        col[i]=FREE;
    }
    for(i=0;i<15;i++){
        dpos[i]=FREE;
        dneg[i]=FREE;
    }
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            Board[i][j]=FREE;
        }
    }
}
void printBoard(){
    int i,j;
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(Board[i][j]==NOT_FREE){
                if(row[i]!=j) return;
            }
        }
    }
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(row[i]==j) printf("Q");
            else printf(".");
        }
        printf("\n");
    }
}

void putQueen(int x){
    int j;
    if(x==N){
        printBoard();
        return;
    }
    for(j=0;j<N;j++){
        if(col[j]==NOT_FREE || dpos[x+j]==NOT_FREE || dneg[x-j+N-1]==NOT_FREE) continue;
        row[x]=j;
        col[j]=dpos[x+j]=dneg[x-j+N-1]=NOT_FREE;
        putQueen(x+1);
        row[x]=col[j]=dpos[x+j]=dneg[x-j+N-1]=FREE;
    }
}

Measured memory_bytes: 572
#include<iostream>
using namespace std;
typedef long long ll;
ll f[87];
int main(){
  int n;cin>>n;
  f[0]=2LL;f[1]=1LL;
  for(int i=2;i<=n;i++)f[i]=f[i-1]+f[i-2];
  cout<<f[n]<<endl;
  return 0;
}


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

int	main()
{
	int N, M;
	cin >> N >> M;
	vector<int>	cnt_vec(N, 0);
	int	a, b;
	for (int i = 0; i < M; ++i) {
		cin >> a >> b;
		--a; --b;
		++cnt_vec.at(a);
		++cnt_vec.at(b);
	}
	for (int i = 0; i < N; ++i)
		cout << cnt_vec.at(i) << endl;
}


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

using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a <= 8 && b <= 8){
        cout<<"Yay!";
    }
    else{
        cout<<":(";
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
    os << "[";
    for (auto x : V) os << x << ", ";
    return os << "]";
}
//--------------------------------------------------//

int main() {
    use_cio();
    int n;
    cin >> n;
    cout << 1LL * (n / 2) * ((n + 1) / 2) << endl;
}


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

int main() {
  int L,R,d,i;
  cin >> L >> R >> d;
  int ans=0;

  for (i = L; i <= R; ++i) {
    if (i % d == 0)ans++;
  }
  cout << ans << endl;
}

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

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

    if(abs(a-b)%2 == 0){
        cout << min(a, b) + abs(a-b)/2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

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

ll n;

int main(void){
	scanf("%lld",&n);
	ll ans=0;
	for(ll i=1LL;i*i<=n;i++){
		if(n%i==0LL){
			ll val=n/i-1LL;
			if(val==0LL)continue;
			if(n%val!=n/val)continue;
			ans+=(n/i)-1LL;
		}	
	}
	printf("%lld\n",ans);
	return 0;
}


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


int main(int argc,char** argv)
{

		string s;
		cin >> s;

		if(s[0] != 'A'){
			cout << "WA" << endl;
			return 0;
		}


		int ccnt=0;
		for(int i = 2; i < s.size()-1; i++){
			if(s[i] == 'C'){
				ccnt++;
			}
		}
		if(ccnt != 1){
			cout << "WA" << endl;
			return 0;
		}
		int ccnt2=0;
		for(int i = 0; i < s.size(); i++){
			if(s[i] == 'C'){
				ccnt2++;
			}
		}
		if(ccnt2 - ccnt != 0){
			cout << "WA" << endl;
			return 0;
		}


		for(int i = 1; i < s.size(); i++){
			if(s[i] != 'C' && s[i] < 97){
				cout << "WA" << endl;
				return 0;
			}
		}

		cout << "AC" <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define endl            "\n"
    #define ll                long long
    #define all(v)            ((v).begin()), ((v).end())
    #define sz(v)            ((int)((v).size()))
    #define clr(v, d)        memset(v, d, sizeof(v))
    #define rep(i, v)        for(int i=0;i<sz(v);++i)
    #define lp(i, n)        for(int i=0;i<(int)(n);++i)
    #define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
    #define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)
    #define vi                vector <int>
    #define vl                vector <ll>
    #define ii                pair <ll,ll>
    #define vii                vector <ii>
    const double PI = 2 * acos(0.0);
    void run() {
    	ios_base::sync_with_stdio(false);
    	cin.tie(nullptr), cout.tie(nullptr);
    }
    const ll M = 1e5, mod = 1e9 + 7;
    ll n;
    int dp[M + 5][2];
    vi v;
    ll k;
    int sol(int rem, bool turn) {
    	if (rem < 0)
    		return turn ? 1 : 2;
    	int &ret = dp[rem][turn];
    	if (~ret)
    		return ret;
    	if (turn) {
    		lp(j,n)
    		{
    			ret = sol(rem - v[j], !turn);
    			if (ret == 1)
    				return ret;
    		}
    		return ret;
    	} else {
    		lp(j,n)
    		{
    			ret = sol(rem - v[j], !turn);
    			if (ret == 2)
    				return ret;
    		}
    		return ret;
    	}
    }
    int main() {
    	run();
    	cin >> n >> k;
    	v.resize(n);
    	lp(i,n)
    		cin >> v[i];
    	//cout << "HI" << endl;
    	clr(dp, -1);
    	cout << ((sol(k, 1)==1)?"First":"Second");
    }


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

int main(void) {
	int a,b; cin >> a>>b;
	if (a == b) {
		cout << "Draw" << endl;
		return 0;
	}
	else if (a == 1)cout << "Alice" << endl;
	else if (b == 1)cout << "Bob" << endl;
	else
		cout << (a < b ? "Bob" : "Alice") << endl;
	return 0;
}

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

int main(int argc, const char * argv[])
{
    string str;
    while(getline(cin, str)){
        for (int i = 0; i < 26; i++) {
            for (int k = 0; k < str.size(); k++) {
                if (isalpha(str[k])) {
                    str[k]++;
                    if (str[k] > 'z') {
                        str[k] -= 26;
                    }
                }
            }
            if (str.find("the") != string::npos || str.find("that") != string::npos || str.find("this") != string::npos){
                goto finish;
            }
        }
    
finish:
        cout << str << endl;
    }
     return 0;
}

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

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

int A[10];

int main()
{
    rep(i, 0, 4)
    {
        cin >> A[i];
    }
    sort(A, A + 4);
    if (A[0] == 1 && A[1] == 4 && A[2] == 7 && A[3] == 9)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll N;cin>>N;
  ll i,j,k,l;
  ll A[N+1];
  rep(i,N) cin>>A[i];
  ll ans[N];
  rep(i,N) ans[i]=0;
  ll left=-1,right=2*INF+1;
  while((right-left)>1){
    ll mid = (left+right)/2;
    //if(mid%2!=0) mid--;
    ans[0]=mid;
    for(i=0;i<N-1;i=i+2){
      ans[i+2]=ans[i]+2*(A[i+1]-A[i]);
    }
    ll tmp = ans[0] + ans[N-1];
    // cout<<left<<" "<<right<<" "<<ans[0]<<" "<<ans[N-1]<<" "<<tmp<<endl;
    if(tmp == 2*A[N-1]) break;
    else if(tmp<2*A[N-1]) left=mid;
    else right=mid;
  }
  ans[1]=ans[N-1]+2*(A[0]-A[N-1]);
  for(i=1;i<N-1;i+=2){
    ans[i+2]=ans[i]+2*(A[i+1]-A[i]);
  }
  rep(i,N){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 2816
#!/usr/bin/env python3
N = int(input())
A = [int(s)-1 for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]


cnt = B[A[0]]
for i in range(1, N):
    if A[i] - A[i - 1] == 1:
        cnt += B[A[i]] + C[A[i - 1]]
    else:
        cnt += B[A[i]]

print(cnt)

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int int64_t
#define ll long long
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

signed main(){

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

    if(a > 0){
        cout<<"Positive"<<'\n';
    }else if(a <= b && b < 0){
        if((b-a+1) % 2 == 0){
            cout<<"Positive"<<'\n';
        }else{
            cout<<"Negative"<<'\n';
        }
    }else{
        cout<<"Zero"<<'\n';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int a[100], b[100], c[100], d[100];
int n, m, q;
int dfs(int i, int arr[]) {
    if(i == n) {
        int ret = 0;
        for(int j = 0; j < q; j++) {
            if(arr[b[j]] - arr[a[j]] == c[j]) ret += d[j];
        }
        return ret;
    }
    int ret = 0;
    for(int j = i?arr[i-1]:1; j <= m; j++) {
        arr[i] = j;
        chmax(ret, dfs(i+1, arr));
    }
    return ret;
}

signed main() {



    cin >> n >> m >> q;
    
    for(int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    
    int arr[10];

    cout << dfs(0, arr) << endl;
    

    
    return 0;
}



Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			// 椅子の長さ
			int chair = sc.nextInt();
			// 人の幅
			int human = sc.nextInt();
			// 隙間
			int gap = sc.nextInt();

			// 座れる人数
			int ans = 0;
			int set = human + gap;
			if(chair % set >= gap){
				// 隙間を開けて座れる
				ans = chair / set;
			} else {
				// 隙間を開けて座れない
				ans = chair / set - 1;
			}
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	set<int> st;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;
vector<int> dp(100010, INF);// key is asiba val is cost

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    dp[0] = 0;
    dp[1] = abs(H[1]-H[0]);
    xrep(i, 2, N) {
        dp[i] = min(dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i]));
    }
    print(dp[N-1]);


    return 0;
}

Measured memory_bytes: 4004
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,T;
    double A;

    int ans_num;
    int ans_val = MOD;
    cin >> N >> T >> A;
    REP(i,N){
        int H;
        cin >> H;
        if(abs((int)((A-(T-H*0.006))*1000)) < ans_val){
            ans_val = abs((int)((A-(T-H*0.006))*1000));
            ans_num = i+1;
        }
    }
    cout << ans_num << endl;
}

Measured memory_bytes: 256
from sys import stdin
import math
a=stdin.readline().split()
H1=int(a[0])
M1=int(a[1])
H2=int(a[2])
M2=int(a[3])
K=int(a[4])

if M2>=M1:
    min=M2-M1
    if H2>=H1:
        hour=H2-H1
    else:
        hour=H2+24-H1
else:
    min=M2+60-M1
    if H2-1>=H1:
        hour=H2-1-H1
    else:
        hour=H2+24-1-H1

elapsed=hour*60+min

print(elapsed-K)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll a;
    while(cin>>a){
        ll mod=11;
        ll output=a/mod*2;
        a%=mod;
        if(a>=1&&a<=6)output++;
        if(a>=7&&a<=10)output+=2;
        cout<<output<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);

    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    int temp = a[0];
    int ans = 1;
    for(int i = 1;i < n;i++){
        if(temp >= a[i]){
            ans++;
            temp = a[i];
        }
    }
    cout << ans << endl;

    return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int r;
  std::cin >> r;
  std::cout << 3 * r * r << std::endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static boolean visited[][];
    static int[][] s;
    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long H = scan.nextLong();
        long ans = 1;
        long numOfMon = 1;
        while(H != 1){
            H = H/2;
            numOfMon *= 2;
            ans += numOfMon;
        }

        os.println(ans);
    }

}

Measured memory_bytes: 23252
n,m,x = map(int, input().split())

c=[]
for i in range(n):
    c.append(list(map(int, input().split())))

ans =[0]*(m+1)

for i in range(m+1):
    for j in range(n):
        ans[i] = ans[i]+c[j][i]

if min(ans[1:]) < x :
    print(-1)
    exit()

tempans = [0]*(m+1)

for i in range(2 ** n):
    tempans = [0]*(m+1)
    for j in range(n):
        if ((i>>j) & 1):
            for k in range(m+1):
                tempans[k] = tempans[k]+c[j][k]
    if min(tempans[1:]) >= x and tempans[0] < ans[0]:
        ans[0] = tempans[0]

print(ans[0])

Measured memory_bytes: 9256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
from numba import jit

@jit
def run_dp(MAP, dp, R, C):
    for i in range(1, R+1):
        for j in range(1, C+1):
            for k in range(4):
                dp[i,j,0] = max(dp[i,j,0], dp[i-1,j,k])
                if MAP[i,j]:
                    dp[i,j,1] = max(dp[i,j,1], dp[i-1,j,k]+MAP[i,j])

                dp[i,j,k] = max(dp[i,j,k], dp[i,j-1,k])
                if MAP[i][j] and k < 3:
                    dp[i,j,k+1] = max(dp[i,j,k+1], dp[i,j-1,k] + MAP[i,j])
    return dp[R, C].max()

def run():
    R,C,K = map(int, sysread().split())
    MAP = np.zeros((R + 1, C + 1), dtype=np.int64)
    for i in range(K):
        r, c, v = map(int, sysread().split())
        MAP[r, c] = v

    dp = np.zeros((R+1, C+1, 4), dtype= np.int64)

    run_dp(MAP, dp, R, C)

    #print(dp)
    #for m in MAP:
    #   print(m)
    ans= run_dp(MAP, dp, R, C)

    print(ans)

if __name__ == "__main__":
    run()

Measured memory_bytes: 470712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d) {
    cout << "Left" << endl;
  }
   
  else if (a + b < c + d) {
    cout << "Right" << endl;
  }
  
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3552
from collections import Counter
n = int(input())
list_A = list(map(int, input().split()))
list_C = Counter(list_A)
list_D = sorted(list_C.items(), key=lambda x:x[0],reverse=True)
q = []
for i in range(len(list_D)):
    if len(q) == 2:
        break
    l = list_D[i]
    if l[1] > 1:
        q.append(l[0])
        if len(q) == 1 and l[1] > 3:
            q.append(l[0])
if len(q) == 2:
    print(q[0]*q[1])
else:
    print(0)

Measured memory_bytes: 22436
#include <stdio.h>

int main(void){
  double xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3;
  int q;
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xp0,&yp0,&xp1,&yp1,&xp2,&yp2,&xp3,&yp3);
    if((yp1-yp0)*(xp3-xp2)==(yp3-yp2)*(xp1-xp0)){
      printf("2\n");
    }
    else if((yp1-yp0)*(yp3-yp2)+(xp1-xp0)*(xp3-xp2)==0){
      printf("1\n");
    }
    else{
      printf("0\n");
    }
  }
  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};
//UnionFind Uni(N);
//Uni.connect;

int main(){
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
    }
    UnionFind Uni(n);
    ll sum = (ll)n*(n-1)/2;
    ll ans[m];
    rep(i,m){
        ans[m-1-i]=sum;
        ll sizea = Uni.size(a[m-1-i]);
        ll sizeb = Uni.size(b[m-1-i]);
        if(Uni.root(a[m-1-i])!=Uni.root(b[m-1-i]))sum -= sizea*sizeb;
        Uni.connect(a[m-1-i],b[m-1-i]);
    }
    rep(i,m){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p1=1000000007;
int n;
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--) {
        string s,t; int a,b;cin>>s>>t>>a>>b;
        string u;cin>>u;
        if(s==u)a--;
        else b--;
        cout<<a<<" "<<b; 
    }   
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (to_string(i).length() & 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(void){
  int N;
  int M;
  int i;
  int j;
  int k;
  int l;
  int sum=0;
  char a;
  int v[1000][1000];

 cin>>M>>N;
  for(i=1;i<=M;i++){
    for(j=1;j<=N;j++){
      cin>>a;
      if(a=='o'){
	for(k=-1;k<2;k++){
	  v[i][j+k]=1;
	}
      }
      if(a=='x'){
	  for(k=-1;k<2;k++)
	    for(l=-1;l<2;l++)
	    v[i+k][j+l]=1;
      }
    }
}
      for(i=2;i<=M;i++){
	for(j=1;j<=N;j++){
	  if(v[i][j]==0){
	    sum++;
	  }
	}
      }
	cout<<sum<<endl;
	return 0;
    }

Measured memory_bytes: 3224
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn =1e5+100;
int n,m,res1,res2;

int a[maxn],b[maxn];
int mx=0;
char s[maxn];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		a[i]=s[i]-'0';
		b[i]=a[i];
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1]){
			a[i]=a[i-1]^1;res1++;
		}
	}
	b[1]^=1;res2++;
	for(int i=2;i<=n;i++)
	{
		if(b[i]==b[i-1]){
			b[i]=b[i-1]^1;res2++;
		}
	}
	cout<<min(res1,res2)<<endl;
	return 0;
}

Measured memory_bytes: 1152
if __name__ == "__main__":
    N, L = map(int, input().split())
    apples = []
    for i in range(1,N+1):
        apples.append(L + i - 1)

    applesabs = [abs(i) for i in apples]
    index = applesabs.index(min(applesabs))

    del apples[index]

    print(sum(apples))



Measured memory_bytes: 3060