akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n=I()

A1=[]
A2=[]
for i in range(n):
    x,y=LI()
    A1+=[x+y]
    A2+=[x-y]

ans=max(max(A1)-min(A1),max(A2)-min(A2))
print(ans)



Measured memory_bytes: 107412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int n,m;
int A[10];
int dp[10002];
int num[10] = {0,2,5,5,4,5,6,3,7,6};
vector<int> v;
int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++) cin >> A[i];
    sort(A,A+m);
    for(int i = 0; i <= n; i++) dp[i] = -1;
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        int tmp = -1;
        for(int j = 0; j < m; j++){
            int k = i - num[A[j]];
            if(k >= 0 && dp[k] >= 0){
                tmp = max(tmp,dp[k]+1);
            }
        }
        dp[i] = tmp;
    }
    int i = n;
    while(true){
        if(i <= 0) break;
        for(int j = m-1; j >= 0; j--){
            int tmp = i - num[A[j]];
            if(tmp >= 0 && (dp[tmp] == (dp[i]-1))){
                v.push_back(A[j]);
                i = tmp;
                break;
            }
        }
    }
    for(int x = 0; x < v.size(); x++){
        cout << v[x];
    }
    cout << endl;
}



Measured memory_bytes: 384
package main

import "fmt"

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var w, a, b int
	fmt.Scan(&w, &a, &b)
	if abs(a-b) <= w {
		fmt.Println("0")
		return
	}
	fmt.Println(abs(a-b) - w)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
 
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b >= c){
    cout << "Yes" << '\n';
  }else{
    cout << "No" << '\n';
  }
  
  return 0;
}

Measured memory_bytes: 3616
#[derive(Clone)]
struct BitSet {
    size: usize,
    a: Vec<usize>,
}

fn bit_size() -> usize {
    8 * std::mem::size_of::<usize>()
}

fn quot_rem(n: usize) -> (usize, usize) {
    let w = bit_size();
    (n / w, n % w)
}

#[allow(dead_code)]
impl BitSet {
    fn new(size: usize) -> Self {
        let w = bit_size();
        BitSet {
            size: size,
            a: vec![0; (size + w - 1) / w],
        }
    }
    fn set_at(&mut self, x: usize) {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        self.a[q] |= 1 << r;
    }
    fn get_at(&self, x: usize) -> usize {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        (self.a[q] >> r) & 1
    }
    fn fix(&mut self) {
        let (q, r) = quot_rem(self.size);
        if r != 0 {
            self.a[q] &= (1 << r) - 1;
        }
    }
    fn clear(&mut self) {
        let len = self.a.len();
        self.a.clear();
        self.a.resize(len, 0);
    }
    fn shift_left(&self, rhs: usize) -> Self {
        let (q, r) = quot_rem(rhs);
        let mut ans = BitSet::new(self.size + rhs);
        if r == 0 {
            for (x, y) in ans.a[q..].iter_mut().zip(self.a.iter()) {
                *x = *y;
            }
        } else {
            let w = bit_size();
            let mut prev = 0;
            for (x, y) in ans.a[q..].iter_mut().zip(self.a.iter()) {
                *x = (*y << r) | (prev >> (w - r));
                prev = *y;
            }
            *ans.a.last_mut().unwrap() |= prev >> (w - r);
        }
        ans.fix();
        ans
    }
    fn truncate(&mut self, len: usize) {
        if len >= self.size {
            return;
        }
        let w = bit_size();
        self.a.truncate((len + w - 1) / w);
        self.size = len;
        self.fix();
    }
    fn bitwise_or(&self, rhs: &Self) -> Self {
        let (x, y) = if self.size >= rhs.size {(self, rhs)} else {(rhs, self)};
        let mut a = x.a.clone();
        for (a, y) in a.iter_mut().zip(y.a.iter()) {
            *a |= *y;
        }
        BitSet {
            size: x.size,
            a: a,
        }
    }
}

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let _n: usize = it.next().unwrap().parse().unwrap();
    let mut bit = BitSet::new(1);
    bit.set_at(0);
    let mut sum = 0;
    for s in it {
        let a: usize = s.parse().unwrap();
        bit = bit.bitwise_or(&bit.shift_left(a));
        sum += a;
    }
    let mut ans = (sum + 1) / 2;
    while bit.get_at(ans) == 0 {
        ans += 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

int main(){
  string s;
  cin >> s;
  
  vector<bool> vec(26);
  for (int i=0; i<s.length(); i++){
    vec.at(s.at(i) - 'a') = true;
  }
  
  for (int i=0; i<26; i++){
    if (vec.at(i)){
      if (i==25) cout << "None" << endl;
      continue;
    }
    else {
      char c = 'a' + i;
      cout << c << endl;
      break;
    }
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int A, B;
    cin >> A >> B;

    int plus = A + B;
    int minus = A - B;
    int multiply = A * B;

    if (plus <= multiply && minus <= multiply) {
        cout << multiply;
    } else if (plus <= minus && multiply <= minus) {
        cout << minus;
    } else {
        cout << plus;
    }
    
    return 0;
}

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

struct Node{
    int key;
    Node *prev, *next;
};

Node *nil; //実データには含めない

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil -> next = nil;
    nil -> prev = nil;
}


void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x -> key = key;
    x -> next = nil -> next;
    nil -> next -> prev = x;
    nil -> next = x;
    x -> prev = nil;
}

