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

long long n, sum = 0, mi = 1e10;
vector<long long> a;
bool res = 0;

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
    mi = min(a[i], mi);
  }
  if(n % 2)
    res = sum % 2;
  else
    res = (sum % 2) | (mi % 2);
  if(res)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 4344
#include <iostream>

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;

    int64_t ans = 0;
    for(int64_t i=1; i<=N; i++) {
        int64_t j = N/i;
        ans += i*j*(j+1)/2;
    }

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


Measured memory_bytes: 3628
#include<algorithm>
#include <cstdio>
#include<iostream>
#include <vector>
using namespace std;
int main(){
vector<int>a(3);
cin>>a[0]>>a[1]>>a[2];
sort(a.begin(),a.end());
cout<<a[2]-a[0]<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

int main() {
  int N; cin >> N;
  vector<int> vec(N);
  for(auto& v : vec) {
    cin >> v;
  }
  sort(vec.begin(), vec.end(), [](int x, int y) -> int {return x > y;});

  int alice = 0, bob = 0;
  for(int i = 0; i < (int)vec.size(); i++) {
    if(i % 2 == 0) {
      alice += vec[i];
    } else {
      bob += vec[i];
    }
  }

  cout << alice - bob << endl;
}


Measured memory_bytes: 256
// Problem : D - Banned K
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define Ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Test Ios; int tz; cin>>tz; while(tz--)
#define prec(ans) cout<<fixed<<setprecision(20)<<ans<<'\n';
#define all(v) v.begin(), v.end()
#define F first
#define S second

#define sa(a,n)  		int a[n]; for(int zz = 0 ; zz<n; zz++) cin>>a[zz];
#define sda(a,n) 		int n; cin>>n; sa(a,n)
#define pra(a,n)        for(size_t zz=0;zz<n;zz++) cout<<a[zz]<<' '; cout<<'\n';
#define prv(a)          for(auto zz:a) cout<<zz<<' '; cout<<'\n';
#define tr1(x)          cerr <<#x<<": "<<x<<'\n';
#define tr2(x, y)       cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define tr3(x, y, z) 	cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define tr4(a, b, c, d) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';


int val(int t){
	return (t*(t-1))/2;
}
int32_t main(){
//Test
{
	sda(a,n);
	map<int,int> f;
	int ans = 0;
	for(int i = 0 ; i<n; i++){
		f[a[i]]++;
	}
	
	for(auto it:f) ans+= (it.second*(it.second-1))/2;
	
	for(int i = 0 ; i<n; i++){
		if(f[a[i]]>=2){
			cout<< ans - val(f[a[i]]) + val(f[a[i]]-1) << '\n';
		}
		else cout<<ans<<'\n';
	}
    
}}


Measured memory_bytes: 11008
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
	long long  a, b, c;
	cin >> a >> b >> c;
	long long  end = c-a-b;
	if (end < 0)
	{
		cout << "No" << endl;
		return 0;
	}
	end *= end;
	long long  x;
	x = 4 * a * b;
	//cout << c - a - b << " " << end << endl;
	if (x<end)
	{
		cout << "Yes" << endl;
		return 0;
	}
	else
	{
		cout << "No" << endl;
		return 0;
	}
}

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

