akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,ans=INF;
  cin >> N;
  for(ll i=1;i*i<=N;i++){
    if(N%i==0){
      ans=min(ans,i+N/i-2);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
  string s;
  cin >> s;
  ll l = s.length();
  bool even = l % 2 == 0;
  bool side = s[0] == s[l - 1];

  if (even ^ side) {
    cout << "Second\n";
    return 0;
  }

  cout << "First\n";

  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 512
S = input()
T = input()
S_len = len(S)

s = S
for i in range(S_len):
    s_list = list(s)
    s_end = s_list.pop()
    b = s_end + ''.join(s_list)
    if b == T:
        print('Yes')
        exit(0)
    s = b
print('No')



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


o = list(input()[:-1])
e = list(input()[:-1])

ans = []
for i in range(len(e)):
    ans.append(o[i])
    ans.append(e[i])

if len(o) > len(e):
    ans.append(o[-1])

print(''.join(ans))


Measured memory_bytes: 3064
N=int(input())
a=list(map(int,input().split()))
na=sorted(a)
Alice=0
Bob=0
Alice_turn=0
for i in range(N):
  if Alice_turn%2==0:
    Alice+=na[N-1-i]
    Alice_turn+=1
  else:
    Bob+=na[N-1-i]
    Alice_turn+=1
print(Alice-Bob)

Measured memory_bytes: 3064
#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);
  vector<char> B;
  for (int i = 0; i < N - 1; i++) {
    if (A.at(i) < A.at(i + 1)) B.push_back('U');
    else if (A.at(i) > A.at(i + 1)) B.push_back('D');
  }
  int ans = 1, M = B.size();
  for (int i = 1; i < M; i++) {
    if (B.at(i) != B.at(i - 1)) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> s(n);
    int ans=0;
    REP(i,n){
        cin>>s[i];
        ans += s[i];
    }
    if(ans%10!=0){
        cout<<ans<<endl;
        return 0;
    }
    VSORT(s);
    int i=0;
    REP(i,n){
        if(s[i]%10==0) continue;
        else{
            ans-=s[i];
            break;
        }
    }
    if(ans%10==0) cout<<0<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let s = read::<String>().chars().map(|c| c as i32 - 97).collect::<Vec<i32>>();
    let t = read::<String>().chars().map(|c| c as i32 - 97).collect::<Vec<i32>>();
    let len = s.len();

    let mut sv = vec![Vec::<i32>::new(); 26];
    let mut tv = vec![Vec::<i32>::new(); 26];
    for i in 0..len {
        sv[s[i] as usize].push(i as i32);
        tv[t[i] as usize].push(i as i32);
    }
    sv.sort();
    tv.sort();
    let mut f = true;
    for i in 0..26 {
        if sv[i] != tv[i] {
            f = false;
            break;
        }
    }
    yn(f);
}


Measured memory_bytes: 10492
a, b = list(map(int, input().split()))

if a == 0 or b == 0 or (a < 0 and b > 0):
    print("Zero")
    exit()

if a == b:
    if a > 0:
        print("Positive")
    else:
        print("Negative")
    exit()

if a > 0:
    print("Positive")
else:
    if (abs(a - b) + 1) % 2 == 0:
        print("Positive")
    else:
        print("Negative")


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int t[4],n[4],yen[4];
	int i,kingaku[5]={0,6000,4000,3000,2000};

	for(i=0;i<4;i++){
		scanf("%d %d",&t[i],&n[i]);
	}

	for(i=0;i<4;i++){
		switch(t[i]){
			case 1:
			printf("%d\n",kingaku[1]*n[i]);
			break;
			
			case 2:
			printf("%d\n",kingaku[2]*n[i]);
			break;

			case 3:
			printf("%d\n",kingaku[3]*n[i]);
			break;

			case 4:
			printf("%d\n",kingaku[4]*n[i]);
			break;

		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
using namespace std; 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    int L = S.size();
    int co = 0;
    for (int i = 0; i < (L/2); ++i){
        if (S[i] != S[L-1-i]){ 
            co++;
        }
    }
    cout << co << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i ,c) for(int i = 0; i < (int)c; i++)
const int inf = 1000000000; //10^9

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    int L = X[0]; 
    int R = X[0];
    rep(i, N) {
        L = min(L, X[i]);
        R = max(R, X[i]);
    }
    int ans = inf;
    for (int i = L; i <= R;i++){
        int cost = 0;
        rep(j, N) cost += (X[j] - i) * (X[j] - i);
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#b
import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)

n = int(input())
edges = [[] for _ in range(n)]
for i in range(n-1):
    b = int(input())
    edges[b-1].append(i+1)
    
def dfs(u):
    e = edges[u]
    if e==[]:
        return 0
    #else
    #return maximum
    length = []
    for v in e:
        length.append(dfs(v))
    l = len(length)
    length.sort()
    maxi = 0
    for v in length:
        cal = v + l
        maxi= max(maxi, cal)
        l -= 1
    return maxi    
    
print(dfs(0))

Measured memory_bytes: 118936
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <functional>
#include <string>
#include <stack>
#include <map>

using namespace std;
using ll = long long;
ll mod = 1e9 + 7;


int main()
{
	int n;
	cin >> n;
	
	int b = 0;
	int r = 0;

	for (int i = 0; i < n; i++)
	{
		char c;
		cin >> c;
		if (c == 'R')
			r++;
		else
			b++;
	}
	if (r > b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
// typedef tree<int, null_type, less<int>, rb_tree_tag,  
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k;
        cin>>k;
        cout<<a[k-1];
    }
    return 0;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	int a, b;
	cin >> a >> b;
	if(a <= 9 && b <= 9){
		cout << a * b << endl;
	}
	else cout << -1 << endl;


}


Measured memory_bytes: 256
##C
N = int(input())
S = list(input() for i in range(N))

import collections

c = collections.Counter(S).most_common()
a,b = c[0]
ans = list()
for j,k in c:
    if k == b:
        ans.append(j)
    else:
        break
        
ans.sort()
for l in ans:
    print(l)

Measured memory_bytes: 45080
#include <iostream>
#include <bitset>
#define ll long long
using namespace std;
const int MDSZ = 1;
const int MD[4] = {503, 1069696919, 701, 1018199999};
int n, k, ar[5001] = {}, rs = 0, a = 0, b = 0;
int dp[5001][MDSZ] = {};
void outDP(string s)
{
	cout << s << " : \n";
	for (int i = 0; i < k; i++)
	{
		cout << i << " " << dp[i][0] << "\n";
	}
}
int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k; rs = n;
	for (int i = 0; i < n; i++) 
	{
		cin >> ar[i];
		if (ar[i] >= k) {a++;}
	}
	rs -= a;
	for (int i = 0; i < MDSZ; i++) {dp[0][i] = 1;}
	for (int i = 1; i <= n; i++)
	{
		for (int j = k - 1; j >= ar[i - 1]; j--) 
		{
			for (int kk = 0; kk < MDSZ; kk++)
			{
				dp[j][kk] += dp[j - ar[i - 1]][kk];
				dp[j][kk] %= MD[kk];
			}
		}
	}
	//outDP("ALL");
	for (int i = 1; i <= n; i++)
	{
		if (ar[i - 1] < k)
		{
			for (int j = ar[i - 1]; j < k; j++)
			{
				for (int kk = 0; kk < MDSZ; kk++)
				{
					dp[j][kk] -= dp[j - ar[i - 1]][kk];
					dp[j][kk] %= MD[kk];
					dp[j][kk] = (dp[j][kk] + MD[kk]) % MD[kk];
				}
			}
			//outDP("REM" + to_string(i));
			for (int j = k - ar[i - 1]; j < k; j++)
			{
				bool ck = 1;
				for (int kk = 0; kk < MDSZ; kk++) {ck &= (dp[j][kk] > 0);}
				if (ck) {rs--; break;}
			}
			for (int j = k - 1; j >= ar[i - 1]; j--) 
			{
				for (int kk = 0; kk < MDSZ; kk++)
				{
					dp[j][kk] += dp[j - ar[i - 1]][kk];
					dp[j][kk] %= MD[kk];
				}
			}
			//outDP("FIX" + to_string(i));
		}
	}
	cout << rs << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,y,a,b,c,i,j,k;
  scanf("%d %d",&n,&y);
  a=-1;
  b=-1;
  c=-1;
  for(i=0;i<=n;i++){
    for(j=0;j<=n-i;j++){
      k=n-i-j;
      if(10000*i+5000*j+1000*k==y){
        a=i;
        b=j;
        c=k;
        goto end;
      }
    }
  }
  end:
  printf("%d %d %d\n",a,b,c);
}

Measured memory_bytes: 128
N, M = map(int, input().split())
left = []
right = []
for i in range(M):
  a, b = map(int, input().split())
  if a == 1:
    left.append(b)
  elif b == N:
    right.append(a)
    
flag = False
left = set(left)
for r in right:
  if r in left:
    flag = True
    break
    
if flag:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')


Measured memory_bytes: 22796
package main

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

func main() {
	var N int
	fmt.Scan(&N)
	var K int
	fmt.Scan(&K)

	p := readLineInts()

	sort.Ints(p)

	var ans int

	for i := 0; i < K; i++ {
		ans += p[i]
	}

	fmt.Println(ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func readLineStrs() []string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	str := string(buf)
	return strings.Split(str, " ")
}

func readLineInts() []int {
	list := readLineStrs()
	res := make([]int, len(list))
	for i, v := range list {
		pi, _ := strconv.ParseInt(v, 10, 64)
		res[i] = int(pi)
	}
	return res
}


Measured memory_bytes: 2308
#include <stdio.h>
#define MAX_PIC 4
#define MAX_RANK 13

int main(void){
	int i, j, card_num, card[MAX_PIC][MAX_RANK], card_answer[MAX_PIC][MAX_RANK];
	char picture;
	int picture_num, rank;
	
	scanf("%d", &card_num);
	
	// ?????????????????????????????????0????????????????????????
	for(i = 0; i < MAX_PIC; i++){
		for(j = 0; j < MAX_RANK; j++){
			card[i][j] = 0;
		}
	}
	
	// ??\?????????????????????????????????????????????1????????£??\??????
	for(i = 0; i < card_num; i++){
		scanf(" %c", &picture);
		scanf("%d", &rank);
		switch(picture){
		case 'S': picture_num = 0; break;
		case 'H': picture_num = 1; break;
		case 'C': picture_num = 2; break;
		case 'D': picture_num = 3; break;
		}
		card[picture_num][rank-1] = 1;
	}
	
	// ???????????¨??¨??????????´¢??????0?????¨???????????¨?????????
	for(i = 0; i < MAX_PIC; i++){
		for(j = 0; j < MAX_RANK; j++){
			if(card[i][j] == 0){
				switch(i){
				case 0: picture = 'S'; break;
				case 1: picture = 'H'; break;
				case 2: picture = 'C'; break;
				case 3: picture = 'D'; break;
				}
				printf("%c %d\n", picture, j + 1);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
def search_sorted(x, xs):
    '''
    >>> search_sorted(3, range(10))
    3
    >>> search_sorted(3, [0, 1, 3, 3, 3, 5])
    4
    >>> search_sorted(3, [0, 1, 3, 3])
    3
    >>> search_sorted(1, [1, 1])
    1
    '''
    i = 0
    j = len(xs)
    while j - i > 1:
        m = (i + j) // 2
        if xs[m] <= x:
            i = m
        elif x < xs[m]:
            j = m
    return i

class FenwickTree:
    '''
    >>> tree = FenwickTree(5)
    >>> tree.add(0, 3)
    >>> tree.add(4, 2)
    >>> tree.add(2, 7)
    >>> tree.sum(5)
    12
    >>> tree.sum(3)
    10
    >>> tree.sum(2)
    3
    >>> tree.sum(1)
    3
    >>> tree.sum(0)
    0

    '''
    def __init__(self, n):
        self.array = [0] * n

    def add(self, i, x):
        while i < len(self.array):
            self.array[i] += x
            w = (i + 1) & -(i + 1)
            i += w

    def sum(self, i):
        i -= 1
        s = 0
        while i >= 0:
            s += self.array[i]
            w = (i + 1) & -(i + 1)
            i -= w
        return s


def solve():
    input()
    A = list(map(int, input().split())); A.sort()
    tree = FenwickTree(len(A))
    for i, a in enumerate(A):
        tree.add(i, a)

    answer = 0
    for i in range(len(A)):
        a = A[i]
        j = i
        while True:
            j = search_sorted(a * 2, A)
            a_ = tree.sum(j + 1)
            if a == a_:
                break
            else:
                a = a_
        if j + 1 == len(A):
            answer += 1
    print(answer)

solve()


Measured memory_bytes: 63856
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		Scanner sc = new Scanner(System.in);
		main.solve(sc);
		sc.close();
	}

	void solve(Scanner sc) {
		int i = sc.nextInt();

		if (i < 1200) {
			System.out.println("ABC");
		} else if (i < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  LL n,m;
  LL p = 1000000007ll;
  cin >> n >> m;
  vector<LL> x(n),y(m);
  for(LL &xi:x) cin >> xi;
  for(LL &yi:y) cin >> yi;
  LL w=0ll,h=0ll;
  REP(i,n-1) {
    w=(w+(x[i+1]-x[i])*(i+1)*(n-i-1))%p;
  }
  REP(i,m-1) {
    h=(h+(y[i+1]-y[i])*(i+1)*(m-i-1))%p;
  }
  cout << w*h%p << endl;
}


Measured memory_bytes: 1792
# AOJ 0167 Bubble Sort
# Python3 2018.6.20 bal4u

while True:
	n = int(input())
	if n == 0: break
	a = [0]*105
	for i in range(n): a[i] = int(input())
	cnt = 0
	for i in range(n-1, 0, -1):
		for j in range(i):
			if a[j] > a[j+1]:
				cnt += 1
				a[j], a[j+1] = a[j+1], a[j]
	print(cnt)



Measured memory_bytes: 5604
class Solution:
    def solve(self, N: int, M: int) -> str:
        if N == M:
            return 'Yes'
        else:
            return 'No'


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(N, M))


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int n;
    cin >> n;
    unordered_map<int, int> f;
    rep(i, 0, n) {
        int x;
        cin >> x;
        ++f[x];
    }
    vector<int> cnt(10, 0);
    for (auto &it : f) {
        if (it.second % 2 == 1) it.second = 1;
        else it.second = 2;
        ++cnt[it.second];
    }
    int ans = cnt[1];
    if (cnt[2] % 2 == 0) ans += cnt[2];
    else ans += cnt[2] - 1;
    cout << ans << '\n';
}

Measured memory_bytes: 4388
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int H = stdIn.nextInt();
        int A = stdIn.nextInt();
        stdIn.close();

        int count = 0;
        if (H > A) {
            if (H % A == 0) {
                count = H / A;
            } else {
                count = H / A + 1;
            }
        } else {
            count = 1;
        }
        
        System.out.println(count);
    }
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	
	int start = h1 * 60 + m1 ;
	int fini = h2 * 60 + m2;
	int count = 0;
	for(int i = start; i < fini; i++){
		if(i + k < fini){
			count ++;
		} else {
			break;
		}
	}
	cout << count << endl;
}


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

int main() {
	int a[3], b[2], daikin;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 2; i++) {
		cin >> b[i];
	}
	daikin=a[0]+b[0];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 2; j++) {
			if (a[i] + b[j] < daikin) {
				daikin = a[i] + b[j];
			}
		}
	}
	cout << daikin-50 << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, d;
    cin >> n >> d;
    double t[25][25];
    for( int i = 0; i < n; ++i ) {
        for( int j = 0; j < d; ++j ) {
            cin >> t[i][j];

        }
    }
    int res = 0;
    for( int i = 0; i < n; ++i ) {
        for( int j = i + 1; j < n; ++j ) {
            int tmp = 0;
            for( int k = 0; k < d; ++k ) {
                tmp += abs( t[i][k] - t[j][k] ) * abs( t[i][k] - t[j][k] );

            }
            double tm = sqrt( (double)tmp );
            int e = tm;
            if( tm == (double)e ) ++res;

        }
    }
    cout << res << endl;
    return 0;
}



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