Node* listSearch(int key){
    Node *cur = nil -> next;
    while(cur != nil && cur -> key != key){
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t){
    if(t == nil) return;
    t -> prev -> next = t -> next;
    t -> next -> prev = t -> prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil -> next);
}

void deleteLast(){
    deleteNode(nil -> prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

int main(){
    int key, n;
    string com;
    cin >> n;
    init();
    for(int i = 0; i < n; i++){
        cin >> com;
        if(com == "insert"){
            cin >> key;
            insert(key);
        }else if(com == "delete"){
            cin >> key;
            deleteKey(key);
        }else if(com == "deleteFirst"){
            deleteFirst();
        }else if(com == "deleteLast"){
            deleteLast();
        }
    }

    Node *last = nil -> next;
    while(last != nil){
        cout << last -> key;
        if(last -> next != nil){
            cout << " ";
        }
        last = last -> next;
    }

    cout << endl;
}




Measured memory_bytes: 34416
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define modul 998244353
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll a,b;
int32_t main(){
CODE_START;
cin>>a>>b;
cout<<a*b<<endl;
}



Measured memory_bytes: 3608
#include<stdio.h>

#include<algorithm>
#include<iostream>
#include<stack>

using namespace std ;

#define y first
#define x second

#define NM_MAX 90

int mx[] = { 0 ,1 ,-1 ,0 } ;
int my[] = { 1 ,0 ,0 ,-1 } ;

struct Data
{
	int cnt ;
	pair<int ,int> p ;
	bool map[ NM_MAX + 2 ][ NM_MAX + 2 ] ;
};


int main( void )
{
	Data init = { 0 ,make_pair(1 ,1) ,false } ;
	stack< pair<int ,int> > start ;

	int W ,H ;
	while( true )
	{
		scanf( "%d %d" ,&W ,&H ) ;

		if( W | H )
		{
			int ans = 0 ;

			int i ,j ;
			for( i = 1 ; i <= H ; ++i )
			{
				for( j = 1 ; j <= W ; ++j )
				{
					int input ;
					scanf( "%d" ,&input ) ;

					init.map[ i ][ j ] = (input == 0 ? false : true ) ;

					if( init.map[ i ][ j ] )
					{
						start.push( make_pair(i ,j) ) ;
					}
				}
			}

			stack< Data > st ;

			while( !start.empty() )
			{
				init.p = start.top() ;
				start.pop() ;

				st.push( init ) ;
				while( !st.empty() )
				{
					Data move = st.top() ;
					st.pop() ;

					int X = move.p.x ;
					int Y = move.p.y ;

					++move.cnt ;
					move.map[ Y ][ X ] = false ;
					ans = max( ans ,move.cnt ) ;

					Data copy = move ;

					for( i = 0 ; i < 4 ; ++i )
					{
						int nextX = X + mx[ i ] ;
						int nextY = Y + my[ i ] ;

						if( move.map[ nextY ][ nextX ] == true )
						{
							copy.p.x = nextX ;
							copy.p.y = nextY ;

							st.push( copy ) ;
						}
					}
				}
			}

			printf( "%d\n" ,ans ) ;
		}
		
		else
		{
			return 0 ;
		}
	}
}


Measured memory_bytes: 3384
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  int N, M, C, S, G;
  while (cin >> N >> M >> C >> S >> G, N) {
    --S, --G;
    auto dp1 = vectors(C, N, N, 0LL);
    rep(c, C) rep(i, N) rep(j, N) dp1[c][i][j] = (i == j) ? 0 : INF;
    int maxD = 0;
    rep(i, M) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      --x, --y, --c;
      cmin(dp1[c][x][y], d);
      cmin(dp1[c][y][x], d);
      cmax(maxD, d);
    }
    auto f = vectors(C, N * maxD + 1, 0LL);
    vector<int> p(C);
    cin >> p;
    rep(c, C) {
      vector<int> q(p[c] - 1), r(p[c]);
      rep(i, p[c] - 1) cin >> q[i];
      rep(i, p[c]) cin >> r[i];
      for (int i = 1, k = 0; i <= N * maxD; i++) {
        if (k + 1 < p[c] && i > q[k]) k++;
        f[c][i] = f[c][i - 1] + r[k];
      }
    }
    auto dp2 = vectors(N, N, 0LL);
    rep(i, N) rep(j, N) dp2[i][j] = (i == j) ? 0 : INF;
    rep(c, C) rep(k, N) rep(i, N) rep(j, N) cmin(dp1[c][i][j], dp1[c][i][k] + dp1[c][k][j]);
    rep(c, C) rep(i, N) rep(j, N) {
      if (dp1[c][i][j] > N * maxD) continue;
      cmin(dp2[i][j], f[c][dp1[c][i][j]]);
    }
    rep(k, N) rep(i, N) rep(j, N) cmin(dp2[i][j], dp2[i][k] + dp2[k][j]);
    cout << (dp2[S][G] == INF ? -1 : dp2[S][G]) << endl;
  }
}



