akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=100005,mod=1e9+7;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a[max_n];
int jiecheng[100005]={1};
ll min1,max1;
long long inv(int i,int p)
{
	if(i==1)return 1;
	return (p-p/i)*inv(p%i,p)%p;
}
ll g(int n,int m,int p)
{
	int fenzi=jiecheng[n+m]%p;
	int fenmu=((ll)jiecheng[m]%p*jiecheng[n]%p)%p;
	ll niyuan=inv(fenmu,p);
	return (ll)fenzi*niyuan%p;
}
ll lucas(int n,int m,int p)
{
	if(n<0)
	{
		return 0;
	}
	if(n+m<=p)
	{
		return g(n,m,p);
	}
	if(m==0)return 1;
	if(m==1)return (n+m)%p;
	else if(n==0)return 1;
	else
	{
		int a1=lucas((n+m)/p-m/p,m/p,p)%p;
		int a2=lucas((n+m)%p-m%p,m%p,p)%p;
		return (ll)a1*a2%p;
	}
}
int main()
{
	for(int i=1;i<=100000;i++)
	{
		jiecheng[i]=(ll)jiecheng[i-1]*i%mod;
	}
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i+k-1<=n;i++)
	{
		min1=(min1+a[i]*lucas(k-1,n-i-k+1,mod))%mod;
	}
	for(int i=k;i<=n;i++)
	{
		max1=(max1+a[i]*lucas(k-1,i-k,mod))%mod;
	}
	cout<<((max1-min1)%mod+mod)%mod<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int n, result, i;
    char s[101];
    
    result = 1;
    scanf("%d %s", &n, s);
    for(i=0; i<n/2; i++){
        if(s[i] != s[n/2+i]){
            result = 0;
        }
    }
    if( (result==0) || (n%2==1)){
        puts("No");
    }
    else{
        puts("Yes");
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n, d[51];

int main() {
    cin >> n;
    rep(i, n) cin >> d[i];
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main() {
    val n = readLine()!!.toLong()
    var m = n

    val counter = mutableMapOf<Long, Int>()
    while (m % 2L == 0L) {
        counter[2L] = (counter[2L] ?: 0) + 1
        m /= 2L
    }

    var factor = 3L
    while (factor * factor <= n) {
        while (m % factor == 0L) {
            counter[factor] = (counter[factor] ?: 0) + 1
            m /= factor
        }

        factor += 2L
    }

    if (m != 1L) {
        counter[0] = 1
    }

    val max = counter.map { it.value }.max() ?: 0
    val triangular = (1..max).map {
        it * (it + 1) / 2
    }

    val result = counter.map { (_, value) ->
        val index = triangular.indexOfLast { value >= it }
        if (index == -1) {
            0
        } else {
            index + 1
        }
    }.sum()

    println(result)
}

Measured memory_bytes: 36604
#include <iostream>

using namespace std;

int main()
{
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int count = 0;
  for (int aId = 0; aId <= A; aId++)
    for (int bId = 0; bId <= B; bId++)
      for (int cId = 0; cId <= C; cId++)
      {
        if (aId * 500 + bId * 100 + cId * 50 == X) count++;
      }

  std::cout << count << endl;
}



Measured memory_bytes: 256
from copy import copy

def popcount(x):
    return bin(x).count("1")

def f(x):
    if x == 0:
        return 0
    return f(x%popcount(x))+1

n = int(input())
x = input()
xx = int(x,2)
p = x.count("1")
stand1 = xx%(p+1)
if p != 1:
    stand2 = xx%(p-1)
for i in range(n):
    if x[i] == "1":
        if p != 1:
            k = copy(stand2)
            k -= pow(2,n-i-1,p-1) 
            k %= p-1
        else:
            print(0)
            continue
    else:
        k = copy(stand1)
        k += pow(2,n-i-1,p+1)
        k %= p+1
    print(1+f(k))

Measured memory_bytes: 9800
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)
int T[16][16];
int gx, gy;
int main()
{	
	int N;
	cin >> N;
	rep(i, N)
	{
		bool Horiz[16][16];
		rep(j, 16)
		{
			Horiz[0][j] = false;
			rep(i, 15) Horiz[i+1][j] = true;
		}
		bool Vert[16][16];
		rep(i, 16)
		{
			Vert[i][0] = false;
			rep(j, 15) Vert[i][j+1] = true;
		}
		cin >> gx >> gy;
		int M;
		cin >> M;
		if (M >= 1)
		{
		
		    rep(j, M)
		    {
			    int x1, y1, x2, y2;
			    cin >> x1 >> y1 >> x2 >> y2;
			    if (x1 == x2) Vert[x1][max(y1, y2)] = false;
			    else if (y1 == y2)Horiz[max(x1, x2)][y1] = false;
		    }
	    }

		rep(x,gx+1)
		{
			rep(y,gy+1)
			{
				if (x == 0 && y == 0)T[x][y] = 1;
				else if (Horiz[x][y] == false && Vert[x][y] == false)T[x][y] = 0;
				else if (Horiz[x][y] == true && Vert[x][y] == false)T[x][y] = T[x - 1][y];
				else if (Horiz[x][y] == false && Vert[x][y] == true)T[x][y] = T[x][y - 1];
				else if (Horiz[x][y] == true && Vert[x][y] == true)T[x][y] = T[x - 1][y] + T[x][y - 1];
			}
		}
		if (T[gx][gy] != 0)cout << T[gx][gy] << endl;
		else if (T[gx][gy] == 0)cout << "Miserable Hokusai!" << endl;
	}
	return 0;
}


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

struct UF {
	int par[100000];
	UF() { for (int i = 0; i < 100000; i++) par[i] = i; }
	int root(int x) { if (x == par[x]) return x; return par[x] = root(par[x]); }
	void unit(int x, int y) { x = root(x); y = root(y); par[x] = y; }
	bool same(int x, int y) { return root(x) == root(y); }
};

int n, q;
int type, x, y;
UF uf;

int main() {
	int i;
	
	cin >> n >> q;
	for (i = 0; i < q; i++) {
		cin >> type >> x >> y;
		if (type == 0) uf.unit(x, y);
		else cout << uf.same(x, y) << endl;
	}
	return 0;
}


Measured memory_bytes: 3516
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a, b, c = sc.nextInt()
    val ans = if(a+b==c||b+c==a||c+a==b) {
      "Yes"
    } else {
      "No"
    }
    println(ans)
  }
}


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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    int x; cin >> x;
    int n; cin >> n;
    int mp[105] = {0};
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        mp[x] = 1;
    }

    int mn = 1001;
    for (int i = x; i >= 0; i--) {
        if (mp[i] == 0) {
            mn = i;
            break;
        }
    }

    int mx = 0;
    for (int i = x; i <= 101; i++) {
        if (mp[i] == 0) {
            mx = i;
            break;
        }

    }
    //cout << mn << " " << mx << endl;

    abs(mn - x) <= abs(mx - x) ? cout << mn << endl : cout << mx << endl;


    return 0; 
}



