akhauriyash/Code-Regression huggingface dataset:
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        s: chars,
    }
    let mut map = vec![std::collections::HashMap::new(); n + 1];
    for i in 0..(1 << n) {
        let mut a = vec![];
        let mut b = vec![];
        let mut k = 0;
        for j in (0..n).rev() {
            if ((i >> j) & 1) == 1 {
                k += 1;
                a.push(s[n + j]);
            } else {
                b.push(s[n + j]);
            }
        }
        let h = (a, b);
        let po = map[k].entry(h).or_insert(0);
        *po += 1;
    }
    let mut ans: u64 = 0;
    for i in 0..(1 << n) {
        let mut a = vec![];
        let mut b = vec![];
        let mut k = 0;
        for j in 0..n {
            if ((i >> j) & 1) == 1 {
                a.push(s[j]);
                k += 1;
            } else {
                b.push(s[j]);
            }
        }
        let h = (a, b);
        match map[k].get(&h) {
            Some(&v) => ans += v,
            _ => (),
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 57596
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,m;
  cin>>n>>m;
  vec k(m);
  Graph G(m);
  loop(i,m){
    cin>>k[i];
    ll w=k[i];
    loop(j,w){
      ll u;
      cin>>u;
      Gput(i,u);
    }
  }
  vec p(m);
  loop(i,m)cin>>p[i];
  ll ANS=0;
    loop(bit,1<<n){
        vector<ll> S;
      bool check=true;
        loop(i,n){
            if(flagon(bit,i)){
                S.push_back(i);
            }
        }
      loop(i,m){
        ll ans=0;
        ll w=k[i];
        loop(j,w){
          if(count(all(S),G[i][j]-1))ans++;
        }
        if(ans%2!=p[i])check=false;
      }
        if(check)ANS++;
    }
  
  putout(ANS);
  
}


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

// https://atcoder.jp/contests/abc042/tasks/abc042_b

string solver(int allStr,int astrLen,vector<string> strs){
    string result;
    result = "";
    sort(strs.begin(),strs.end());
    for(int j=0;j<allStr;j++){
        result = result + strs.at(j);
    }
    return result;
}

int main(void){
    int N,L;
    string answer;
    cin >> N >> L;
    vector<string> STI(N);
    for(int j=0;j<N;j++){
        cin >> STI.at(j);
    }
    answer = solver(N,L,STI);
    cout << answer << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int N,i,v,j,k,A[1000];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(k=0;k<N-1;k++){
    printf("%d ",A[k]);
  }
  printf("%d\n",A[N-1]);
    
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0;k<N-1;k++){
      printf("%d ",A[k]);
    }
    printf("%d\n",A[N-1]);
  }
  return 0;
}

Measured memory_bytes: 600
package main

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

func BubbleSort(buf []int) int {
	count := 0
	for i := 0; i < len(buf)-1; i++ {
		for j := len(buf) - 1; j > i; j-- {
			if buf[j] < buf[j-1] {
				buf[j], buf[j-1] = buf[j-1], buf[j]
				count++
			}
		}
	}
	return count
}

func main() {

	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	buf := make([]int, n)

	sc.Scan()
	line := sc.Text()
	words := strings.Split(line, " ")
	for i, word := range words {
		buf[i], _ = strconv.Atoi(word)
	}

	count := BubbleSort(buf)

	for i, val := range buf {
		if i == len(buf)-1 {
			fmt.Printf("%d\n", val)
		} else {
			fmt.Printf("%d ", val)
		}
	}
	fmt.Println(count)
}



Measured memory_bytes: 1112
#include <cstdio>
using namespace std;
#define Mod 1000000007
#define N 100
int n,f[N][3][3],i,j,k,jj,kk;
char a[N],b[N];
int main()
{
	scanf("%d",&n);
	scanf("%s%s",a,b);
	if (a[0]==b[0]) for (j=0;j<3;j++) f[0][j][j]=1;else for (j=0;j<3;j++)
		for (k=0;k<3;k++) if (j!=k) f[0][j][k]=1;
	for (i=1;i<n;i++) if (a[i]==b[i]){
		for (j=0;j<3;j++) 
		for (jj=0;jj<3;jj++)
		for (kk=0;kk<3;kk++) if (j!=jj && j!=kk) f[i][j][j]=(f[i][j][j]+f[i-1][jj][kk])%Mod;
	}else if (i&&a[i]==a[i-1]){
		for (j=0;j<3;j++)
		for (k=0;k<3;k++) f[i][j][k]=f[i-1][j][k];
	}else{
		for (j=0;j<3;j++)
		for (k=0;k<3;k++) if (j!=k)
		for (jj=0;jj<3;jj++)
		for (kk=0;kk<3;kk++) if (j!=jj && k!=kk) f[i][j][k]=(f[i][j][k]+f[i-1][jj][kk])%Mod;
	}int psz=0;
	for (j=0;j<3;j++)
	for (k=0;k<3;k++) psz=(psz+f[n-1][j][k])%Mod;printf("%d\n",psz);
	return 0;
}