Measured memory_bytes: 8048
K, A, B = [int(_) for _ in input().split()]

def solve(K, A, B):
    r = 1
    if B - A <= 2:
        return r + K
    x = min(A - 1, K)
    r += x
    K -= x
    # print("*", r, K)
    if r >= A:
        x = K // 2
        r += x * (B - A)
        K -= x * 2
    # print("*", r, K)
    r += K
    K -= K
    return r

print(solve(K, A, B))


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static long[] X, Y, R;

  public static void main(String[] args) {
    long SX = sc.nextLong();
    long SY = sc.nextLong();
    long TX = sc.nextLong();
    long TY = sc.nextLong();
    int N = sc.nextInt();
    X = new long[N];
    Y = new long[N];
    R = new long[N];
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      Y[i] = sc.nextInt();
      R[i] = sc.nextInt();
    }
    double[][] dist = new double[N + 2][N + 2];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < i; j++) {
        long d = dist2(X[i], Y[i], X[j], Y[j]);
        long r2 = (R[i] + R[j]) * (R[i] + R[j]);
        if (d > r2) {
          dist[i][j] = dist[j][i] = Math.sqrt(d) - (R[i] + R[j]);
        }
      }
    }
    for (int i = 0; i < N; i++) {
      dist[N][i] = dist[i][N] = Math.max(0, Math.sqrt(dist2(SX, SY, X[i], Y[i])) - R[i]);
      dist[N + 1][i] = dist[i][N + 1] = Math.max(0, Math.sqrt(dist2(TX, TY, X[i], Y[i])) - R[i]);
    }
    dist[N][N + 1] = dist[N + 1][N] = Math.sqrt(dist2(SX, SY, TX, TY));

    double[] minDist = new double[N + 2];
    boolean[] visited = new boolean[N + 2];
    Arrays.fill(minDist, 1e300);
    minDist[N] = 0;
    for (int i = 0; i < N + 2; i++) {
      int pos = -1;
      double minD = 1e300;
      for (int j = 0; j < N + 2; j++) {
        if (!visited[j] && minDist[j] < minD) {
          minD = minDist[j];
          pos = j;
        }
      }
      visited[pos] = true;
      for (int j = 0; j < N + 2; j++) {
        minDist[j] = Math.min(minDist[j], minDist[pos] + dist[pos][j]);
      }
    }

    System.out.printf("%.10f\n", minDist[N + 1]);
  }

  static long dist2(long x1, long y1, long x2, long y2) {
    return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
  }

}


Measured memory_bytes: 23316
from functools import reduce

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
factor = [1] + prime_factorize(n)

if len(factor) < 2:
    print('Yes')
else:
    for i in range(1,len(factor)):
        a = reduce(lambda x,y:x*y, factor[:i])
        b = reduce(lambda x,y:x*y, factor[i:])
        if 1 <= a <= 9 and 1 <= b <= 9:
            print('Yes')
            break
    else:
        print('No')

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