Measured memory_bytes: 3540
use text_io::*;
use std::collections::HashMap;

fn main() {
    let n:usize = read!();
    if 600 > n {
        println!("8");
    }
    else if 800 > n {
        println!("7");
    }
    else if 1000 > n {
        println!("6");
    }
    else if 1200 > n {
        println!("5");
    }
    else if 1400 > n {
        println!("4");
    }
    else if 1600 > n {
        println!("3");
    }
    else if 1800 > n {
        println!("2");
    }
    else  {
        println!("1");
    }
}

Measured memory_bytes: 2136
from collections import Counter

N = int(input())

list_s = []
for i in range(N):
    list_s += [input()]

list_t = []
M = int(input())
for i in range(M):
    list_t += [input()]

counter_s = Counter(list_s)
counter_t = Counter(list_t)

for key, count in counter_t.items():
    if key in counter_s:
        counter_s[key] -= count
    else:
        counter_s[key] = -1 * count

m = max(counter_s.values())

print(m if m > 0 else 0)

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

struct edge {
    int from;
    int to;
    long long cost;
};
long long INF = 1e12;

vector<long long> bellman_ford(vector<edge> es, int start_point, int vertex_num) {
    vector<long long> shortest_path(vertex_num, INF);
    shortest_path[start_point] = 0;
    for (int i = 0; i < vertex_num-1; i++) {
        for (int j = 0; j < es.size(); j++) {
            shortest_path[es[j].to] = min(shortest_path[es[j].to], shortest_path[es[j].from]+es[j].cost);
        }
    }
    return shortest_path;
}

bool find_negative_loop(vector<edge> es, int start_point, int vertex_num) {
    vector<long long> shortest_path(vertex_num, INF);
    shortest_path[start_point] = 0;
    for (int i = 0; i < vertex_num; i++) {
        for (int j = 0; j < es.size(); j++) {
            if (shortest_path[es[j].to] > shortest_path[es[j].from]+es[j].cost) {
                shortest_path[es[j].to] = shortest_path[es[j].from]+es[j].cost;
                if (i == vertex_num-1 && es[j].to == vertex_num-1)
                    return true;
            }
        }
    }
    return false;
}

int main(void){
    int N, M;
    cin >> N >> M;
    vector<edge> es(M);
    for (int i = 0; i < M; i++) {
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--;
        es[i].to--;
        es[i].cost = -es[i].cost;
    }
    if (find_negative_loop(es, 0, N))
        cout << "inf";
    else {
        vector<long long> shortest_path = bellman_ford(es, 0, N);
        cout << -shortest_path[N-1];
    }
}

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