signed main(){
    int s;
    cin>>s;
    map<int,int>memo;
    for(int i=1;i<=100000;i++){
        if(i!=1){
            if(s%2==0){
                s=s/2;
            }
            else{
                s=3*s+1;
            }
        }
        memo[s]++;
        if(memo[s]!=1){
            cout<<i<<endl;
            break;
        }
    }
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int INF = 1e9+5;

int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    	cout.precision(10);
    	cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif
        
	int n,W;
	cin>>n>>W;

	vi v(n),w(n);
	forn(i,n) cin>>w[i]>>v[i];

	int sum = accumulate(all(v),0);

	vi dp(sum+1,INF);
	dp[0]=0;
	forn(i,n){
	 	for(int j=sum-v[i];j>=0;--j){
	 	 	uin(dp[j+v[i]],dp[j]+w[i]);
	 	}
	}
	int ans=0;                 
	forn(i,sum+1){
	 	if(dp[i]<=W){
	 	 	uax(ans,i);
	 	}
	}
	cout<<ans<<endl;
        #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

	return 0;
}	



Measured memory_bytes: 640
import java.util.Scanner;

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

        long H = sc.nextLong();
        int N = sc.nextInt();
        long A = 0;

        for (int i = 0; i < N; i++)
            A += sc.nextLong();

        System.out.println(A >= H ? "Yes" : "No");
    }
}