int main() {

  int n;
  cin >> n;
  for(int q=0;q<n;q++) {

    
    string a,b,t1,t2;
   
    cin >> t1 >> t2;
    a = b = "1";
    a+= t1;
    b+= t2;
    //m=1000,c=100,x=10,i=1;

    int ra= 0;
    int flg = 0;
    for(int i=1;i<a.size();i++){
      if(a[i] == 'm') flg = 1000;
      else if(a[i] == 'c') flg =100;
      else if(a[i] == 'x') flg = 10;
      else if(a[i] == 'i') flg = 1;
      else continue;
      
      if('2'<=a[i-1] && a[i-1]<='9')ra += flg*(a[i-1]-'0');
      else ra += flg;
    }

    int rb=0;
    for(int i=1;i<b.size();i++){
      if(b[i] == 'm') flg = 1000;
      else if(b[i] == 'c') flg =100;
      else if(b[i] == 'x') flg = 10;
      else if(b[i] == 'i') flg = 1;
      else continue;
      
      if('2'<=b[i-1] && b[i-1]<='9')rb += flg*(b[i-1]-'0');
      else rb += flg;
    }

    //    cout << ra <<" "<<rb<<endl;
    int sum = ra + rb;
    string ans;
    while(sum !=0){
      if(sum >= 1000) flg = 1000;
      else if(sum >= 100) flg = 100;
      else if(sum >= 10) flg = 10;
      else if(sum >= 1) flg =1;
      
      if(sum/flg !=1) ans += sum/flg+'0';

      if(flg == 1000) ans+= 'm';
      else if(flg == 100) ans +='c';
      else if(flg == 10) ans += 'x';
      else if(flg == 1) ans += 'i';
      
      sum %= flg;
    }
    cout << ans <<endl;

  }

  return 0;
}
      
    

Measured memory_bytes: 1204
N = int(input())
B = list(map(int,input().split()))
sum = 0

for i in range(len(B)+1):   
  if i == 0:
    sum += B[0]
  elif i > 0 and i < N-1:
    sum += min(B[i-1],B[i])
  else:
    sum += B[N-2]
print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  string s;
  cin >> s;
  string t;
  for (int i = 0; i < s.size(); i+=2 ) {
    if (i >= s.size()) break;
    t.push_back(s[i]);
  }
  cout << t << endl;
  return 0;
}


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

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

int main() {
    vector<int> A(3);
    int K;
    rep (i, 3)
        cin >> A.at(i);

    cin >> K;
    sort(A.begin(), A.end());

    int maxv = A.at(2) * 2;
    for (int i = 0; i < K - 1; i++) {
        maxv = (maxv * 2);
    }
    cout << ((A.at(0) + A.at(1)) + maxv) << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {
    string s,t;
    cin>>s>>t;
    int l=s.size();
    int count=0;
    for(int i=0;i<l;i++){

        if(s[i]!=t[i]){
            count++;
        }
    }
    cout<<count<<endl;



}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(',');
                double w = double.Parse(temp[1]);
                double h = double.Parse(temp[2]);

                double bmi = w / (h * h);

                if (bmi >= 25.0) sb.AppendLine(temp[0]);
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9292
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	string s;
	cin >> s;
	int n = s.size();
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == 'C'&&s[j] == 'F') {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 3580
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;
class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			if(n == 0 && k == 0) break;
			
			int[][] edge = new int[n][n];
			for(int i = 0; i < n; i++) {
				Arrays.fill(edge[i], 2 << 28);
			}
			
			for(int i = 0; i < k; i++) {
				if(sc.nextInt() == 0) {
					int a = sc.nextInt();
					int b = sc.nextInt();
					
					int[] map = new int[n];
					Arrays.fill(map, 2 << 27);
					
					PriorityQueue<Data> queue = new PriorityQueue<Data>();
					
					queue.add(new Data(0,a-1));
					int ans = -1;
					while(!queue.isEmpty()) {
						Data tmp = queue.poll();
						if(map[tmp.now] != 2 << 27) continue;
						map[tmp.now] = tmp.time;
						if(tmp.now == b-1) {
							ans = tmp.time;
							break;
						}
						for(int j = 0; j < n; j++) {
							if(edge[tmp.now][j] != 2 << 28) queue.add(new Data(tmp.time + edge[tmp.now][j],j));
						}
					}
					
					System.out.println(ans);
				}
				else {
					int c = sc.nextInt();
					int d = sc.nextInt();
					int e = sc.nextInt();
					
					edge[c-1][d-1] = Math.min(edge[c-1][d-1], e);
					edge[d-1][c-1] = Math.min(edge[d-1][c-1], e);
				}
			}
		}
	}
	
	static class Data implements Comparable<Data>{
		int time;
		int now;
		@Override
		public int compareTo(Data o) {
			
			return this.time - o.time;
		}
		
		Data(int a, int b) {
			time = a;
			now = b;
		}
	}


}

Measured memory_bytes: 65452
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=4010,mod=998244353;
char s[N];
int n,ans,a[N],b[N],f[N][N];
void inc(int &x,int y){ x+=y; x-=(x>=mod)?mod:0; }

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	rep(i,1,n) a[i]=a[i-1]+2-(s[i]-'0'),b[i]=b[i-1]+s[i]-'0';
	f[0][0]=1;
	rep(i,0,2*n) rep(j,0,i) if (f[i][j]){
		if (a[min(i+1,n)]>j) inc(f[i+1][j+1],f[i][j]);
		if (b[min(i+1,n)]>i-j) inc(f[i+1][j],f[i][j]);
	}
	printf("%d\n",f[2*n][a[n]]);
	return 0;
}

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