int now,n,k;

int main(){
  ll s;
  cin >> s;
  double ds=s;
  double ipn=sqrt(ds);
  ll llpn=ipn-1;
  for(int i=0;i<990;i++){
    if (llpn*llpn<s){
      llpn++;
    }else{
      if (llpn*llpn==s)break;
      
      break;
    }
  }

  ll a,b,y,x;
  ll t=llpn*llpn-s;
  b=1LL;
  x=t;
  a=llpn-b;
  y=llpn;

  cout<<0<<" ";
  cout<<x<<" ";
  cout<<a<<" ";
  cout<<y<<" ";
  cout<<(a+b)<<" ";
  cout<<0<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
    vector<double> x(3), y(3);
    rep(i, 3)
    {
        cin >> x[i] >> y[i];
    }
    int first[3]={0,1,2};
    int second[3]={1,2,0};
    vector<double> dis(3);
    rep(i,3){
        dis[i]=sqrt(pow(x[first[i]]-x[second[i]],2)+pow(y[first[i]]-y[second[i]],2));
    }

    double s = (dis[0] + dis[1] + dis[2]) / 2.0;
    /*へロンの公式*/
    double area = sqrt(s * (s - dis[0]) * (s - dis[1]) * (s - dis[2]));
    //area=(a+b+c)/2*r+hr
    //c=(a+b+c)/2+h
    //c=s+h
    //area=cr 
    //h*dis[i]/2=area
    //h=area*2/dis[i]
    vector<double> h(3);
    rep(i, 3)
    {
        h[i] = area * 2 / dis[i];
    }
    vector<double> c(3);
    
    rep(i, 3)
    {
        c[i]=s+h[i]; //c[i]*r=S
    }
    double ans = 0.0;
    rep(i, 3)
    {
        double r;
        r=area/c[i];
        ans = max(r, ans);
    }
    cout << setprecision(12) << ans  << endl;
}

