akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

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

    vector<pair<long,long>> v(n);
    for(auto &e: v) {
        long x, l;
        cin >> x >> l;
        e = make_pair(x+l, x-l);
    }
    sort(v.begin(), v.end());

    long r = 0;
    long t = -1e18;
    for(auto &e: v) {
        if(t <= e.second)
            r++, t = e.first;
    }
    cout << r << endl;
}


Measured memory_bytes: 1792
def calc(a)
  while a.size > 1
    b = []
    for i in 0...(a.size - 1)
      b << (a[i] + a[i + 1]) % 10
    end
    a = b
  end

  a.first
end

while line = gets
  stack = line.chomp.split('').map(&:to_i)
  puts calc(stack)
end

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

int main() {
  string S , T;
  cin >> S >> T;
  
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(S.at(i) == T.at(i)){
      count++;
    }
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Int long long
#define pb push_back
using namespace std;


Int N,M,K;
Int X,Y,Z,D;
const int MAXN=105;
Int B,C;


struct DisJointSet{
    vector<int> SZ;
    vector<int> ID;
    int n;

    DisJointSet(int n){
        SZ.resize(n);
        ID.resize(n);
        this->n=n;
        
        for(int i=0;i<n;++i){
            ID[i]=i;
            SZ[i]=1;
        }
    }
    
    int find(int x){
        return (ID[x]==x ? x:find(ID[x]));
    }
    
    void Union_find(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(SZ[x]>SZ[y]){
            ID[y]=x;
            SZ[x]+=SZ[y];
        }
        else{
            ID[x]=y;
            SZ[y]+=SZ[x];
        }
        return;
    }
};


int main()
{
    
    
    cin>>N>>M;
    cout<<(N+M-1)/M<<"\n";
    
   
     
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool f = true;
    if (s[a] == '-')
    {
        for (int i = 0; i < a; i++)
        {
            if (s[i] == '-')
            {
                f = false;
            }
        }
        for (int i = a + 1; i < s.length(); i++)
        {
            if (s[i] == '-')
            {
                f = false;
            }
        }
        if (f == true)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
li = [int(input()) for i in range(Q)]
member = [0 for x in range(N)]
for i in li:
    member[i-1] += 1
for j in member:
    ans = j-Q+K
    if ans <= 0:
        print('No')
    else:
        print('Yes')

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

int main(){
	ll n;
	cin >> n;
	
	vector<string> s(n);
	rep(i, n) {
		string ss;
		cin >> ss;
		sort(ss.begin(), ss.end());
		s.at(i) = ss;
	}
	sort(s.begin(), s.end());
//	rep(i, n) cout << s.at(i) << endl;
	
	vector<ll> equal(n, 0);
	ll ans = 0;
	rep(i, n) {
		if (i == 0) continue;
		if (s.at(i) == s.at(i-1)) {
			equal.at(i) = equal.at(i-1)+1;
		}
		ans += equal.at(i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var h = cin.NextLong();
			var w = cin.NextLong();
			var best = long.MaxValue;
			for (var i = 1; i < h; i++)
			{
				var a = i*w;
				var hh = h - i;
				var a2 = hh*(w/2);
				var a3 = hh*(w - w/2);
				best = Math.Min(best, Diff(a, a2, a3));
				a2 = hh/2*w;
				a3 = (hh - hh/2)*w;
				best = Math.Min(best, Diff(a, a2, a3));
			}
			var temp = h;
			h = w;
			w = temp;
			for (var i = 1; i < h; i++)
			{
				var a = i * w;
				var hh = h - i;
				var a2 = hh * (w / 2);
				var a3 = hh * (w - w / 2);
				best = Math.Min(best, Diff(a, a2, a3));
				a2 = hh / 2 * w;
				a3 = (hh - hh / 2) * w;
				best = Math.Min(best, Diff(a, a2, a3));
			}
			Console.WriteLine(best);

			//var a = h*w;
			//var t = a/3;
			//var hh = t / w;
			//var piece1 = hh*w;
			//var piece2 = (h - hh)*(w/2);
			//var piece3 = (h - hh)*(w - w/2);
			//var diff = Math.Max(Math.Max(Math.Abs(piece1 - piece2), Math.Abs(piece1 - piece3)), Math.Abs(piece2 - piece3));
			//piece1 = hh * w;
			//piece2 = (h - hh)/2 * w;
			//piece3 = ((h - hh) - (h - hh)/2) * w;
			//var diff3 = Math.Max(Math.Max(Math.Abs(piece1 - piece2), Math.Abs(piece1 - piece3)), Math.Abs(piece2 - piece3));
			//var temp = h;
			//h = w;
			//w = temp;
			//a = h * w;
			//t = a / 3;
			//hh = t / w;
			//piece1 = hh * w;
			//piece2 = (h - hh) * (w / 2);
			//piece3 = (h - hh) * (w - w / 2);
			//var diff2 = Math.Max(Math.Max(Math.Abs(piece1 - piece2), Math.Abs(piece1 - piece3)), Math.Abs(piece2 - piece3));
			//piece1 = hh * w;
			//piece2 = (h - hh) / 2 * w;
			//piece3 = ((h - hh) - (h - hh) / 2) * w;
			//var diff4 = Math.Max(Math.Max(Math.Abs(piece1 - piece2), Math.Abs(piece1 - piece3)), Math.Abs(piece2 - piece3));
			//var res = Math.Min(Math.Min(diff, diff2), Math.Min(diff3, diff4));
			//Console.WriteLine(res);
		}

		private long Diff(long a, long b, long c)
		{
			return Math.Max(Math.Abs(a - b), Math.Max(Math.Abs(a - c), Math.Abs(b - c)));
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
			new Template().Solve();
			Console.ReadLine();
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int n,k,a[233333];double mx;
inline bool check(double x){
	int cnt=0;
	for(int i=1;i<=n;i++)
		cnt+=(int)ceil(a[i]/x)-1;
	return cnt<=k;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i],mx=max(mx,(double)a[i]);
	double l=0.0,r=mx,ans=mx;
	while(r-l>1e-6){
		double mid=(l+r)/2.0;
		if(check(mid))r=mid;else l=mid;
	}
	printf("%d\n",(int)ceil(r));
}

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

int main() {

  int X = 0;

  cin >> X;

  int ans = 0;

  ans = (X / 500) * 1000;
  X = X % 500;
  ans += (X / 5) * 5;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    long sum = 0;
    for(int i = 1; i <= N; i++){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; t=1; while(t--)
typedef long long int ll;
int main() {
    FIO;
    test{
        ll k,n,x=0,i;
        cin>>k>>n;
        ll a[n];
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        for(i=0;i<n-1;i++){
            x=max(a[i+1]-a[i],x);
        }
        x=max(k-a[n-1]+a[0],x);
        cout<<k-x<<endl;
    }
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;
typedef pair<int,int> pii;

int h,w,s;
pii dp[32][32][32][32];
int field[32][32];
int sumTbl[32][32];
int allSum;

pii dfs(int minx,int miny,int maxx,int maxy){
	if(dp[minx][miny][maxx][maxy].first!=-1)return dp[minx][miny][maxx][maxy];
	int sum=0;
	// »ÝÌé`Ìùva
	for(int i=miny;i<=maxy;i++){
		if(minx==0)sum+=sumTbl[i][maxx];
		else sum+=sumTbl[i][maxx]-sumTbl[i][minx-1];
	}
	pii res(1,sum);
	// yÌÇ±©Åª
	for(int i=miny;i<maxy;i++){
		// ªµ½ç»ê¼êÌÌæÌaðßA»ê¼êÌaªðð½·©²×é
		int sum1=0;
		int sum2=0;
		for(int j=miny;j<=i;j++){
			if(minx==0)sum1+=sumTbl[j][maxx];
			else sum1+=sumTbl[j][maxx]-sumTbl[j][minx-1];
		}
		for(int j=i+1;j<=maxy;j++){
			if(minx==0)sum2+=sumTbl[j][maxx];
			else sum2+=sumTbl[j][maxx]-sumTbl[j][minx-1];
		}
//		for(int j=miny;j<=i;j++)for(int k=minx;k<=maxx;k++)sum1+=field[j][k];
//		for(int j=i+1;j<=maxy;j++)for(int k=minx;k<=maxx;k++)sum2+=field[j][k];
		// ðð½·
		if(allSum-sum1<=s&&allSum-sum2<=s){
			// »ê¼êÌßèlðæ¾
			pii p1=dfs(minx,miny,maxx,i);
			pii p2=dfs(minx,i+1,maxx,maxy);
			if(res.first<p1.first+p2.first){
				res.first=p1.first+p2.first;
				res.second=min(p1.second,p2.second);
			}
			else if(res.first==p1.first+p2.first)
				res.second=max(res.second,min(p1.second,p2.second));
		}
	}
	for(int i=minx;i<maxx;i++){
		// ªµ½ç»ê¼êÌÌæÌaðßA»ê¼êÌaªðð½·©²×é
		int sum1=0;
		int sum2=0;
		for(int j=miny;j<=maxy;j++){
			if(minx==0)sum1+=sumTbl[j][i];
			else sum1+=sumTbl[j][i]-sumTbl[j][minx-1];
		}
		for(int j=miny;j<=maxy;j++)sum2+=sumTbl[j][maxx]-sumTbl[j][i];
//		for(int j=miny;j<=maxy;j++)for(int k=minx;k<=i;k++)sum1+=field[j][k];
//		for(int j=miny;j<=maxy;j++)for(int k=i+1;k<=maxx;k++)sum2+=field[j][k];
		// ðð½·
		if(allSum-sum1<=s&&allSum-sum2<=s){
			// »ê¼êÌßèlðæ¾
			pii p1=dfs(minx,miny,i,maxy);
			pii p2=dfs(i+1,miny,maxx,maxy);
			if(res.first<p1.first+p2.first){
				res.first=p1.first+p2.first;
				res.second=min(p1.second,p2.second);
			}
			else if(res.first==p1.first+p2.first)
				res.second=max(res.second,min(p1.second,p2.second));
		}
	}
	return dp[minx][miny][maxx][maxy]=res;
}

int main(){

	while(cin>>h>>w>>s&&(h|w|s)){
		allSum=0;
		for(int i=0;i<32;i++)for(int j=0;j<32;j++)
				for(int k=0;k<32;k++)for(int l=0;l<32;l++)dp[i][j][k][l]=pii(-1,-1);
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>field[i][j];
				allSum+=field[i][j];
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(j==0)sumTbl[i][j]=field[i][j];
				else sumTbl[i][j]=sumTbl[i][j-1]+field[i][j];
			}
		}
		pii res=dfs(0,0,w-1,h-1);
		cout<<res.first<<" "<<s-(allSum-res.second)<<endl;
	}
	return 0;
}

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

int main(){
 
  int a,b;
  cin >> a >> b;
  int num[1000];
  num[0] = 0;
  for(int i = 0; i < 999; i++){
    num[i + 1] = num[i] + i + 1;
  } 

  for(int i = 1; i < 999; i++){
    if(num[i] - a == num[i + 1] - b){ cout << num[i] - a << endl; return 0; }
  }
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a * b % 2 == 0 ? "No" : "Yes") << endl;
}


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

using namespace std;

int main(){
  int N, i, j;
  char c;
  while(cin >> N, N){
    int ba = 0;
    vector<int> player(100, 0);
    for(j = 0; j < 100;){
      for(i = 0; i < N; i++, j++){
	if(j == 100) break;
	cin >> c;
	if(c == 'S') {
	  ba += player[i] + 1;
	  player[i] = 0;
	}
	else if(c == 'L') {
	  player[i] += ba + 1;
	  ba = 0;
	}
	else if(c == 'M')
	  player[i]++;
      }
    }
    sort(player.begin(), player.begin() + N);
    for(i = 0; i < N; i++)
      cout << player[i] << ' ';
    cout << ba << endl;
    
  }
  return 0;
}

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

int main(){
	char S[3];
	cin >> S;
	sort(S, S+3);
	string s=S;
	if(s=="abc"){
		cout << "Yes" << endl;
	} else if(s!="abc"){
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def read_input():
    n, m = map(int, input().split())
    return n, m


def submit():
    # 1 * N の場合
    # 1*1 -> 1
    # 1*2以上の場合、両端は表、ほかは裏

    # 2以上 * Nの場合
    # 角、辺は表、ほかは裏になる

    n, m = read_input()
    short_side = min(n, m)
    long_side = max(n, m)

    if short_side == 1:
        if long_side == 1:
            print(1)
        else:
            print(long_side - 2)
    else:
        # 角
        corners = 4
        sides = 2 * (short_side - 2) + 2 * (long_side - 2)
        insides = n * m - corners - sides

        print(insides)



if __name__ == '__main__':
    submit()


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

#define MAX 300
int main(void)
{
  int H[MAX],W[MAX];
  int i,j,k,l;

  for(i=0;i<MAX;i++)
    {
      scanf("%d %d",&H[i],&W[i]);
      if((H[i]==0)&&(W[i]==0))
	break;
    }
  
  for(l=0;l<i;l++)
    {
      for(j=0;j<W[l];j++)
	printf("#");
      printf("\n");
      for(k=1;k<H[l]-1;k++)
	{
	  printf("#");
	  for(j=1;j<W[l]-1;j++)
	    printf(".");
	  printf("#");
	  printf("\n");
	}
      for(j=0;j<W[l];j++)
	printf("#");
      
      printf("\n");
      printf("\n");
    }
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

// struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visited[MAX]; // 訪問状況


int main() {
    // input
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    // solve
    int f = 0;
    rep(i, n) {
        f += a[i] - 1;
    }
    // output
    cout << f << "\n";
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int m[30];
char s[100005];
int main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    memset(m,0,sizeof(m));
    ll chang=strlen(s);
    for(int i=0;i<chang;i++)
    {
        m[s[i]-'a']++;
    }
    int flag=1;
    for(int i=0;i<27;i++)
    {
        if(m[i]>1)
        {
            printf("no\n");
            flag=0;
            break;
        }
    }
    if(flag)
        printf("yes\n");
}


Measured memory_bytes: 256
import heapq

N,M = map(int,input().split())
A = [-int(_) for _ in input().split()]


#print(A)
heapq.heapify(A)

for i in range(M):
    heapq.heappush(A,-(-heapq.heappop(A)//2))
    
print(-sum(A))

Measured memory_bytes: 20456
from sys import stdin, stdout

n = input()
f = dict()
inp = stdin.readlines()
for line in inp:
    s = line.strip()
    try: f[s] += 1
    except: f[s] = 1

mx = 0
for key in f:
    mx = max(mx, f[key])

l = []
for key in f:
    if f[key] == mx:
        l.append(key)
l.sort()

stdout.write("\n".join(l))


Measured memory_bytes: 89292
bool DBG = false;
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using ld = long double;
//using i128 = __int128_t;
//using bint = boost::multiprecision::cpp_int;
//using d1024 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << (x) << (" ")
#define coutn(x) cout << (x) << ("\n")
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define dcouts(x) if(DBG) couts(x)
#define dcoutn(x) if(DBG) coutn(x);
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;



void solve(){
  int r; cin >> r;
  couts(2*acos(-1.0)*r);
}

void solveb(){
  //
}

void solvec(){
  //
}

void solved(){
  //
}


int main(void){
  std::cout << std::fixed << std::setprecision(20);
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 3800
from bisect import bisect_right

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    ass.sort()
    return ass 


N,M = map(int,input().split())
a = M//N
c = True

li = divisor(M)

x = bisect_right(li,a)

print(li[x-1])


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

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  int ans = S.length();
  int cnt = 0;
  for(int i = 0; i < S.length(); i++){
    if (i%2 == 0 && S[i] != '0')cnt++;
    if (i%2 != 0 && S[i] == '0')cnt++;
  }
  ans = min(cnt, ans);

  cnt = 0;
  for(int i = 0; i < S.length(); i++){
    if (i%2 == 0 && S[i] != '1')cnt++;
    if (i%2 != 0 && S[i] == '1')cnt++;
  }
  ans = min(cnt, ans);

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cmath>

using namespace std;

int A, B, C;

int main()
{
  cin >> A >> B >> C;
  int temp = max(A, max(B, C)) * 3 - (A + B + C);
  if (temp % 2 == 0)
  {
    cout << temp / 2 << endl;
  }
  else
  {
    cout << (temp + 1) / 2 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500 * i + 100 * j + 50 * k == X:
                cnt += 1
print(cnt)


Measured memory_bytes: 3060
s = input()

temp = 0
c = 0
ACGT = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    if s[i] in ACGT:
        temp += 1
    elif s[i] not in ACGT and temp != 0:
        if temp > c:
            c = temp
        temp = 0
    
    if i + 1 == len(s):
        if temp > c:
            c = temp

print(c)

Measured memory_bytes: 3060
using System;  
class Program
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();

            int sum = 0;

            for (int i = 0; i < input.Length; i++)
            {
                sum += int.Parse(input[i].ToString());
            }
            
            Console.WriteLine(sum);

        }
    }

Measured memory_bytes: 11092
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<Double, Integer> h = new TreeMap<>();
        int c;
        for (int i = 0; i < 3; i++) {
            Map<Double, Integer> m = new TreeMap<>();
            for (int j = 0; j < 8; j++) {
                int n = sc.nextInt();
                double t = sc.nextDouble();
                m.put(t, n);
            }
            c = 0;
            for (Entry<Double, Integer> entry : m.entrySet()) {
                if (c++ < 2) {
                    System.out.println(entry.getValue() + " " + entry.getKey());
                } else if (c < 4) {
                    h.put(entry.getKey(), entry.getValue());
                }else {
                    break;
                }
            }
        }
        c=0;
        for (Entry<Double, Integer> entry : h.entrySet()) {
            if (c++ < 2)
                System.out.println(entry.getValue() + " " + entry.getKey());
        }
    }
}


Measured memory_bytes: 28352
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	array := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&array[i])
	}
	sort.Ints(array)

	first := 0
	second := 0

	for i := len(array) - 1; i >= 0; i-- {
		if i%2 == (len(array)-1)%2 {
			first += array[i]
		} else {
			second += array[i]
		}
	}
	ans := first - second
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
ll n;
ll a[100010];
cin>>n;
REP(i,n) cin>>a[i];
ll ans=0;
REP(i,n) ans+=abs(a[i]);
ll min=abs(a[0]);
ll cnt=0;
REP(i,n)
{
    if(a[i]<=0) cnt++;
}
REP(i,n){
    if (abs(a[i])<min){
        min=abs(a[i]);
    }
}
//cerr<<ans<<" "<<min<<endl;
if(cnt%2==0){
    cout<<ans<<endl;
}
else {
    //cerr<<min<<endl;
    cout<<ans-2*min<<endl;
}
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)
    cin>>i;
  sort(A.begin(),A.end());
  int ans1=0;
  for(int i=0;i<N/2-1;i++)
    ans1-=A[i]*2;
  for(int i=N/2-1;i<(N+1)/2;i++)
    ans1-=A[i];
  for(int i=(N+1)/2;i<N/2+1;i++)
    ans1+=A[i];
  for(int i=N/2+1;i<N;i++)
    ans1+=A[i]*2;
  int ans2=0;
  for(int i=0;i<(N+1)/2-1;i++)
    ans2-=A[i]*2;
  for(int i=(N+1)/2-1;i<N/2;i++)
    ans2-=A[i];
  for(int i=N/2;i<(N+1)/2+1;i++)
    ans2+=A[i];
  for(int i=(N+1)/2+1;i<N;i++)
    ans2+=A[i]*2;
  cout<<max(ans1,ans2)<<endl;
}

Measured memory_bytes: 4060
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 120

int main(){
  int n,c;
  cin>>n>>c;
  int maxx,minx,sum,y;
  maxx=c/10000;
  minx=(c-5000*n)/5000;
  if(minx<0) minx=0;
  for(int x=minx;x<=maxx;x++){
    for(int z=0;z<=n-x;z++){
      y=n-x-z;
      sum=10000*x+5000*y+1000*z;
      if(sum<n) break;
      
      if(sum==c){
        cout<<x<<" "<<y<<" "<<z<<endl;
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int M=1e9+7;// M=1e9+7;//M=300000;//
const int N=2e6+5;
typedef long long int ll;
using namespace std;
 
ll cnt(0),sum(0),n,x,y,t,i,j,temp,k,ans(0),mn(M),mx(-9e9);
ll table[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	string s,p;
	cin>>s>>p;
	for(i=0;i<s.size();i++)
	{
		if(s[i]!=p[i])
		{
			break;
		}
	}
	cout<<(i==s.size()?"Yes":"No");
}

Measured memory_bytes: 3568
A,B,C,D,E,F=map(int,input().split())
ans={'water':A*100,'suger':0}
def density(water,suger):
    return 100*suger/(water+suger)
for a in range(31):
    for b in range(31):
        water=(a*A+b*B)*100
        if water>F:
            continue
        max_suger=min((a*A+b*B)*E,F-water)
        for c in range(max_suger//C+1):
            suger=c*C
            suger+=((max_suger-suger)//D)*D
            if water+suger==0:
                continue
            elif density(water,suger)>density(ans['water'],ans['suger']):
                ans['water']=water
                ans['suger']=suger
print(ans['water']+ans['suger'],ans['suger'])


Measured memory_bytes: 3064
// A - +-x
package main

import "fmt"

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

	max := A + B
	if A-B > max {
		max = A - B
	}
	if A*B > max {
		max = A * B
	}

	fmt.Println(max)
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ld N,K;
    cin>>N>>K;
    vector<ld> p(N,0);
    for(ll i=0;i<N;++i)cin>>p[i];
    ll sum=-INF;
    ll t=0;
    for(ll i=0;i<K;++i)t+=p[i];
    sum=t;
    for(ll i=0;i<N-K;++i){
        t+=p[K+i];
        t-=p[i];
        chmax(sum,t);
    }
    cout << fixed << setprecision(12);
    cout<<((ld)(sum+K))/2.0<<endl;

    return 0;
}



Measured memory_bytes: 6400
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str;
	if(str[0]=='1'){str[0]='9';}
	else if(str[0]=='9'){str[0]='1';}
	if(str[1]=='1'){str[1]='9';}
	else if(str[1]=='9'){str[1]='1';}
	if(str[2]=='1'){str[2]='9';}
	else if(str[2]=='9'){str[2]='1';}

	cout<<str;

	cout<<endl;
} 


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
  int a, b;
  scanf("%d%d", &a, &b);
  if(a <= b) {
    printf("%d\n", a);
  } else {
    printf("%d\n", a-1);
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a+b>0){
    int c[100],cnt=0;
    vector<int> ans;
    for(int i=a+1;cnt<100;i++){
      int cnt2=0;
      for(int j=2;j*j<=i;j++){
	if(i%j==0)cnt2++;
      }
      if(cnt2==0&&i!=1)c[cnt]=i,cnt++;
    }
    for(int i=0;i<100;i++)
      for(int j=i;j<100;j++)
	ans.push_back(c[i]+c[j]);
    sort(ans.begin(),ans.end());
    cout<<ans[b-1]<<endl;
  }
  return 0;
}

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

int main() {
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int A,B,C,D;
  cin>>A>>B>>C>>D;

  cout<< (D==1 ? 1 : 0) <<endl;

}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n;
  cin >> n;
  vector<ll> p(n);
  for (ll i = 0; i < n; ++i) {
    cin >> p[i];
  }
  sort(p.begin(), p.end(), greater<ll>());

  ll ans = 0;
  p[0] = p[0]/2;
  for (ll i = 0; i < p.size(); ++i) {
    ans += p[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cstdlib>

constexpr intmax_t MOD = 1e9+7;

intmax_t fact(intmax_t n) {
  intmax_t res = 1;
  for (intmax_t i = 2; i <= n; ++i)
    (res *= i) %= MOD;
  return res;
}

int main() {
  int N, M;
  scanf("%d %d", &N, &M);

  if (abs(N-M) > 1)
    return puts("0"), 0;

  intmax_t res = 1;
  if (N == M) {
    res = fact(N) * fact(N) % MOD;
    (res *= 2) %= MOD;
  } else {
    res = fact(N) * fact(M) % MOD;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
#define ll long long int

ll Pow(ll a, ll b)
{
    ll ans = 1;
    for(ll i = 0; i < b; i++)
    {
        ans *= a;
    }

    return ans;
}

int main(){
    ll n, m;
    ll ans = LLONG_MAX;
    cin >> n >> m;
    if(m == 0){
        if(n == 1){
            cout << 0 << endl;
            return 0;
        }
        cout << Pow(10, n - 1) << endl;
        return 0;
    }
    ll s[100], c[100];
    for(ll i = 0; i < m; i++){
        cin >> s[i] >> c[i];
    }
    bool flag = true;
    for(ll i = Pow(10, n - 1); i < Pow(10, n); i++){
        if(n == 1 && flag){
            i = 0;
            flag = false;
        }
        for(ll j = 0; j < m; j++){
            if(  ( i / (int)Pow(10, n - s[j])) % 10 != c[j]) break;

            if(j == m - 1){
                cout << i << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;


   



    




    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  char str[5];
  int n;
  scanf("%s", str);
  
  if(str[0]==str[1]&&str[2]==str[3]&&str[1]!=str[2]){

        printf("Yes");
  }
  else if(str[0]==str[2]&&str[1]==str[3]&&str[0]!=str[1]){

      printf("Yes");
  }
  else if(str[0]==str[3]&&str[1]==str[2]&&str[0]!=str[1]){

      printf("Yes");
  }
  else
    printf("No");
  return 0;
}
    

Measured memory_bytes: 128
#include <iostream>
using namespace std;
     
int main() {
int H, W;
string odd, even;
while (cin >> H >> W && H!=0 && W != 0) {
for(int j = 0; j < W; j++) {
if(j % 2 == 0) {
odd = odd + "#";
} else {
odd = odd + ".";
}
}
for(int k = 0; k < W; k++) {
if(k % 2 == 0) {
even = even + ".";
} else {
even = even + "#";
}
}
for(int i = 0; i < H; i++) {
if(i % 2 == 0) {
cout << odd << endl;
} else {
cout << even <<endl;
}
}
cout << endl;
odd = "";
even = "";
} 
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
void judge(ll m,ll x)
{
    if(!m)return;
    if(n / m == x && n % m == x) ans += m;
}
int main()
{
    cin>>n;
    for(ll i = 1;i * i <= n ; i++)
    if(n % i == 0)
    {
        judge(i - 1 , n / i);
        if(i * i < n)judge( n / i - 1 , i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,t;
  cin >>k >>t;
  int a[k];
  for(int i=0;i<t;i++)cin >>a[i];
  sort(a,a+t);
  int ans=a[t-1];
  cout <<max(2*ans-k-1,0)<<endl;
}


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

int main(void){
  int a,b;
  cin >> a >> b;
  if(b < 10){
    a = a*10 + b;
  }else if(b < 100){
    a = a*100 + b;
  }else{
    a = a*1000 + b;
  }
  
  int x = 1;
  while(true){
    if(x*x == a){
      cout << "Yes" << endl;
      break;
    }else if(x*x > a){
      cout << "No" << endl;
      break;
    }else{
      x++;
    }
  }
  
}

Measured memory_bytes: 256
import math


pi = math.pi
A, B, H, M = [int(i) for i in input().split()]

a_rad = (H * 60 + M) * pi / 360
b_rad = M * pi / 30
rad = abs(a_rad - b_rad)
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad))
print(ans)

Measured memory_bytes: 9508
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    long long int min = 10000000;
    long long int max = -10000000;
    long long int x, sum = 0;
    for (int i = 0; i < n; i++){
        cin >> x;
        if (min > x){min = x;}
        if (max < x){max = x;}
        sum =sum + x;
    }
    cout << min << " ";
    cout << max << " ";
    cout << sum << endl;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  bool able = false;
  for(int i = 1; i <= 9; i++){
    for(int j = i; j <= 9; j++){
      if(i * j == n) able = true;
    }
  }
  
  cout << (able ? "Yes" : "No") << endl;
  
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

using namespace std;
int main(){
	int N;
	string S;
	set<string>gacha;
	cin >> N;
	rep(i, N) {
		cin >> S;
		gacha.insert(S);
	}
	cout << gacha.size() << endl;
}


Measured memory_bytes: 19064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
ll n,t[400010] = {};
void built(){
	for(int i = n-1;i>0;i--){
		t[i] = t[i<<1] + t[i<<1|1];
	}
}

void update(ll p,ll a){
	for(t[p+=n] += a;p>1;p >>= 1){
		t[p>>1] = t[p] + t[p^1];
	}
}

ll query(int l, int r){
	ll sum = 0;
	for(l += n, r += n; l<r; l >>= 1,r >>= 1){
		if(l&1) sum += t[l++];
		if(r&1) sum += t[--r];
	}
	return sum;
}
int midi(ll y){
	int l = 0,r = n;
	while(r - l>1){
		int mid = (l + r)/2;
		//cout << "a " << l << " " << mid << " " << query(0,mid) << endl;
		if(query(0,mid)>=(y + 1)/2) r = mid;
		else l = mid;
	}
	return r;
}

ll s[400010] = {};
void update2(ll p,ll a){
	for(s[p+=n] += a;p>1;p >>= 1){
		s[p>>1] = s[p] + s[p^1];
	}
}

ll query2(int l, int r){
	ll sum = 0;
	for(l += n, r += n; l<r; l >>= 1,r >>= 1){
		if(l&1) sum += s[l++];
		if(r&1) sum += s[--r];
	}
	return sum;
}
ll a[200010],b[200010],c[200010],inv[200010];
vector<ll> v;
map<ll,int> mp;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,q;
	cin >> q;
	for(i=0;i<q;i++){
		cin >> c[i];
		if(c[i]==1){
			cin >> a[i] >> b[i];
			v.push_back(a[i]);
		}
	}
	sort(v.begin(),v.end());
	int now = 0;
	mp[v[0]] = now; inv[0] = v[0];
	for(i=1;i<v.size();i++){
		if(v[i-1]<v[i]) now++;
		mp[v[i]] = now;
		inv[now] = v[i];
	}
	now++;
	n = now;
	int cnt = 0; ll p = 0;
	for(i=0;i<q;i++){
		if(c[i]==1){
			update(mp[a[i]],1); update2(mp[a[i]],a[i]);
			cnt++; p += b[i];
		}else{
			ll z = midi(cnt);
			ll k = query(0,z),l = query(z,now);
			//cout << z << " " << k << " " << l << " " << p << endl;
			//cout << query2(0,z) << " " << query2(z,now) << endl;
			cout << inv[z-1] << " " << -query2(0,z) + query2(z,now) + (k - l)*inv[z-1] + p << "\n";
		}
	}
}

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

import itertools

while True:
  try: n = int ( input ( ) )
  except EOFError: break
  r = 0
  for ( i, j, k ) in itertools.product ( range ( 10 ), range ( 10 ), range ( 10 ) ):
    r += ( 0 <= n - i - j - k < 10 )
  print ( r )

Measured memory_bytes: 6724
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define F first
#define S second
#define M 1000000007

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t,x;
	cin>>t>>x;
	double ans=(double)t/x;
	cout<<setprecision(15)<<fixed<<ans;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

const int maxn = 1e5+100;
int n,m,x,y,dis,d[maxn],f[maxn];

int get(int x)
{
    if (f[x] == x) return x;
    int fx = get(f[x]);
    d[x] = d[x]+d[f[x]];
    f[x] = fx;
    return f[x];
}

int main()
{
    scanf("%d %d",&n,&m);
    memset(d,0,sizeof(d));
    for (int i=1;i<=n;i++) f[i] = i;
    bool tag = 1;
    for (int i=0;i<m;i++)
    {
        scanf("%d %d %d",&x,&y,&dis);
        if (tag)
        {
            int fx = get(x);
            int fy = get(y);
            if (fx == fy)
            {
                if (dis != d[y]-d[x]) tag = 0;
            }
            else
            {
                d[fy] = d[x]+dis-d[y];
                f[fy] = fx;
            }
        }
    }
    if (tag) printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 896
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    X = list(iim())

    av = (2 * sum(X) + N) // N // 2
    ans = 0
    for x in X:
        ans += (x - av)**2
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
#define print(var) cout<<var<<endl;
#define DEBUG(var) cerr<<var<<endl;
// puts("str");

const int inf = 1000000000;//10^9

int main (){

  int H1,H2,M1,M2,S,ans;
  cin>>H1>>M1>>H2>>M2>>S;
  ans=(H2*60+M2)-(H1*60+M1)-S;

  print(ans);
  return 0;

}


Measured memory_bytes: 3636
w, h, n = map(int, input().split())
dots = [[0] * w for i in range(h)]
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        for i in range(len(dots)):
            for j in range(x):
                dots[i][j] = 1
    elif a == 2:
        for i in range(len(dots)):
            for j in range(x, w):
                dots[i][j] = 1
    elif a == 3:
        for i in range(y):
            dots[i] = [1]*w
    else:
        for i in range(y, h):
            dots[i] = [1]*w
ans = 0
for i in range(h):
    ans += dots[i].count(0)
 
print(ans)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	rep(i,h){
		rep(j,w){
			if((b <= i && j < a) || (i < b && j >= a)) cout << 1;
			else cout << 0;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
int h, w, n, x, y;
bool state[mxN][2];
string tak;
string aok;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>h>>w>>n>>x>>y>>tak>>aok;
    int x1 = 1;
    int y1 = 1;
    int x2 = h;
    int y2 = w;
    reverse(tak.begin(), tak.end());
    reverse(aok.begin(), aok.end());
    owo(i, 0, n) {
        if(aok[i]=='L')y2 = min(w, y2+1);
        if(aok[i]=='R')y1 = max(1, y1-1);
        if(aok[i]=='U')x2 = min(h, x2+1);
        if(aok[i]=='D')x1 = max(1, x1-1);
        if(tak[i]=='L')y1++;
        if(tak[i]=='R')y2--;
        if(tak[i]=='U')x1++;
        if(tak[i]=='D')x2--;
        if(x2<x1||y2<y1) {
            cout<<"NO\n";
            exit(0);
        }
    }
    //cout<<x1<<" "<<x2<<" "<<y1<<" "<<y2<<"\n";
    cout<<(x1<=x&&x2>=x&&y1<=y&&y2>=y ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

vector<int> v[111111];

P dfs(ll x,ll p) {
  ll sum=0;
  vector<int> g;
  rep(i,v[x].size()) {
    ll y=v[x][i];
    if(y==p) continue;
    P d=dfs(y,x);
    sum+=d.F;
    g.pb(d.S);
  }
  sort(all(g));
  P q=P(sum,0);
  if(!g.size()) {
    q.F++;
    q.S=1;
  } else if(g.size()==1&&g[0]==1) q.S=1;
  else q.F-=g.back();
  return q;
}

void Main() {
  int n;
  R n;
  rep(i,n-1) {
    int x,y;
    cin >> x >> y;
    v[x].pb(y);
    v[y].pb(x);
  }
  ll M=0,x=0;
  rep(i,n) {
    if(v[i].size()>M) {
      M=v[i].size();
      x=i;
    }
  }
  pr(dfs(x,-1).F);
}

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

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

int main() {
    uint64_t N, M;
    std::cin >> N >> M;

    std::map<uint64_t, uint64_t> m;
    uint64_t A;
    for (size_t i = 0; i < N; ++i) {
        std::cin >> A;
        if (m.count(A) == 0) {
            m[A] = 1;
        } else {
            m[A] += 1;
        }
    }

    uint64_t B, C;
    for (size_t i = 0; i < M; ++i) {
        std::cin >> B >> C;
        if (m.count(C) == 0) {
            m[C] = B;
        } else {
            m[C] += B;
        }
    }

    auto itr = m.end();
    --itr;
    size_t cnt = 0, sum = 0;
    while (true) {
        const uint64_t k = (*itr).first;
        const uint64_t v = (*itr).second;
        if (cnt + v < N) {
            sum += k * v;
            cnt += v;
        } else {
            sum += k * (N - cnt);
            break;
        }

        --itr;
    }

    std::printf("%lu\n", sum);

    return 0;
}


Measured memory_bytes: 12800
#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>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll x = a[0];
  ll y = 0;
  for (int i = 1; i < n; ++i) y += a[i];
  ll ans = abs(x - y);
  for (int i = 1; i < n-1; ++i) {
    x += a[i];
    y -= a[i];
    ans = min(ans, abs(x - y));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4008
#include<stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a+b>c+d){
        printf("Left");
    }else if(a+b<c+d){
        printf("Right");
    }else{
        printf("Balanced");
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
p = input().split(" ")
p = [int(i) for i in p]
c = 0
for i in range(n - 2):
    n1 = p[i]
    n2 = p[i+1]
    n3 = p[i+2]
    #print(n1,n2,n3)
    if (n2 > n1 and n2 < n3) or (n2 < n1 and n2 > n3):
        c += 1
print(c)

Measured memory_bytes: 3064
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    ans = INF
    snuke = 0
    arai_san = sum(a)

    for x in a[:-1]:
        snuke += x
        arai_san -= x
        ans = min(ans, abs(snuke - arai_san))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71760
#include <stdio.h>
int main(void)
{
	int n,i,z=0;
	char s[101];
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%c",&s[i]);
		if(s[i]=='Y'){
			z=1;
		}
	}
	if(z==1){
      printf("Four\n");
    }else if(z==0){
      printf("Three\n");
    }
	return 0;
}

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

const int M = 1000000007;

int main() {
    long long A[2][16] = { { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 }, { 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 }};
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        long long ans = 0;
        for (int k = 15; k >= 0; k--) ans = (ans * n + A[n%2][k]) % M;
        cout << (ans % M + M) % M << endl;
    }
}


Measured memory_bytes: 3172
s = raw_input()
if s[0] != 'A':
    print "WA"
else:
    c = 0
    occur = -1
    for i in xrange(2, len(s)-1):
        if s[i] == 'C':
            c += 1
            occur = i
    if c != 1:
        print "WA"
    else:
        good = True
        for i in xrange(1, len(s)):
            if i == occur:
                continue
            good = good and s[i].islower()
        print "AC" if good else "WA"


Measured memory_bytes: 2568