akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

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")
}

fn main() {
    let s: u32 = read();
    let hours: u32 = s / (60 * 60);
    let hours_remaining: u32 = s % (60 * 60);
    let minites: u32 = hours_remaining / 60;
    let seconds: u32 = hours_remaining % 60;
    println!("{}:{}:{}", hours, minites, seconds);
}



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

int main() {
    int n, temp, sum = 0;
    cin >> n;
    temp = n;
    while(temp) {
        sum += temp % 10;
        temp /= 10;
    }
    if(n % sum) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int isprime(int n){
  for(int i = 2 ; i*i<=n ;i++){
    if(n%i==0)return 0;
}
 return 1;
}
int main(){
  int number[10000+2]={0};
  int n ,i , fir ,sec;
  while(scanf("%d" ,&n)){
    if(n==0)break;
    fir = 0 ,sec = 0;
    for(i=n ;i>3 ;i--){
      if(isprime(i) && isprime(i-2)){
        fir = i-2;
        sec = i;
        break;
      }
    }
    printf("%d %d\n" ,fir ,sec);
  }
  return 0;
}

Measured memory_bytes: 2604
x, y, a, b, c = map(int, input().split())
r = list(map(int, input().split()))
g = list(map(int, input().split()))
cl = list(map(int, input().split()))
r.sort(reverse=True)
g.sort(reverse=True)
ans = r[:x] + g[:y] + cl
print(sum(sorted(ans, reverse=True)[:x+y]))


Measured memory_bytes: 23328
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
n=int(input())
t=[int(input()) for i in range(n)] 
 
print(lcm_list(t))

Measured memory_bytes: 6072
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, K = map(int, read().decode('utf8').split())
ans = 1

for _ in range(N):
    if ans <= K:
        ans *= 2
    else:
        ans += K

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long GCD(long long a,long long b)
{
	if(b==0)
		return a;
	return GCD(b,a%b);
}
long long LCM(long long a,long long b)
{
	return a*b/GCD(a,b);
}
int main()
{
	long long a,b;
	scanf("%lld %lld",&a,&b);
	printf("%lld",LCM(a,b));
	return 0;
}

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

int main(void) {
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cout << (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
from collections import deque
K=int(input())
lun=deque([1,2,3,4,5,6,7,8,9])
for i in range(K):
    x=lun.popleft()
    if x%10!=0:
        lun.append(10*x+x%10-1)
    lun.append(10*x+x%10)
    if x%10!=9:
        lun.append(10*x+x%10+1)
print(x)

Measured memory_bytes: 11908
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

typedef vector <int> VI;

VI roll_y( VI& box )
{
	VI work = box;
	work[0] = box[2];
	work[2] = box[5];
	work[5] = box[3];
	work[3] = box[0];
	return work;
}

VI roll_x( VI& box )
{
	VI work = box;
	work[5] = box[1];
	work[1] = box[0];
	work[0] = box[4];
	work[4] = box[5];
	return work;
}

VI roll_z( VI& box )
{
	VI work = box;
	work[3] = box[4];
	work[4] = box[2];
	work[2] = box[1];
	work[1] = box[3];
	return work;
}

void register_box( VI& box, set <VI>& V )
{
	V.insert( box );

	VI work;
	
	work = box;
	for ( int i = 0; i < 3; i++ )
	{
		work = roll_y( work );
		V.insert( work );
	}

	work = box;
	for ( int j = 0; j < 3; j++ )
	{
		work = roll_x( work );
		V.insert( work );
		for ( int i = 0; i < 3; i++ )
		{
			work = roll_y( work );
			V.insert( work );
		}
		work = roll_y( work );
	}

	work = box;
	for ( int j = 0; j < 3; j++ )
	{
		work = roll_z( work );
		V.insert( work );
		for ( int i = 0; i < 3; i++ )
		{
			work = roll_y( work );
			V.insert( work );
		}
		work = roll_y( work );
	}

}

int main( void )
{
	// Redツ、Yellowツ、Blueツ、Magentaツ、Greenツ、Cyan
	map <string, int> hash_table;
	hash_table["Red"]		= 1;
	hash_table["Yellow"]	= 2;
	hash_table["Blue"]		= 3;
	hash_table["Magenta"]	= 4;
	hash_table["Green"]		= 5;
	hash_table["Cyan"]		= 6;

	int n;
	while ( cin >> n && n )
	{
		int cnt = 0;
		set < VI > V;
		VI box(6);
		string color;

		for ( int i = 0; i < n; i++ )
		{
			for ( int j = 0; j < 6; j++ )
			{
				cin >> color;
				box[j] = hash_table[color];
			}

			if ( V.find( box ) != V.end() )
				cnt ++;

			register_box( box, V );
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

typedef long long ll;


int main(void){
  int  n , m;
  scanf("%d %d",&n ,&m);

  int max = m/n , ans;

  for(int i = max;i > 0;i --){
    if(m%i == 0){
      ans = i;
      i = 0;
    }
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1700
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function

main :: IO ()
main = do
  Just (n,_) <- BS.readInt <$> BS.getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'-')) <$> BS.getLine
  print $ VU.minimum $ VU.imap (\i -> (`div` (i+1))) $ VU.postscanl' (+) 0 as



Measured memory_bytes: 4376
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace Template
{
    public static class Scan
    {
        public static string NextLine => Console.ReadLine();
        public static int NextInt => int.Parse(NextLine);
        public static long NextLong => long.Parse(NextLine);
        public static double NextDouble => double.Parse(NextLine);
 
        public static string[] StrAry(char separator = ' ') => Console.ReadLine().Split(separator);
        public static int[] IntAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), int.Parse);
        public static long[] LongAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), long.Parse);
        public static double[] DoubleAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), double.Parse);
    }
 
    internal class Template
    {
        public static void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
        private static void Fill<T>(T[] src, T value, int len) { for (int i = 0; i < len; i++) { src[i] = value; } }
 
        static void Solve() 
        {            
            var str = Scan.StrAry(',');
            Console.WriteLine(string.Join(" ", str));            
        }
 
        private static void Main()
        {
            Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Console.Out.Flush();
        }
    }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int num=0;
  for (int i = A; i<=B; i++){
    int s1, s2, s3, s4, s5;
    s1 = i / 10000;
    s2 = (i - s1*10000) / 1000;
    s3 = (i - s1*10000 - s2*1000) / 100;
    s4 = (i - s1*10000 - s2*1000 - s3*100) / 10;
    s5 = (i - s1*10000 - s2*1000 - s3*100 - s4*10) / 1;
    if (s1==s5 && s2 ==s4) {
      num++;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

int N, M, Q;
vector<vector<int>> sum;
void bulidTable(vector<int> L, vector<int> R) {
   sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
   rep(i, 0, M) { sum[L[i]][R[i]]++; }
   rep(i, 1, N + 1) {
      rep(j, 1, N + 1) {
         sum[i][j] += sum[i - 1][j];
         sum[i][j] += sum[i][j - 1];
         sum[i][j] -= sum[i - 1][j - 1];
      }
   }
}
int getSumRange(int L, int R) {
   int res = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1];
   return res;
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   cin >> N >> M >> Q;
   vector<int> L(M), R(M);
   rep(i, 0, M) { cin >> L[i] >> R[i]; }
   vector<int> p(Q), q(Q);
   rep(i, 0, Q) cin >> p[i] >> q[i];
   bulidTable(L, R);
   rep(i, 0, Q) {
      int ans = getSumRange(p[i], q[i]);
      cout << ans << endl;
   }
   return 0;
}

Measured memory_bytes: 5120
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 H, W;
  std::cin >> H >> W;
  std::vector<std::string> s;
  tools::read(s, H);

  std::vector<std::vector<i64>> dp(H, std::vector<i64>(W, std::numeric_limits<i64>::max()));
  dp[0][0] = s[0][0] == '#' ? 1 : 0;
  for (i64 i = 0; i < H; ++i) {
    for (i64 j = 0; j < W; ++j) {
      if (i + 1 < H) {
        dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j] + (s[i][j] == '.' && s[i + 1][j] == '#' ? 1 : 0));
      }
      if (j + 1 < W) {
        dp[i][j + 1] = std::min(dp[i][j + 1], dp[i][j] + (s[i][j] == '.' && s[i][j + 1] == '#' ? 1 : 0));
      }
    }
  }

  std::cout << dp[H - 1][W - 1] << std::endl;
  return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a + b == 15) cout << '+' << endl;
  else if(a * b == 15) cout << '*' << endl;
  else cout << 'x' << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<string> s(n), t(m);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}

	int tmp = 0;
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			tmp = 0;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (s[i + k][j + l] == t[k][l]) {
						tmp++;
					}
				}
			}

			if (tmp == m * m) {
				cout << "Yes" << endl;

				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String result = "Impossible";
		if((a * b) % 3 == 0 || (a + b) % 3 == 0) result = "Possible";
		System.out.println(result);
	}

}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(S);
  int ans = 0;
  EACH(si, S) {
    if (si == '1') ans++;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	private static int counter = 0;
	private static int upperOrder = 0;
	private static int lowerOrder = 0;
	
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		char c = s.charAt(0);
		
		if ((c - 'a') >= 0 && c - 'a' <= 26) {
			System.out.println("a");
		} else {
			System.out.println("A");
		}
		
		//System.out.println();
	}
	
	public static void permuteHelper(int[] nums, int start, int end, List<String> ans) {
        if (start == end) {
            String str = "";
            for (int num: nums) {
                str += ("" + num);
            }
            ans.add(str);
        } else {
            for (int i = start; i < end; i++) {
                swap(nums, i, start);
                permuteHelper(nums, start + 1, end, ans);
                swap(nums, i, start);
            }
        }
    }
	
	static public void swap(int[] nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }
	
	static boolean isEqual(int[] a, int[] b) {
		for (int i = 0; i < a.length; i++) {
			if (a[i] != b[i]) {
				return false;
			}
		}
		return true;
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


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

//タワー高さを求める再起関数
int height(int n){
  if( n == 1) return 1;
  return n + height(n-1);
}

int main(){
  int a, b;
  cin >> a >> b;
  //高さの差分
  int dif = b - a;
  int ans = - b + height(dif);
  cout << ans << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <stack>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}

typedef pair<double, double> xy;

const double ERR = 1e-6;
double rnddouble(double d) {
    long l = 1 / ERR * 100;
    return (double)round(d * l) / l;
}

double area(xy A, xy B, xy C) {
    double ab = sqrt((A.first-B.first)*(A.first-B.first) + (A.second-B.second)*(A.second-B.second));
    double ac = sqrt((A.first-C.first)*(A.first-C.first) + (A.second-C.second)*(A.second-C.second));
    double bc = sqrt((B.first-C.first)*(B.first-C.first) + (B.second-C.second)*(B.second-C.second));
    double b = rnddouble((ab*ab+ac*ac-bc*bc)/2/ab/ac);
    double theta = acos(b);
    double a = 0.5 * ab * ac * sin(theta);
    return a;
}

int main() {
    float x1,y1,x2,y2,x3,y3,x4,y4;
    while(scanf("%f,%f,%f,%f,%f,%f,%f,%f", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4) != EOF) {
        xy A, B, C, D;
        A = make_pair(x1, y1);
        B = make_pair(x2, y2);
        C = make_pair(x3, y3);
        D = make_pair(x4, y4);
        if (abs(area(A,B,C) + area(A,C,D) - area(B,A,D) - area(B,C,D)) < ERR) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

#define Max 10000
#define NIL -1

typedef struct Node{
  int parent, l, r;
}Node;

Node T[Max];
int n, D[Max], H[Max];

void setDepth(int u, int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].l, d + 1);
  setDepth(T[u].r, d + 1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;

  if(T[u].l != NIL) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL) h2 = setHeight(T[u].r) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}


int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].l != u && T[T[u].parent].l != NIL) return T[T[u].parent].l;
  if(T[T[u].parent].r != u && T[T[u].parent].r != NIL) return T[T[u].parent].r;

  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if(T[u].l != NIL) deg++;
  if(T[u].r != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }
  else if(T[u].l == NIL && T[u].r == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}