Measured memory_bytes: 384
#[allow(dead_code)]
fn main() {
    let (s, w) = (i::u(), i::u());
    println!("{}", if w >= s { "unsafe" } else { "safe" });
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2104
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

#define MAX 999999

using namespace std;

int num_prime[MAX+1];
bool not_prime_flag[MAX+1];

int main()
{
    int n;

    for (int i = 2; i < MAX+1; ++i) {
        if(!not_prime_flag[i]){
            for (int j = 2; i*j < MAX+1; ++j) {
                not_prime_flag[i*j] = true;
            }
        }
        num_prime[i]=num_prime[i-1]+!not_prime_flag[i];
    }
    while (cin>>n){
        cout<<num_prime[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 6044
#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 debug = 1;


int main(){
    int k,a,b;
    cin >> k>>a>>b;
    for(int i=a;i<b+1;++i){
        if(i % k == 0 ){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout <<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3592
n=int(input())
s=str(input())
a=""
l=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for car in s:
  for alp in l:
    if car == alp:
      a = a + l[l.index(alp)+n]

print(a[0::2])

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int digit_sum(int n)
{
    int res = 0;
    while (n)
    {
        res += n % 10;
        n /= 10;
    }
    return (res);
}

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

    int ans = 0;
    while (n)
    {
        ans++;
        n /= k;
    }
    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
  ll N, h, n, w;
  bool flag = true;
  cin >> N;
  for (ll Y = 1; Y <= 3500 && flag; Y++) {
    for (ll Z = 1; Z <= 3500; Z++) {
      if ((4 * Y * Z - N * Z - N * Y) != 0
          && (N * Y * Z % (4 * Y * Z - N * Z - N * Y) == 0)
          && N * Y * Z / (4 * Y * Z - N * Z - N * Y) > 0) {
        h = N * Y * Z / (4 * Y * Z - N * Z - N * Y);
        n = Y;
        w = Z;
        flag = false;
        break;
      }
    }
  }

  cout << h << " " << n << " " << w << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String s = br.readLine();
            // String s = "vanceknowledgetoad";
            StringBuilder sb = new StringBuilder();
            char[] arr = s.toCharArray();
            
            sb.append(s);
            for(int i=0; i<arr.length-1; i++){
                sb.append(arr[i]);
            }
            
            s = new String(sb);
            
            String p = br.readLine(); 
            // String p = "advanced";
            if(s.contains(p)){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }    
        }catch(IOException e){
            e.printStackTrace();
        }
        
        
    }
}


Measured memory_bytes: 24264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin>>n;
  ll x[n],y[n];
  int f[2]={0,0};
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    f[(x[i]+y[i]+1000000000000)%2]++;
  }
  if(f[0]*f[1]>0){
    cout<<-1<<endl;
    return 0;
  }
  vector<ll> d;
  for(int i=0;i<35;i++)d.push_back((ll)pow(2,i));
  if(f[0]>0)d.push_back(1);
  cout<<d.size()<<endl;
  for(int i=0;i<d.size()-1;i++)cout<<d[i]<<" ";
  cout<<d.back()<<endl;
  for(int i=0;i<n;i++){
    ll u=x[i]+y[i];
    ll v=x[i]-y[i];
    if(f[0]>0){
      u--;
      v--;
    }
    for(int j=0;j<35;j++){
      u+=d[j];
      v+=d[j];
    }
    u/=2;
    v/=2;
    for(int j=0;j<35;j++){
      ll s=u/((ll)pow(2,j))&1;
      ll t=v/((ll)pow(2,j))&1;
      if(s){
        if(t)cout<<"R";
        else cout<<"U";
      }
      else{
        if(t)cout<<"D";
        else cout<<"L";
      }
    }
    if(f[0]>0)cout<<"R";
    cout<<endl;
  }
}
  
  

Measured memory_bytes: 256
module Main (main) where

import qualified Data.ByteString.Char8     as C8
import           Data.Maybe

main :: IO ()
main = do
  [a,b,c] <- readInts
  print . showAnswer $ solve (a,b,c)

type Input  = (Int, Int, Int)
type Output = Int

solve :: Input -> Output
solve (a,b,c)
  | a == b    = c
  | a == c    = b
  | otherwise = a

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | AB Bool
  | Number Int

instance Show Answer where
  show (YesNo b)  = if b then "Yes" else "No"
  show (AB b)     = if b then "A"   else "B"
  show (Number i) = show i

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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TC int tc; cin >> tc; while(tc--)

using namespace std;

const int INF = 1e9 + 7;


int main(void)
{
	FAST
	int n, x, t; cin >> n >> x >> t;

	int times = (x + n - 1) / x;
	cout << (times * t) << '\n';

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define psi std::pair<string,int>
#define pli std::pair<ll,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%I64d",&x)
#define prll(x) printf("%I64d ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vli std::vector<std::list<int>>
#define vlpi vector<list<pii>>
#define li std::list<int>
#define Endl printf("\n")
#define ma 1000000
#define mod 786433
#define FOR(i,a) for(int i=0; i<a; i++)

using namespace std;

int main() {
    int n ; cin >> n ;
    if (n==1) {
        long double  x ; cin >> x ;
        cout << x ;
    }
    else {
    vector <long double> v ;
    FOR(i,n) {
        long double x ;
        cin >> x ;
        v.pb(x) ;
    }
    sort(v.begin(),v.end());

    long double  x = (v[0] + v[1])/2  ;
    for(int i =2 ; i<n ; i++){
        x= (x+v[i])/2 ;
    }

    cout << x ;
    }
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid u1(5, 10); u1(rnd);
 
int main() {
    fast;
    ll a,k; cin>>a>>k;
    vec<pair<int, pii>> m(a);
    for(int q=0; q<a; q++){
        int a1,a2,x; cin>>a1>>a2>>x;
        m[q] = {x, {a1-x,a2-x-1}};
    }
    sort(m.begin(), m.end(), [](pair<int, pii> p1, pair<int, pii> p2){return p1.F<p2.F;});
    vec<int> ans(k);
    set<pii> s;
    for(int q=0; q<k; q++){
        int n; cin>>n;
        s.insert({n,q});
    }
    for(int q=0; q<a; q++){
        int l = m[q].S.F, r = m[q].S.S, x = m[q].F;
        for(; s.size()>0;){
            auto it = s.lower_bound({l,-1});
            if(it == s.end()) break;
            pii p = *it;
            if(p.F>r) break;
            ans[p.S] = x;
            s.erase(p);
        }
    }
    for(pii p : s) ans[p.S] = -1;
    for(int i : ans) cout<<i<<endl;
   
}

Measured memory_bytes: 14464
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    int n;cin>>n;
    int ans=n*n*n;
    cout<<ans<<endl;
    
    return 0;
}

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

char S[100009];

int main() {
    scanf("%s",S);
    int N = strlen(S); int ans = N;
    for(int i=0, s=-1; i<N; i++) {
        if(S[i] == '1' && s == -1) s = i;
        if(S[i] == '1' && S[i+1] != '1') {
            int a=0, b=0, c=0, d=0;
            if(s != 0) {
                a = s, b = i+1;
                a = max(a, N-a);
                b = max(b, N-b);
            }
            if(i != N-1) {
                c = N-i-1, d = N-s;
                c = max(c, N-c);
                d = max(d, N-d);
            }
            ans = min(ans, max({i-s+1, min(a, b), min(c, d)}));
            s = -1;
        }
    }
    printf("%d",ans);
}



Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n,m,c; cin >> n >> m >> c;
    vector<int> b(m),a(m);
    for(int i = 0;i < m;i ++){
        cin >> b.at(i);
    }

    int ans = 0;

    for(int i = 0;i < n;i ++){
        for(int j = 0;j < m;j ++){
            cin >> a.at(j);
        }

        int sum = 0;

        for(int j = 0;j < m;j ++){
            sum += a.at(j) * b.at(j);
        }
        sum += c;

        if(sum > 0) ans ++;

    }

    cout << ans << endl;
}


Measured memory_bytes: 256
def p_s(H, W):
    for i in range(H):
        str = ''
        for j in range(W):
            if (i + j) % 2 == 0:
                str += "#"
            else:
                str += "."
        print(str)
    print()


while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    p_s(H, W)



Measured memory_bytes: 5612
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	for(int i=n;;i++) {
		int a = i%10, b = (i/10)%10, c = (i/100)%10;
		if(a == b&&b == c) {
			cout << i << endl;
			break;
		}
	}
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int n,ma=0;
map<string,int> m;

signed main() {
    cin >> n;
    rep(i,n) {
        string s;
        cin >> s;
        m[s]++;
        ma = max(ma, m[s]);
    }
    for(auto i : m) if (i.se == ma) cout << i.fi << endl;

}



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


int main() {
    int n,m; cin >> n >> m;
    vector<int> s(m), c(m);
    rep(i, m) cin >> s[i] >> c[i];

    string ans = "";
    rep(i, n) ans += "_";
    rep(i, m) {
        if(ans[s[i]-1] == '_' || ans[s[i]-1]-'0' == c[i]) {
            ans[s[i]-1] = to_string(c[i])[0];
        } else {
            cout << -1 << endl;
            return 0;
        }
        if(s[i] == 1 && n > 1 && c[i] == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    rep(i, n) {
        if(ans[i] == '_') {
            if(i == 0 && n > 1) ans[i] = '1';
            else ans[i] = '0';
        }
    }

    cout << ans << endl;

    return 0;
}



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

using namespace std;

const int maxn = 1e5 + 10;
int n,a[maxn],b[maxn],c[maxn],dpc[maxn],dpb[maxn],dpa[maxn],ans;

int main(){
	cin >> n;
	for(int i = 0 ; i<n ; i++)
		cin >> a[i] >> b[i] >> c[i];
	dpc[0] = c[0];
	dpb[0] = b[0];
	dpa[0] = a[0];
	for(int i = 1 ; i<n ; i++){
		dpc[i] = max(dpb[i-1],dpa[i-1]);
		dpc[i] += c[i];
		dpa[i] = max(dpb[i-1],dpc[i-1]);
		dpa[i] += a[i];
		dpb[i] = max(dpa[i-1],dpc[i-1]);
		dpb[i] += b[i];
	}
	ans = max(dpb[n-1],dpa[n-1]);
	ans = max(ans , dpc[n-1]);
	cout << ans << endl;
}

	
	
	


Measured memory_bytes: 2560
namespace VainZero.Procon.FSharp

open System
open System.Collections.Generic

[<AutoOpen>]
module Operators =
  let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

module Program =
  [<EntryPoint>]
  let main _ =
    let n = Console.ReadLine() |> int
    let scores =
      [|
        for i in 0..(n - 1) ->
          Console.ReadLine() |> int
      |]

    let calc () =
      let total = scores |> Array.sum
      if total % 10 = 0 then
        let ts = scores |> Array.filter (fun x -> x % 10 <> 0)
        if ts.Length = 0 then
          0
        else
          let min = ts |> Array.min
          total - min
      else
        total

    printfn "%d" (calc ())
    0


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
// #define map unordered_map
// #define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

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

  vector<ll> a_list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    a_list[i] = v;
  }

  vector<pair<ll, ll>> list;

  for (ll i = 0; i < M; i++) {
    ll b, c;
    scanf("%lld %lld", &b, &c);
    list.emplace_back(make_pair(c, b));
  }

  sort(a_list.begin(), a_list.end());
  sort(list.rbegin(), list.rend());

  ll a_index = 0;
  for (ll i = 0; i < M; i++) {
    if (a_index >= N) {
      goto end;
    }

    ll num = list[i].first;
    ll cnt = list[i].second;

    for (ll j = 0; j < cnt; j++) {
      if (num > a_list[a_index]) {
        a_list[a_index] = num;
        a_index++;
        if (a_index >= N) {
          goto end;
        }
      } else {
        goto end;
      }
    }
  }
end:

  ll ans = 0;

  for (ll i = 0; i < N; i++) {
    ans += a_list[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  string s;cin>>s;
  ll t=0;
  rep(i,0,s.size()-1){
    if(s[i]!=s[i+1]){
      t++;
    }
  }
  cout<<t<<endl;
}


Measured memory_bytes: 3732
#include <iostream>
#include <array>
#include <algorithm>

int main()
{
    int N,answer=0;
    std::cin >> N;
    std::array<int,100> A;
    for(int i = 0; i < N; i++)
    {
        std::cin >> A.at(i);
    }
    
    std::sort(A.begin(), A.begin() + N);

    if(N%2 != 0)
    {
        answer += A.at(0);
        for(int i = 0; i < (N-1)/2; i++)
        {
            answer += A.at(2*i+2) - A.at(2*i+1); 
        }
    }
    else
    {
        for(int i = 0; i < N/2; i++)
        {
            answer += A.at(2*i+1) - A.at(2*i);
        }
    }
    std::cout << answer << std::endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class Program {
    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );

        int a = int.Parse( values[ 0 ] );
        int b = int.Parse( values[ 1 ] );

        int d = a / b;
        int r = a % b;
        decimal f = (decimal)a / b;

        var output = string.Format( "{0} {1} {2}", d, r, f );
        Console.WriteLine( output );

        return 0;
    }
}

Measured memory_bytes: 9756
#include <stdio.h>
#include <math.h>




int main()
{
	int i, j, k,n,l;
	scanf("%d", &n);
	printf("2 ");
	l = 1;
	for (i = 3;;i += 2)
	{
		k = 0;
		for (j = 3;j <= sqrt(i);j += 2)
		{
			if (i%j == 0)
			{
				k = 1;
				break;
			}
		}

		if (k == 0&&i%5==1) { printf("%d ", i); ++l;if (l == n) break; }
	}

	printf("\n");

	return 0;
}

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

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}
bool is_prime(ll x) {
    for(ll i = 2; i * i <= x; i++) {
        if(x % i == 0) return false;
    }
    return true;
}

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }

int main(){
    ll A, B;
    cin >> A >> B;

    ll g = gcd(A, B);
    //cout << g << "\n";
    map<ll, ll> m;
    m = prime_factor(g);
    cout << m.size() + 1 << "\n";
    return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)(n); i++)