Measured memory_bytes: 48640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

vector<vector<pair<int, int>>> edge(100010, vector<pair<int, int>>(0));
long long dp[100010];
int k;

long long dfs(int par, int ver) {
  if (dp[ver] != LINF) return dp[ver];
  for (auto aut : edge[ver]) if (aut.first != par) {
    dp[ver] = min(dp[ver], dfs(ver, aut.first) + aut.second);
  }
  return dp[ver];
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  REP(i, 100010) dp[i] = LINF;
  int n; cin >> n;
  REP(i, n-1) {
    int a, b, c; cin >> a >> b >> c; --a; --b;
    edge[a].push_back(make_pair(b, c));
    edge[b].push_back(make_pair(a, c));
  }
  int q; cin >> q >> k; --k;
  dp[k] = 0;
  REP(i, q) {
    int x, y; cin >> x >> y; --x; --y;
    cout << dfs(-1, x) + dfs(-1, y) << '\n';
  }
  return 0;
}


Measured memory_bytes: 14336
using System;
using System.Linq;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str1=Console.ReadLine().Split(' ');
    int x=int.Parse(str1[0]);
    
    int count = 360 / x;
    
    int Num = 1;
    while((360*Num % x) != 0){
        Num = Num + 1;
        count = 360*Num/x;
    }

    Console.WriteLine(count);
    
   }
   
  }
 
}