Measured memory_bytes: 128
import math

def f(d, angle):
    r = math.radians(angle)
    x = d * math.cos(r)
    y = d * math.sin(r)
    return x, y

def main():
    A, B, H, M = map(int, input().split())
    x1, y1 = f(A, H / 12 * 360 + (M / 60 * 360 / 12))
    x2, y2 = f(B, M / 60 * 360)
    print(math.sqrt((x1-x2)**2 + (y1-y2)**2))

main()


Measured memory_bytes: 79640
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")



S = sys.stdin.readline().rstrip()
l = S.index('A')
r = S.rindex('Z')
print(r-l+1)


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

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    string S;
    cin >> S;
    cout << ((S[0] != S[1] && S[1] != S[2] && S[2] != S[3]) ? "Good" : "Bad") << endl;
    return 0;
}

Measured memory_bytes: 256
(A, B, C, X) = [int(input()) for i in range(4)]
ways = 0

max_a = int( X / 500 )
if A < max_a :
  max_a = A
for a in reversed(range( max_a+1 )) :
  max_b = int( (X - 500 * a) / 100 )
  if B < max_b :
    max_b = B
  for b in reversed(range( max_b+1 )) :
    c = int ( ( X - 500 * a - 100 * b ) / 50 )
    if c > C :
      break
    ways += 1
print('%d' %ways ) ;


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