int main(){
  int i, v, l, r, root = 0;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) T[i].parent = NIL;

  for(i = 0 ; i < n ; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(i = 0 ; i < n ; i++){
    if(T[i].parent == NIL) root = i;
  }

  setDepth(root, 0);
  setHeight(root);

  for(i = 0 ; i < n ; i++) print(i);

  return 0;
}


Measured memory_bytes: 2048
from copy import copy
D,G=map(int,input().split())
p=[]
c=[]
for i in range(D):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
lst1=[]
lst2=[]
lst3=[]
def func1(l1,l2,l3,p,c,G):
    S=0
    n=0
    ind=0
    for i in range(len(l1)):
        S+=c[i]*l1[i]
        n+=p[i]*l1[i]
        S+=p[i]*100*(i+1)*l1[i]
    for i in range(len(l2)):
        if S>=G:
            break
        kazu=len(l2)-i
        a=l2[kazu-1]
        for j in range(1,a+1):
            if j==a:
                break
            S+=100*kazu
            n+=1
            if S>=G:
                break
    if S>=G:
        l3.append(n)
        l3.append(S)
    return 0
def func(l1,l2,l3,num,p,c,G):
    if num==0:
        func1(l1,l2,l3,p,c,G)
        return 0
    y1=copy(l2)
    y2=copy(l2)
    y2[len(l1)]=0
    x1=copy(l1)
    x1.append(0)
    x2=copy(l1)
    x2.append(1)
    num-=1
    return func(x1,y1,l3,num,p,c,G),func(x2,y2,l3,num,p,c,G)
