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

int main() {
	int n;
	cin >> n;
	vector<int>a(n+1);
	for (int i = 0; i < n+1; i++)cin >> a.at(i);
	vector<int>b(n);
	for (int i = 0; i < n; i++)cin >> b.at(i);
	int64_t ans = 0;
	for (int i = 0; i < n; i++) {
		if (b.at(i) <= a.at(i)) {
			a.at(i) -= b.at(i);
			ans += b.at(i);
		}
		else if ((a.at(i) < b.at(i) )&&( b.at(i) <= a.at(i) + a.at(i + 1))) {
			a.at(i + 1) -= (b.at(i) - a.at(i));
			a.at(i) = 0;
			ans += b.at(i);
		}
		else {
			ans += a.at(i) + a.at(i + 1);
			a.at(i) = 0;
			a.at(i + 1) = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  int x, n;
  int p;
  bool q[101];
  int i;

  cin >> x >> n;
  if (n==0) {
    printf("%d\n", x);
    return 0;
  }
  for (i=1; i<=100; i++) q[i] = true;
  for (i=0; i<n; i++) {
    cin >> p;
    q[p] = false;
  }
//for (i=1; i<=100; i++) printf("%d ", q[i]);
//printf("\n");
  for (i=x; i>=1; i--) {
    if (q[i]) {
      break;
    }
//printf("x*2-i = %d q[]=%d\n", x*2-i, q[x*2-i]);
    int i2 = x*2-i;
    if (i2<=100) {
      if (q[i2]) {
        i = i2;
        break;
      }
    } else {
      i = i2;
      break;
    }
  }

  printf("%d\n", i);
  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
using namespace std;

/*
            ॐ
    || Jai Shree Ram ||  
 
 */

void solve()
{
   
    ll n,m,k;
    cin>>n>>m>>k;
 
    vecl a(n+1);
    a[0] = 0;
    ll sum= 0;
    fo(i,1,n) {
        ll x;
        cin>>x;
 
        sum+= x;
        a[i] = sum;
    }
 
    vecl b(m+1);
    b[0] = 0;
    sum=0;
 
    fo(i,1,m) {
        ll x;
        cin>>x;
 
        sum+= x;
        b[i] = sum;
    }
    ll ans  =0;
    for(ll i=0; i<=n; i++) {
        ll val = k - a[i];
        if(val<0) {
            break;
        }
        if(val==0) {
            ans = max(ans, i);
            break;
        }
 
        int temp = lower_bound(all(b),val) - b.begin();
        if(temp>m || b[temp] > val) {
            temp--;
        }
        ans = max(ans, i+temp);
    }
 
    cout<<ans<<endl;
 
 
 
 
}


// void solve()
// {
   
//     int n,m,k;
//     cin>>n>>m>>k;

//     vec a(n+1);
//     a[0] = 0;
//     int sum= 0;
//     fo(i,1,n) {
//         int x;
//         cin>>x;

//         sum+= x;
//         a[i] = sum;
//     }

//     vec b(m+1);
//     b[0] = 0;
//     sum=0;

//     fo(i,1,m) {
//         int x;
//         cin>>x;

//         sum+= x;
//         b[i] = sum;
//     }
//     int ans  =0;
//     int j= m;
//     for(int i=0; i<=n; i++) {
//         if(a[i] > k) {
//             break;
//         }

//         while(b[j] > k-a[i] && j>=0) {
//             j--;
//         }
//         ans = max(ans, i+j);
//     }

//     cout<<ans<<endl;




// }
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}


Measured memory_bytes: 6372
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC129A
{
    static class Program
    {
        static void Main(string[] args)
        {
            var line = ReadLine().SplitTryParseToList<int>();

            var list = new List<int>();

            WriteLine(Math.Min(line[0] + line[1], Math.Min(line[0] + line[2], line[1] + line[2])));
        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                return (T)converter.ConvertFromString(input);
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 14432
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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;
typedef pair<int64_t, int64_t> P;

int main(){
    char C;
    cin >> C;
    C++;
    cout << C << endl;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200020
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	string n;
	cin >> n;
	bool f = n[0] == '7' || n[1] == '7' || n[2] == '7';
	out(f ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

#include <vector>
using namespace std;
typedef long long i64;

struct StronglyConnectedComponets{
  vector<bool> vis;
  vector<int> vs;
  const vector<vector<int> >& G;
  vector<vector<int> > rG;


  vector<int> res;
  int cnt;

  StronglyConnectedComponets(const vector<vector<int> >& g) : 
    G(g),vis(g.size(),false),res(g.size(),-1),cnt(0),rG(g.size()){
      for(int i = 0;i < G.size();i++){
        for(int j = 0;j < G[i].size();j++){
          rG[G[i][j]].push_back(i);
        }
      }
    }
  
  void sccd(){
    for(int i = 0;i < G.size();i++) dfs(i);
    cnt = 0;
    for(int i = (int)vs.size() - 1;i >= 0;i--){
      int v = vs[i];
      rdfs(v,cnt++);
    }
  }

  void dfs(int v){
    if(vis[v]) return;
    vis[v] = true;
    for(int i = 0;i < G[v].size();i++){
      dfs(G[v][i]);
    }
    vs.push_back(v);
  }

  void rdfs(int v,int k){
    if(res[v] != -1) return;
    res[v] = k;
    for(int i = 0;i < rG[v].size();i++)
    {
      rdfs(rG[v][i],k);
    }
  }
};

int N,M;
int main(){
  cin >> N >> M;
  vector< vector< int > > G(N);
  rep(i,0,M -1){
    int s,t;
    cin >> s >> t;
    G[s].push_back(t);
  }
  StronglyConnectedComponets scc(G);
  scc.sccd();
  int Q;
  cin >> Q;
  rep(i,0,Q - 1){
    int u,v;
    cin >> u >> v;
    cout << (scc.res[u] == scc.res[v]) << endl;
  }
}



Measured memory_bytes: 4180
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;

int main() {
	LL Q, H, S, D;
	cin >> Q >> H >> S >> D;
	LL N;
	cin >> N;
	S = min(S, min(Q * 4, H * 2));
	if (2 * S <= D) {
		cout << N*S << endl;
	}
	else {
		cout << (N / 2)*D + (N % 2)*S << endl;
	}
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val n = readLine()!!
  val p = readLine()!!.split(" ").map { it.toInt() }
  var count = 0
  (0..(p.size-3)).forEach {
    val p0 = p[it]
    val p1 = p[it + 1]
    val p2 = p[it + 2]
    if (p1 in p0..p2 || p1 in p2..p0) count++
  }
  println(count)
}

Measured memory_bytes: 37988
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define enter "\n"

typedef long long ll;



int abc097_b(){
    //入力
    int x;
    cin >> x;
    int ans = 0;
    
    //処理
    REP(i,35){
        for(int j=2; j<=10; ++j){
            int tmp;
            tmp = pow(i,j);
            if(x<tmp) break;
            else ans = max(ans,tmp);
        }
    }
    
    //出力
    cout << ans << enter;
    return 0;
}

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


Measured memory_bytes: 384
count = gets.to_i
arr = []

count.times do
  arr << gets.to_i
end
ans = 0
arr.each do |number|
  next if number == 1
  sqrt = Math.sqrt(number)
  factor_found = (2..sqrt).any? { |int| number % int == 0 }

  unless factor_found
    ans += 1
  end
end

p ans

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k, ans = 0;
  cin >> n >> k;
  
  rep(i, k, n+2) {
    ans += (i*(n-i+1)+1);
    ans %= 1000000007;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<set>
#include<cmath>
using namespace std;

int main()
{
    int n,ma=0;
    char s[105];
    cin>>n>>s;
    for(int i=0;i<n;i++)
    {
        set<char>s1(s,s+i);
        set<char>s2(s+i,s+n);
        int ss1=s1.size();
        int ss2=s2.size();
        int temp=0;
        set<char>::iterator it1;
        set<char>::iterator it2;
        for(it1=s1.begin();it1!=s1.end();it1++)
        {
            for(it2=s2.begin();it2!=s2.end();it2++)
            {
                if(*it1==*it2)
                    temp++;
            }
        }
        ma=max(ma,temp);
    }
    cout<<ma<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  int ans=0;
  cin >> N >> M;
  
  for (int i = 0;i<N;i++){
    int x=0;
   	cin >> x;
    if(M-x>x){
     ans +=2*x; 
    }else{
      ans +=2*(M-x);
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let ab = readInts()
    if 1 <= ab[0] && ab[0] <= 9 && 1 <= ab[1] && ab[1] <= 9 {
        print(ab[0] * ab[1])
    } else {
        print("-1")
    }
}

main()


Measured memory_bytes: 8248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<long long> a(N), b(N);
  long long count_a = 0, count_b = 0;
  rep(i, N)
  {
    cin >> a[i];
  }
  rep(i, N)
  {
    cin >> b[i];
  }
  rep(i, N)
  {
    if (a[i] > b[i])
    {
      count_b += a[i] - b[i];
    }
    else if (a[i] < b[i])
    {
      if (a[i] % 2 == b[i] % 2)
      {
        count_a += (b[i] - a[i]) / 2;
      }
      else
      {
        count_a += (b[i] + 1 - a[i]) / 2;
        count_b += 1;
      }
    }
  }

  long long M = count_a - count_b;
  if (M >= 0)
    cout
        << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	ll sum_jpy = 0, sum_bit = 0;

	rep(i, n) {
		string money, cur;
		cin >> money >> cur;
		if (cur == "JPY")sum_jpy += stol(money);
		else {
			ll bit = 0;
			rep(j, money.size()) {
				if (money[j] == '.')continue;
				bit *= 10;
				bit += money[j] - '0';
			}
			sum_bit += bit;
		}
	}

	cout << fixed << setprecision(6);
	cout << (sum_jpy * 100000000 + sum_bit * 380000) / 1e8 << endl;

}

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

#define int long long int
#define ull unsigned long long int
#define for0(i, n) for (int i = 0; i < (int)(n); i++) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); i++) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); i++) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; i--) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; i--) // reverse 1 based


#define pb push_back
#define fi first
#define se second

#define I_max (unsigned int)1e9
#define size6 (int)1e6


#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())


using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef double ld;

//-----------------------------------------------------------------------------------END-------------------------------------------------------------------------------------//

int a[size6];


bool inc(vi vec){
	for1(i,vec.size()-1){
		if(vec[i]<vec[i-1])return 0;
	}
	return 1;
}


void solve(){
   string s,t;cin>>s>>t;

   int ans=I_max;

   forc(i,0,s.length()-t.length()){
	   int temp=0;
	   int p=0;
	   forc(j,i,i+t.length()-1){
		   if(t[p++] != s[j])temp++;
	   }
	   ans = min(temp,ans);
   }
   cout<<ans<<'\n';
}



int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout.precision(10);
	//cout << fixed;
	//int tt;cin>>tt;
	//while(tt--){
		solve();
	//}
	return 0;
}




Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;


int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL r,D,x2000;
	LL ans = 0;

	cin >> r >> D >> x2000;

	for(int i=0 ; i < 10 ;i++){
		ans = r * x2000 - D;
		cout << ans << endl;
        x2000 = ans;
	}

	return 0;

}


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

num = [1]*n
red = [1] + [0]*(n-1)

for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    num[x] -= 1
    num[y] += 1

    if red[x]:
        red[y] = 1
    if num[x] == 0:
        red[x] = 0

print(sum(red))

Measured memory_bytes: 5364
N = int(input())
S = input()

import re

count = 0
for i in range(10):
    try:
        i_ = re.search(str(i), S).start()
    except:
        continue
    for j in range(10):
        try:
            j_ = re.search(str(j), S[i_+1:]).start()
        except:
            continue
        for k in range(10):
            try:
                k_ = re.search(str(k), S[i_+1+j_+1:]).start()
            except:
                continue

            count += 1

print(count)

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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint32_t;
using int64 = int64_t;
using uint64 = uint64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

template<typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; }
template<typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; }

int64 m;
using Line = pair<PLL, PLL>;
vector<PLL> pts;
vector<Line> ls;
int64 dp[17][1 << 16] = {};

bool isParallel(Line a, Line b) {
  PLL aa = PLL(a.sc.fs-a.fs.fs, a.sc.sc-a.fs.sc), bb = PLL(b.sc.fs-b.fs.fs, b.sc.sc-b.fs.sc);
//  cout << aa.fs << " " << aa.sc << ": " << bb.fs << " " << bb.sc << endl;
  if (aa.fs*bb.sc-aa.sc*bb.fs == 0) {
    return 1;
  } else {
    return 0;
  }
}

int64 dfs(int64 d=0, int64 used=0) {
  if (used == (1 << m) -1) {
    int64 sum = 0;
    REP(i, m/2) {
      FOR(j, i+1, m/2) {
        sum += isParallel(ls[i], ls[j]);
      }
    }
//    cout << sum << endl;
    return sum;
  }
  while ((used >> d) & 1) d++;
  FOR(i, d+1, m) {
    if (used >> i & 1) continue;
    ls.push_back({pts[i], pts[d]});
    chmax(dp[d][used], dfs(d+1, used | (1 << d) | (1 << i)));
    ls.pop_back();
  }
  return dp[d][used];
}

int main(void) {
  cin >> m;
  REP(i, m) {
    PLL p;
    cin >> p.fs >> p.sc;
    pts.push_back(p);
  }
  memset(dp, -1, sizeof dp);
  cout << dfs() << endl;
}


Measured memory_bytes: 11800
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/cmplx"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	h := getNextInt(scanner)
	m := getNextInt(scanner)
	ca := complex(0, float64(a))
	cb := complex(0, float64(b))
	ca = rotate(ca, degToRad(float64(h)*30+0.5*float64(m)))
	cb = rotate(cb, degToRad(6*float64(m)))
	fmt.Fprintln(writer, cmplx.Abs(ca-cb))
}
func compare(a, b float64) int {
	eps := 1e-9
	if a > b+eps {
		return 1
	}
	if b > a+eps {
		return -1
	}
	return 0
}
func rotate(v complex128, theta float64) complex128 {
	r, th := cmplx.Polar(v)
	th += theta
	return cmplx.Rect(r, th)
}
func degToRad(deg float64) float64 {
	return deg * math.Pi / 180.0
}
func radTodeg(rad float64) float64 {
	return rad * 180.0 / math.Pi
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	vll a(n);
	rep(i,n) cin >> a[i];
	sort(all(a));
	cout << a[n/2]-a[n/2-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
arr = []
A, B, C, D = map(int, input().split())

arr.append(A)
arr.append(B)
arr.append(C)
arr = sorted(arr)

if abs(C-A) <= D:
  print("Yes")
elif arr[1]-arr[0] <= D and arr[2]-arr[1] <= D:
  print("Yes")
else:
  print("No")

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

class BIT {
private:
	int sequence_size_;
	std::vector<int> container_;
public:
	BIT(int);
	void add(int place, int num);
	int get_sum(int left, int right);
};

BIT::BIT(int n)
	:sequence_size_(n)
{
	// 各ノードは1-indexedの数列の要素に紐づけられる
	container_.resize(n + 1);
}

void BIT::add(int place, int num)
{
	while (place <= sequence_size_)
	{
		container_[place] += num;
		place += place & -place;
	}
}

// 1-indexedで(left, right]の和
int BIT::get_sum(int left, int right)
{
	int sum{};
	while (right)
	{
		sum += container_[right];
		right -= right & -right;
	}
	while (left)
	{
		sum -= container_[left];
		left -= left & -left;
	}
	return sum;
}

int main()
{
	int n, q;
	scanf("%d%d", &n, &q);
	BIT rsq(n);
	for (int i{}; i < q; i++)
	{
		int com, x, y;
		scanf("%d%d%d", &com, &x, &y);
		switch(com)
		{
		case 0:
			rsq.add(x, y);
			break;
		case 1:
			printf("%d\n", rsq.get_sum(x - 1, y));
			break;
		}
	}
	return 0;
}


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

using namespace std;



int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
   
   long long int n,cnt=1,min=0;
   cin>>n;
   long long int a[n],i;
   for(i=0;i<n;++i)
      cin>>a[i];
      
     min=a[0]; 
    for(i=1;i<n;++i)
     {
         if(min>a[i])
          {
              min=a[i];
              cnt++;
          }
           
    
     }
     cout<<cnt;
        
   
     return 0;
}

Measured memory_bytes: 5208
N = int(input())
p = [0]*N
p = list(map(int, input().split()))
ans = int(0)

for i in range(1,N-1):
    if(p[i-1]<p[i]<p[i+1]):
       ans +=1
    elif(p[i+1]<p[i]<p[i-1]):
        ans +=1
print(ans)




Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] Ai = new long[N+1];
    	for (int i = 0; i < Ai.length; i++) {
    		Ai[i] = sc.nextLong();
    	}
    	long tmp = 0L;
    	long hunt = 0L;
    	for (int i = 0; i < N; i++) {
    		long B = sc.nextLong();
    		long Btmp = B + tmp;
    		if (Ai[i] <= Btmp) {
    			if (Ai[i] <= tmp) {
    				tmp = B;
    			} else {
    				tmp = Btmp - Ai[i];
    			}
    			hunt += Ai[i];
    		} else {
    			tmp = 0L;
    			hunt += Btmp;
    		}
    	}
    	if (Ai[N] <= tmp) {
    		hunt += Ai[N];
    	} else {
    		hunt += tmp;
    	}
    	System.out.println(hunt);
    }
}

Measured memory_bytes: 64852
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    ll n,a;
    cin>>n;
    
    rep(i,n){
        cin>>a;
        if(a%2==0){
            if(a%3!=0&&a%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    }


Measured memory_bytes: 3584
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextDouble
//  val h = List.fill(n)(sc.nextInt)

  val ans = if (n == 1) 1 else if (n % 2 == 0) 0.5 else (n.toInt / 2 + 1) / n
  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=0;i--)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<endl
#define DO(x, y) cout<<x<<" "<<y<<endl
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<<endl
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)



int main(void)
{
    int i, j;
    int n, m, x, y;
    DI(n, m);
    priority_queue <int, vector<int>, greater<int> > pq;
    F(i, 0, n)
    {
        SI(x);
        pq.push(x);
    }
    vii dp;
    F(i, 0, m)
    {
        DI(x, y);
        dp.pb(mp(y, x));
    }
    DESC(dp);
    F(i, 0, m)
    {
        if(dp[i].first <= pq.top())
            break;
        else
        {
            F(j, 0, dp[i].second)
            {
                if(dp[i].first <= pq.top())
                    break;
                else
                {
                    pq.pop();
                    pq.push(dp[i].first);
                }
            }
        }
    }

    ll sum = 0;
    while(!pq.empty())
    {
        sum += pq.top();
        pq.pop();
    }
    SO(sum);
    return 0;
}


Measured memory_bytes: 1784
if __name__ == '__main__':
    s = input()
    x1 =0
    x2=0
    y1=0
    y2=0

    for i in s:
        if i =="N":
            y1+=1
        if i == "S":
            y2+=1
        if i == "E":
            x1+=1
        if i == "W":
            x2+=1
    if ((x1 ==0 and x2 ==0) or (x1>0 and x2>0) ) and ((y1 ==0 and y2 ==0)or(y1 > 0and y2 > 0)):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,d;
    cin >> n >> d;
    int rs = 1;
    int i = d + 1;
    while (i+d < n){
        // db(i);
        i+=d + d + 1;
        rs++;
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define LL long long


int main()
{
   // freopen("asass.txt","w",stdout);

   long long start=0,ends=0,i,l;
   string st;
   cin>>st;
   l=st.size();
   for(i=0;i<l;i++)
   {
       if(st[i]=='A')
       {
           start=i;
           break;
       }
   }
   for(i=l-1;i>start;i--)
   {
       if(st[i]=='Z')
       {
           ends=i;
           break;
       }
   }
   cout<<(ends-start)+1<<"\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
int main()
{
    fio;
    ll a, b, c;
    cin >> a >> b >> c;
    if((a == c && b != a) ||(a == b && a != c) || (b == c && a != b)){
        cout << "Yes" ;
    }
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll n;
    cin >> n;
    int m = sqrt(n);
    for (ll i = m; i > 0; i--) {
        if (n % i == 0) {
            ll a = i, b = n / i;
            ll ans = a + b - 2;
            ans = max(ans, ll(0));
            cout << ans << endl;
            break;
        }
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


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

int main(void){
    int N, M, Hbuf, Abuf, Bbuf;
    cin >> N >> M;
    vector<bool> GoodObservatory(N, true);
    vector<int> Height;
    for(int i=0; i<N; i++){
        cin >> Hbuf;
        Height.push_back(Hbuf);
    }
    for(int i=0; i<M; i++){
        cin >> Abuf >> Bbuf;
        Abuf--;
        Bbuf--;
        if(Height[Abuf] >= Height[Bbuf]){
            GoodObservatory[Bbuf] = false;
        }
        if(Height[Abuf] <= Height[Bbuf]){
            GoodObservatory[Abuf] = false;
        }
    }
    int res = 0;
    for(int i=0; i<N; i++){
        if(GoodObservatory[i])res++;
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  string s;
  int i;
  int count=0;
  cin >> s[0] >> s[1] >> s[2];
  for(i=0;i<3;i++){
  	if(s[i]=='o'){
    	count++;
    }
  }
  cout << 700+(100*count) << endl;
  
  return 0;
}

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

using namespace std;
long gcd(long a, long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long lcm(long a, long b)
{
   return a * b / gcd(a, b);
}

int main() {
    long a,b,c,d;
    cin >>a>>b>>c>>d;
    long cd =lcm(c,d);
    long dmk= b/d;
    long dsk = (a-1)/d;
    long cmk = b/c;
    long csk = (a-1)/c;
    long cdmk = b/cd;
    long cdsk = (a-1)/cd;
    long dk = dmk-dsk;
    long ck = cmk-csk;
    long cdk = cdmk-cdsk;
    long kazu = dk+ck-cdk;
    cout<<(b-a+1)-kazu;
    //cout<<cd;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

char s[12345];
int c,f;

void test() {
	scanf("%s", s);
	for (int i=0;s[i];i++) {
		if (s[i]=='C') c=1;
		if (c==1 && s[i]=='F') f=1;
	}
	printf("%s\n", f ? "Yes" : "No");
}

int main() {test();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl

int main() {
	int n; cin>>n;
	vector<int> c(n), v(n);
	for(int i = 0; i < n; i++){
		cin>>v[i];
	}
	for(int i = 0; i < n; i++){
		cin>>c[i];
	}	
	int answer = 0;
	for(int i =0 ; i < n; i++){
		if(v[i] - c[i] > 0){
			answer += (v[i] - c[i]);
		}
	}
	cout<<answer<<endl;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
w, h, n = map(int,input().split()) 
a = []
for i in range(n):
    a.append([int(i) for i in input().split()])

x_left = 0
x_right = w
y_lower = 0
y_upper = h
for i in range(n):
    if a[i][2] == 1:
        x_left = max(a[i][0], x_left)
    if a[i][2] == 2:
        x_right = min(a[i][0], x_right)
    if a[i][2] == 3:
        y_lower = max(a[i][1], y_lower)
    if a[i][2] == 4:
        y_upper = min(a[i][1], y_upper)
if y_lower >= y_upper or x_left >= x_right:
    print(0)
else:
    #print(y_upper)
    #print(y_upper - y_lower, x_right - x_left)
    print((y_upper - y_lower) * (x_right - x_left))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string first,second;
    cin >> first;
    cin >> second;
    vector<int> grid;
    for(int i = 0 ; i < n ; i++)
    {
        if(first[i] == first[i+1])
        {
            grid.push_back(0);
            i++;
        }
        else
        grid.push_back(1);
    }
    unsigned long long int score = 0;
    if(grid[0] == 0)
        score = 6;
    else
        score = 3;
    for(int i = 1 ; i < grid.size() ; i++)
    {
        if(grid[i] == 0)
        {
            if(grid[i-1] == 0)
            {
                score *= 3;
            }
            else
            {
                score *= 2;
            }
        }
        else
        {
            if(grid[i-1] == 0)
            {
                score = score;
            }
            else
            {
                score *= 2;
            }    
        }
    }
    cout << score%1000000007 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(int n){
	int h,m,s,ans=0;
	vi v(100000,0);
	rep(i,n){
		scanf("%d:%d:%d",&h,&m,&s);
		v[h*3600+m*60+s]++;
		scanf("%d:%d:%d",&h,&m,&s);
		v[h*3600+m*60+s]--;
	}
	range(i,1,100000){
		v[i]+=v[i-1];
		chmax(ans,v[i]);
	}
	cout<<ans<<endl;
}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n;
	while(cin>>n,n)solve(n);
}


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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

	int n,m;
	cin>>n>>m;
	string s;
	vector<vector<bool> > mat(n, vector<bool>(m, true));
	vector<vector<int> > dp(n+1, vector<int>(m+1, 0));

	for(int i=0;i<n;++i){
		cin>>s;
		for(int j=0;j<m;++j)	if(s[j] == '#')		mat[i][j] = false;
	}
	int mod = 1e9+7;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(mat[i-1][j-1])	dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
			if(i+j == 2)	dp[i][j] = 1;
		}
	}

	cout<<dp[n][m]<<"\n";
	
	return 0;
}

Measured memory_bytes: 7432
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

/*
0-index
functionの中を書いて使う
segtree<ll> seg(n, [](ll a, ll b){return a + b;}, 0);
*/
template<typename T>
struct segtree{
	int n;
	vector<T> dat;
	T ZERO;
	function<T(T,T)> func;//要素と要素をマージする関数

	segtree(int n_, function<T(T,T)> func_, T zero):func(func_), ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}

	void update(int k, T a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = func(dat[k*2+1],dat[k*2+2]);
	  }
	}

	void set(int k, T a) {
		k += n - 1;dat[k] = a;
	}

	void build(){
		for(int i = n - 2;i >= 0;i--){
			dat[i] = func(dat[2 * i + 1], dat[2 * i + 2]);
		}
	}

	T get(int k){return dat[k+n-1];}

	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = func(L,dat[A++]);
            if((B & 1) == 0)R = func(dat[--B],R);
            A = A >> 1;
            B = B >> 1;
		}
		return func(L,R);
	}
};


vector<P> v;
segtree<ll> seg(222222, [](ll a, ll b){return max(a, b);}, -LLINF);
ll num[222222];

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

	ll n;cin >> n;
	num[n] = 1;
	num[n+1] = 1;
	REP(i, n){
		ll x, d;cin >> x >> d;
		d += x;
		v.EB(x, d);
	}
	sort(ALL(v));
	REP(i, n)seg.update(i, v[i].SE);

	//REP(i, n){cout << "(" << v[i].FI << " " << v[i].SE << ")" << endl;}

	REV(i, n){
		int id = lower_bound(ALL(v), MP(v[i].SE, -LLINF)) - v.begin();
		v[i].SE = seg.que(i, id);
		seg.update(i, v[i].SE);
	}

	//REP(i, n){cout << "(" << v[i].FI << " " << v[i].SE << ")" << endl;}

	REV(i, n){
		int id = lower_bound(ALL(v), MP(v[i].SE, -LLINF)) - v.begin();
		num[i] = (num[i+1] + num[id]) % MOD;
		//cout << "i " << i << " num " << num[i] << " id " << id << endl;
	}

	cout << num[0] << endl;

	return 0;
}


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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const ll MOD = 1e9 + 7;

int main() {
    fastio;

    int n, k;
    cin >> n >> k;
    ll total = 0;
    FOR(i, 0, n) {
        int x;
        cin >> x;
        total += 2*(min(abs(x), abs(k-x)));
    }
    cout << total << "\n";
    return 0;
}


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

temp=0
if n==0:
    print(x)
    exit()
P=list(map(int,input().split())) 
   
while True:
    if not x-temp in P:
        print(x-temp)
        exit()
    if not x+temp in P:
        print(x+temp)
        exit()
    temp+=1

Measured memory_bytes: 61652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  int k,n;
  cin>>k>>n;
  int a[n+1];
  for(i=0;i<n;i++) cin>>a[i];
  a[n]=k+a[0];
  int ma=0;
  for(i=1;i<=n;i++) ma=max(ma,a[i]-a[i-1]);
  cout<<k-ma<<endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

int main(void) {
    int n;
    read(n);
    vector < pair <int, int> > ans;
#define answer(x, y) ans.push_back({x, y});
    if (n & 1) {
        rep (i, n - 1) answer(i, n);
        rep (i, n - 1)
            rep (j, n - 1) if (i + j != n && i < j) answer(i, j);
    } else {
        ++n;
        rep (i, n - 1)
            rep (j, n - 1) if (i + j != n && i < j) answer(i, j);
    }
    cout << ans.size() << "\n";
    for (auto i : ans)
        cout << i.first << " " << i.second << "\n";
    // vector < pair <int, int> > edge;
    // rep (i, n) rep (j, i - 1) edge.push_back({i, j});
    // rep (st, (1 << edge.size()) - 1) {
    //     vector <int> sum(n + 1, 0);
    //     re0 (i, edge.size()) if (st >> i & 1) {
    //         sum[edge[i].first] += edge[i].second;
    //         sum[edge[i].second] += edge[i].first;
    //     }
    //     if (*min_element(sum.begin() + 1, sum.end()) ==
    //         *max_element(sum.begin() + 1, sum.end())) {
    //         cout << *min_element(sum.begin() + 1, sum.end()) << "\n";
    //         re0 (i, edge.size()) if (st >> i & 1) {
    //             cout << edge[i].first << " " << edge[i].second << "\n";
    //         }
    //         // return 0;
    //     }

    // }
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    if(s>t) cout<<">"<<endl;
    else if(s<t) cout<<"<"<<endl;
    else cout<<"="<<endl;
    return 0;
}

Measured memory_bytes: 256