akhauriyash/Code-Regression huggingface dataset:
def solve():
    N = int(input())
    Ps = list(map(float, input().split()))

    Qs = [1-P for P in Ps]

    dp = [0.0] * (N+2)
    dp[0] = 1.0
    for P, Q in zip(Ps, Qs):
        dp2 = [0.0] * (N+2)
        for j in range(N+1):
            if dp[j] == 0.0: continue
            dp2[j] += dp[j] * Q
            dp2[j+1] += dp[j] * P
        dp = dp2

    print(sum(dp[(N+1)//2:]))


solve()


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#define ll long long
const int MX = 120;
using namespace std;
int main()
{
	int x; cin >> x;
	for (ll i = 1; i <= MX; i++)
	{
		ll ff = pow(abs(i * i * i * i * i - x), 0.2) * ((i * i * i * i * i > x) ? 1 : -1);
		if (i * i * i * i * i - ff * ff * ff * ff * ff == x) {cout << i << " " << ff << "\n"; return 0;}
	}
	return 0;
}

Measured memory_bytes: 4028
import sys

N, Q = map(int, input().split())
S = sys.stdin.readline()
P = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

a = [0] * N
for i in range(N - 1):
    a[i + 1] = a[i] + int(S[i] == 'A' and S[i + 1] == 'C')

for q in P:
    print(a[q[1] - 1] - a[q[0] - 1])

Measured memory_bytes: 32276
#include <stdio.h>
int main(void)
{
    char str[5];

    scanf("%s", str);

    if(str[0]==str[1] && str[1]!=str[2] && str[2]==str[3])
    printf("Yes\n");
    else if(str[0]==str[2] && str[2]!=str[1] && str[1]==str[3])
    printf("Yes\n");
    else if(str[0]==str[3] && str[3]!=str[1] && str[1]==str[2])
    printf("Yes\n");
    else
    printf("No\n");

    return 0;
    
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

/*
//ABC129 D
int main(void) {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> hc(2000,vector<int>(2000, 0));
	vector<vector<int>> wc(2000, vector<int>(2000, 0));
	vector<string> mp;
	rep(0, h) {
		string s;
		cin >> s;
		mp.push_back(s);
	}

	rep(0, h) {
		int count = 0;
		int lastIndex = 0;
		for (int j = 0; j < w; j++) {
			if (mp[i][j] == '.')count++;
			else {
				for (int k = lastIndex; k < j; k++) {
					if(hc[i][k] != -1)
					hc[i][k] = count;
				}
				count = 0;
				hc[i][j] = -1;
				lastIndex = j;
			}
			if (j == w - 1) {
				for (int k = lastIndex; k <= j; k++) {
					if (hc[i][k] != -1)
					hc[i][k] = count;
				}
			}
		}
	}

	rep(0, w) {
		int count = 0;
		int lastIndex = 0;
		for (int j = 0; j < h; j++) {
			if (mp[j][i] == '.')count++;
			else {
				for (int k = lastIndex; k < j; k++) {
					if (wc[i][k] != -1)
					wc[k][i] = count;
				}
				count = 0;
				wc[i][j] = -1;
				lastIndex = j;
			}
			if (j == h - 1) {
				for (int k = lastIndex; k <= j; k++) {
					if (wc[i][k] != -1)
					wc[k][i] = count;
				}
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (hc[i][j] == -1 || wc[i][j] == -1) continue;
			ans = max(ans, (ll)(hc[i][j] + wc[i][j] - 1));
		}
	}
	cout << ans << endl;
}
*/



//ABC129 C
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(void) {
	COMinit();
	int n, m;
	int lastA = -1;
	
	cin >> n >> m;
	int index = 0;
	vector<ll> ans(n, 0);
	rep(0, m) {
		int a;
		cin >> a;
		if (a - lastA == 1) {
			ans[index] = 0;
			break;
		}
		else if (a == lastA) {
			ans[index] = 1;
			index++;
			continue;
		}
		else {
			int now = lastA + 1;
			int diff = a - now-1;
			rep(0, diff / 2 + 1) {
				ans[index] += (COM(diff - i, i) % (1000000007));
				ans[index] %= 1000000007;

			}
			lastA = a;
			index++;
		}
	}
	int a = n+1;
	if (a - lastA == 1) {
		ans[index] = 0;
	}
	else if (a == lastA);
	else {
		int now = lastA + 1;
		int diff = a - now-1;
		rep(0, diff / 2 + 1) {
			ans[index] += (COM(diff - i, i) % (1000000007));
			ans[index] %= 1000000007;

		}
		lastA = a;
	}
	ll as = 1;
	rep(0, m+1) {
		as = (as * ans[i]) % 1000000007;
	}

	cout << as << endl;

	
}

Measured memory_bytes: 12928
import sys
input = sys.stdin.readline

import heapq

def main():  
    N,M=map(int, input().split())
    B=[[] for _ in range(M+1)]
    heapq.heapify(B)
    for i in range(N):
        a,b=map(int, input().split())
        if a > M: continue
        B[a].append(-b)
    max=[]
    heapq.heapify(max)
    ans=0
    for i in range(1, M+1):
        for j in B[i]:
            heapq.heappush(max, j)
        if len(max) != 0:
            ans+=heapq.heappop(max)
    print(-ans)


if __name__ == "__main__":
    main()

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

signed main() {
  int n; cin >>n;
  vector<string> s(n);
  vector<int> p(n);
  rep(i,n) cin >> s[i] >> p[i];

  vector<int> r(n);
  rep(i,n) r[i] = i;

  auto func = [&](int a, int b) -> bool { return s[a] == s[b] ? p[a] > p[b] : s[a] < s[b]; };

  sort(r.begin(), r.end(), func);
  for(auto k : r ) cout << k+1 << endl;

}


Measured memory_bytes: 256
# sqrt(N)以上であるNの約数のうち、最小のものを求めれば良い
N = gets.to_i

i = 1
a = 0
while true do
	if N % i == 0 
		a = i
	end
	break if i * i >= N
	i += 1
end

a = N / a
puts a.to_s.length


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

using namespace std;

int main()
{
    int n, m;

    cin >> n >> m;

    vector <int> penalty(n+1, 0);
    vector <int> solved(n+1, 0);

    int ans = 0;
    long long int total = 0;

    for (int i = 0; i < m; i++)
    {
        int problem;
        string verdict;

        cin >> problem >> verdict;

        if (solved[problem])
            continue;

        if (verdict == "WA")
            penalty[problem]++;

        if (verdict == "AC")
        {
            solved[problem] = 1;
            total += penalty[problem];
            ans++;
        }
    }

    cout << ans << " " << total << "\n";

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        if (Math.abs(N - M) > 1) {
            System.out.println(0);
            return;
        } else if (N == M) {
            System.out.println((((fact(N) * fact(M)) % (1000000000 + 7) * 2)) % (1000000000 + 7));
        } else {
            System.out.println(fact(N) * fact(M) % (1000000000 + 7));
        }
    }

    static long fact(int n) {
        long ans = 1;
        for (int i = 1; i <= n; i++) {
            ans = (ans * (i % (1000000000 + 7))) % (1000000000 + 7);
        }
        return ans;
    }
}


Measured memory_bytes: 23764
AE = []
for i in range(5):
    AE.append(int(input()))

ans = 0
mini = []
for i in AE:
    if(i%10 == 0):
        ans += i
    else:
        ans += (i//10 + 1)*10
        mini.append(i%10)
if(mini != []):
    print(ans + min(mini) - 10)
else:
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 3584
import sys
import numpy as np

N = int(input())
As = list(map(int, input().split()))

f = True
for A in As:
    if A % 2 == 0 and not (A % 3 == 0 or A % 5 == 0):
        f = False
        break

if f:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 21508
N = int(input())
lst_c = []
lst_s = []
lst_f = []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    lst_c.append(c)
    lst_s.append(s)
    lst_f.append(f)

for i in range(N):
    t = 0
    for j in range(i, N - 1):
        if t <= lst_s[j]:
            t = lst_s[j]
        else:
            t = (t + lst_f[j] - 1) // lst_f[j] * lst_f[j]
        t += lst_c[j]
    print(t)

Measured memory_bytes: 3064
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())

    AC = [False] * N
    WA = [0] * N
    for _ in range(M):
        p, s = readline().split()
        p = int(p) - 1

        if AC[p]:
            continue
        if s == 'AC':
            AC[p] = True
        else:
            WA[p] += 1

    ac = sum(AC)
    wa = sum(p for flag, p in zip(AC, WA) if flag)

    print(ac, wa)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 75608
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int x;
    int y;
    bool is_ok=false;
    cin >> x >> y;
    for(int i=0; i<=x; i++){
        if(i*2+(x-i)*4==y){
            is_ok=true;
        }
    }

    if(is_ok==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int A, B, C;
  cin >> A >> B >> C;
  Yes(A <= C && C <= B);
  return 0;
}

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

#import fileinput
import math

def main():
    while True:
        a, b = map(int, input().split())

        if (a == 0 and b == 0):
            break
        else:
            for i in range(a):
                for j in range(b):
                    print('#', end='')
                print('')

            print('')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9232
X,Y = (int(x) for x in input().split())
flag = False
for i in range(X):
    a = X - i
    b = i
    if (a*4)+(b*2) == Y:
        flag = True
    else:
        pass
    a = i
    b = X - i
    if (a*4)+(b*2) == Y:
        flag = True
    else:
        pass
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9184
use proconio::input;

fn main() {
    input! {
        mut n: i64,
    };
    let mut s = vec![];
    while n > 0 {
        n -= 1;
        s.push(((n % 26) as u8 + b'a') as char);
        n /= 26;
    }
    println!("{}", s.iter().rev().collect::<String>());
}


Measured memory_bytes: 2164
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))+[0]
L=[0]*(n+1)
R=[0]*(n+1)
for i in range(n):
  L[i+1]=gcd(L[i],A[i])
  R[n-1-i]=gcd(R[n-i],A[n-i])
m=1
for i in range(n+1):
  m=max(m,gcd(L[i],R[i]))
print(m)
  

Measured memory_bytes: 16208
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

unordered_map< int64_t, int64_t > cnt;

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

	int64_t n;
	cin >> n;

	int64_t ans = 0, sum = 0;
	cnt[0]++;
	for(int64_t i = 1; i <= n; i++) {
		int64_t a;
		cin >> a;

		sum += a;
		ans += cnt[sum];
		cnt[sum]++;
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8520
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }
    let mut ret = 0u64;
    let n = s.len() - 1;
    for mask in 0..1<<n {
        let mut nums = vec![vec![]];
        nums.last_mut().unwrap().push(s[0]);
        for j in 0..n {
            if mask >> j & 1 == 1 {
                nums.push(vec![]);
            }
            nums.last_mut().unwrap().push(s[j+1]);
        }
        // dbg!(&nums);
        for v in nums {
            ret += vec_to_num(&v);
        }
    }
    println!("{}", ret);
}