using namespace std;

typedef long long ll;

ll n, a, b;

int main()
{
	cin >> n >> a >> b;
	if((b - a) % 2 == 0)
	{
		cout << (b - a) / 2 << endl;
	}
	else
	{
		ll x = n - a + 1, y = n - b + 1;
		ll ans1 = a + (b - a - 1) / 2, ans2 = y + (x - y - 1) / 2;
		cout << min(ans1, ans2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var pre = -1
    var ans = 0

    for (i in 1..n) {
        val a = sc.nextInt()
        if (a == pre) {
            ans++
            pre = -1
        } else {
            pre = a
        }
    }
    println(ans)
}


Measured memory_bytes: 31272
/* generated by esotope-bfc */
#include <stdio.h>
#include <stdint.h>
#define GETC() (fflush(stdout), fgetc(stdin))
#define PUTC(c) fputc(c, stdout)
#define PUTS(s) fwrite(s, 1, sizeof(s)-1, stdout)
static uint8_t m[30000], *p = m;
int main(void) {
	p[1] = GETC();
	++p[1];
	p[0] = 0;
	p[2] = 0;
	while (p[1]) {
		while (p[0]) {
			--p[0];
			p[1] -= 2;
			p[2] += 9;
			p[1] -= 9*p[2];
			p[2] = 0;
			p += 4;
		}
		while (p[1]) {
			p[2] += 11;
			++p[0];
			p[1] -= 7*p[2];
			p[2] = 0;
			p += 4;
		}
		++p[-1];
		if (p[-3]) {
			--p[-1];
			p[-3] = 0;
		}
		p[-3] = GETC();
		++p[-3];
		p -= 4;
	}
	p[4] += 10;
	while (p[3]) {
		p[5] += 8*p[4]-2;
		p[6] += 11*p[4]+1;
		p[4] = 0;
		PUTC(p[5]);
		PUTC(p[6]);
		p[6] = 0;
		p += 3;
	}
	while (p[4]) {
		p[5] += 9*p[4]-1;
		p[6] += 10*p[4]+1;
		p[4] = 0;
		PUTC(p[5]);
		PUTC(p[6]);
		p[6] += 14;
		PUTC(p[6]);
		p[6] = 0;
		p += 2;
	}
	PUTS("\n");
	return 0;
}


Measured memory_bytes: 128
using System;
class tapdance{
  public static void Main(){
    String str = Console.ReadLine();
    Check chk = new Check();
    if(chk.dancing(str)){
      Console.WriteLine("Yes");
    }
    else{
      Console.WriteLine("No");
    }
  }
}

class Check{
  public bool dancing(String str){
    int count = 1;
    foreach(char c in str){
      if(count%2==0){
        if(c.Equals('R')){
          return false;
        }
      }
      else{
        if(c.Equals('L')){
          return false;
        }
      }
      count++;
    }
    return true;
  }
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  int tmp, counter = 1;
  for (int i = 0; i < 100000; i++) {
    if (i == 0) tmp = a.at(0);
    if (tmp != 2) {
      tmp = a.at(tmp-1);
      counter++;
    } else break;
  }
  
  if (tmp == 2) {
    cout << counter << endl;
  } else cout << -1 << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>

#define EPS (1e-10)

using namespace std;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;



class Point{
public:
  double x,y;
  
  Point(double x = 0, double y = 0): x(x),y(y){};
  
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(a*x,a*y);}

  double own_dot(){return x*x+y*y;};
  double abs(){return sqrt(own_dot());}

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

double dot(Point a, Point b){
  return a.x*b.x+a.y*b.y;
}

double cross(Point a, Point b){
  return a.x*b.y-a.y*b.x; 
}


int ccw(Point p0, Point p1, Point p2){
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS) return CLOCKWISE;
  if(dot(a,b) < -EPS) return ONLINE_BACK;
  if(a.own_dot() < b.own_dot()) return ONLINE_FRONT;
  return ON_SEGMENT;
}

const int MAX = 51;
int n;
vector<Point> V[MAX];

void init(){
  for(int i = 0; i < MAX; i++) V[i].clear();
}

void input(){


  for(int i = 0; i <= n; i++){
    int m;
    cin >> m;

    V[i].resize(m);
    for(int j = 0; j < m; j++) cin >> V[i][j].x >> V[i][j].y;
  }
}

bool isSame(const vector<Point>& P1, vector<Point> P2, const bool option){
  
  if(P1.size() != P2.size()) return false;

  if(option) reverse(P2.begin(),P2.end());

  for(int i = 1; i < P1.size(); i++){
    double diff1 = (P1[i].x-P1[i-1].x)*(P1[i].x-P1[i-1].x) + (P1[i].y-P1[i-1].y)*(P1[i].y-P1[i-1].y);
    double diff2 = (P2[i].x-P2[i-1].x)*(P2[i].x-P2[i-1].x) + (P2[i].y-P2[i-1].y)*(P2[i].y-P2[i-1].y);
    if(diff1 != diff2) return false;
  }
  
  
  for(int i = 2; i < P1.size(); i++){
    int rev1 = ccw(P1[i-2],P1[i-1],P1[i]);
    int rev2 = ccw(P2[i-2],P2[i-1],P2[i]);
    if(rev1 != rev2) return false;
  }
  return true;
}


void solve(){

  for(int i = 1; i <= n; i++){
    
    if(isSame(V[0],V[i],false) || isSame(V[0],V[i],true)) cout << i << endl; 
    
  }

  cout << "+++++" << endl;
}

int main(){
  while(cin >> n && n){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1240
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    ll N,K; cin>>N>>K;
    ll ans=K;
    rep(i,N-1){
        ans*=K-1;
    }
    cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> V(1000001,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
    V[A[i]]++;
  }
  
  int ans=0;
  for(int i=0;i<N;i++){
    bool ok=true;
    if(A[i]!=1 && V[1]!=0) ok=false;
    if(V[A[i]]>=2) ok=false;
    for(int j=2;j*j<=A[i];j++){
      if(A[i]%j==0){
        if(V[j]!=0) ok=false;
        if(V[A[i]/j]!=0) ok=false;
      }
    }
    if(ok) ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7960
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int X;
    cin >> X;
    if (X < 30)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

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;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string s;
	ll k; cin>>s>>k;
    for(auto c:s){
        int l=c-'0';
        if(l>1 or !--k){cout<<l<<endl; break;}
    }
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

bool correspond(string s, string t){
    ll L = s.size();
    FOR(i, 0, L){
        if(s[i]=='?'){
            continue;
        }
        else{
            if(s[i]!=t[i]){
                return false;
            }
        }
    }
    return true;
}

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

    // input
    string s;
    cin >> s;
    ll S = s.size();
    
    string t;
    cin >> t;
    ll T = t.size();

    // 一応
    if(S<T){
        p("UNRESTORABLE");
        return 0;
    }

    for(int i=S-T; i>=0; i--){
        string s0 = s.substr(i, T);
        if(correspond(s0, t)){
            // sを書き換える
            FOR(j, 0, T){
                s[i+j] = t[j];
            }
            goto HERE;
        }
    }
    p("UNRESTORABLE");
    return 0;

HERE:
    for(char c : s){
        if(c=='?'){
            cout << 'a';
        }else{
            cout << c;
        }
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<functional>
#define pb push_back
#define ll long long
#define ld long double
#define f first
#define s second
using namespace std;
const int N = 1005;



int main() {
    ll n; cin >> n;
    ll nn = n;
    int nans = 0, tans = 0;
    for(ll i = 2; i * i <= nn; i++)
    {
        int cnt = 0;
        while(n % i == 0)
        {
            n /= i;
            cnt++;
        }
        nans = 0;
        //cout << i << ' ' << cnt << endl;
        for(int j = 1; j <= 10; j++)
        {
            if(((1 + j) * j) / 2 <= cnt)nans = max(nans, j);
            else break;
        }
        tans += nans;
    }
    if(n != 1)tans++;
    cout << tans << endl;
    return 0;
}


Measured memory_bytes: 3636
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0006
#include <iostream>
#include <string>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string str; cin >> str;
	for (auto it = str.rbegin(); it != str.rend(); it++) {
		cout << *it;
	}
	cout << endl;
}

Measured memory_bytes: 3128
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

const int m = 2019;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    int x = 1, tot = 0;
    vector<int> cnt(m);
    ll ans = 0;
    rep(i, n) {
        cnt[tot]++;
        tot += (s[i]-'0')*x;
        tot %= m;
        ans += cnt[tot];
        x = x*10%m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
import copy
import sys
import numpy as np

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    count = 0
    for i in range(N):
        input_raw = read_func().strip().split()
        [l, r] =[int(input_raw[0]), int(input_raw[1])]
        count += r - l + 1
    print count

if __name__ == '__main__':
    main()


Measured memory_bytes: 12952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    char c;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        c = sc.next().charAt(0);
        solve();
    }

    void solve() {
        if (c == 'a' || c =='e' || c == 'i' || c == 'o' || c == 'u') {
            System.out.println("vowel");
        } else {
            System.out.println("consonant");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define cpd complex<double>
const cpd rot90(0, 1);
const int inf = 1 << 30;
const ll linf = 1e18;
const double EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

struct circle{
    complex<double> c;//中心
    double r;//半径
    circle(complex<double> c, double r) : c(c), r(r) {}
};

vector<complex<double>> culc_intersection(circle c1, circle c2){
    double l = abs(c1.c - c2.c), r1 = c1.r, r2 = c2.r;
    vector<complex<double>> ps;

    if(l > r1 + r2) return ps;
    if(r1 > l + r2) return ps;
    if(r2 > l + r1) return ps;

    double x = ((r1 * r1) - (r2 * r2) + (l * l)) / (2 * l);
    double a = sqrt((r1 * r1) - (x * x));
    complex<double> vec1 = (c2.c - c1.c) * x / l;
    complex<double> vec2 = (c2.c - c1.c) * rot90 * a / l;

    ps.push_back(c1.c + vec1 + vec2);
    if(vec2 != complex<double>(0, 0)) ps.push_back(c1.c + vec1 - vec2);
    return ps;
}

bool culc_eps(db x, db y){
    return abs(x - y) > EPS * (abs(x) + abs(y));
}

struct meat{
    cpd p;
    db c;
    meat(cpd p, db c) : p(p), c(c) {}
};

int N, K;
vector<meat> f; 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        double x, y, c;
        cin >> x >> y >> c;
        f.push_back(meat{cpd(x, y), c});
    }
    double lb = 0, ub = 1e6;
    while(culc_eps(lb, ub)){
        db T = (ub + lb) / 2;
        vector<circle> cs;
        for(int i = 0; i < N; i++){
            cs.push_back(circle{f[i].p, T / f[i].c});
        }

        vector<cpd> ps;
        for(int i = 0; i < N; i++){
            for(int j = i; j < N; j++){
                if(i == j){
                    ps.push_back(f[i].p);
                }else{
                    vector<cpd> qs = culc_intersection(cs[i], cs[j]);
                    for(auto& u : qs) ps.push_back(u);
                }
            }
        }

        bool flag = false;
        for(auto u : ps){
            int cnt = 0;
            for(int i = 0; i < N; i++){
                double l = abs(u - cs[i].c);
                if(l <= cs[i].r *(1 + EPS)) cnt++;
            }
            if(cnt >= K) flag = true;
        }
        if(flag) ub = T;
        else lb = T;
    }
    cout << fixed << setprecision(15);
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
import math
for i in sys.stdin.readlines():
    a,b,p,c,d,q= map(float, i.split())
    print "{:.3f} {:.3f}".format((d*p-b*q)/(a*d-b*c)+0,(-c*p+a*q)/(a*d-b*c)+0)

Measured memory_bytes: 4360
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <fstream>

#define SMAX 1000

using namespace std;

int main()
{
  char X[SMAX], Y[SMAX];
  scanf("%s",X);
  scanf("%s",Y);
  int size_X = strlen(X);
  int size_Y = strlen(Y);

  int LD[SMAX+1][SMAX+1];
  for(int i = 0; i <= size_X; i++) LD[i][0] = i;
  for(int i = 0; i <= size_Y; i++) LD[0][i] = i;

  int l;
  for(int i = 1; i <= size_X; i++) {
    for(int j = 1; j <= size_Y; j++) {
      if(X[i-1] == Y[j-1]) l = 0;
      else l = 1;
      LD[i][j] = min({LD[i-1][j]+1, LD[i][j-1]+1, LD[i-1][j-1]+l});
    }
  }
  cout << LD[size_X][size_Y] << endl;
  
  return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l, r;
  l = a + b;
  r = c + d;
  
  if (l > r) {
    cout << "Left" << endl;
  }
  else if (l == r) {
    cout << "Balanced" << endl;
  }
  else if (l < r) {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int ans = 0;
    for (int i = 0; i < n;) {
        if (h[i] == 0) {
            i++;
            continue;
        }
        if (i == n - 1 && h[i] != 0) {
            ans += h[i];
            h[i] = 0;
            break;
        }

        for (int j = i + 1; j < n; j++) {
            if (h[j] <= 0) {
                int m = *min_element(next(h.begin(), i), next(h.begin(), j));
                for (int k = i; k < j; k++) {
                    h[k] -= m;
                }
                ans += m;
                break;
            } else if (j == n - 1) {
                int m = *min_element(next(h.begin(), i), next(h.begin(), n));
                for (int k = i; k <= n - 1; k++) {
                    h[k] -= m;
                }
                ans += m;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define N 100

using namespace std;

const int infty = 1<<27;

int main()
{
  while(true){
    int n,m;
    cin >> n >> m;
    if( n == 0 && m == 0 )break;
    
    int gcost[N][N];
    int gtime[N][N];
    
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
	gtime[i][j] = gcost[i][j] = infty;
      }
    }
    
    for(int i = 0; i < n; ++i){
      int a,b,cost,time;
      
      cin >> a >> b >> cost >> time;
      --a;--b;
      gcost[a][b] = gcost[b][a] = cost;
      gtime[a][b] = gtime[b][a] = time;
    }
  
    for(int k = 0; k < m; ++k){
      for(int i = 0; i < m; ++i){
	for(int j = 0; j < m; ++j){
	  gcost[i][j] = min( gcost[i][j], gcost[i][k]+gcost[k][j] );
	  gtime[i][j] = min( gtime[i][j], gtime[i][k]+gtime[k][j] );
	}
      }
    }
    
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; ++i){
      int st,ed,r;
      cin >> st >> ed >> r;
      --st;--ed;
      if(st==ed){
	cout << 0 << endl;
	continue;
      }
      if( r == 0 ){
	cout << gcost[st][ed] << endl;
      }else{
	cout << gtime[st][ed] << endl;
      }
    }    
  }

  return 0;
}

Measured memory_bytes: 944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

signed main(void) {
    ll n;
    vector<ll> a;
    cin >> n;
    for (ll i = 0; i < n; i++)
    {
        ll t; cin >> t;
        a.push_back(t); 
    }

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

    ll lsum = 0;
    for (ll i = 0; i < n / 2; i++)
        lsum += a[i];

    ll usum = 0;
    for (ll i = n / 2; i < n; i++) 
        usum += a[i];

    ll lM = a[n / 2 - 1];
    ll um = a[n / 2];
    ll um2= a[n / 2 + 1];
    
    if (n % 2 == 0) {
        ll res = usum * 2 - um;
        res -= lsum * 2 - lM;
        cout << res << endl;
    }
    else {
        ll res = (usum - um) * 2;
        res -= (lsum + um) * 2 - lM - um;
        ll res2 = (usum * 2) - um2 - um;
        res2 -= (lsum * 2);
        cout << max(res, res2) << endl;
    }
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VVI val;
in n;
VI minc[2][2];
const in inf=1e18;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  val.resize(n,VI(3));
  forn(i,n){
    cin>>val[i][1]>>val[i][2];
    val[i][0]=val[i][1]+val[i][2];
  }
  sort(all(val));
  forn(z,2){
    forn(zz,2){
      minc[z][zz].resize(n+3,inf);
    }
  }
  in endlef=(n-1)/2;
  in endrig=(n-1-endlef);
  in nw=0;
  in sw=1;
  minc[nw][0][0]=0;
  in curr;
  forv(i,val){
    swap(nw,sw);
    forn(z,2){
      forn(j,endlef+1)
	minc[nw][z][j]=inf;
    }
    forn(z,2){
      forn(j,endlef+1){
	if(minc[sw][z][j]==inf)
	  continue;
	curr=i-z-j;
	if(curr+1<=endrig)
	  minc[nw][z][j]=min(minc[nw][z][j],minc[sw][z][j]+(endrig-curr-1)*val[i][0]+val[i][1]);
	if(j+1<=endlef)
	  minc[nw][z][j+1]=min(minc[nw][z][j+1],minc[sw][z][j]+(endlef-j-1)*val[i][0]+val[i][2]);
	if(z==0)
	  minc[nw][1][j]=min(minc[nw][1][j],minc[sw][z][j]+endlef*val[i][1]+endrig*val[i][2]);
      }
    }
  }
  cout<<minc[nw][1][endlef]<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b, x;
  cin >> a >> b >> x;
  ll ax = (a == 0) ? 0 : (a - 1) / x + 1, bx = b / x + 1;
  cout << bx - ax << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007



signed main(){
    
    int a, b;
    cin >> a >> b;
    if(a <= 5)b = 0;
    else if(6 <= a && a <= 12)b /= 2;
    cout << b << endl;

    return 0;
}
/*


*/

Measured memory_bytes: 256
X,N = map(int,input().split())
if N>0:
  p=list(map(int,input().split()))
  for d in range(0,101):
    if (X-d) not in p:
      print(X-d)
      break
    elif (X+d) not in p:
      print(X+d)
      break
else:print(X)

Measured memory_bytes: 9188
N = int(input())
ops =[6**i for i in range(7)] + [9 ** i for i in range(1,6)]
ops.sort()
dp = [10*5+5]*(N+1)
dp[0]=0
for i in range(1,N+1):
    for s in range(len(ops)):
        if i-ops[s]>=0:
            dp[i] = min(dp[i-ops[s]]+1,dp[i])
print(dp[N])

Measured memory_bytes: 41920