Measured memory_bytes: 27392
#include<iostream>
using namespace std;
struct dise{
  int num[100];
  double x[100];
};
int main(){
  int t;
  double top = 0;
  cin >>t;
  while(t--){
    int n,m;
    double sum = 0,all = 0;
    dise d;
    cin >>n>>m;
    for(int i=0; i<m; i++){
      int x;
      double y;
      cin >>x>>y;
      d.num[i] = x;
      d.x[i] = y;
      sum+=y;
    }
    for(int i=0; i<m; i++){
      all+=d.num[i]*(d.x[i]/sum);
    }
    if(all>top){top = all;}
  }
  int n,m;
  double all = 0,sum = 0;
  dise boss;
  cin >>n>>m;
  for(int i=0; i<m; i++){
    int x;
    double y;
    cin >>x>>y;
    boss.num[i] = x;
    boss.x[i] = y;
    sum+=y;
  }    
  for(int i=0; i<m; i++){
    all+=boss.num[i]*(boss.x[i]/sum);
  }
  if(all+0.0000001<top){cout <<"YES"<<endl;}
  else{cout <<"NO"<<endl;}
  return 0;
}

Measured memory_bytes: 0
/*
   Creator - Glitched
   Yeet!!
*/

#include "bits/stdc++.h"

using namespace std;
#define testcases ll t;cin>>t;while(t--)
#define queries ll q;cin>>q;while(q--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);