#define reps(i,s,e) for(int i=s; i<(int)(e); i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    string S, T;
    cin >> S >> T;
    int slen = S.length();
    int tlen = T.length();
    int min = INT_BIG;
    rep(i, slen - tlen + 1) {
        int tmp = 0;
        rep(j, tlen) {
            if (S[i+j] != T[j]) {
                tmp++;
            }
        }
        if (min > tmp) {
            min = tmp;
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
long long int z[1001][1001];
int main(void)
{
	int n,m,d[1001],c[1001],i,j;
	long long int min,s;
	s=9223372036854775806; 
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<m;i++){
		scanf("%d",&c[i]);
	}	
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++){
			z[i][j]=s;
		}
	}
	z[0][0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++){
			if(z[i][j]!=s){
				if(z[i+1][j]>z[i][j]){
					z[i+1][j]=z[i][j];
				}
				if(z[i+1][j+1]>z[i][j]+d[j]*c[i]){
					z[i+1][j+1]=z[i][j]+d[j]*c[i];
				}	
			}	
		}
	}
	min=s;
	for(i=0;i<=m;i++){
		if(min>z[i][n]){
			min=z[i][n];
		}
	}
	printf("%lld\n",min);
}

Measured memory_bytes: 10392
n = int(input())
s = [int(i) for i in input().split(" ")]
q = int(input())
t = [int(i) for i in input().split(" ")]
searched = []