int main(){
 int n,k; cin >> n >> k;
 int ans=0;
 while(n>0){
     ans++;
     n/=k;
 }
 cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
import heapq

n, q = list(map(int, input().split()))
a = [[] for _ in range(n)]

for i in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        heapq.heappush(a[c[1]],-c[2])
    elif c[0] == 1:
        if a[c[1]]:
            print(-a[c[1]][0])
    else:
        if a[c[1]]:
            heapq.heappop(a[c[1]])


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

int main() {
    int A, B, i;
    scanf("%d %d", &A, &B);

    int l = A + B + 1;
    char str[l + 1];
    scanf("%s", &str);

    if (str[A] == '-') {
        for (i = 0; i < l; i++) {

            if (str[i] < 48 || str[i] > 57) {
                if (i == A) {
                    continue;
                }
                printf("No\n");
                break;
            }
        }
    } else {
        printf("No\n");
    }

    if (i == l) {
        if (strlen(str) == l) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()

    ans = calc(N)
    ans = max(ans, calc(int(str(int(str(N)[0])-1) + "9" * (len(str(N)) - 1))))
    ans = max(ans, calc(max(0, N - N % 10 - 1)))
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
N=int(input())
C_max=N//4
D_max=N//7
M=0

for i in range(C_max+1):
    for j in range(D_max+1):
        if N== 4*i+7*j:
            M+=1
if M==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38500
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

count=0
for i in B :
    a=bisect.bisect_left(A,i)
    c=bisect.bisect_right(C,i)
    p=a*(N-c)
    count+=p

print(count)

Measured memory_bytes: 29272
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int n,s=0;
  cin>>n;
  int tmp=n;
  while(tmp!=0){
    s+=tmp%10;
    tmp=tmp/10;
  }
  cout<<((n%s==0)?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;
 
//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;
 
//少数点表示
//cout << std::fixed << std::setprecision(14) << 値
 
int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    
    int n,i;
    cin >> n >>i;
    cout << n-i+1 <<endl;
    
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

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

  ll N; cin >> N;
  ll M; cin >> M;

  Graph G(N);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<ll> d(N, -1);
  queue<ll> q;
  q.push(0);

  while (!q.empty()) {
    ll p = q.front(); q.pop();

    for (int i = 0; i < G[p].size(); i++) {
      ll n = G[p][i];
      if (d[n] == -1) {
        d[n] = p;
        q.push(n);
      }
    }
  }

  bool ok = true;
  for (ll i = 1; i < N; i++) {
    if (d[i] == -1) ok = false;
  }
  if (!ok) {
    cout << "No";
    return 0;
  }
  cout << "Yes"<< '\n';
  for (ll i = 1; i < N; i++) {
    cout << (d[i] + 1) << '\n';
  }

  return 0;
}

Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i,n)cin >> h[i];
	sort(ALL(h));
	int ans = INF*2;
	rep(i,n-k+1)
	{
		ans = min ( ans , h[k+i-1]-h[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << (a[0] ^ a[1] || a[2] ^ 7 ? "NO" : "YES");
    
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
int main(void){
    int n,h;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>h;
        deq.emplace_back(h);
    }
    const long long int INF=1LL<<60;
    std::deque<long long int> dp(100001);
    for (int i=0;i<100001;i++) {
        dp[i]=INF;
    }
    dp[0]=0;
    for (int i=1;i<n;i++) {
        chmin(dp[i],dp[i-1]+abs(deq[i]-deq[i-1]));
        if (i>1) {
            chmin(dp[i],dp[i-2]+abs(deq[i]-deq[i-2]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4776
def solve():
    S = ''.join(list(map(str, input().split())))
    if S.find('1') == -1 or S.find('9') == -1 or S.find('7') == -1 or S.find('4') == -1:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
        int[] ac = new int[n+1];
        int count=0;
        for(int i=0;n-1>i;i++) {
        	if(list.get(i).equals("A")) {
        		if(list.get(i+1).equals("C"))
        			count++;
        	}
        	ac[i+1] = count;
        }
        //System.out.println(ac);
        //List<Integer> answer = new ArrayList<Integer>();
        for(int i=0;q>i;i++) {
        	int a = sc.nextInt()-1;
        	int b = sc.nextInt()-1;
        	System.out.println(ac[b]-ac[a]);
        }
        //System.out.println(answer);

	}
}

Measured memory_bytes: 85788
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

int main(){
	int n[4];
	for(int i=0;i<4;i++)scanf("%d",&n[i]);
	int time=n[0]+n[1]+n[2]+n[3];
	printf("%d\n%d\n",time/60,time%60);
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    char s[100005];
    scanf("%s", s);
    int ans1 = 0, ans2 = 0;
    int slen = strlen(s);
    for(int i = 0; i < slen; ++i)
    {
        if(i % 2 == 0)
        {
            if(s[i] != '1')
                ans2++;
            if(s[i] != '0')
                ans1++;
        }
        else
        {
            if(s[i] != '0')
                ans2++;
            if(s[i] != '1')
                ans1++;
        }
    }
    printf("%d\n", min(ans1, ans2));
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>v,v2;
bool check(int x){
    v2.clear();
    for(int i=0;i<2*n-1;i++)v2.push_back(v[i]>=x);
    if(v[n-1]>=x&&v[n-2]>=x)return 1;
    if(v[n-1]>=x&&v[n]>=x)return 1;
    if(v[n-1]<x&&v[n-2]<x)return 0;
    if(v[n-1]<x&&v[n]<x)return 0;
    int l=n-2,r=n;
    while(l>0&&v2[l]!=v2[l-1])l--;
    while(r<2*n-2&&v2[r]!=v2[r+1])r++;
    if(r-l==2*n-2)return v2[l]; 
    if((r-l+1)%2)return v2[l];//ÏàÍ¬ 
    if(n-1-l<r-n+1)return v2[l];//ÀëµÃ¸ü¶Ì 
    return v2[r];
}
int main(){
    cin>>n;
    for(int i=0;i<2*n-1;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    int l=1,r=2*n-1;
    while(l<r){
        int mid=(l+r+1)/2;
        if(check(mid))
            l=mid;
        else
            r=mid-1;
        //cout<<l<<' '<<r<<endl;
    }
    cout<<l;
}

Measured memory_bytes: 2548
import itertools as itr

antenna = []

s = 0

for _ in range(5) : 
    antenna.append(int(input()))
    
k = int(input())

l = list(itr.combinations(antenna, 2))

for i in l : 
    if (abs(i[0] -i[1])) > k :
        s = 1

if (s == 0) : 
    print("Yay!")
else : 
    print(":(")

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

bool check_month(int x){
	if(x == 0) return false;
	if(x > 12) return false;
	return true;
}

int main() {
	int n;
	cin >> n;
	int x = n / 100, y = n % 100;
	if(check_month(x)){
		if(check_month(y)){
			cout << "AMBIGUOUS\n";
		}
		else{
			cout << "MMYY\n";
		}
		return 0;
	}
	if(check_month(y)){
		if(check_month(x)){
			cout << "AMBIGUOUS\n";
		}
		else{
			cout << "YYMM\n";
		}
		return 0;
	}
	cout << "NA\n";
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp::*;
use std::collections::*;

const INF: i64 = 0x3f3f3f3f;

fn main() {
    let n: usize = readln();
    let mut c: Vec<Vec<char>> = Vec::with_capacity(n);
    for _ in 0..n {
        let cs = get_chars();
        c.push(cs);
    }

    let mut has_black = false;
    for i in 0..n {
        for j in 0..n {
            if c[i][j] == '#' {
                has_black = true;
                break;
            }
        }
    }

    if !has_black {
        println!("-1");
        return;
    }

    let mut res = INF;

    for i in 0..n {
        let mut acc = 0;
        let mut has_black = false;
        for j in 0..n {
            if c[j][i] == '#' {
                has_black = true;
                break;
            }
        }
        if !has_black {
            acc += 1
        }
        for j in 0..n {
            if c[i][j] == '.' {
                acc += 1;
            }
        }
        res = min(acc, res);

    }

    for i in 0..n {
        let mut has_white = false;
        for j in 0..n {
            if c[j][i] == '.' {
                has_white = true;
                break;
            }
        }
        if has_white {
            res += 1;
        }
    }


    println!("{}", res);
}


fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_string()
}

fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

trait Read {
    fn read(s: &str) -> Self;
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}


Measured memory_bytes: 4352
def calculate(N, A, B, p):
    if p == '+':
        N.append(A + B)
    elif p == '-':
        N.append(A - B)
    else:
        N.append(A * B)
    return 0

if __name__ == '__main__':
    N = []
    A = [x for x in input().split()]
    A.reverse()

    N.append(int(A.pop()))
    N.append(int(A.pop()))
    while(A):
        B = A.pop()
        if B == '+' or B == '-' or B == '*':
            calculate(N, N.pop(-2), N.pop(-1), B)
        else:
            N.append(int(B))
    print(*N)


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

ll A;

void solve()
{
	const int n = 1e9;
	ll y = A/n, q = A%n;
	while(q > 0){
		y++, q-=n;
	}
	cout<<0<<' '<<0 << ' ' << n << ' ' << 1 << ' '<< -q <<' ' << y<<'\n';
}

int main()
{
	cin >> A;
	solve();
	return 0;
}

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

char A[50][50],B[50][50];
int N,M;

bool check(int x,int y){
  for(int i=0;i<M;i++) for(int j=0;j<M;j++){
    if(A[i+x][j+y]!=B[i][j]) return false;
  }
  return true;
}

int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++) for(int j=0;j<N;j++) cin >> A[i][j];
  for(int i=0;i<M;i++) for(int j=0;j<M;j++) cin >> B[i][j];
  for(int i=0;i<N-M+1;i++) for(int j=0;j<N-M+1;j++){
    if(check(i,j)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

#define pi 3.141592653589793

void koch(double x1, double y1, double x2, double y2, int n) {
    if (n == 0) {
        printf("%.8f %.8f\n", x1, y1);
    }
    else {
        double sx, sy, tx, ty, ux, uy;
        sx = x1 + (x2 - x1) / 3;
        sy = y1 + (y2 - y1) / 3;
        tx = x2 - (x2 - x1) / 3;
        ty = y2 - (y2 - y1) / 3;
        ux = (tx - sx)*cos(pi / 3) - (ty - sy)*sin(pi / 3) + sx;
        uy = (tx - sx)*sin(pi / 3) + (ty - sy)*cos(pi / 3) + sy;
        koch(x1, y1, sx, sy, n-1);
        koch(sx, sy, ux, uy, n-1);
        koch(ux, uy, tx, ty, n-1);
        koch(tx, ty, x2, y2, n-1);
    }
    return;
}

int main() {
    int n;
    scanf("%d", &n);
    koch(0.0, 0.0, 100.0, 0.0, n);
    printf("100.00000000 0.00000000\n");
    return 0;
}


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

ll x = 1e9 + 7; 
const int INF = 1001001001;


int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = a*(n/(a+b));
  ans += min(n%(a+b), a);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
#define int long long 
#define cint boost::multiprecision::cpp_int

int N,P;

vector<int> Enumeration_diviser(int N){
    std::vector<int> diviser;
    for(int i=1;i*i<=N;++i){
        if(N % i == 0){
            diviser.emplace_back(i);
            diviser.emplace_back(N/i);
        }
    }
    return diviser;
}

cint POW(cint x,cint n){
    cint res = 1;
    while(n){
        if(n%2) res *= x;
        if(res > P){
            res = -1;
            break;
        }
        x *= x;
        n >>= 1; 
    }
    return res;
}

bool is_prime(int p){
    bool is_prime = true;
    for(int j=2;j*j<=p;++j){
        if(p % j == 0){
            is_prime = false;
            break;
        }
    }
    return is_prime;
}

signed main(){
    cin >> N >> P;

    vector<int> d = Enumeration_diviser(P);
    sort(all(d));
    int ans = 1;

    if(is_prime(P)){
        cout << ans << endl;
        return 0;
    }

    for(int i=1;i<d.size();++i){
        if(POW(d[i],N) == -1) break;
        if(P % POW(d[i],N) == 0) ans = d[i];
    }

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

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    string S;
    ll K;
    cin>>S>>K;
    bool ok=true;
    for(int i=0;i<K;i++){
        if(S[i]=='1')continue;
        cout<<S[i]<<endl;
        ok=false;
        break;
    }
    if(ok)cout<<1<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n; std::cin >> n;
    int s = 0; int m = 0;
    for (int i = 0; i < n; i++) {
        int a; std::cin >> a;
        s+=a;
        m = std::max(m, a);
    }
    std::cout << ((s-m>m)?"Yes":"No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
#define mod 1000000007
#define pi 3.141592653589793238
#include<numeric>
using namespace std;
int gcd(int a, int b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int main() {
	lb r;
	cin >> r;
	cout << fixed << set(10) <<r * r * pi << " " <<fixed << set(10) <<
		2*r * pi << endl;
}


Measured memory_bytes: 3296
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two=[0]*n
four=[0]*n
for i,j in data.items():
    if 2<=j<=3:
        two.append(i)
    elif 4<=j:
        four.append(i)
two.sort()
two.reverse()
four.sort()
four.reverse()
print(max(four[0]*four[0],four[0]*four[1],two[0]*two[1],two[0]*four[0]))


Measured memory_bytes: 18316
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 62
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef pair<lint, lint> P;

bool pairCompare(const P &value1, const P &value2)
{
	return value1.first < value2.first;
}

void execute()
{
	int N, K;
	lint input_x, input_y;
	lint right, left, top, bottom;
	lint ans = INF64;
	int count;
	cin >> N >> K;
	vector<P> point(N);
	vector<lint> y(N);

	for (int i = 0; i < N; i++)
	{
		cin >> input_x >> input_y;
		point[i].first = input_x;
		point[i].second = input_y;
		y[i] = input_y;
	}
	sort(all(point), pairCompare);
	sort(all(y));

	for (int i = 0; i < N - K + 1; i++)
	{
		for (int j = i + K - 1; j < N; j++)
		{
			for (int k = 0; k < N - K + 1; k++)
			{
				for (int l = k + K - 1; l < N; l++)
				{
					right = point[i].first;
					left = point[j].first;
					top = y[k];
					bottom = y[l];
					count = 0;
					for (int m = i; m <= j; m++)
					{
						if (right <= point[m].first && point[m].first <= left &&
							top <= point[m].second && point[m].second <= bottom)
							count++;
					}
					if (count == K)
						ans = min(ans, (left - right) * (bottom - top));
					//cout << (left - right) * (bottom - top) << " " << top << " " << bottom << " " << left << " " << right << endl;
				}
			}
		}
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let x: i64 = read();
    let y: i64 = read();
    let mut xv: Vec<i64> = vec![x];
    let mut yv: Vec<i64> = vec![y];

    for _ in 0..n {
        xv.push(read());
    }

    for _ in 0..m {
        yv.push(read());
    }

    let maxv = xv.iter().max();
    let minv = yv.iter().min();

    if maxv < minv {
        println!("No War");
    } else {
        println!("War");
    }
}


Measured memory_bytes: 4352
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val mise = (1..n).map { readLine()!!.replace(" ", "").let { strTo2Bit(it) } }
    val rieki = (1..n).map { readLine()!!.split(" ").map { it.toLong() } }
    val prc = Proc(n, mise, rieki)
    val ans = prc.getAns(0,0)
    println(ans)
}

fun strTo2Bit(inpt:String):Int {
    var num = 0
    var n = 1
    for(i in (inpt.indices).reversed()) {
        if(inpt[i] == '1') {
            num += n
        }
        n = (n shl 1)
    }
    return num
}

class Proc(val miseCount:Int, val miseOpen:List<Int>, val rieki:List<List<Long>>) {
    fun getAns(idx:Int, subTotal:Int):Long {
        if(idx >= 10) {
            if(subTotal == 0) {
                return Long.MIN_VALUE
            }
            val ret = (0 until miseCount).map {msIndex ->
                val kyotsu = (miseOpen[msIndex] and subTotal)
                val kyotsuCount = count1bit(kyotsu)
                val r = rieki[msIndex][kyotsuCount]
                r
            }.sum()
            return ret
        }
        var ans = getAns(idx + 1, subTotal)
        ans = Math.max(ans, getAns(idx + 1, subTotal + (1 shl idx)))
        return ans
    }

    fun count1bit(num:Int):Int {
        return (0..11).filter { (num and (1 shl it)) != 0 }.count()
    }
}


Measured memory_bytes: 44036
#include <stdio.h>

int main (void) {
	int a;
	int b;
	int c;
	int i;
	int k;
	
	i = 0;
	while (scanf("%d%d", &a,&b) != EOF) {
		c = a + b;
		k = 1;
		while ((c / 10) != 0 ) {
			c = c / 10;
			k++;
		}
		printf("%d\n", k);
	}
    return 0;
}

Measured memory_bytes: 0
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                ans += 1
print(ans)

Measured memory_bytes: 3064
from itertools import accumulate
 
n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
 
P = [p-1 for p in P]
 
check = [False] * n
loops = []
 
for i in range(n):
    if check[i]:
        continue
    check[i] = True
    next = P[i]
    tmp = [i]
    while next != i:
        check[next] = True
        tmp.append(next)
        next = P[next]
    loops.append(tmp)
 
 
ans = 0
 
for loop in loops:
 
    num = len(loop)
    div = k // num
    r = k % num
    if r == 0:
        r = num
        div -= 1
    L = [C[p] for p in loop]
    ans_tmp = 0 
    by_loop = max(sum(L), 0) * div
    if k>num and by_loop == 0:
      r = num
    L += L[:r]
    ACC = [0] + list(accumulate(L))
 
    for i in range(num):
            for j in range(i+1, i+r+1):
                ans_tmp = max(ans_tmp, ACC[j] - ACC[i] + by_loop)
 
    ans = max(ans, ans_tmp)
if ans == 0:
    ans = max(C)
print(ans)

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

int main(){
  int P,Q,R;
  cin >> P >> Q >> R;
  cout << min(P+Q,min(Q+R,R+P)) << endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r, c;
    cin >> r >> c;
    int tab[r+1][c+1];
    for(int i=0;i<r;i++){
        int sum=0;
        for(int j=0;j<c;j++){
            cin >> tab[i][j];
            sum+=tab[i][j];
        }
        tab[i][c]=sum;
    }
    for(int i=0;i<=c;i++) tab[r][i]=0;
    for(int j=0;j<c+1;j++){//locked yoko
        for(int i=0;i<r;i++){//move tate
            tab[r][j]+=tab[i][j];
        }
    }
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
            if(j==c)cout << tab[i][j];
            else cout << tab[i][j]<< " ";
        }
        cout << endl;
    }
    return 0;
}


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

int main() {

	int H, W;

	cin >> H >> W;

	while (H != 0 && W != 0)
	{
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if (i == 1 || j == 1 || i == H || j == W) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}

	return 0;
}


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

#define DEBUG(x) cerr << #x << " = " << x << endl

const int INF = (int)1e9;

struct SegmentTree {
  int N;
  vector<vector<int>> data;
  SegmentTree(const vector<int> &X) {
    N = 1;
    while(N < X.size()) N *= 2;
    data.resize(2*N - 1);
    data[0].assign(N, INF);

    for(int i = 0; i < (int)X.size(); ++i) {
      data[0][i] = X[i];
    }
    for(int i = 0; i < N - 1; ++i) {
      data[2*i + 1] = vector<int>(data[i].begin(), data[i].begin() + (data[i].size() / 2));
      data[2*i + 2] = vector<int>(data[i].begin() + (data[i].size() / 2), data[i].end());
    }
    for(int i = 0; i < 2 * N - 1; ++i) {
      sort(data[i].begin(), data[i].end());
    }
  }
  int query(int a, int b, int lower, int upper, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) {
      int ans = 0;
      ans += lower_bound(data[k].begin(), data[k].end(), lower) - data[k].begin();
      ans += data[k].end() - upper_bound(data[k].begin(), data[k].end(), upper);
      return ans;
    }
    return query(a, b, lower, upper, 2 * k + 1, l, (l + r) / 2) +
      query(a, b, lower, upper, 2 * k + 2, (l + r) / 2, r);
  }
};

int main() {
  ios::sync_with_stdio(false);
  int D; cin >> D;
  vector<int> X(D);
  for(int i = 0; i < D; ++i) {
    cin >> X[i];
  }
  SegmentTree S(X);
  int Q; cin >> Q;
  while(Q--) {
    int l, r, e;
    cin >> l >> r >> e;
    l--; r--;
    int a = min(X[l], X[r]) - e;
    int b = max(X[l], X[r]) + e;
    cout << S.query(l, r, a, b, 0, 0, S.N) << endl;
  }
}

Measured memory_bytes: 23036
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin >>a>>b>>c;
    int g[1000][1000];
    int bg[1000];
    int math=0;
    int count=0;
    for(int p=0;p<b;p++) {
        cin>>bg[p];
    }
    for(int i=0;i<a;i++){
        
        for (int l=0;l<b;l++) {
            /* code */
            cin>> g[i][l];
            math += g[i][l]*bg[l];
            
        }
        if(math+c > 0) count++;
        math=0;
    }
        
    
    
    cout << count <<endl;
}


Measured memory_bytes: 384
#include <cfloat>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int XS, YS, XT, YT;
  cin >> XS >> YS >> XT >> YT;
  int N;
  cin >> N;
  vector<int64_t> X(N + 2);
  vector<int64_t> Y(N + 2);
  vector<int64_t> R(N + 2);
  rep(i, N) { cin >> X[i + 2] >> Y[i + 2] >> R[i + 2]; }
  X[0] = XS;
  Y[0] = YS;
  R[0] = 0;
  X[1] = XT;
  Y[1] = YT;
  R[1] = 0;

  vector<vector<double>> G(N + 2, vector<double>(N + 2));
  for (int i = 0; i < N + 1; ++i) {
    G[i][i] = 0;
    for (int j = i + 1; j < N + 2; ++j) {
      int64_t dist =
          (X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]);
      double distD = sqrt(dist) - (double)(R[i] + R[j]);
      distD = max(0.0, distD);
      G[i][j] = distD;
      G[j][i] = distD;
    }
  }

  // dijkstra
  priority_queue<pair<double, int>, vector<pair<double, int>>,
                 greater<pair<double, int>>>
      que;
  que.emplace(0.0, 0);
  vector<double> D(N + 2, DBL_MAX);
  D[0] = 0;
  while (!que.empty()) {
    double dist = que.top().first;
    int u = que.top().second;
    que.pop();
    if (u == 1) break;
    rep(v, N + 2) {
      double ndist = dist + G[u][v];
      if (D[v] <= ndist) continue;
      D[v] = ndist;
      que.emplace(ndist, v);
    }
  }
  double answer = D[1];
  cout << setprecision(20) << answer << endl;
  return 0;
}


Measured memory_bytes: 15244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

double p, dp[3000][3000];

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  REP(i, 3000) REP(j, 3000) dp[i][j] = 0;
  dp[0][0] = 1.0;
  REP(i, n) {
    cin >> p;
    FOR(j, 0, i) {
      dp[i + 1][j + 1] += dp[i][j] * p;
      dp[i + 1][j] += dp[i][j] * (1.0 - p);
    }
  }
  double ans = 0;
  FOR(i, n / 2 + 1, n) {
    ans += dp[n][i];
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

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

struct edge{
  int to, cost;
  edge(int to, int cost):
    to(to), cost(cost){}
};
struct vertex{
  vector<edge> V;
};

vertex G[1000];
int ne, nv, r;
int d[1000];

bool bellman(int s){
  fill(d, d+nv, INF);
  d[s]=0;
  rep(p, nv){
    bool update=false;
    rep(i, nv){
      rep(j, G[i].V.size()){
	edge e=G[i].V[j];
	if(d[i]!=INF && d[i]+e.cost<d[e.to]){
	  d[e.to]=d[i]+e.cost;
	  update=true;
	}
      }
    }
    if(!update)break;
    if(p==nv-1)return false;//?????????
  }
  return true;
}

int main(){
  cin>>nv>>ne>>r;
  rep(i, ne){
    int s, t, d;
    cin>>s>>t>>d;
    G[s].V.push_back(edge(t, d));
  }
  if(bellman(r)){
    rep(i, nv)
      if(d[i]==INF)cout<<"INF"<<endl;
      else cout<<d[i]<<endl;
  }
  else{
    cout<<"NEGATIVE CYCLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  ll count = 0;
  vi a(n);
  rep(i,n){
    cin >> a[i];
  }
  bool ans = true;
  while(ans){
    rep(i, n){
      if(a[i]%2!=0){
        ans = false;
      }
    }
    if(ans){
      rep(j,n){
        a[j] /= 2;
      }
      count++;      
    }
  }
  print(count);
}


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

int main(void){
        char s[100000];
        scanf("%s", s);
        int a[26] = {0};
        for (int i = 0; i < strlen(s); i++) {
                a[s[i] - 'a' ]++;
        }
        for (int i = 0; i < 26; i++) {
                if (a[i]==0) {
                        printf("%c\n",'a'+i);
                        break;
                }
                if (i==25 && a[i]!=0) {
                printf("None\n");
                }
        }
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, A, B, C, K);
	ll sum = A + B + C;
	ll m = max({ A, B, C });
	out(sum - m + m * pow(2, K));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int x[4];
double dp[301][310][301];
int main() {
	int n,a[300];
	scanf("%d",&n);
	for(int i=0;i<n;i+=1){
	    scanf("%d",&a[i]);
	    x[a[i]]+=1;
	}
	for(int k=0;k<=303;k+=1){
	    for(int j=0;j<=303;j+=1){
	        for(int i=0;i<=303;i+=1){
	            if(i==0&&j==0&&k==0){
	                continue;
	            }
	            if((i+j+k)>n){
	                continue;
	            }
	            double t0=1.0*n/(i+j+k),t1=1.0*i/(i+j+k),t2=1.0*j/(i+j+k),t3=1.0*k/(i+j+k);
	            dp[i][j][k]=t0;
	            if(i){
	                dp[i][j][k]+=t1*dp[i-1][j][k];
	            }
	            if(j){
	                dp[i][j][k]+=t2*dp[i+1][j-1][k];
	            }
	            if(k){
	                dp[i][j][k]+=t3*dp[i][j+1][k-1];
	            }
	        }
	    }
	}
	printf("%.10lf",dp[x[1]][x[2]][x[3]]);
	return 0;
}


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

int main() {
  
  int R;
  cin >> R;
  


  if( R<1200 ){ cout << "ABC" << endl; }
  else if( R<2800 ){ cout << "ARC" << endl; }
  else{ cout << "AGC" << endl; }
  

}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void){
    int With,Height,Metropolice;
    int AllRoad=0;
    int i,j;
    int x,y,Now_x,Now_y,dx,dy;
    cin>>Height>> Height>> Metropolice;
    cin>>Now_x>> Now_y;
    for(i=0;i<Metropolice-1;i++){
        cin>>x>> y;
        dx=x-Now_x;
        dy=y-Now_y;
        if(dx*dy>=0){
            if(dx<0)dx=-1*dx;
            if(dy<0)dy=-1*dy;
            dx>dy ? AllRoad+=dx : AllRoad+=dy;
        }
        else{
            if(dx<0)dx=-1*dx;
            if(dy<0)dy=-1*dy;
            AllRoad+=(dx+dy);
        }
        Now_x=x;
        Now_y=y;
    }
    printf("%d\n",AllRoad);


}

Measured memory_bytes: 1144
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;

template<typename T>
struct BIT {
  vector<T> data;
  BIT() {}
  BIT(int n) : data(n+1, 0) {}
  void init(int n) { data.assign(n+1, 0); }
  T sum(int ed) const {
    for(T res(0); ; ed &= ed-1) if(ed) res += data[ed]; else return res;
  }
  void add(int i, const T& x) {
    for(++i; i < (int)data.size(); i += i&-i) data[i] += x;
  }
};


int vs[100000+10];
ll cs[100000+10];

struct K {
  ll v;
  int idx;
};
bool operator<(const K& a, const K& b) {
  if(a.v != b.v) return a.v < b.v;
  return a.idx > b.idx;
}

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
  }

  priority_queue<K> q;
  REP(i, n) {
    q.push((K){vs[i], i});
  }
  BIT<ll> bit1(n);
  BIT<ll> bit2(n);
  while(!q.empty()) {
    K cur = q.top(); q.pop();
    ll sum = bit1.sum(n) - bit1.sum(cur.idx+1);
    ll cnt = bit2.sum(n) - bit2.sum(cur.idx+1);
    cs[cur.idx] = sum - cnt * cur.v;
    bit1.add(cur.idx, cur.v);
    bit2.add(cur.idx, 1);
  }

  ll last = -1;
  ll rest = bit1.sum(n);
  REP(i, n) {
    if(vs[i] <= last) {
      puts("0");
      continue;
    }
    ll cur = rest - cs[i];
    printf("%lld\n", cur);
    rest -= cur;
    last = vs[i];
  }
  
  return 0;
}


Measured memory_bytes: 5360
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DWideFlip solver = new DWideFlip();
        solver.solve(1, in, out);
        out.close();
    }

    static class DWideFlip {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int[] s = in.string().chars().map(i -> i - '0').toArray();
            if (Arrays.stream(s).allMatch(i -> i == 1)) {
                out.println(s.length);
            } else if (Arrays.stream(s).allMatch(i -> i == 0)) {
                out.println(s.length);
            } else {
                int ans = Integer.MAX_VALUE;
                for (int i = 1; i < s.length; i++) {
                    if (s[i - 1] != s[i]) {
                        ans = Math.min(ans, Math.max(i, s.length - i));
                    }
                }
                out.println(ans);
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 28244
def main():
    n, m = list(map(int, input().split()))
    ac_list = [0] * n
    wa_list = [0] * n
    for _ in range(m):
        tmp = input().split()
        contest_num = int(tmp[0]) - 1
        if ac_list[contest_num]:
            continue
        ret = tmp[1]
        if ret == "AC":
            ac_list[contest_num] = 1
        else:
            wa_list[contest_num] += 1

    penalty = [wa_list[i] if ac_list[i] else 0 for i in range(n)]

    print(sum(ac_list), sum(penalty))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main()
{
	cin>>n;
	if(n%2==1)
	{
		cout<<0<<endl;
		return 0;
	}
	n/=2;
	ll a=0;
	while(n>=5)
	{
		n/=5;
		a+=n;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256