signed main(){
    int N;cin>>N;
    double ans=0;
    REP(i,N){
        double a;string s;cin>>a>>s;
        if(s=="JPY")ans+=a;
        else ans+=a*380000;
    }
  	cout<<setprecision(10.10)<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int H, W, i=0,k=0;

  while(1){
    scanf("%d%d",&H,&W);
    if(H+W==0) break;

    for(i=0;i<H;++i){
      for(k=0;k<W;++k){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout((d == 1) ? 1 : 0);
}

Measured memory_bytes: 256
import collections

n=int(input())
list=[]
for i in range(n):
    s=input()
    list.append(s)
c=collections.Counter(list)
most=c.most_common()
i=0
ans=[most[0][0]]
flag=1
for i in range(len(most)-1):
    if most[i][1]==most[i+1][1]:
            ans.append(most[i+1][0])
    else:
        break
ans.sort()
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 47676
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

int culc(int x){
    int cnt=0;
    while(x){
        x=x/10;
        cnt++;
    }
    return cnt;
}


int main(){
    int N; cin >>N;
    int ans=0;
    for(int i=1; i<=N; i++){
        if(culc(i)%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <iomanip>


using namespace std;

typedef unsigned long long ull;
int main(void) {
	ull a, b;
	while(cin >> a >> b){
		if(a < b){
			ull tmp = a;
			a = b;
			b = tmp;
		}
		ull gcd = 1, lcm = a * b;
		for(int i = 2; i <= b; i++){
			while(a > 0 && b > 0 && a % i == 0 && b % i == 0){
				a /= i;
				b /= i;
				gcd *= i;
			}
		}
		lcm /= gcd;
		cout << gcd << " " << lcm << endl;
	}
}

Measured memory_bytes: 0
N,A,B=map(int,input().split())
P=[int(i) for i in input().split()]
dp=[10**19]*(N+1)
dp[0]=0
for i in range(1,N+1):
    ndp=[10**19]*(N+1)
    for j in range(N+1):
        if j < P[i-1]:
            ndp[P[i-1]]=min(ndp[P[i-1]],dp[j])
            ndp[j]=min(ndp[j],dp[j]+A)
        else:
            ndp[j]=min(ndp[j],dp[j]+B)
    dp=ndp
print(min(dp))


Measured memory_bytes: 78044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	int RED = 0;
	int WHITE = 1;

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		int[] stoneArr = new int[n];
		
		String s = fs.next();
		TreeSet<Integer> redIndex = new TreeSet<>();
		TreeSet<Integer> whiteIndex = new TreeSet<>();
		for(int i = 0; i < n; i++) {
			if(s.charAt(i) == 'R') {
				stoneArr[i] = RED;
				redIndex.add(i);
			}else {
				stoneArr[i] = WHITE;
				whiteIndex.add(i);
			}
		}
		
		int ans = 0;
		
		if(whiteIndex.isEmpty() || redIndex.isEmpty()) {
			System.out.println(0);
			return;
		}
		
		while(whiteIndex.first() < redIndex.last()) {
			
			int whiteLeft =  whiteIndex.first();
			int redRight = redIndex.last();
			
			whiteIndex.remove(whiteLeft);
			redIndex.remove(redRight);
			
			whiteIndex.add(redRight);
			redIndex.add(whiteLeft);
			
			ans++;
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

int main(){
	static int n,t,s,a,b,dp[3000+2][3000+2];
	scanf("%d%d%d",&n,&t,&s);
	dp[0][0]=0;
	for(int i=1;i<=n;i++)dp[i][0]=0;
	for(int i=1;i<=t;i++)dp[0][i]=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		for(int j=1;j<b;j++)dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		for(int j=b;j<=t;j++){
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			if(!(j-b<s&&j>s))dp[i][j]=max(dp[i][j],dp[i-1][j-b]+a);
		}
	}
	printf("%d\n",dp[n][t]);
}

Measured memory_bytes: 36384
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
def inli()
  n = gets.to_i
  as = []
  n.times {
    as << gets.split.map(&:to_i)
  }
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

def eratosthenes(size)
  prime_list = []
  is_prime = Array.new(size, true)
  is_prime[0] = false
  is_prime[1] = false

  2.upto(size-1){|i|
    if is_prime[i]
      prime_list << i
      (2).upto((size.to_f/i).ceil-1){|j|
        is_prime[j*i] = false
      }
    end
  }
  [prime_list, is_prime]
end

def dijkstra(s, e, cost)
  size = cost.length
  if s==e
    return 0
  end
  dp = {}
  dp[s] = 0
  undefined_node = {}
  size.times{|i|
    if i != s
      undefined_node[i] = cost[s][i]
    end
  }
  while undefined_node.length != 0
    min = undefined_node.min_by{|_, v| v}
    stock = {}
    temp = undefined_node.clone
    temp.each{|k, v|
      if min[1] == v
        undefined_node.delete(k)
        if k == e
          return v
        end
        dp[k] = v
        stock[k] = v
      end
    }

    stock.each{|k, v|
      undefined_node.each{|k2, v2|
        undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
      }
    }
  end
end

def get_bits(len)
  res =  []
  (2**len).times{|i|
    res << i.to_s(2).rjust(len, '0')
  }
  res
end

def get_GCD(m, n)
  tmp = [n, m].max
  n = [n, m].min
  m = tmp
  while n != 0
    tmp = m % n
    m = n
    n = tmp
  end
  m
end

n, x = li()
ls = li()
sum = 0
count = 1
ls.each { |l|
  sum += l

  if sum > x
    break
  end
  count  += 1
}
if n+1 <= count
  puts n+1
else
  puts count
end

Measured memory_bytes: 1788
#include<stdio.h>
int main(void)
{
	int n;
	int i;
	int p,d,d1,d2;
	int max,pm;
	
	scanf("%d",&n);
	while(n!=0){
		max=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&p,&d1,&d2);
			d=d1+d2;
			if(d>max){
				max=d;
				pm=p;
			}
		}
		printf("%d %d\n",pm,max);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

ll binary_method(ll a,ll b){
    if(b==0) return (ll)1;
    ll temp = binary_method(a,b>>1);
    if(b%2) return (((temp*temp)%mod)*a)%mod;
    else return (temp*temp)%mod;
}

ll inv(ll a){
    return binary_method(a,mod-2);
}

const int thre = 1000000;
int prime[thre+1];
int num[thre+1]={};

int init(){
    map<int,int> ans;
    bool b[thre+1];    
    rep(i,thre+1) b[i] = true;
    int p=0;
    b[0] = false;
    b[1] = false;
    Rep(i,2,thre){
        if(b[i]){
            ans[i] = 0;
            int j = 2;
            while(i*j<=thre){
                b[i*j] = false;
                j++;
            }
            prime[p] = i;
            p++;
        }
    }
    return p;
}

int log(ll A,int val){
    int ans = 0;
    while((A%val)==0){
        ans++;
        A = A/val;
    }
    return ans;
}

void fact(ll a){
    for(int i=0;prime[i]*prime[i]<=a;i++){
        int hoge = 0;
        while(a%prime[i] == 0){
            a /= prime[i];
            hoge++;
        }
        num[prime[i]] = max(hoge,num[prime[i]]);
    }
    num[a] = max(num[a],1);
}

int main(){
    int N;
    cin>>N;
    ll A[10000];
    rep(i,N) cin>>A[i];
    ll ans = 0;
    rep(i,N){
        ans += inv(A[i]);
        ans %= mod;
    }
    int p = init();
    // cout<<p<<endl;
    // rep(i,p) cout<<prime[i]<<" ";
    // cout<<endl;
    rep(i,N) fact(A[i]);
    // cout<<num[2]<<" "<<num[3]<<endl;
    rep(i,p){
        ans *= binary_method(prime[i],num[prime[i]]);
        ans %= mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    
    N=I()
    #約数列挙
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)

        # divisors.sort()
        return divisors
    
    ans=set(make_divisors(N-1))
    ans=ans - set([1])
    ans.add(2)
    
    L=make_divisors(N)
    
    for i in range(1,len(L)):
        temp=L[i]
        N2=N
        while N2>=temp:
            if N2%temp==0:
                N2=N2//temp
            else:
                N2=N2%temp
        if N2==1:
            ans.add(temp)
            
        
            
    
    print(len(ans))

        

main()


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

int main() {
  int A = 0, B = 0, C = 0, D = 0;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a;
vector<pair<int,int>> op;
int n;

void print(){
	for(int i = 1; i <= n; ++i){
		cout << a[i] << " ";
	}
	cout << endl;
}

int main(void){
	int mabs = 0, mi = 0, count = 0;;
	cin >> n;
	a.resize(n+2);
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		if(mabs <= abs(a[i])){
			mabs = abs(a[i]);
			mi = i;
		}
	}
	for(int i = 1; i <= n; ++i){
		if(i == mi) continue;
		a[i] += a[mi];
		//cout << mi << " " << i << endl;
		count++;
		op.push_back(make_pair(mi,i));
	}
	//print();
	if(a[mi] >= 0){
		for(int i = 1; i <= n - 1; ++i){
			if(a[i] > a[i+1]){
				a[i+1] += a[i];
				//cout << i << " " << i+1 << endl;
				count++;
				op.push_back(make_pair(i,i+1));
			}
		}
	}else{
		for(int i = n - 1; i >= 1; --i){
			if(a[i] > a[i+1]){
				a[i] += a[i+1];
				//cout << i+1 << " " << i << endl;
				count++;
				op.push_back(make_pair(i+1, i));
			}
		}
	}
	//print();
	cout << count << endl;
	for(auto x : op){
		cout << x.first << " " << x.second << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; ++i)
  {
    string com, str;
    cin >> com >> str;
    if (com[0] == 'i')
      mp[str]++;
    else
    {
      if (mp[str] > 0)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
}


Measured memory_bytes: 52440
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

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

    int n = sc.nextInt(); //すぬけくんの数
    int k = sc.nextInt(); //お菓子の種類

    Set<Integer> set = new HashSet<>();
    for (int i = 0; i < k; i++) {
      int d = sc.nextInt();
      for (int j = 0; j < d; j++) {
        set.add(sc.nextInt());
      }
    }

    System.out.println(n - set.size());

  }
}


Measured memory_bytes: 37584
// jha4032

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int 
#define mp make_pair
#define M 1000000007
#define N 1000006
void fast()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

ll power(ll a, ll b)
{
  if (b == 0)
    return 1;
  ll tmp = power(a, b / 2)%M;
  tmp = (tmp * tmp )%M ;
  if (b & 1)
    return (tmp * a )%M ;
  return tmp;
}
ll fact[N], invfact[N];
ll ans=0;
void pre1()
{
  fact[0] = 1;
  invfact[0] = power(fact[0], M - 2);
  for (int i = 1; i < N; i++)
  {
    fact[i] = (i * fact[i - 1]) % M;
    invfact[i] = power(fact[i], M - 2);
  }
}


ll n;
ll a[100005][3];	
ll dp[100005][3];



int main(){

//dp[0]=0;
int k;
cin>>n;
for(int i=1;i<=n;i++){
	 for(int j=0;j<3;j++)
	      {
	      	cin>>a[i][j];dp[i][j]=0;
	      }
}

for(int i=1;i<=n;i++){
	dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + a[i][0];
	dp[i][1]=max(dp[i-1][2],dp[i-1][0]) + a[i][1];
	dp[i][2]=max(dp[i-1][0],dp[i-1][1]) + a[i][2];
}

cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;

}

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

using namespace std;
using ll = long long;

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

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
    string s;
    cin >> s;

    sort(ALL(s));
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


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

#define ll long long
ll sum[200001], a[200001], dp[200001];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	for(int i=1;i<=n;i++) {
		cin >> a[i];
		sum[i] = (i > 2 ? sum[i-2] : 0) + a[i];
	}

	for(int i=2;i<=n;i++) {
		if(i&1) dp[i] = max(dp[i-1], dp[i-2]+a[i]);
		else    dp[i] = max(sum[i-1], dp[i-2]+a[i]);
	}
	cout << dp[n];
}

Measured memory_bytes: 8328
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

l = 1
for i in 0...n do
  l = l.lcm(a[i] / 2)
end

def two(n)
  res = 0
  while n % 2 == 0 do
    res += 1
    n /= 2
  end
  res
end

b = a.map{|x| two(x)}
if b.min == b.max then
  puts ((m / l) - m / (2 * l))
else
  puts 0
end

Measured memory_bytes: 13444
def func str
    a = str[0]
    b = str[1..24]
    c = str[25..31]
    sign = (-1) ** (a.to_i)
    sum1, k = 0, 1
    b.reverse.each_char{|x|
        sum1 += k if x == '1'
        k *= 2
    }
    sum2, k = 0.0, 0.5
    c.each_char{|x|
        sum2 += k if x == '1'
        k /= 2
    }
    sign * (sum1 + sum2)
end

q = gets.to_i
q.times{
    puts func(sprintf("%032b", gets.chomp.to_i(16)))
}


Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
 
 
vector<ll> fac(100001); //n!(mod MOD)
vector<ll> ifac(100001); //k!^{M-2} (mod MOD)
//a,bの範囲的にこれだけ配列を用意していけば十分
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}
 
int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<50000; i++){
      fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod MOD)
      ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{MOD-2} (mod OD) ←累乗にmpowを採用
  }
  bool judge = true;
  ll n,k;cin>>n>>k;
  ll p=n-k;  
  for(i=1;i<=k;i++){
    ll a=comb(p+1,i)%MOD;
    ll b=comb(k-1,k-i)%MOD;
    qmod(res,a,b);
    cout<<res<<endl;
  }
 
  
  return 0;
}

Measured memory_bytes: 1792
/******************************************
* AUTHOR : AMAN SAXENA *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

template <typename TYPE> void in(TYPE &x){cin>>x;}

void solve()
{
    ll a; long double b; cin >> a >> b;
    ll ans=a*b;
    cout << ans << endl;
}

void test()
{
    int t;
    cin>>t;
    while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
    {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // test();
    solve();
    
    return 0;
}

Measured memory_bytes: 3752
n = gets.to_i
as = gets.split.map(&:to_i)
count_minus = 0
as.map { |a| a < 0 ? count_minus += 1 : nil }
if count_minus.even?
  puts as.inject(0) { |sum, num| sum += num.abs }
else
  as.map! { |a| a.abs }.sort!
  min = as.shift
  puts as.inject(:+) - min
end


Measured memory_bytes: 10112
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"math/cmplx"
	"math"
)

var sc = bufio.NewScanner(os.Stdin)
func init_for_competitive_programing() {
	sc.Split(bufio.ScanWords)
}
func nextInt() int {
	sc.Scan()
	i,e := strconv.Atoi(sc.Text())
	if e!=nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f,e := strconv.ParseFloat(sc.Text(),64)
	if e!= nil {
		panic(e)
	}
	return f
}

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func fun(r float64,theta float64) complex128{
	return complex(r,0)*cmplx.Exp(complex(0,2.*math.Pi*theta))
}
func main(){
	init_for_competitive_programing()
	
	a,b,h,m := nextFloat(),nextFloat(),nextFloat(),nextFloat()
	
	var rateA float64 = float64((h*5. + m/12.)/60.)
	var rateB float64 = float64(m/60.)
	
	posA := fun(float64(a),rateA)
	posB := fun(float64(b),rateB)

	fmt.Println(cmplx.Abs(posA-posB))
	
}




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

int main() {
      int N, M;
      cin >> N >> M;
      vector<int> p(M);
      vector<string> S(M);
      rep(i, M){
            cin >> p[i];
            cin >> S[i];
      }

      int cr = 0;
      int pn = 0;
      vector<int> pnnum(N+1);
      vector<bool> doneAC(N+1, false);
      rep(i, M){
            if(S[i] == "WA" && doneAC[p[i]] == false){
                  pnnum[p[i]]++;
            }
            if(S[i] == "AC" && doneAC[p[i]] == false){
                  cr++;
                  pn += pnnum[p[i]];
                  doneAC[p[i]] = true;
            }
      }

      cout << cr << " " << pn << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	for (int i = 1;; i++) {
		int x;
		std::cin >> x;
		if (x == 0)
			break;
		std::cout << "Case " << i << ": " << x << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3000
import java.util.*;
import java.math.*;

 class Main {
     static boolean[][] graph = new boolean[8][8];

     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long Nw= N;
        long[] yaku=new long[100000];
        int k=0;
        long root = (long) Math.pow(N,1.0/2.0)+1;
        
        for(long i=1;i<root;i++) {
        	if(Nw%i==0) {
        		yaku[k]=i;
//                System.out.println(i);
        		k++;
        	}
        }
//        System.out.println(Nw);
//        System.out.println("k="+k);
        long ans=999;
        for(int i=k-1;i>=0;i--) {
            long A=yaku[i];
            long B=N/yaku[i];
            long result=Math.max(A, B);
//          System.out.println("A=" + A);
//          System.out.println("B=" + B);
            if (String.valueOf(result).length()<ans)ans=String.valueOf(result).length();
        }
        System.out.println(ans);
     }   
    static int dfs(int first, int max, boolean[] visited) {
    	int ret = 0;
    	boolean all_visited = true;
    	for(int i=0;i<max;i++) {
    		if(visited[i]==false) {
    			all_visited=false;    			
    		}
    	}
    	if (all_visited) {
    		return 1;
    	}
    	
    	for(int i=0;i<max;i++) {
    		if(graph[first][i]==false) {
    			continue;
    		}
    		if(visited[i]==true) {
    			continue;
    		}
    		visited[i]=true;
			ret += dfs(i,max,visited);
			visited[i] = false;
    	}
    	return ret;
    }
}

Measured memory_bytes: 21844
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	ios::sync_with_stdio(false);cin.tie(0);
	reg int res=0;
	int a,b,t=1;
	cin>>a>>b;--a;
	while(t<b)
		t+=a,++res;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[200007];
int main(){
	int n;
	int i,j,k;
	long long int s[10]={0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		s[0]+=a[i];
	}
	s[3]=10000000000;
	for(i=0;i<n-1;i++){
		s[1]+=a[i];
		s[2]=s[0]-s[1]*2;
		if(s[2]<0)s[2]=-s[2];
		if(s[2]<s[3])s[3]=s[2];
	}
	cout<<s[3]<<endl;
	return 0;
}
	
	


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

using namespace std;

#define M 1000000007

int main() {
	long long int n;
	cin >> n;
	vector<long long int> t(n);
	vector<long long int> a(n);
	for (long long int i = 0; i < n; i++) {
		cin >> t[i];
	}
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<long long int> c(n);
	vector<long long int> d(n);
	c[0] = t[0];
	for (long long int i = 1; i < n; i++) {
		if (t[i-1] < t[i]) {
			c[i] = t[i];
		} else {
			c[i] = -1;
		}
	}
	d[n-1] = a[n-1];
	for (long long int i = n-2; i >= 0; i--) {
		if (a[i+1] < a[i]) {
			d[i] = a[i];
		} else {
			d[i] = -1;
		}
	}

	bool h = true;
	vector<long long int> e(n);
	long long int sm = 1;
	for (long long int i = 0; i < n; i++) {
		e[i] = max(c[i], d[i]);
		if ((c[i] > 0 && d[i] > 0 && c[i] != d[i]) || (t[i] < e[i]) || (a[i] < e[i])) {
			sm = 0;
			h = false;
			break;
		}
		if (e[i] == -1) {
			sm *= min(t[i], a[i]);
			sm %= M;
		}
	}

	cout << sm << endl;
/*	
	for (long long int i = 0; i < n; i++) {
		cout << c[i] << ' ' << d[i] << ' ' << e[i] << endl;
	}*/
	return 0;
}

Measured memory_bytes: 4224
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n,a[5];
	cin >> n;
	for(int i=0; i<5; i++)cin >> a[i];
	sort(a,a+5);
	if(a[0]>=n){
		cout << 5 << endl;
		return 0;
	}
	ll add = (n+a[0]-1)/a[0]-1;
	cout << add+5 << endl;
}	



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

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