cnt = 0
for i in range(q):
    target = t[i]
    
    upper = n
    lower = 0
    while upper > lower:
        j = int((upper+lower)/2)
        
        if s[j] == target:
            cnt += 1
            break
        elif s[j] > target:
            upper = j
        elif s[j] < target:
            lower = j+1

print(cnt)


Measured memory_bytes: 16892
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int n,m;
  cin >> n >> m;
  
  bool fn[n][n] = {};

  rep(i,0,n){
    string s;
    cin >> s;
    rep(j,0,s.size()){
      if(s[j] == '#')
        fn[i][j] = true;
    }
  }

  bool fm[m][m] = {};
  rep(i,0,m){
    string s;
    cin >> s;
    rep(j,0,s.size()){
      if(s[j] == '#')
        fm[i][j] = true;
    }
  }
  /*
  rep(i,0,n){
    rep(j,0,n){
      cout << fn[i][j];
    }
    cout << endl;
  }
  rep(i,0,m){
    rep(j,0,m){
      cout << fm[i][j];
    }
    cout << endl;
  }
  */
  rep(i,0,n){
    rep(j,0,n){
      if(fn[i][j] == fm[0][0]){
        bool f = false;
        rep(k,0,m){
          rep(l,0,m){
            if(i+k < n && j+l < n){
              if(fn[i+k][j+l] != fm[k][l]){
                f = true;
                break;
              }
            }else{
              f = true;
              break;
            }
          }
          if(f)
            break;
        }
        if(!f){
          Yes;
          ret 0;
        }
      }


    }
  }
  No;
  ret 0;
}

Measured memory_bytes: 256
//ysh_gpta
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;