fn vec_to_num(v: &[char]) -> u64 {
    let s = v.iter().cloned().collect::<String>();
    s.parse::<u64>().unwrap()
}


Measured memory_bytes: 4352
using System;
using System.Linq;

namespace ABC114B
{
    public class NumberString
    {
        string _InputString;
        public NumberString(string InputString)
        {
            _InputString = InputString;
        }
        public int LeastDifference()
        {
            int Result = int.MaxValue;
            
            foreach(var x in Enumerable.Range(0, _InputString.Length - 2))
            {
                var PartialStringVal = Math.Abs(int.Parse(new String(_InputString.Skip(x).Take(3).ToArray()))-753);
                Result = Math.Min(PartialStringVal, Result);
            }
            return Result;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var InputString = Console.ReadLine();
            NumberString numberString = new NumberString(InputString);
            Console.WriteLine(numberString.LeastDifference());

        }
    }
}


Measured memory_bytes: 13268
//自力では解けなかったやつ
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;

    vector<int> red_x,red_y,blue_x,blue_y;
    for(int i=0;i<N;i++){
        int temp1,temp2;
        cin>>temp1>>temp2;
        red_x.push_back(temp1);
        red_y.push_back(temp2);                
    }
    for(int i=0;i<N;i++){
        int temp1,temp2;
        cin>>temp1>>temp2;
        blue_x.push_back(temp1);
        blue_y.push_back(temp2);                
    }

    
    //x
    for(int i=N-1;i>0;i--){
        for(int j=N-1;j>0;j--){
            if(red_x[j-1]>red_x[j]){
                swap(red_x[j-1],red_x[j]);
                swap(red_y[j-1],red_y[j]);
            }
            if(blue_x[j-1]>blue_x[j]){
                swap(blue_x[j-1],blue_x[j]);
                swap(blue_y[j-1],blue_y[j]);
            }
        }
    }
    
    for(int i=0;i<N;i++){
        int red_y_tmp;red_y_tmp=-1;
        int red_idx;red_idx=300;
        for(int j=0;j<red_x.size();j++){
            if(blue_x[i]>red_x[j] && blue_y[i]>red_y[j]){
                if(red_y[j]>red_y_tmp){
                    red_idx=j;
                    red_y_tmp=red_y[j];
                }
            }
            if(j==red_x.size()-1 && red_idx!=300){
                red_x.erase(red_x.begin()+red_idx);
                red_y.erase(red_y.begin()+red_idx);                
                break;
            }
        }
    }
    cout<<N-red_x.size()<<endl;


   

    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    vector<int> ans(200000);
    for(int x=1; x<=101; x++){
        for(int y=1; y<=101; y++){
            for(int z=1; z<=101; z++){
                int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                ans[tmp]++;
            }
        }
    }
    for(int i=1; i<=N; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Cat Snuke and a Voyage
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	sc.Split(bufio.ScanWords)
	var a, b int
	c := make(map[int]int, M)
	d := make(map[int]int, M)

	for i := 0; i < M; i++ {
		a = nextInt()
		b = nextInt()
		if a == 1 {
			c[b]++ // = append(c, b)
		} else if b == N {
			d[a]++ // = append(d, a)
		}
	}
	//fmt.Println(c, d)
	//sort.Sort(sort.IntSlice(c))
	//sort.Sort(sort.IntSlice(d))
	/*
		var flag int = 0
		for _, v1 := range c {
			for _, v2 := range d {
				if v1 == v2 {
					flag = 1
					break
				} else if v1 < v2 {
					break
				}
			}
			if flag == 1 {
				break
			}
		}
	*/
	var flag int = 0
	for i := 0; i < N; i++ {
		if c[i] > 0 && d[i] > 0 {
			flag = 1
			break
		}
	}
	if flag == 1 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 13804
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;

        vector<int> imos(100000, 0);
        for(int i=0; i<n; i++){
            int h1, m1, s1;
            char a1, b1;
            cin>>h1>>a1>>m1>>b1>>s1;

            int h2, m2, s2;
            char a2, b2;
            cin>>h2>>a2>>m2>>b2>>s2;

            int startTime = h1 * 3600 + m1 * 60 + s1;
            int stopTime = h2 * 3600 + m2 * 60 + s2;

            imos[startTime]++;
            imos[stopTime]--;
        }

        int ans=imos[0];
        for(int i=0; i<=90000; i++){
            imos[i+1] += imos[i];
            chmax(ans, imos[i+1]);
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3472
fun main(args: Array<String>) {
    val (N,K) = readLine()!!.split(" ").map(String::toLong)
    val x0 = if (N > K) { N} else {K - N}
    val x = x0 % K
    if(x <= K / 2) {x} else {K - x}.run(::println)
}

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

int digit(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
        
    }
    return sum;
}

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

    int sum = 0;
    int ans = 0;

    for(int i = 1; i <= n; i++){
        int sum = 0;
        sum = digit(i);
        if(sum >= a && sum <= b){
            ans += i;
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
n = int(input())
s = [list(map(int,input().split())) for _ in range(n)]
now = 0
now_t = 0
flag = 1
for i in range(n):
    t,x,y = s[i][0],s[i][1],s[i][2]
    next = x+y
    dist = abs(next - now)
    time = t - now_t
    if dist == 0 and time == 1:
        print('No')
        exit()
    if dist > time:
        print('No')
        exit()
    elif dist == time:
        now_t = t
        now = next
    else:
        if abs(dist - time) % 2 == 0:
            now_t = t
            now = next
        else:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 27144
#include <stdio.h>
void MRoy(){
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i = a-1;i>=1;i--){
        printf("%d ",b-i);
    }
    printf("%d",b);
    for(int i = 1;i<a;i++) printf(" %d",b+i);
    printf("\n");
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main(){
  int N;ll K; cin >> N >> K;
  vector<ll> A(N,0);
  FOR(i,0,N) cin >> A[i];
  sort(A.begin(), A.end());
  ll l, r, m;
  r = (ll)(1e18)+20; l = -r;
  while(r-l>1){
    m = (l+r)/2;
    auto F = [&](){
      ll cnt=0;
      FOR(i,0,N){
        int lll, rrr, mmm;
        ll X = m;
        ll smcnt=0;
        if(A[i]<0){
          lll=i; rrr=N;
          while(rrr-lll>1){
            mmm = (lll+rrr)/2;
            if(A[mmm]*A[i]<=X) rrr = mmm;
            else lll = mmm;
          }
          smcnt = (N-rrr);
        }
        else{
          lll=i; rrr=N;
          while(rrr-lll>1){
            mmm = (lll+rrr)/2;
            if(A[mmm]*A[i]<=X) lll = mmm;
            else rrr = mmm;
          }
          smcnt = (lll-i);
        }
        cnt += smcnt;
      }
      return cnt;
    };
    ll tmp = F();
    if(tmp<K) l = m;
    else r = m;
  }
  cout << r << endl;
}
//1 1 2 2 4 4-> f(0)=0/f(1)=2f(2)=4 f(3)=4 f(4)=6 f(n):n ika no kosu

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

int T[101];

int main(void) {
	int N, M;
	cin >> N;

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

	cin >> M;
	int P, X;
	for (int i = 1; i <= M; i++) {
		cin >> P >> X;
		cout << total - T[P] + X << endl;
	}
		
	return 0;
}


Measured memory_bytes: 256
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{   
    int n;
    scn(n);

    map<int, int> ma;

    ll sum = 0;

    for(int i=0; i<n; i++) {
        int val;
        scn(val);

        sum += 1LL * val;
        ma[val] ++;
    }

    int q;
    scn(q);

    while(q --) {
        int b, c;
        scn(b); scn(c);

        if(ma.count(b)) {
            sum -= (1LL * ma[b] * b);
            sum += (1LL * ma[b] * c);
            ma[c] += ma[b];
            ma.erase(b);
        } 
        lprin(sum);
    }
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 6712
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

int main()
{
	set<int> st1{ 1, 3, 5,  7, 8, 10, 12 }, st2{ 4, 6, 9, 11 }, st3{ 2 };
	int x, y;
	cin >> x >> y;
	auto f = [&](int x, int y) {
		if (st1.count(x) == 1 && st1.count(y) == 1
			|| st2.count(x) == 1 && st2.count(y) == 1
			|| st3.count(x) == 1 && st3.count(y) == 1)
			return true;
		else return false;
	};
	if (f(x, y)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}


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

typedef long long ll;
ll n, s, b;

ll f(ll b, ll n){
	if(n < b) return n;
	return f(b, n / b) + n % b;
}

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

	cin >> n >> s;

	for(b=2; b*b<=n; b++){
		if(f(b, n) == s){
			cout << b << endl;
			return 0;
		}
	}

	for(ll p = b; p>0; p--){
		ll q = s - p;
		b = (n - q) / p;
		if(p >= b || q < 0 || q >= b) continue;
		if(n == p * b + q){
			cout << b << endl;
			return 0;
		}
	}

	if(n==s){
		cout << n+1 << endl;
		return 0;
	}

	cout << -1 << endl;

	return 0;
}


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

int main(){
    int n, now, cnt=0, ans=0;
    vector<int> a_set, cnt_v;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++) scanf("%d",a+i);
    sort(a,a+n);
    now=a[0];
    a_set.push_back(a[0]);
    for(int i=0; i<n; i++){
        if(now==a[i]) cnt++;
        else{
            cnt_v.push_back(cnt);
            a_set.push_back(a[i]);
            cnt=1;
            now=a[i];
        }
    }
    cnt_v.push_back(cnt);

    int c[3];
    int L=(int)a_set.size();
    for(int i=0; i<L;i++){
        c[0]=cnt_v[i];
        c[1]=cnt_v[i];
        c[2]=cnt_v[i];
        if(i>0 && a_set[i-1]==a_set[i]-1){
            c[0]+=cnt_v[i-1];
            c[1]+=cnt_v[i-1];
        }
        if(i<L-1 && a_set[i+1]==a_set[i]+1){
            c[0]+=cnt_v[i+1];
            c[2]+=cnt_v[i+1];
        }
        if(i>1 && a_set[i-2]==a_set[i]-2){
            c[1]+=cnt_v[i-2];
        }
        if(i<L-2 && a_set[i+2]==a_set[i]+2){
            c[2]+=cnt_v[i+2];
        }

        if(ans < *max_element(c, c+3)){
            ans=*max_element(c, c+3);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1404
N, K = map(int, input().split())
S = input()

nums = []
now = 1
seq_count = 0
for char in S:
    if char == str(now):
        seq_count += 1
    else:
        now = 1 - now
        nums.append(seq_count)
        seq_count = 1

nums.append(seq_count)

if len(nums) % 2 == 0:
    nums.append(0)

sums = [0] * (len(nums) + 1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]

ans = 0
for i in range(1, len(sums), 2):
    left = i - 1
    right = min(i + 2 * K, len(sums) - 1)
    ans = max(ans, sums[right] - sums[left])
print(ans)

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

int main(){
	int a, b, i;
	scanf("%d %d", &a, &b);
	char str[100];
	scanf("%s", str);
	if(str[a] == '-'){
		for(i = 0;i < a + b + 1;i++){
			
			if(str[i] < 48 || str[i] > 57){
				if(i == a){
					continue;
				}
				printf("No");
				break;
			}
			}
		}
	else{
		printf("No");
    }
	if(i == a + b + 1){
	if(strlen(str) == a + b + 1){
		printf("Yes");
	}else{
		printf("No");
	}
	}
	
	
	return 0;
}

Measured memory_bytes: 1704
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include <iomanip>
#include <limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
    if (n == 0) { return 1; }
    int x = rui(a, n / 2);
    x *= x; x %= p;
    if (n % 2 == 1) { x *= a; x %= p; }
    return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
    for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
    inv_kai = kai;
    rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
    if (n < 0 || r<0 || r>n) { return 0; }
    int a = kai[n] * inv_kai[r]; a %= p;
    a *= inv_kai[n - r]; a %= p;
    return a;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
#define pd pair<int,double>
#define ved vector<double>
int sz = 131072;
signed main() {
    cin >> p;
    vel a(p);
    rep(i, p) { cin >> a[i]; }
    vel b(p,0);
    for(int i=1;i<p;i++) {
        int x = inv(i);
        int rui1 = x;
        for(int j=1;j<p;j++) {
            b[j] += (p-1)*a[i] * rui1;
            b[j] %= p;//x^(j+1)
            rui1 *= x; rui1 %= p;
        }
    }
    b[0] += a[0];
    b[p - 1] += a[0] * (p - 1);
    rep(i, p - 1) { cout << b[i]%p<<" "; }
    cout << b[p-1]%p << endl;
    return 0;
}


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

int saisyo(int a, int b) { // a > b
    int x = a * b;
    int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return x / b;
}


int main(void)
{
  int x;
  int k;
  cin >> x;

  int dig = saisyo(360, x) ;
  
//  cout << "dig" << dig << '\n';
  
  k = dig / x;
  
//  cout << "ans" << k;
  cout << k; 
  return 0;
 
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
#include <bits/stdc++.h>
using namespace std;
double pi=3.14159265358979323846264338;
#include <bits/stdc++.h>

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};

template<typename T> T& updMin(T& a, T const& b) { if (b < a) a = b; return a; }
template<typename T> T& updMax(T& a, T const& b) { if (a < b) a = b; return a; }

// ========================================================================= //
//999977 17 499998
const int ind=6000000;
double h,c,t;
double tem(double cur){
	if((2*cur+3)*labs(t*(2*cur+1)-(cur*(h+c)+h))>(2*cur+1)*fabs(t*(2*cur+3)-((cur+1)*(h+c)+h))){
		return (2*cur+3);
	
	}else {
		if((2*cur-1)*labs(t*(2*cur+1)-(cur*(h+c)+h))<(2*cur+1)*fabs(t*(2*cur-1)-((cur-1)*(h+c)+h))){
			return(2*cur+1);
			//cout<<fabs(t-(cur*(h+c)+h)/(2*cur+1))<<" "<<fabs(t-((cur-1)*(h+c)+h)/(2*cur-1))<<endl;
		}else {
			//cout<<fabs(t-(cur*(h+c)+h)/(2*cur+1))<<" "<<fabs(t-((cur-1)*(h+c)+h)/(2*cur-1))<<endl;
			return (2*cur-1);
			
		}
	}
}
long long culc(){
	long long fr=0;
	long long ls=ind;
	long long mid;
	while(ls>=fr){
		mid=(fr+ls)/2;
		if ((mid*(h+c)+h)/(2*mid+1)<t)ls=mid-1; else if((mid*(h+c)+h)/(2*mid+1)>t)fr=mid+1; else return mid;
	}
	return mid;
}



int main() {
	
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int cur=60*(h2-h1)+m2-m1;
	if(cur<=k){
		cout<<"0"<<endl;
		return 0;
	}
	cout<<cur-k<<endl;
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public Data[] D;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }

            D = new Data[M];

            for (int i = 0; i < M; i++)
            {
                var line = Input.ReadIntArray();
                var x = line[0] - 1;
                var y = line[1] - 1;
                var d = new Data { X = x, Y = y };
                D[i] = d;
            }

            Array.Sort(D, Data.CompareTo);

            {
                int R = -1;
                int i = 0;
                int ret = 0;
                while (i < M)
                {
                    if (D[i].X >= R)
                    {
                        ret++;
                        R = D[i].Y;
                    }
                    i++;
                }

            Console.WriteLine(ret);
            }

        }

    }

    // libs ----------
    class Data
    {
        public int X;
        public int Y;

        public static int CompareTo(Data d1, Data d2)
        {
            int result = d1.Y.CompareTo(d2.Y);
            if (result == 0)
                result = d1.X.CompareTo(d2.X);
            return result;
        }

    }

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 22328
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	 public static void main(String args[]){
	Scanner scanner = new Scanner(System.in);

	int n=scanner.nextInt();
	int i=scanner.nextInt();
	Integer[] m=new Integer[n];
	int t=0;


	for(int j=0;j<n;j++) {
		int a=scanner.nextInt();
		m[j]=a;
	}

	for(int j=0;j<n;j++) {
		t=t+m[j];
	}

	Arrays.sort(m,Collections.reverseOrder());
	
	int g=4*i;
	if(m[i-1]*g<t) {
	System.out.println("No");
	}
	else {
		System.out.println("Yes");
	}


	 }
}

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

bool is_once(int n,string S){
  char x = 'a' + n;
  int count=0;
  for(int i=0;i<S.size();i++){
    if(x==S[i]){
      count ++;
    }
  }
  return (count<2);
}

int main(){
  string S;
  cin >> S;
  for(int i=0;i<26;i++){
    if(!is_once(i,S)){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashSet;

type Question = (u64, u64, u64, u64);

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn input_tuple_4() -> (u64, u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2], vec[3])
}

fn dfs(idx: usize, a_vec: &Vec<u64>, n: u64, m: u64, questions: &Vec<Question>) -> u64 {
    if idx == n as usize {
        let mut sum = 0;
        for q in questions {
            if a_vec[q.1 as usize] - a_vec[q.0 as usize] == q.2 {
                sum += q.3
            }
        }
        return sum;
    }
    let num: u64;
    if idx == 0 {
        num = 1;
    } else {
        num = a_vec[idx - 1];
    }
    let mut ans: u64;
    let mut max = 0;
    for i in num..(m+1) {
        let mut new_vec = a_vec.to_vec();
        new_vec.push(i);
        ans = dfs(idx+1, &new_vec, n, m, questions);
        if ans > max {
            max = ans;
        }
    }
    return max;
}



fn main() {
    let (n, m, q) = input_tuple();
    let mut questions: Vec<Question> = Vec::new();
    for _ in 0..q {
        let (a, b, c, d) = input_tuple_4();
        questions.push((a-1, b-1, c, d));
    }
    println!("{}", dfs(0, &Vec::new(), n, m, &questions));

}


Measured memory_bytes: 2148
from heapq import*
def dijkstra(s,e):
  g=10**6;d=[10**18]*n;f=[1]*n;d[s]=f[s]=0;q=[]
  for a,b in e[s]:heappush(q,a*g+b)
  while q:
    m=heappop(q)
    if f[m%g]<1:continue
    v=m%g
    x=d[v]=m//g
    f[v]=0
    for y,w in e[v]:
      if f[w]:heappush(q,(x+y)*g+w)
  return d
(n,m,s,t),*z=[map(int,t.split())for t in open(0)]
e,f=eval('[[]for _ in"_"*n],'*2)
for u,v,a,b in z:
  u-=1
  v-=1
  e[u]+=(a,v),
  e[v]+=(a,u),
  f[u]+=(b,v),
  f[v]+=(b,u),
a=[]
m=0
for y,s in zip(dijkstra(s-1,e)[::-1],dijkstra(t-1,f)[::-1]):
  m=max(m,10**15-y-s)
  a+=m,
print(*a[::-1])


Measured memory_bytes: 131976
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int i,j,n,m;
     int tc;
     
     	int odd=0,even=0;
     	
        cin>>n;
         while(n)
         {
         	int k=n%10;
         	n/=10;
         	
         	if(k==7)
			 {
			 	
			    cout<<"Yes"<<endl;
			    return 0;
			 }
		
		 }
		cout<<"No"<<endl;
  	
	  
	
	
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pr;
typedef long long LL;

const int N = 200010;

LL a[N];
LL cnt2[N], cnt5[N];
LL sum[50][30];
int n;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		double x;
		scanf("%lf", &x);
		x *= 1e9;
		a[i] = x + 0.5;
	}
	
	for (int i = 1; i <= n; i++)
	{
		LL x = a[i];
		while (x % 2 == 0)
		{
			cnt2[i]++;
			x /= 2;
		}
		while (x % 5 == 0)
		{
			cnt5[i]++;
			x /= 5;
		}
	}
	
	for (int i = 1; i <= n; i++)
		sum[cnt2[i]][cnt5[i]]++;
	for (int i = 44; i >= 0; i--)
		for (int j = 18; j >= 0; j--)
			sum[i][j] += sum[i][j+1];
	for (int i = 43; i >= 0; i--)
		for (int j = 19; j >= 0; j--)
			sum[i][j] += sum[i+1][j];
	
	LL Ans = 0;
	for (int i = 0; i <= 44; i++)
		for (int j = 0; j <= 19; j++)
		{
			LL a = sum[i][j] - sum[i+1][j] - sum[i][j+1] + sum[i+1][j+1];
			LL b = sum[max(18 - i, 0)][max(18 - j, 0)];
			if (a && b)
			{
				if (18 - i <= i && 18 - j <= j) b -= a;
				Ans += a * b;
			}
		}
	Ans /= 2LL;
	for (int i = 0; i <= 44; i++)
		for (int j = 0; j <= 19; j++)
			if (18 - i <= i && 18 - j <= j)
			{
				LL v = sum[i][j] - sum[i+1][j] - sum[i][j+1] + sum[i+1][j+1];
				if (!v) continue;
				Ans += v * (v - 1) / 2LL;
			}
	cout << Ans << endl;
	
	return 0;
}

Measured memory_bytes: 8372
if __name__ == '__main__':
    N, A, B, C, D = list(map(int, input().split()))
    if C + D == 0:
        if A == B:
            print("YES")
        else:
            print("NO")
    else:
        average_c_d = (C + D) / 2

        range_c_d = (D - C) / 2

        ul = A - average_c_d * (N - 1)

        target_index = round((B - ul) / (C + D))

        if target_index < 0:
            target_index = 0
        elif N - 1 < target_index:
            target_index = N - 1

        under = ul + (C + D) * target_index - range_c_d * (N - 1)
        upper = ul + (C + D) * target_index + range_c_d * (N - 1)

        if under <= B <= upper:
            print("YES")
        else:
            print("NO")


Measured memory_bytes: 3064
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 505;
const int cx[] = {1, 0, -1, 0};
const int cy[] = {0, 1, 0, -1};

int n;
int arr[N*N];

int dist[N][N];
int cost[N][N];
queue<pii>q;

void bfs(){
	while(!q.empty()){
		int x = q.front().F;
		int y = q.front().S;
		q.pop();

		FOR(k,4){
			int tx = x + cx[k];
			int ty = y + cy[k];
			if(dist[tx][ty] > dist[x][y] + cost[tx][ty]){
				dist[tx][ty] = dist[x][y] + cost[tx][ty];
				q.push({tx, ty});
			}
		}
	}
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>n;
    REP(i,1,n*n)cin>>arr[i];

    REP(i,1,n){
    	REP(j,1,n){
    		dist[i][j] = min(i, j);
    		dist[i][j] = min(dist[i][j], 1+min(n-i, n-j));
    		cost[i][j] = 1;
    	}
    }

    int ans = 0;
    REP(i,1,n*n){
    	int x = (arr[i]-1)/n+1;
    	int y = arr[i]-n*(x-1);
    	// printf("%d %d -> %d\n",x,y,dist[x][y]);

    	ans += dist[x][y];
    	cost[x][y] = 0;

    	// invalidate y
    	dist[x][y]--;
    	q.push({x, y});
    	bfs();
    }
    ans -= n*n;

    cout << ans << endl;

    return 0;
}


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

int main(){

	double p,r,q,s;

	cin>>r;

	p=3.141592653589;

	q=p*r*r;

	s=2*p*r;
	
	printf("%lf %lf\n",q,s);

	return 0;

}

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

string s;
char a, b, c, d;

int main () {
	cin >> s;
	a = s[2];
	b = s[3];
	c = s[4];
	d = s[5];
	if (a==b && c==d){
		cout << "Yes";
	} else {
		cout << "No";
	}
}

Measured memory_bytes: 3600
h,w=map(int,input().split())
a=[input() for _ in range(h)]

count=0

for i in range(h):
  k=a[i]
  for j in range(w):
    if k[j]=="#":
      count+=1

if count==(h-1)+(w-1)+1:
  print("Possible")
else:
  print("Impossible")

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

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

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

typedef long long  ll;

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

int main() {
    int n,y;
    cin>>n>>y;
    int a=-1,b=-1,c=-1;
    //1000円をi,5000円をj,10000円をkとする
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int k=n-i-j;
            
                if(i+j+k==n &&i>=0 && j>=0 && k>=0){
                    if(y==10000*i+5000*j+1000*k){
                        a=i;
                        b=j;
                        c=k;
                        cout<<a<<' '<<b<<' '<<c<<endl;
                        return 0;

                    }
                }

            }
        }
    
    cout<<a<<' '<<b<<' '<<c<<endl;

    return 0;
}

Measured memory_bytes: 256
# Aizu Problem ITP_1_8_C: Counting Characters
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


letters = [chr(k) for k in range(97, 123)]
count = {char: 0 for char in letters}
for line in sys.stdin:
    for char in line.lower():
        if char in letters:
            count[char] += 1

for char in letters:
    print(char, ':', count[char])

Measured memory_bytes: 7528