using namespace std;
using ll = long long;

const int INF = INT_MAX;

int cnt = 0;

void merge_sort(vector<int> &a) {
    if(a.size() == 1) return;
    int mid = a.size() / 2;
    vector<int> sorted1(mid), sorted2(a.size() - mid);
    copy(a.begin(), a.begin() + mid, sorted1.begin());
    copy(a.begin() + mid, a.end(), sorted2.begin());
    merge_sort(sorted1);
    merge_sort(sorted2);
    sorted1.emplace_back(INF);
    sorted2.emplace_back(INF);
    auto itr1 = sorted1.begin(), itr2 = sorted2.begin();
    rep(i, a.size()) {
        if(*itr1 <= *itr2) {
            a[i] = *itr1;
            itr1++;
        } else {
            a[i] = *itr2;
            itr2++;
        }
        cnt++;
    }
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    merge_sort(a);

    rep(i, n) {
        printf("%d", a[i]);
        printf(i == n - 1 ? "\n" : " ");
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 8912
(function(input) {
  var p = input.replace(/\n$/, '').split('\n').map(Number);
  while (p.length > 0) {
    var d = p.shift();
    var area = 0;
    for (var i = 0; i < 600; i += d) {
      area += i * i * d;
    }
    console.log(area);
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7908
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007
  */
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    println(calc(n, 100000))
  }

  def calc(week: Int, balance: Int): Int = {
    val Rate = BigDecimal(1.05)
    if (week > 0) {
      calc(week - 1, (balance * Rate).setScale(-3, BigDecimal.RoundingMode.UP).toInt)
    } else {
      balance
    }
  }
}

Measured memory_bytes: 43608
N = int(input())
XYH = [list(map(int, input().split())) for _ in range(N)]
H_list= [XYH[i][2] for i in range(N)]
H_max = max(H_list)
H_min = min(H_list)
H_diff = H_max - H_min
ans = []

# 高さH,中心座標を(Cx, Cy)として総当たりで試す
for H in range(H_max - (200 - H_diff), H_max + (201 - H_diff)):
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            count = 0
            for X, Y, h in XYH:
                if h == max(H - abs(X - Cx) - abs(Y - Cy), 0):
                    count += 1
                else:
                    break

            if count == N:
                ans = [str(Cx), str(Cy), str(H)]

print(' '.join(ans))




Measured memory_bytes: 57564
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
bool f=false;
int main()
{
	string s;
	cin>>s;
	string x,y;
	x=y="";
	int q;
	cin>>q;
	while(q--)
	{
		int Ty,a;char c;
		cin>>Ty;
		Ty--;
		if(Ty==0)f=!f;
		else{
			cin>>a>>c;
			a--;
			if(f^a==0)x+=c;
			else y+=c;
		}
	}
	reverse(x.begin(),x.end());
	s=x+s+y;
	if(f)reverse(s.begin(),s.end());
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <algorithm>

using namespace std;

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

int main() {
	while (true) {
		int a, b, c, n;
		int ans[300], d[1000][4];
		cin >> a >> b >> c;
		if (!a && !b && !c) break;
		cin >> n;

		fill(ans, ans + a + b + c, 2);

		REP(i, n) {
			REP(j, 4) cin >> d[i][j];
			REP(j, 3) d[i][j]--;
			if (d[i][3] == 1) REP(j, 3) ans[d[i][j]] = 1;
		}
		REP(i, n) {
			if (d[i][3] == 0) {
				REP(j, 3) if (ans[d[i][(j+1)%3]] == 1 && ans[d[i][(j+2)%3]] == 1)
					ans[d[i][j]] = 0;
			}
		}

		REP(i, a + b + c) cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll dp[1<<20];

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    vector<vector<int> > c(m);

    for(int i=0;i<m;i++){
        int A,b;
        cin>>A>>b;
        a[i]=A;
        for(int j=0;j<b;j++){
            int _; cin>>_;
            _--;
            c[i].push_back(_);
        }
    }

    queue<int> q;
    q.push(0);
    for(int i=0;i<1<<n;i++) dp[i]=INF;
    dp[0]=0;

    while(!q.empty()){
        int bit=q.front(); q.pop();
        for(int i=0;i<m;i++){
            int nbit=0;
            for(int j:c[i]){
                nbit+=1<<j;
            }
            if(bit==(bit|nbit)) continue;
            nbit=bit|nbit;
            if(dp[nbit]>dp[bit]+a[i]){
                dp[nbit]=dp[bit]+a[i];
                q.push(nbit);
            }
        }
    }
    if(dp[(1<<n)-1]==INF){
        cout<<-1<<endl;
    }else{
        cout<<dp[(1<<n)-1]<<endl;
    }

}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000ll
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N;cin >> N;
VI A(N);  
rep(i, 0, N) cin >> A[i];

int64_t cnt = 0, len = 0;
rep(i, 0, N){
    if (A[i]) 
        len += A[i];
    else {
        cnt += len / 2;
        len = 0;
    }
}

cout << cnt + len / 2 << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        /**           入力                    **/
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //キー入力を取得
        String line = br.readLine();//1列目を取得
        String aInput[] = null;
        aInput = line.split(" ");
        //デバッグ
//        for(String aTxt : aInput) {
//          System.out.println(aTxt);
//        }
        
        /********** ここから問題 ********/
        /**           定数                    **/
        
        /**           変数                    **/
        String aDate = null;
        
        /**           出力                    **/
        System.out.println(aInput[0].replaceAll("2017", "2018"));
    }
}

Measured memory_bytes: 21204
N,M=map(int,input().split())
P=list(map(int,input().split()))
par=[i for i in range(N)]
ans=0

def root(x):
    if x!=par[x]:
        par[x]=root(par[x])
    return par[x]

def connect(x,y):
    if root(x)!=root(y):
        par[root(y)]=root(x)

for i in range(M):
    x,y=map(int,input().split())
    connect(x-1,y-1)

for i in range(N):
    if root(i)==root(P[i]-1):
        ans+=1

print(ans)

Measured memory_bytes: 13812
using System;
//using System.Text;
using System.Linq;
namespace AIZU_Cs_
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (arr[0] == 0 && arr[1] == 0) break;
                if (arr[0] * arr[1] % 2!=0) Console.WriteLine("no");
                else Console.WriteLine("yes");
            }
            
        }
    }
}

Measured memory_bytes: 9296
N, M = map(int, input().split())

adj = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    adj[a - 1].append((b - 1, c))

# ベルマン-フォード法
INF = float('inf')
cost = [-INF for i in range(N)]
cost[0] = 0
prev = [None for i in range(N)]

for i in range(N):
    for v in [v for v in range(N) if cost[v] != -INF]:
        for v2, c in adj[v]:
            if cost[v2] < cost[v] + c:
                cost[v2] = cost[v] + c
                prev[v2] = v

v = N - 1
for i in range(N):
    v = prev[v]
    if v == None:
        print(cost[N - 1])
        break
else:
    print('inf')


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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N;
  map<string, int> record;
  while(N--){
    string get;
    cin >> get;
    record[get]++;
  }
  cout << record.size();
  return 0;
}

Measured memory_bytes: 19200
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        for(int i=0; i<=100; i++){
            if(a*i%b==c){
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}

Measured memory_bytes: 22868