#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define IN(i,l,r) (l<i&&i<r)   //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)


#define repf(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define repfe(i,L,R) for (int i = L; i <= R; i++)
#define repb(i,L,R) for (int i = L; i > R; i--)
#define repbe(i,L,R) for (int i = L; i >= R; i--)


typedef long long ll;
#define cerr if(false)cerr
#define vb vector<bool>
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define mkp make_pair
#define pb push_back
#define INF 1000000000000000
#define MOD 1000000007
#define ff first
#define ss second


#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


ll gcd( ll a, ll b ){if(b==0) return a; else return gcd( b, a%b );}
ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}


vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll n,k;
vvi m(55,vi(55));

vvi matmul(vvi &a,vvi &b){
    vvi c(n,vi(n,0));
    repf(row,0,n){
        repf(col,0,n){
            repf(k,0,n){
                c[row][col] += a[row][k]*b[k][col];
                c[row][col]%=MOD;
            }
            
        }
    }
    return c;
}

vvi power(vvi m,ll e){
    if(e==1)
    return m;
    vvi a = power(m,e/2);
    vvi ans = matmul(a,a);
    if(e%2==1)
    ans = matmul(ans,m);
    return ans;
}

int main(){
    FastIO
    cin>>n>>k;
    repf(i,0,n) repf(j,0,n) cin>>m[i][j];
    vvi res = power(m,k);
    ll sum = 0;
    repf(i,0,n) repf(j,0,n) sum= (sum + res[i][j])%MOD;
    cout<<sum;

    return 0;
}

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

long long index_2(int x) {
  long long n=1;
  if (x==0) {
    return 1;
  }
  else {
    for (int i=0;i<x;i++) {
      n = n*2;
    }
  return n;
  }
}

int main() {
  int N;
  long long X;
  cin >> N >> X;
  
  long long count=0;
  for (int i=0;i<N;i++) {
    if (X>index_2(N+1-i)-1) {
      if (X==index_2(N+2-i)-3) {
        count += index_2(N-i+1)-1;
        break;
      }
      count += index_2(N-i);
      if (i==N-1) {
        count++;
        break;
      }
      X = X -index_2(N+1-i)+1;
    }
    else if (X<index_2(N+1-i)-1) {
      if (i==N-1 && X==2) {
        count++;
        break;
      }
      X -= 1;
    }
    else if (X==index_2(N+1-i)-1) {
      count += index_2(N-i);
      break;
    }
  }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
int h1,m1,h2,m2,k;
int main (){
	cin>>h1>>m1>>h2>>m2>>k;
	int t=(h2-h1)*60+m2-m1;
	cout<<max(0,t-k)<<endl;
	
	return 0;
} 

Measured memory_bytes: 3616
#include<iostream>
#include<cmath>
#include<sstream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define eps 1e-10
const double rs =1.;

int count(double x,double y,double *dx,double *dy,int n){
  int ret =0;
  rep(i,n){
    if ( (x-dx[i])*(x-dx[i])+(y-dy[i])*(y-dy[i]) <=1.+eps)ret++;
  }
  return ret;
}



int solve(double *x,double *y,int n){
  int cnt=1;
  rep(i,n){
    REP(j,i+1,n){
      double midx=(x[i]+x[j])/2.,midy=(y[i]+y[j])/2.;
      double tx=x[i]-midx,ty=y[i]-midy;
      double tr=sqrt(1-tx*tx-ty*ty);
      if (isnan(tr))continue;
      if ( tx==0 &&ty==0)continue;
      double rate = tr/sqrt(tx*tx+ty*ty);
      cnt=max(cnt,max(count(-ty*rate+midx,tx*rate+midy,x,y,n),
		      count(ty*rate+midx,-tx*rate+midy,x,y,n)));
    }
  }
  return cnt;
}





main(){
  int n;
  while(cin>>n&&n){
    double x[n],y[n];
    rep(i,n)cin>>x[i]>>y[i];
    cout << solve(x,y,n)<<endl;
  }

}

Measured memory_bytes: 984
#include <stdio.h>

int main(void){
	int i,m,n,a,ok=0,pena=0,cnt[100010]={};
	char s[3];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %s",&a,s);
		if(cnt[a]<0) continue;
		if(s[0]=='W') cnt[a]++;
		else{
			pena = pena + cnt[a];
			cnt[a] = -1;
			ok++;
		}
	}
	printf("%d %d",ok,pena);
	return 0;
	
}

Measured memory_bytes: 512
// 2014/09/11 Tazoe

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

struct dic{
	string ds;
	int di;
};

bool operator<(const dic& left, const dic& right)
{
	return left.di < right.di;
}

bool operator>(const dic& left, const dic& right)
{
	return left.di > right.di;
}