func(lst1,p,lst3,D,p,c,G)
print(min(lst3))

Measured memory_bytes: 44016
#include <stdio.h>
#include <math.h>

int main(void)
{
	int x, h;
	double s, i;
	
	while (1){
		scanf("%d %d", &x, &h);
		if (x == 0 && h == 0){
			break;
		}
		
		i = (x / 2.0) * (x / 2.0) + (h * h);
		i = sqrt(i);
		
		s = (2 * x * i) + (x * x);
		printf("%f\n", s);
	}
	
	return (0);
}	

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  bool flag = true;
  if(vec.at(0) != 0){
    flag = false;
  }
  
  sort(vec.begin(),vec.end());
  if(N > 1 && vec.at(1) == 0){
    flag = false;
  }
  
  vector<int> num(0);
  int cnt = 1;
  for(int i=0; i<N-1; i++){
    if(vec.at(i) == vec.at(i+1)){
      cnt++;
    }
    else{
      if(vec.at(i) +1 < vec.at(i+1)){
        flag = false;
      }
      num.push_back(cnt);
      cnt = 1;
    }
  }
  
  num.push_back(cnt);
  
  //for(int i=0; i<num.size(); i++){
    //cout << num.at(i);
  //}
  
  int64_t ans = 1;
  for(int i=0; i<num.size()-1; i++){
    if(num.at(i) == 1){
      continue;
    }
    else{
      for(int j=1; j<=num.at(i+1); j++){
        ans *= num.at(i);
        ans %= 998244353;
      }
    }
  }
  
  if(flag){
    cout << ans << endl;
  }
  else{
    cout << 0 << endl;
  }
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		int n,x,y;
		cin >> n >> x >> y;
		int dp[n+5][n+5];
		rep(i,1,n)
		{
			rep(j,1,n)
			{
				dp[i][j] = abs(i-j);
				//cout << dp[i][j] << " ";
			}
			//cout << endl;
		}
		dp[x][y] = 1;
		dp[y][x] = 1;
		rep(i,1,n)
		{
			rep(j,1,n)
			{
				dp[i][j] = min({dp[i][j],dp[i][x] + 1 + dp[y][j],dp[j][i]});
				//cout << dp[i][j] << " ";
			}
			//cout << endl;
		}
		int freq[n+5] = {0};
		rep(i,1,n)
		{
			rep(j,1,n)
			{
				freq[dp[i][j]]++;
			}
		}
		rep(i,1,n-1)
		{
			cout << freq[i]/2 << endl;
		}
		
	}
}


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