ll power(ll x, ll y){
    ll ans = 1;

    loop(i,0,y){
        ans = ans*x;
    }
    return ans;
}

int main()
{
    long long n,x,sum=0;
    cin>>n;
    ll i = 0;
    while(n!=0){

        sum+=power(2,i);
        i++;
        n = n/2;          
    }

    cout<<sum;
    flush;

    
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
	int n, i;
	string s, t;
	map<string, int> m;

	cin >> s;
	n = s.size();
	for (i = 0; i < n; i++) {
		t = s[i];
		m[t]++;
	}

	for (i = 0; i < m.size(); i++) {
		t = 'a' + i;
		if (m[t] >= 2) {
			cout << "no" << endl;
			return 0;
		}
	}

	cout << "yes" << endl;

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int t[N+1], x[N+1], y[N+1];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  int flag = 0;

  for(int i=0; i<N; i++){
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }

  for(int i; i<N; i++){
    int dt = t[i+1] - t[i];
    int manhattan = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if(dt < manhattan || dt%2 != manhattan%2){
      flag = 1;
      break;
    }
  }

  if(flag==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int N; cin >> N;
	vector<int64_t> Xs(N);
	vector<int64_t> Ys(N);
	vector<array<int64_t, 2>> rooks(N);
	for (int i = 0; i < N; i++) {
		int x, y; cin >> x >> y;
		Xs[i] = x, Ys[i] = y;
		rooks[i] = {x, y};
	}
	sort(Xs.begin(), Xs.end());
	sort(Ys.begin(), Ys.end());
	vector<int> P(N);
	vector<int> invP(N);
	vector<int> rookID(N);
	for (int i = 0; i < N; i++) {
		int x = int(lower_bound(Xs.begin(), Xs.end(), rooks[i][0]) - Xs.begin());
		int y = int(lower_bound(Ys.begin(), Ys.end(), rooks[i][1]) - Ys.begin());
		rookID[x] = i;
		P[x] = y;
		invP[y] = x;
	}

	vector<int64_t> ans(N);

	vector<array<int, 2>> runs; runs.reserve(N);
	for (int i = 0; i < N; i++) {
		int j = i;
		while (j+1 < N && abs(P[j] - P[j+1]) == 1) {
			j++;
		}
		runs.push_back({i,j});
		i = j;
	}

	int R = int(runs.size());
	for (int st = 0; st < R; st++) {
		int a = st, b = st;
		int x0 = runs[st][0], y0 = P[x0];
		int x1 = runs[st][1], y1 = P[x1];
		int64_t cost[2][2];
		cost[0][0] = cost[1][1] = 2 * (abs(Xs[x0] - Xs[x1]) + abs(Ys[y0] - Ys[y1]));
		cost[0][1] = cost[1][0] = abs(Xs[x0] - Xs[x1]) + abs(Ys[y0] - Ys[y1]);
		while (true) {
			assert(x0 <= x1 && abs(x0 - x1) == abs(y0 - y1));
			bool can_left = x0-1 >= 0 && abs(P[x0-1] - y1) == 1;
			bool can_right = x1+1 < N && abs(P[x1+1] - y0) == 1;
			if (!(can_left || can_right)) break;
			if (can_left) a--;
			if (can_right) b++;
			int nx0, ny0, nx1, ny1;
			if (can_left) {
				nx0 = runs[a][0];
				ny0 = P[nx0];
			} else {
				nx0 = x0;
				ny0 = y1;
			}
			if (can_right) {
				nx1 = runs[b][1];
				ny1 = P[nx1];
			} else {
				nx1 = x1;
				ny1 = y0;
			}

			for (int s = 0; s < 2; s++) {
				int64_t nc0 = min(
					cost[s][0] + abs(Xs[x0] - Xs[nx0]) + abs(Ys[y0] - Ys[ny0]),
					cost[s][1] + abs(Xs[x1] - Xs[nx0]) + abs(Ys[y1] - Ys[ny0])
				);
				int64_t nc1 = min(
					cost[s][0] + abs(Xs[x0] - Xs[nx1]) + abs(Ys[y0] - Ys[ny1]),
					cost[s][1] + abs(Xs[x1] - Xs[nx1]) + abs(Ys[y1] - Ys[ny1])
				);
				int64_t nd = abs(Xs[nx0] - Xs[nx1]) + abs(Ys[ny0] - Ys[ny1]);
				if (can_left && can_right) {
					cost[s][0] = nc1 + nd;
					cost[s][1] = nc0 + nd;
				} else if (can_left) {
					cost[s][0] = nc0;
					cost[s][1] = nc0 + nd;
				} else if (can_right) {
					cost[s][0] = nc1 + nd;
					cost[s][1] = nc1;
				} else assert(false);
			}

			x0 = nx0;
			y0 = ny0;
			x1 = nx1;
			y1 = ny1;
		}

		int num_rooks = x1 - x0 + 1;
		for (int i = runs[st][0]; i <= runs[st][1]; i++) {
			int64_t cnds[2];
			for (int z = 0; z < 2; z++) {
				cnds[z] = abs(Xs[i] - Xs[runs[st][z]]) + abs(Ys[P[i]] - Ys[P[runs[st][z]]]) + min(cost[z][0], cost[z][1]);
			}
			ans[rookID[i]] = min(cnds[0], cnds[1]) - (num_rooks - 1);
		}
	}

	for (int i = 0; i < N; i++) {
		cout << ans[i] << '\n';
	}

	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(ALL(s));
    string t = "";
    rep(i, n) t += s[i];
    OP(t);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
Taro = 0
Hanako = 0
for i in range(n):
    s = input().split()
    if s[0] > s[1]:
        Taro += 3
    elif s[0] < s[1]:
        Hanako += 3
    else:
        Taro += 1
        Hanako += 1
print(Taro,Hanako)


Measured memory_bytes: 5592
K, S = map(int, input().split())
t = S - K
r = S - 2*K
if t <= 0:
    answer = (S+2)*(S+1)/2
elif r <= 0:
    answer = (S+2)*(K-t+1)/2 + (S*2-t*3+1)*t/2
else:
    answer = (3*K-S+2)*(3*K-S+1)/2
    
print(int(answer))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
//#define DEBUG
using namespace std;

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

int main()
{
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n)
	{
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int a, b, c;
	int ret = 0;
#ifdef DEBUG
	rep(i, n)
		cout << l[i] << " ";
	cout << endl;
#endif
	int k = 0;
	rep(i, n)
	{
		a = l.back();
		l.pop_back();
		
		int size = l.size() - 1;
		if (size == 0) break;
		rep(j, size)
		{
			b = l[size - j];

			if (b * 2 <= a) break;

			for (k=0; k < size - j; k++)
			{
				c = l[k];
				if (b + c > a)
				{
					ret += size - k - j;
#ifdef DEBUG
					cout << i << " " << j << " " << k << endl;
					cout << "a=" << a << " b=" << b << " c=" << c << " ret=" << ret << endl << endl;
#endif
					break;
				}
			}
			if (k == size) break;
		}
	}


	cout << ret;

	return 0;
}

Measured memory_bytes: 256
n,m,k = map(int,input().split())
p = abs(2*k-n*m)

a = n
while a>0:
  if p%a == 0 and p//a <= m and (p//a)%2 == m%2:
    print("Yes")
    quit()
  elif p > a*m:
    break  
  a -= 2
print("No")
  

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

namespace ALDS1_6_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n  = ReadInt();
            int[] line = ReadIntAr();
            Console.WriteLine(string.Join(" ",CountingSort(line).Select(x => x.ToString()).ToArray()));
        }

        public static int[] CountingSort(int[] array)
        {
            int[] res  = new int[array.Length];
            int[] tmp =  new int[array.Max()+1];
            for (int i = 0 ; i < array.Length ; i++) { tmp[array[i]]++; }
            for (int i = 1 ; i < tmp.Length ; i++) { tmp[i] += tmp[i - 1]; }
            for (int i = array.Length - 1 ; i >= 0 ; i--)
            {
                res[tmp[array[i]]-1] = array[i];
                tmp[array[i]]--;
            }
            return res;
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 147116
S = str(raw_input())
n = len(S)

pattern0 = ("10" * (n//2 + 1))
pattern1 = ("01" * (n//2 + 1))
count0 = 0
count1 = 0

for i in range(n):
    if pattern0[i] != S[i]:
        count0 += 1
    if pattern1[i] != S[i]:
        count1 += 1

print min(count0, count1)

Measured memory_bytes: 6020
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():

    N = int(input())
    d = [[0] * 19 for _ in range(19)]
    c = []
    for _ in range(N):
        x = round(float(input()) * 10**9)
        d2 = 0
        d5 = 0
        while x % 2 == 0 and d2 < 18:
            x //= 2
            d2 += 1
        while x % 5 == 0 and d5 < 18:
            x //= 5
            d5 += 1
        d[d2][d5] += 1

    a = [[0] * 19 for _ in range(19)]
    for i in range(18,-1,-1):
        s = 0
        for j in range(18,-1,-1):
            s += d[i][j]
            a[i][j] = s
            if i < 18:
                a[i][j] += a[i+1][j]

    ans = 0
    for i in range(19):
        for j in range(19):
            ans += d[i][j] * a[18-i][18-j]
            if i >= 9 and j >=9:
                ans -= d[i][j]


    print(ans//2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 77008
#include <iostream>
using namespace std;
int main(void){
    
    string S, T;
    int A, B;
    string U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    
    if(U == S){
        cout << A - 1 << " " << B << endl;
    }
    else{
        cout << A << " " << B - 1 << endl;
    }
    
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long a = 2;
        long b = 1;
        for (int i = 2; i <= n; i++)
        {
            var tmp = b;
            b = a + b;
            a = tmp;
        }
        Console.WriteLine(b);
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main(void)
{
	int i,a,x,b,c;
	while((scanf("%d%d",&a,&b))!=EOF){
		c=0;
		x=a+b;
		while(x!=0){
			x=x/10;
			c++;
		}
		printf("%d\n",c);
	}
}

Measured memory_bytes: 1028
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	string s, t;
	cin >> a;
	cin >> b;
	cin >> c;
	for (int i = 0; i < a; i++)
	{
		cin >> d;
		cin >> e;

		if (d>=b&&e>=c)
		{
			ans++;
		}
	}




	cout << ans << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 256
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf


a,b,h,m = imap()
h += m/60
r1 = 2*PI * (h/12)
r2 = 2*PI * (m/60)
z1 = a * np.exp(r1 * 1j)
z2 = b * np.exp(r2 * 1j)
ans = abs(z1 - z2)
print(ans)


Measured memory_bytes: 37768
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll r,c,k; cin >> r >> c >> k;
    vector table(r, vector(c, 0LL));
    rep(i,0,k){
        ll x,y,v; cin >> x >> y >> v;
        x--;y--;
        table[x][y] = v;
    }

    vector dp(r + 1, vector(c + 1, vector<ll>(4)));
    ll temp = 0;
    rep(i,0,r)rep(j,0,c){
        rep(k,0,4){
            chmax(dp[i][j+1][k], dp[i][j][k]);
            if(table[i][j] && k + 1 <= 3) chmax(dp[i][j+1][k+1], dp[i][j][k] + table[i][j]);
            chmax(dp[i+1][j][0], dp[i][j][k]);
            if(table[i][j] && k <= 2)chmax(dp[i+1][j][0], dp[i][j][k] + table[i][j]);
        }
    }

    debug(dp);

    ll ans = 0;
    rep(i,0,r+1)rep(j,0,c+1)rep(k,0,4)chmax(ans, dp[i][j][k]);
    cout << ans << "\n";
}

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


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

    string S;
    cin >> S;
    int ans=S.size();
    for(int i=0;i<S.size()-1;i++){
        if(S.at(i)==S.at(i+1)) {
            ans--;
            i+=2;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 720
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}


//for(int i = ; i < ; i++){}

int main(){
  int n,m;
  cin>>n>>m;
  if(n%3==0||m%3==0||(n+m)%3==0) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
  }
  



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(2);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 15;
const ll bits = 63;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;



int main(){
    // FASTIO;

    ll a,b;
    cin>>a>>b;

    if((a==1 && b==2) || (a==2 && b==1) ){
        cout<<3<<"\n";
    }


    if((a==1 && b==3) || (a==3 && b==1) ){
        cout<<2<<"\n";
    }

    if((a==3 && b==2) || (a==2 && b==3) ){
        cout<<1<<"\n";
    }

    


    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  int H,W;
  cin >> H >> W;
  
  vector<char> TJ(H*W);
  for(int i=0;i<H*W;i++)
    cin >> TJ.at(i);
  
  for(int j=0;j<W+1;j++)
    cout << "#" ;
  cout << "#" << endl;
  
  
  for(int k=0;k<H;k++){
    cout << "#" ;
     for(int l=0;l<W;l++)
      cout << TJ.at(k*W+l); 
   cout<< "#" << endl;
  }  
  
  
  
  
  for(int j=0;j<W+1;j++)
    cout << '#' ;
  
    cout << "#" << endl;
  
  
}   

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
    
    long long n;
    long long y=0;
    long long ans=0;
    
    scanf("%lld", &n);
    
    for(long long i=1; i<=n; i++){
        
        if(i*i==n){
            
            y = i;
            break;
            
        }
        
        if(i*i>=n){
            
            break;
            
        }
        
        if(n%i==0){
            
            y = i;
            
        }
        
    }
    
    ans = y - 1;
    // printf("%lld\n", ans); // debug
    y = n / y;
    ans += y - 1;
    
    printf("%lld", ans);
    
    return 0;
    
}

Measured memory_bytes: 128
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
        ulong a = ulong.Parse(input[0]);
        ulong b = ulong.Parse(input[1]);
		ulong n = a*b;
		if(a%2==1&&b%2==1){
			n += 1;
		}
		if(a==1||b==1){n=2;}
		Console.WriteLine(n/2);
	}

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  int d;
  cin>>d;
  a=d/100;
  b=(d-a*100)/10;
  c = (d - a * 100 - b * 10);
  if (a == 7 || b == 7 || c == 7) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no { cout << -1; return; }

const int N = 2e5 + 7, INF = 1e9 + 7;

int a[N], b[N];

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    loop(i, n)
        cin >> a[i];
    loop(i, m)
        cin >> b[i];
    a[n] = b[m] = INF;
    int kk = k, ra = 0, rb = 0;
    while (kk - a[ra] >= 0) {
        kk -= a[ra]; ++ra;
    }
    while (kk - b[rb] >= 0) {
        kk -= b[rb]; ++rb;
    }
    int ans = rb + ra;
    for (; ra > 0; --ra) {
        kk += a[ra - 1];
        while (kk - b[rb] >= 0) {
            kk -= b[rb]; ++rb;
        }
        ans = max(ans, ra + rb - 1);
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 6776
using System;

class AOJ {
  static void Main(string[] args)
  {
    string[] s;
    DateTime d;

    while (true) {
      s = Console.ReadLine().Split(' ');

      if (s[0] == "0")
        break;

      d = new DateTime(2004, int.Parse(s[0]), int.Parse(s[1]));

      Console.WriteLine(d.DayOfWeek);
    }
  }
}

Measured memory_bytes: 9404