int main()
{
	while(true){
		string N;
		getline(cin, N);

		if(N=="0")
			break;

		istringstream isN(N);
		int n;
		isN >> n;

//		cout << n << endl;

		vector<string> w;

		for(int i=0; i<n; i++){
			string S;
			getline(cin, S);

			istringstream isS(S);
			while(!isS.eof()){
				string s;
				isS >> s;

//				cout << s << endl;

				w.push_back(s);
			}
		}

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

//		for(int i=0; i<w.size(); i++){
//			cout << w[i] << endl;
//		}

		string K;
		getline(cin, K);

		istringstream isK(K);
		char k;
		isK >> k;

//		cout << k << endl;

		vector<struct dic> D;
		string pre = "";

		for(int i=0; i<w.size(); i++){
			if(w[i][0]!=k)
				continue;

//			cout << w[i] << endl;

			if(w[i]==pre){
				D[D.size()-1].di++;
			}
			else{
				struct dic tmp;
				tmp.ds = w[i];
				tmp.di = 1;
				D.push_back(tmp);
				pre = w[i];
			}
		}

//		for(int i=0; i<D.size(); i++){
//			cout << D[i].di << ' ' << D[i].ds << endl;
//		}

		if(D.size()==0){
			cout << "NA" << endl;
			continue;
		}

		for(int i=0; i<D.size()-1; i++){
			for(int j=i+1; j<D.size(); j++){
				if(D[i].di<D[j].di || (D[i].di==D[j].di && D[i].ds>D[j].ds)){
					swap(D[i], D[j]);
				}
			}
		}

//		stable_sort(D.begin(), D.end(), greater<dic>());

//		for(int i=0; i<D.size(); i++){
//			cout << D[i].di << ' ' << D[i].ds << endl;
//		}

		int m = D.size();
		if(m>5){
			m = 5;
		}

		for(int i=0; i<m; i++){
			cout << D[i].ds;

			if(i==m-1){
				cout << endl;
			}
			else{
				cout << ' ';
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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 a,b,k;
  cin >> a >> b >> k;
  vector<int> ans;
  if(b-a+1<k*2){
    rep(i,b-a+1) ans.emplace_back(a+i);
  }else{
    rep(i,k) ans.emplace_back(a+i);
    rep(i,k) ans.emplace_back(b-k+1+i);
  }
  rep(i,ans.size()) printf("%d\n",ans[i]);
}


Measured memory_bytes: 256
N = gets.to_i
A = []
2.times{A << gets.chomp.split(" ").map(&:to_i)}

u = 0
wk = 0
B = []
0.upto(N-2){|i|
  u += A[0][i+1]
  wk += A[0][i+1] - A[1][i]
  B << wk
}
if not B.empty? then
  m = B.max
  if m > 0 then
    dif = u + m - B[-1]
  else
    dif = u - B[-1]
  end
else
  dif = 0
end

puts A[0][0] + A[1][N-1] + dif


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
//#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF =0;

signed main(){
	int n;
	cin >> n;
	int a;
	int cnt = 0,ans = 0,cntb = 0;
	bool flga=true,flgb=true,flgc=true,flgd=true,flge=true,flgf=true,flgg=true,flgh=true;
	rep(i,n){
		cin >> a;
		if(a < 400 && flga){
			++cnt;
			flga = false;
		}
		else if(a >= 400 && a < 800 && flgb){
			++cnt;
			flgb = false;
		}
		else if(a >= 800 && a < 1200 && flgc){
			++cnt;
			flgc = false;
		}
		else if(a >= 1200 && a < 1600 && flgd){
			++cnt;
			flgd = false;
		}
		else if(a >= 1600 && a < 2000 && flge){
			++cnt;
			flge = false;
		}
		else if(a >= 2000 && a < 2400 && flgf){
			++cnt;
			flgf = false;
		}
		else if(a >= 2400 && a < 2800 && flgg){
			++cnt;
			flgg = false;
		}
		else if(a >= 2800 && a < 3200 && flgh){
			++cnt;
			flgh = false;
		}
		else if(a >= 3200) ++cntb;
	}
	if(cnt == 0) cout << 1 << ' ' << cntb << '\n';
	else cout << cnt << ' ' << cnt + cntb << '\n';
	return 0;
}



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

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

//istream& operator>>(istream& is, const mint& a){return is >> a.x;}
//ostream& operator<<(ostream& os, const mint& a){return os << a.x;}

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

// nCa
mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> b(n+1, -1);
	int fst, sec;
	rep(i,n+1){
		int a;
		cin >> a;
		if(b[a] == -1) b[a] = i;
		else{
			fst = b[a];
			sec = i;
		}
	}
	Combination comb(n+5);
	for(int k = 1; k <= n+1; ++k){
		mint ans = comb(n+1, k) - comb(n - (sec - fst), k-1);
		cout << ans.x << endl;
	}
	return 0;
}

Measured memory_bytes: 5196