int main()
{
    int n, a = 0;
    std::cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (i % 2 != 0) { a++; }
    }
    std::cout << (double)a / (double)n << std::endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> data;

set<pii> bad;
set<int> blocked[200005];

void solve() {
  int r, c, n;
  cin >> r >> c >> n;
  while(n--) {
    int x, y;
    cin >> x >> y;
    bad.insert({x, y});
    blocked[y].insert(x);
  }
  int ret = r;
  int currX = 1;
  int currY = 1;
  while(true) {
    if(blocked[currY].upper_bound(currX) != blocked[currY].end()) {
      ret = min(ret, (currX-1) + (*blocked[currY].upper_bound(currX) - currX));
    }
    if(currX == r || bad.count({currX+1, currY})) break;
    currX++;
    if(currY < c && !bad.count({currX, currY+1})) currY++;
  }
  cout << ret << endl;
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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

int main()
{
    int sum = 0, num = 0, k = 0, p = 0;
    string s;
    cin >> s;
    for(int i = s.size()-1; i >= 0; i--)
    {
        k = s[i] - '0';
        sum += k;
        num += (k * (pow(10.0, p)));
        p++;
    }
    if(num % sum == 0) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n,k=0,h=0;
    scanf("%d",&n);
    if(n>=2)
    {
        int s[n];
        for(i=0;i<n;i++)
        {
            scanf("%d",&s[i]);
            if(s[i]%4==0)k++;
            else if(s[i]%2==0)h++;
        }
        if((k+h/2)>=n/2)
            printf("Yes");
        else
            printf("No");
    }
    else
        printf("No");
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int n, m;
	while (cin >> n >> m, n || m){
		vector < pair <int, int> > data(m);
		pair <int, int> edge[20050];
		for (int i = 0; i < 20050; i++){
			edge[i].first = edge[i].second = -1;
		}
		int t, s, d;
		for (int i = 0; i < m; i++){
			cin >> t >> s >> d;
			data[i].first = t;
			data[i].second = i;
			edge[i].first = s;
			edge[i].second = d;
		}
		sort(data.begin(), data.end());

		bool infect[20050] = {false};
		infect[1] = true;
		for (int i = 0; i < m; i++){
			int from = edge[data[i].second].first;
			int goal = edge[data[i].second].second;
			if (infect[from]){
				infect[goal] = true;
				// cout << goal << " is infect" << endl;
			}
		}

		int ret = 0;
		for (int i = 0; i <= 20050; i++){
			if (infect[i]) ret++;
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1540
N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))
    
def gcd(a, b):
    while b:
        a, b = b, a%b   
    return a

tmp = T[0]
for i in range(1, N):
    tmp = T[i]//gcd(T[i], tmp)*tmp
    
print(tmp)

Measured memory_bytes: 3060
fun main() = Thread(null, ::msolutions2020c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2020c() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val aList = readLine()!!.split(" ").map { it.toLong() }.toLongArray()

    val answer = (0 until n - k)
        .joinToString(System.lineSeparator()) { if (aList[it] < aList[it + k]) "Yes" else "No" }

    println(answer)
}


Measured memory_bytes: 65852
N, L = map( int, input().split())
A = list( map( int, input().split()))
ans = "Impossible"
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        ans = "Possible"
        t = i
        break
if ans == "Impossible":
    print(ans)
else:
    print(ans)
    for i in range(t):
        print(i+1)
    for i in range(N-2,t,-1):
        print(i+1)
    print(t+1)

Measured memory_bytes: 14052
N = int(input())
b_list = list(map(int,input().split()))

b_list = [0] + b_list

result = []
def func():
    global b_list
    global result
#     print(b_list)
    for i in range(len(b_list)-1,-1,-1):
        if i==0:
#             print("karanisuru")
            b_list = []
            break
        if b_list[i] == i:
#             print("icchi")
            result.append(i)
            del b_list[i]
            break

    if len(b_list) > 1:
        func()

func()

if len(b_list) == 0:
    print(-1)
else:
    for i in result[::-1]:
        print(i)

Measured memory_bytes: 38512
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
a.sort()
if n%2==0:
    ans = -2*sum(a[:n//2])
    ans += 2*sum(a[n//2:])
    ans += a[n//2-1] - a[n//2]
else:
    ans = -2*sum(a[:n//2])
    ans += 2*sum(a[n//2+1:])
    ans += max(a[n//2-1]-a[n//2], a[n//2]-a[n//2+1])
print(ans)

Measured memory_bytes: 7508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  string S;
  cin >> S;
  int mae=10*(S[0]-'0')+(S[1]-'0');
  int ato=10*(S[2]-'0')+(S[3]-'0');

  bool a=true, b=true;

  if(mae==0 || mae>=13){
    if(ato!=0 && ato<13){
      cout << "YYMM" << endl;
      return 0;
    }else{
      cout << "NA" << endl;
      return 0;
    }
  }else{
    if(ato!=0 && ato<13){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<functional>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;
//cout << << endl;
int main(){
  int a,b,c,e,f,g;
  int d[5];
  string s,t;
  cin >> d[0] >> d[1] >> d[2] >> d[3] >> d[4];
  int ans=0;
  int max=0;
  int index;
  for(int i=0;i<5;i++){
    if(10 - d[i]%10 >= max && d[i]%10!=0){
      max = 10 - d[i]%10;
      index = i;
    }
  }
  for(int i=0;i<5;i++){
    if(i!=index){
      ans += d[i] + (10-d[i]%10);
      if(d[i]%10==0){
        ans -= 10;
      }
    }
  }
  cout << ans+d[index] << endl;
  return 0;
}


Measured memory_bytes: 256
wordlist = []
wordlist = raw_input().split()
dic = {}       
longest = ['',0]  
m = 0
for word in wordlist:    
    # mode
    if word not in dic:
        dic[word] = 1
    else:
        dic[word] += 1
    
    # word_length    
    if m == 0:
        longest[0] = word
        longest[1] = len(word)
        m += 1
    else:
        if len(word) > longest[1]:
            longest[0] = word
            longest[1] = len(word)

mode_key = sorted(dic.items(),key = lambda x:x[1],reverse=True)[0][0]                   
print '%s %s' % (mode_key,longest[0])

Measured memory_bytes: 4232
N, M = map(int, input().split(" "))
ary = [0] * M
for i in range(0,N):
    KA = list(map(int, input().split(" ")))
    for a in KA[1:KA[0]+1]:
        ary[a-1] += 1
rtn = 0
for i in ary:
    rtn += i == N
print(rtn)

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

int main() {
    int K,S;

    cin >> K >> S;
    int x, y, z, s = 0;

    for (x = 0; x <= K; x++) {
        for (y = x; y <= K; y++) {
            z = S-x-y;
            if (z < y || z > K) continue;
            if (x == y && y == z) {
                s++;
            } else if (x == y || y == z || x == z) {
                s += 3;
            } else {
                s += 6;
            }
        }
    }
    cout << s;

    return 0;
}

Measured memory_bytes: 888
def check(N, A, F, K, mid):
    k = 0
    for i in range(N):
        x = mid // F[i]
        k += max(A[N-i-1] - x, 0)
    return k <= K


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort()
    F.sort()
    lo = 0
    hi = A[-1] * F[-1]
    while lo < hi:
        mid = (lo + hi) // 2
        if check(N, A, F, K, mid):
            hi = mid
        else:
            lo = mid + 1
    print(lo)


if __name__ == "__main__":
    main()


Measured memory_bytes: 120652
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e;
    cin >> k;
    
    //処理
    string ans;
    if(k >= e - a){ ans = "Yay!"; }
    else { ans = ":("; }
    
    //出力
    cout << ans << endl;
}

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

for i in range(len(A)):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(map(str,A)))

Measured memory_bytes: 7620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;
using llong = long long;

int table[200001];
int main(){
  int N,K;
  cin >> N >> K;
  for(int i=0;i<N;++i){
    int a;
    cin >> a;
    table[a]++;
  }
  sort(table,table+N+1);
  int si=0;
  while(table[si]==0) si++;
  int writtennum = 0;
  for(int i=si;i<N-K+1;++i){
    writtennum += table[i];
  }
  cout << writtennum << endl;
  return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

H,W = map(int,readline().split())
a = [readline().rstrip() for i in range(H)]

h = [True] * H
w = [True] * W

for i in range(H):
    if a[i] == "."*W:
        h[i] = False
for i in range(W):
    if all(a[j][i] == "." for j in range(H)):
        w[i] = False
ans = []
for i in range(H):
    s = ""
    for j in range(W):
        if h[i] and w[j]:
            s += a[i][j]
    if s != "":
        ans.append(s)
for s in ans:
    print(s)



Measured memory_bytes: 9368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();
		String S=sc.next();
		int K=sc.nextInt();

		String[] strs=S.split("");

		String check=strs[K-1];

		for(int i=0;i<N;i++) {
			if(!strs[i].equals(check)) strs[i]="*";
			System.out.print(strs[i]);
		}
		System.out.println();


		sc.close();
	}

}


Measured memory_bytes: 21584
n, k = gets.split.map(&:to_i)

ans = 0
1.upto(n) do |i|
  if i >= k
    ans += Rational(1,n)
  else
    j = 0
    tmp = i
    while tmp < k do
      tmp *= 2
      j += 1
    end
    ans += Rational(1,n*(2**j))
  end
end

puts ans.to_f


Measured memory_bytes: 1788
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip() # ignore trailing spaces 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

def abc_b106(num):#numの約数が8個だったらTrueを返す
    cnt = 0
    for i in range(1,num+1):
        if num%i == 0:
            cnt+=1
        if cnt > 8:
            return False
    if cnt == 8:
        return True
    else:
        return False

def main():
    n = ni()
    ans = 0
    for i in range(1,n + 1):
        if i%2 == 1:
            if abc_b106(i):
                ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()


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

#define int long long
#define endl "\n"
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);

const int N = 2e5 + 5;
const double pi = 3.141592653589793238;


int32_t main()
{
    IOS;
    int n;
    cin >> n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        int num = n/i;
        cnt += i*(num+1)*num/2;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
// #include <cctype>


using namespace std;


int main()
{
    double x1, y1, x2, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    cout << fixed << sqrt(pow(x1-x2, 2) + pow(y1-y2, 2)) << endl;;

}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i = l; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0);cin.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  int N, M;
  cin >> N >> M;
  int sum = 0;
  int a;
  rep(i, 0, M) {
    cin >> a;
    sum += a;
    if (sum > N) { cout << "-1\n"; return 0; }
  }
  cout << N - sum << endl;
  return 0;
}


Measured memory_bytes: 3656
//void __(){
//    ll a,b;
//    cin >> a >> b;
//    if(a > b)
//        swap(a,b);
//    if(a == 1){
//        if(b == 1)
//            print 1;
//        else
//            print b-2;
//    }else{
//        print (a-2)*(b-2);
//    }
//
//}
//
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout)
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }
    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
void __(){
    ll a,b;
    cin >> a >> b;
    if(a > b)
        swap(a,b);
    if(a == 1){
        if(b == 1)
            print 1;
        else
            print b-2;
    }else{
        print (a-2)*(b-2);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}


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

using namespace std;

typedef long long ll;

const int MAXR = 100000;

bool is_prime[MAXR + 1];
bool is_liked[MAXR];
int acc[MAXR];

// return how many prime numbers by O(n loglogn)
void sieve(int n){
  for(int i=0;i<=n;i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      for(int j=2*i;j<=n;j+=i) is_prime[j] = false;
    }
  }
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int Q; cin >> Q;
  int L[Q], R[Q];
  for(int i=0;i<Q;i++){
    cin >> L[i] >> R[i];
  }
  sieve(MAXR);
  for(int n=1;n<=MAXR;n+=2){
    if(is_prime[n] && is_prime[(n + 1)/2]) is_liked[n] = true;
  }
  acc[0] = 0;
  for(int i=1;i<=(MAXR + 1)/2;i++){
    acc[i] = acc[i-1] + is_liked[2*i - 1];
  }
  for(int i=0;i<Q;i++){
    cout << acc[(R[i] + 1)/2] - acc[(L[i] - 1)/2] << endl;
  }
}

Measured memory_bytes: 1792
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    if n % 2 != 0:
        print(0)
    else:
        i = 5
        ans = 0
        while i <= n:
            ans += n // (i*2)
            i *= 5
        print(ans)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 23224
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin >> n;
    int p[n];
    rep(i,n) cin >> p[i];
    int ans = 0;
    for(int i=1; i<n-1; i++){
        if(p[i-1]<p[i] && p[i]<p[i+1]) ans++;
        if(p[i-1]>p[i] && p[i]>p[i+1]) ans++;
    }

    cout << ans << ln;
    return 0;
}

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

int main(void) {
    int a, b;
    string s;
    cin >> a >> b;
    if (a < b) s = "<";
    else if (a > b) s = ">";
    else s = "==";
    cout << "a " << s << " b" << endl;
    return 0;
}

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

int n;
int a[3] = {0};
// dp[i][j][k] cnt, i:3,j:2,k:1
long double dp[305][305][305] = {0};

long double solve();

int main() {
  cout << fixed << setprecision(10);
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++a[x - 1];
  }
  cout << solve() << endl;
  return 0;
}

long double solve() {
  for(int i = 0; i <= n; ++i)
    for(int j = 0; j <= n; ++j)
      for(int k = 0; k <= n; ++k) {
        if(i + j + k == 0) continue;
        dp[i][j][k] = 1;
        if(i != 0)
          dp[i][j][k] += i * dp[i - 1][j + 1][k] / n;
        if(j != 0)
          dp[i][j][k] += j * dp[i][j - 1][k + 1] / n;
        if(k != 0) dp[i][j][k] += k * dp[i][j][k - 1] / n;
        dp[i][j][k] *= n;
        dp[i][j][k] /= i + j + k;
      }
  return dp[a[2]][a[1]][a[0]];
}

Measured memory_bytes: 438656
using System;

namespace B___YYMM_or_MMYY
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var a = int.Parse(S.Substring(0,2));
            var b = int.Parse(S.Substring(2,2));

            if(isMonth(a) && isMonth(b)) Console.WriteLine("AMBIGUOUS");
            if(isMonth(a) && !isMonth(b)) Console.WriteLine("MMYY");
            if(!isMonth(a) && isMonth(b)) Console.WriteLine("YYMM");
            if(!isMonth(a) && !isMonth(b)) Console.WriteLine("NA");
        }
    static bool isMonth(int n)
    {
        return(n <=12 && n >= 1);
    }
    }

}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=2e5+5;

typedef long long LL;

char S[N],T[N];

int n,nn,m,Fail[N],ss[N],cs[N],ct[N];

LL l,r,cnt[N],fs[N],ft[N],g[N];

void calc(LL t,int sig)
{
	if (!t) return;
	memset(ss,0,sizeof(ss));
	for (int i=m-1;i>=0;i--) if (t>=g[i])
	{
		t-=g[i]; ss[i]++;
	}
	for (int i=m-1;i>=0;i--) if (ss[i])
	{
		for (int c=0;c<26;c++)
		{
			cnt[c]+=sig*(fs[i]*cs[c]+ft[i]*ct[c]);
		}
	}
	if (t)
	{
		for (int i=1;i<=t;i++) cnt[S[i]-'a']+=sig;
	}
}

int main()
{
	scanf("%s%lld%lld",S+1,&l,&r); n=strlen(S+1)/2;
	for (int i=2,j=0;i<=n;i++)
	{
		for (;j>0 && S[i]!=S[j+1];j=Fail[j]);
		if (S[i]==S[j+1]) j++;
		Fail[i]=j;
	}
	for (int i=1;i<=n-Fail[n];i++) T[++nn]=S[i];
	for (int i=1;i<=n;i++) cs[S[i]-'a']++;
	for (int i=1;i<=nn;i++) ct[T[i]-'a']++;
	fs[0]=fs[1]=ft[1]=1; g[0]=n; g[1]=nn+n;
	for (m=2;g[m-1]<r;m++) fs[m]=fs[m-1]+fs[m-2],ft[m]=ft[m-1]+ft[m-2],g[m]=g[m-1]+g[m-2];
	if (n>=r) calc(r,1);else
	{
	for (int i=0;i<m;i++) if (g[i+1]>=(r+1)/2)
	{
		calc(g[i],1); calc(r-g[i],1); break;
	}
	}
	if (n>=l-1) calc(l-1,-1);else
	{
	for (int i=0;i<m;i++) if (g[i+1]>=l/2)
	{
		calc(g[i],-1); calc(l-1-g[i],-1); break;
	}
	}
	for (int c=0;c<26;c++) printf("%lld ",cnt[c]);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  int n,m,k; 
  cin >> n >> m >>k;
  bool a=false;
  rep(i,n+1){
    rep(j,m+1){
    int x,y;
      x=i;
      y=j;
      if(m*x+n*y-2*x*y==k){
        a=true;
        break;
      }
    }
      if(a)break;
  }
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		int n = sc.nextInt();

		int[] count = new int[6];
		for (int i = 0; i < n; i++) {
			count[cate(sc.nextDouble())]++;
		}
		for (int i = 0; i < count.length; i++) {
			out.print((1+i) + ":");
			for (int j = 0; j < count[i]; j++) {
				out.print("*");
			}
			out.println();
		}
	}

	int cate(double x) {
		if (x < 165.0) return 0;
		if (x < 170.0) return 1;
		if (x < 175.0) return 2;
		if (x < 180.0) return 3;
		if (x < 185.0) return 4;
		return 5;
	}

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

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 16944
#include <stdio.h>

int main(void)
{
        int a,b,n;
        scanf("%d",&n);
        a=n/100;
        b=n%100;
        if(1<=a && 12>=a){
                if(1<=b && 12>=b) printf("AMBIGUOUS\n");
                else printf("MMYY\n");
        }
        else {
                if(1<=b && 12>=b) printf("YYMM\n");
                else printf("NA\n");
        }
        return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){

    int N;
    scanf("%d", &N);

    int a[N];
    for (int i = 0; i < N; i += 1){
        scanf("%d", &a[i]);
    }

    int ans;
    int checker = 0;

    for (int i = 0; i < N; i += 1){

        if(a[i] == checker + 1){
            checker += 1;
        }
    }

    if (checker == 0){ans = -1;}
    else{ans = N - checker;}

    printf("%d\n", ans);

    return 0;
}

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

ll N, K, A[200000], F[200000];

bool check(ll X){
    ll need = 0;
    for(int i=0; i<N; i++){
        ll ok = X/F[i];
        if(ok < A[i]) need += A[i] - ok;
    }
    return (need <= K);
}

int main(){
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> F[i];
    sort(A, A+N);
    sort(F, F+N, greater<>());
    ll ok = 1e12, ng = -1;
    while(ok-ng>1){
        ll mid = (ok+ng)/2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 3328
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int n, a, b, ans = 0;
	scanf("%d%d%d", &n, &a, &b);
	rep(i, n + 1) if (i / 10000 + i / 1000 - int(i / 10000) * 10 + i / 100 - int(i / 1000) * 10 + i / 10 - int(i / 100) * 10 + i / 1 - int(i / 10) * 10 >= a && i / 10000 + i / 1000 - int(i / 10000) * 10 + i / 100 - int(i / 1000) * 10 + i / 10 - int(i / 100) * 10 + i / 1 - int(i / 10) * 10 <= b)ans += i;
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128