akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x+r<=W && x-r>=0 && y+r<=H && y-r >= 0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

int main() {
  ll n,m; cin >> n >> m;
  vector<P> p(n);
  rep(i,n) cin >> p[i].first >> p[i].second; 
  
  sort(p.begin(), p.end());
  ll cost = 0; ll res = m;
  rep(i,n){
    ll a = p[i].first; ll b = p[i].second;
    if(b < res){
      cost += a*b;
      res -= b;
    }
    else{
      cost += res*a;
      break;
    }
  }
  
  cout << cost << endl;
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  string s,t;
  cin >> s; cin >> t;
  bool ans = true;
  map<char, char> repl1;
  map<char, char> repl2;
  map<char, bool> used;
  int n = s.size();

  for (int i=0; i<26; i++) {
    repl1['a'+i] = '-';
    repl2['a'+i] = '-';
  }

  for (int i=0; i<n; i++) {
    // if (s[i] == t[i]) continue;

    if ((repl1[s[i]]!='-' && repl1[s[i]]!=t[i])
        || (repl2[t[i]]!='-' && repl2[t[i]]!=s[i])) {
      ans = false;
      break;
    }

    if (repl1[s[i]]=='-') {
      repl1[s[i]] = t[i];
    }

    if(repl2[t[i]]=='-') {
      repl2[t[i]] = s[i];
    }


  }

  cout << (ans? "Yes" : "No") << endl;
}

/*
abc
aaa

b → c
c → a

b ← a
c ← a
*/

Measured memory_bytes: 1020
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	n := oneInt()
	d := scanNums(n)

	m := make(map[int]int)
	for i := 0; i < n; i++ {
		m[d[i]]++
	}

	fmt.Println(len(m))
}

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

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums []int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums []int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func sum(nums []int) int {
	sum := 0
	for i := 0; i < len(nums); i++ {
		sum += nums[i]
	}
	return sum
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}

func sumOfEachDigit(num int) int {
	sum := 0
	for num > 0 {
		sum += num % 10
		num /= 10
	}
	return sum
}


Measured memory_bytes: 640
import std.stdio;
import std.string;
import std.conv;
import std.array;

void main(){
  int n=to!int(chomp(readln())),b=0;
  string s="";
  bool f=false;
  for(int i=0;i<n;++i){
    string[] input=split(readln());
    if(input[0]=="(") b+=to!int(input[1]);
    else b-=to!int(input[1]);
    if(b<0) f=true;
  }
  writeln((b==0&&!f)?"YES":"NO");
}

Measured memory_bytes: 1060
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0

#define PLUS 0
#define MINUS 1

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

using namespace std;

lli goal = 0;

int main(){

	lli n,m;
	cin>>n>>m;
	lli ans = 1900*m+100*(n-m);
	REP(i,m){
		ans *= 2;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,B,N,M,K,X,Y,Z;
  cin >> N >> K;

  int digit=1;
  int tmp = N;
  while(1){
     if(tmp / K != 0){
       digit++;
       tmp = tmp / K;
     }else{
       cout << digit << endl;
       return(0);
     }

  }


}

Measured memory_bytes: 256
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    ll q;
    cin>>n>>k>>q;
    sum=0;
    ll arr[n+10];
    memset(arr,0,sizeof arr);
    FOR(i,q)
    {
        cin>>a;
        arr[a]++;
    }
    FOR1(i,n)
    {
        ll rem=q-arr[i];
        ///cout<<k<<" "<<rem<<endl;
        if(k-rem>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using ll = long long int;

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c;
    cin >> x >> y;

    if(a + b > 2*c){
        if(x > y){
            cout << min(2*c*y + a*(x-y), 2*c*x)<< endl;
        }else{
            cout << min(2*c*x + b*(y-x), 2*c*y) << endl;
        }
    }else{
        cout << a*x + b*y << endl;
    }

 }


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from functools import reduce

lst = [int(input()) for i in range(5)]
lst.sort(key=lambda x: 10 - (x % 10) if x % 10 > 0 else 0)
ans = 0
for i, v in enumerate(lst):
  ans += v + (10 - v % 10) if v % 10 > 0 and i != len(lst) - 1 else v

print(ans)

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << max(60 * (h2-h1) + m2 - m1 - k, 0);
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    scan.close();
    int res = (B - 1) / (A - 1);
    int mod = (B - 1) % (A - 1);
    System.out.println(mod == 0 ? res : res + 1);
  }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var dg = Console.ReadLine().Split(' ').Select(v => double.Parse(v)).ToArray();

            var x1 = dg[0];
            var y1 = dg[1];
            var x2 = dg[2];
            var y2 = dg[3];

            var x3 = x2 - (y2 - y1);
            var y3 = y2 + (x2 - x1);
            var x4 = x1 - (y2 - y1);
            var y4 = y1 + (x2 - x1);

            Console.WriteLine(String.Format("{0} {1} {2} {3}", x3, y3, x4, y4));
        }
    }
}


Measured memory_bytes: 13396
N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
M = sum(A)

for i in range(N):
    if A[i] <= B[i]:
        A[i] = 0
        B[i] -= A[i]

ne = M
for i in range(N):
    if A[i] != 0 and B[i] < ne:
        ne = B[i]
print(M - ne)

Measured memory_bytes: 4852
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
sys.setrecursionlimit(10 ** 6)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()

ans = 0
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        ans += 1

print(ans)

Measured memory_bytes: 10172
# coding: utf-8

a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
strings = 'k:'

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      # print('i = %s, j = %s, k = %s' %(i,j,k))
      if i * 500 + j * 100 + k * 50 == x:
        # print(x)
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <iomanip>

int main () {
    int n, dis;
    double sum = 0;
    std::cin >> n;
    int x[n], y[n];
    for(int i = 0; i < n; ++i) {
        std::cin >> x[i] >> y[i];
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            dis = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
            sum += std::sqrt(dis);
        }
    }
    std::cout << std::fixed << std::setprecision(10);
    std::cout << sum / n << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int N, r=0, b=0, i;
    scanf("%d", &N);

    char S[N];
    scanf("%s", S);

    for (i=0; i<N; i++){
        if (S[i] == 'R') {
            r++;
        }else{
            b++;
        }
    }

    if (r>b){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

type Graph = Vec<Vec<usize>>;

fn topological_sort(graph: &Graph) -> Vec<usize> {
    let mut count = vec![0; graph.len()];

    for edge in graph {
        for &to in edge {
            count[to] += 1;
        }
    }
    let mut res = vec![];
    let mut check = vec![];

    for (i, &c) in count.iter().enumerate() {
        if c == 0 {
            check.push(i);
        }
    }

    while !check.is_empty() {
        let i = check.pop().unwrap();
        for &to in &graph[i] {
            count[to] -= 1;
            if count[to] == 0 {
                check.push(to);
            }
        }
        res.push(i);
    }

    res
}


fn main() {
    input! {
        n: usize, m: usize,
        edges: [(usize1, usize1); m],
    }

    let mut graph = vec![vec![]; n];
    for &(f, t) in &edges {
        graph[f].push(t);
    }

    let ordered_index = topological_sort(&graph);

    let mut dp = vec![0; n];

    for &i in &ordered_index {
        for &to in &graph[i] {
            dp[to] = std::cmp::max(dp[i] + 1, dp[to]);
        }
    }
    println!("{}", dp.iter().fold(0, |res, &v| std::cmp::max(res, v)));
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    string s0, s1, s2;
    cin >> s0 >> s1 >> s2;
    cout << s0.at(0) << s1.at(0) << s2.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int t1,t2,s1,s2;
  int p[1000];
  int n;
  while( cin >> n){
    for(int i = 0 ; i < 1000; i++)p[i] = 0;

    int m = n*(n - 1)/2;

    while(m--){
      cin >> t1 >> t2 >> s1 >> s2;
      if(s1 > s2)p[t1-1]+=3;
      else if(s1 < s2)p[t2-1]+=3;
      else {
	p[t1-1]++;
	p[t2-1]++;
      }
    }

    int cnt;
    for(int i =  0 ; i < n ; i++ ){
      cnt = 1;
      for(int j =  0 ; j < n ; j++ ){
	if(p[i] < p[j])cnt++;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(int argc, char *argv[])
{
	char s[10];
	gets(s);
	if(s[0]=='S')
	{
		printf("Cloudy\n");
	}
	else if(s[0]=='C')
	{
		printf("Rainy\n");
	}
	else{
		printf("Sunny\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ar = a + 1, br = b + 1;
    double x1, y1, x2, y2;
    x1 = a / 0.08;
    y1 = ar / 0.08;
    x2 = b / 0.1;
    y2 = br / 0.1;
    if (a % 2 == 1) {
        x1 = ceil(x1);
        y1 = floor(y1) - 1;
    } else {
        x1 = floor(x1);
        y1 = floor(y1);
    }
    x2 = floor(x2);
    y2 = ceil(y2) - 1;
    if (y1 < x2 || y2 < x1) cout << -1 << endl;
    else {
        if (x1 <= x2) cout << x2 << endl;
        else cout << x1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);
	
	if(a - b >= 0){
		printf("delicious\n");
	}else if(a - b < 0 && b - a < x + 1){
		printf("safe\n");
	}else{
		printf("dangerous\n");
	}
}

Measured memory_bytes: 128
using System;

namespace B_008_53
{
    internal class Program
    {
        private static void Main(string[] args)
        {

            new Logic_B().Start();//

        }

        public class Logic_B
        {
            public void Start()
            {
                var str = Console.ReadLine();
                var firstIndex = str.IndexOf('A');
                var lastIndex = str.LastIndexOf('Z');

                Console.WriteLine(lastIndex - firstIndex + 1);
            }
        }

    }
}

Measured memory_bytes: 11616
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

#define ALL(x) begin(x), end(x)

int main() {
  map<string, int> m;
  int N;
  cin >> N;
  string s;
  while (N--) {
    cin >> s;
    ++m[s];
  }
  cin >> N;
  while (N--) {
    cin >> s;
    --m[s];
  }

  int ma = max_element(ALL(m), [](auto &p1, auto &p2) {
             return p1.second < p2.second;
           })->second;
  cout << max(ma, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn.{ readInt, readLine }
  val n = readInt()
  def loop(x: Int): Unit = {
    if (x == 0) {
      ()
    } else {
      val as = readLine().toList.map(_.toInt - 48)
      val bs = readLine().toList.map(_.toInt - 48)

      val al = as.length
      if (80 < al) {
        println("overflow")
        loop(x - 1)
        return
      }
      val bl = bs.length
      if (80 < bl) {
        println("overflow")
        loop(x - 1)
        return
      }

      val padding = if (al < bl) bl - al else al - bl
      val ts =
        if (al < bl) as.reverse ++ List.fill[Int](padding)(0) zip bs.reverse
        else         as.reverse zip bs.reverse ++ List.fill[Int](padding)(0)

      var f = false
      val rs = ts.map { t =>
        val tmp = if (f) t._1 + t._2 + 1 else t._1 + t._2
        f = if (tmp < 10) false else true
        tmp % 10
      }

      val ans = if (f) 1 :: rs.reverse else rs.reverse
      if (80 < ans.mkString.length) println("overflow") else println(ans.mkString)

      loop(x - 1)
    }
  }
  loop(n.toInt)
}

Measured memory_bytes: 44008
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

string s;
ll n;

string dt[4]={"dream","dreamer","erase","eraser"};

bool dfs(ll st){ //stは開始位置
    if(st==n) return true;
    bool ok=false;
    rep(i,4){
        ll m=dt[i].length();
        if(m>n-st) continue;
        bool good=true;
        rep(j,m){
            if(s[st+j]!=dt[i][j]){
                good=false;
            }
        }
        if(good){
            if(dfs(st+m)){
                ok=true;
                break;
            }
        }
    }
    if(ok) return true;
    else return false;
}

int main(){
    cin >> s;
    n=s.length();
    if(dfs(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

int h,w,k;
char c[10][10];

int ans = 0;

int slv(int bh,int bw){
	int cnt = 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if( ( (bh&(1<<i))==0 )
			  &&( (bw&(1<<j))==0 ) ){
				if(c[i][j]=='#'){
					cnt++;
				}
			}
		}
	}

	if(cnt == k)ans++;
	return(0);
}

int main(){

	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>c[i][j];
		}
	}

	// slv
	int lh = 1<<h;
	int lw = 1<<w;
	for(int i=0;i<lh;i++){
		for(int j=0;j<lw;j++){
			slv(i,j);
		}
	}

	cout<<ans<<endl;

	return (0);
}

Measured memory_bytes: 3632
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 200005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    double x=100;
    for(int i=1;;i++){
        x*=1.01;
        x=floor(x);
        if(x>=n){
            cout<<i;
            return;
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3628
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
a.sort(reverse=True)
res = 0
for i in range(n):
    if i < k:
        continue
    res += a[i]
print(res)

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

const int s=1000000;
bool vis[s+1];
bool is_prime[s+1];

int main()
{
    long long int a,b,i,j,count=0,num1,num2;
    cin>>a>>b;
    is_prime[0]=true;
    for(i=2;i*i<=s;i++)
    {
        if(!is_prime[i])
        {
            for(j=i*i;j<=s;j+=i)
            {
                is_prime[j]=true;
            }
        }
    }
    num1=a,num2=b;
    for(i=1;i*i<=a;i++)
    {
        if(!is_prime[i])
        {
            if(a%i==0)
            {
             vis[i]=true;
            }
            while(i!=1&&num1%i==0)
            {
                num1=(num1/i);
            }
        }
    }
    for(i=1;i*i<=b;i++)
    {
        if(!is_prime[i])
        {
            if(b%i==0)
            {
                if(vis[i])
                {
                 count++;
                }
                else if(i==num1)
                 count++;
                while(i!=1&&num2%i==0)
            {
                num2/=i;
            }
            }
        }
    }
    if(num1!=1&&num2!=1&&num1==num2)
    {
     count++;
    }
    else if(num2!=1&&num2<=s&&vis[num2])
     count++;
    cout<<count<<"\n";
}

Measured memory_bytes: 1280
from fractions import gcd
N = int(input())
T = [int(input()) for _ in range(N)]
T = list(set(T))
l = T[0]
for i in range(1,len(T)):
  temp = l
  g = gcd(temp,T[i])
  l = l * T[i] // g
  
print(l)

Measured memory_bytes: 5048
def solve():
    N, K = map(int, input().split())
    
    ans = 0
    for b in range(1, N + 1):
        ans += N // b * max(0, b - K) + max(0, N % b - K + 1)
    if K == 0:
        ans -= N
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
 
#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl
#else
#define tr(a)    
#endif
#define int 		long long
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;
 
vector<pii> adj[1000005];
void solve(){
	int N,M,S,T;
	cin>>N>>M>>S>>T;
	rep(i,1,M+1){
		int a,b,c;
		cin>>a>>b>>c;
		adj[a].pb({b,c});
		adj[b].pb({a,c});
	}
	vi dp1(N+1),d1(N+1,LLONG_MAX);
	vi dp2(N+1),d2(N+1,LLONG_MAX);
	vi order1,order2;
	priority_queue<pii,vector<pii>,greater<pii>>pq;
	pq.push({0,S});
	while(!pq.empty()){
		auto cur=pq.top();
		pq.pop();
		if(d1[cur.S]!=LLONG_MAX)continue;
		order1.pb(cur.S);
		d1[cur.S]=cur.F;
		for(auto i:adj[cur.S]){
			pq.push({cur.F+i.S,i.F});
		}
	}
	pq.push({0,T});
	while(!pq.empty()){
		auto cur=pq.top();
		pq.pop();
		if(d2[cur.S]!=LLONG_MAX)continue;
		order2.pb(cur.S);
		d2[cur.S]=cur.F;
		for(auto i:adj[cur.S]){
			pq.push({cur.F+i.S,i.F});
		}
	}
	assert(d1[T]==d2[S]);
	{
		dp1[S]=1;
		for(auto cur:order1){
			for(auto i:adj[cur]){
				if(d1[cur]+i.S==d1[i.F] and d1[cur]+d2[cur]==d1[T] and d1[i.F]+d2[i.F]==d1[T]){
					dp1[i.F]+=dp1[cur];
					if(dp1[i.F]>=hell)dp1[i.F]-=hell;
				}
			}
		}
	}
	{
		dp2[T]=1;
		for(auto cur:order2){
			for(auto i:adj[cur]){
				if(d2[cur]+i.S==d2[i.F] and d1[cur]+d2[cur]==d1[T] and d1[i.F]+d2[i.F]==d1[T]){
					dp2[i.F]+=dp2[cur];
					if(dp2[i.F]>=hell)dp2[i.F]-=hell;
				}
			}
		}
	}
	tr(d1);
	tr(dp1);
	tr(d2);
	tr(dp2);
	assert(dp1[T]==dp2[S]);
	ll ans=1LL*dp1[T]*dp2[S]%hell;
	for(int i=1;i<=N;i++){
		if(d1[i]==d2[i] and d1[i]+d2[i]==d1[T]){
			ans=(ans-1LL*dp1[i]*dp2[i]%hell*dp1[i]%hell*dp2[i]%hell)%hell;
		}
	}
	for(int i=1;i<=N;i++){
		for(auto j:adj[i]){
			if(d1[i]+j.S==d1[j.F] and d1[i]+d2[i]==d1[T] and d1[j.F]+d2[j.F]==d1[T]){
				if(d1[i]*2LL<d1[T] and d1[T]<d1[j.F]*2LL){
					ans=(ans-1LL*dp1[i]*dp2[j.F]%hell*dp1[i]%hell*dp2[j.F]%hell+hell)%hell;
				}
			}
		}
	}
	cout<<ans;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 44784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=103,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    vector<int> A(N+1,1);
    for(int i=0;i<M;i++){
        int c,d;cin>>c>>d;
        for(int j=c;j<d;j++) A[j]=3;
    }
    
    int ans=0;
    
    for(int i=0;i<N+1;i++) ans+=A[i];
    
    cout<<ans<<endl;
}






Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    double a,b;
    cin>>a>>b;
    printf("%.7f\n",a/b);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, j;
	for(i = 1; i <= 9; i++){
		for(j = 1; j <= 9; j++){
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	return 0;
}

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

int main()
{
	//freopen("..//data.in", "r", stdin);
	//freopen("..//data.out", "w", stdout);

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

	int t1 = n % 10;
	n /= 10;
	int t2 = n % 10;
	n /= 10;
	int t3 = n % 10;

	if (t1 == 7 || t2 == 7 || t3 == 7)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}


	return 0;
}

Measured memory_bytes: 3760
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

dp_list = [0]
for n in range(1, N):
    tmp_h = h_list[n]
    if n < K:
        lst = [abs(tmp_h - h_list[i]) + dp_list[i] for i in range(n)]
    else:
        lst = [abs(tmp_h - h_list[n-k]) + dp_list[n-k] for k in range(1, K + 1)]
    dp_list.append(min(lst))
print(dp_list[-1])

Measured memory_bytes: 20700
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 :$base :expr } ) =>{read_value !($iter ,String ) .chars () .map (|c |(c as u8 -$base as u8 ) as usize ) .collect ::<Vec <usize >>() } ;($iter :expr ,{char :$base :expr } ) =>{read_value !($iter ,{chars :$base } ) [0 ] } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,char ) =>{read_value !($iter ,chars ) [0 ] } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .unwrap () } ;}
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,mut $var :ident :$t :tt $($r :tt ) *) =>{let mut $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,mut $var :ident $($r :tt ) *) =>{input_inner !{$iter ,mut $var :usize $($r ) *} } ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,$var :ident $($r :tt ) *) =>{input_inner !{$iter ,$var :usize $($r ) *} } ;}
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;(iter =$iter :ident ,$($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 ) *} } ;($($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! chmin {
    ($l:expr, $r:expr) => {{
        let x = $r;
        $l = std::cmp::min($l, x);
    }};
}
fn main() {
    input!(h, w, c: [chars; h]);
    let mut ans = 0;
    for i in 0..w - 1 {
        let ni = i + 1;
        let mut dp = vec![vec![std::usize::MAX; h + 1]; h + 1];
        dp[0][0] = 0;
        let mut cost = vec![vec![0; h + 1]; h + 1];
        for j in 0..h {
            cost[j][0] = (0..h - j).filter(|&k| c[k][i] == c[k + j][ni]).count();
        }
        for j in 1..h {
            cost[0][j] = (0..h - j).filter(|&k| c[k + j][i] == c[k][ni]).count();
        }
        for j in 0..h {
            for k in 0..h {
                let nj = j + 1;
                let nk = k + 1;
                cost[nj][nk] = cost[j][k] - (c[h - nj][i] == c[h - nk][ni]) as usize;
            }
        }
        for j in 0..h + 1 {
            for k in 0..h + 1 {
                let nj = j + 1;
                let nk = k + 1;
                if j < h {
                    chmin!(dp[nj][k], dp[j][k] + cost[j][k]);
                }
                if k < h {
                    chmin!(dp[j][nk], dp[j][k] + cost[j][k]);
                }
            }
        }
        ans += dp[h][h];
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <fstream>
#include <algorithm>
#include <limits.h>
using namespace std;

int n, mt[100000][4], dp[100000][4];

int main() {
    cin >> n;

    for (int i = 1; i <= n; ++i)
        for(int j = 1; j <= 3; ++j)
            cin >> mt[i][j];

    dp[1][1] = mt[1][1];
    dp[1][2] = mt[1][2];
    dp[1][3] = mt[1][3];

    for (int i = 2; i <= n; ++i) {
        dp[i][1] += max (dp[i-1][2], dp[i-1][3]) + mt[i][1];
        dp[i][2] += max (dp[i-1][1], dp[i-1][3]) + mt[i][2];
        dp[i][3] += max (dp[i-1][1], dp[i-1][2]) + mt[i][3];
        //cout << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << '\n';
    }
  
    cout << max (dp[n][1], max(dp[n][2], dp[n][3]) );
    return 0;
}


Measured memory_bytes: 6200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class abc134_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int D = in.nextInt();

            int mans = (int) Math.ceil(N / ((D * 2) + 1));
            if (N % ((D * 2) + 1) != 0) {
                mans++;
            }
            out.println(mans);

        }

    }
}



Measured memory_bytes: 25044
#include <stdio.h>

int main(void){
    int n,i;
    scanf("%d\n",&n);
    int s[14]={0},h[14]={0},c[14]={0},d[14]={0};
    char mark;
    for(i=0; i<n; i++){
        int num;
        scanf("%c %d\n",&mark,&num);//???????????????????????¨?????????????????????
        switch(mark){
            case 'S'://"???7"??????s[7]=1??¨?????????????????????
                s[num]=1;
                break;
            case 'H'://??\?????£???????????§???????§??????????
                h[num]=1;
                break;
            case 'C':
                c[num]=1;
                break;
            case 'D':
                d[num]=1;
                break;
        }
    }
    for(i=1;i<=13;i++){//s[i]=0??¨?????£????????????????¶??????????????????¨?????????
        if(s[i]==0){
            printf("S %d\n",i);
        }
    }
    for(i=1;i<=13;i++){//h,c,d??§???????§??????????
        if(h[i]==0){
            printf("H %d\n",i);
        }
    }
    for(i=1;i<=13;i++){
        if(c[i]==0){
            printf("C %d\n",i);
        }
    }
    for(i=1;i<=13;i++){
        if(d[i]==0){
            printf("D %d\n",i);
        }
    }
    return 0; /*0?????????*/
}

Measured memory_bytes: 600
// https://atcoder.jp/contests/dp/tasks/dp_a
#include <iostream>
#include <vector>

int main()
{
    size_t n;
    std::cin >> n;
    std::vector<int> heights(n + 1, 0);
    std::vector<int> dp(n + 1, 0);
    for (size_t i = 1; i <= n; ++i)
    {
        std::cin >> heights[i];
    }
    dp[1] = 0;
    dp[2] = std::abs(heights[2] - heights[1]);
    for (size_t i = 3; i <= n; ++i)
    {
        dp[i] = std::min(std::abs(heights[i] - heights[i - 1]) + dp[i - 1], std::abs(heights[i] - heights[i - 2]) + dp[i - 2]);
    }
    std::cout << dp[n] << '\n';
    return 0;
}

Measured memory_bytes: 4048
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
  cin>>n>>m;
  vector<ll>a(n);
  rep(i,n){cin>>a[i];}
  Sort(a);
  ll Min=mod;
  rep(i,n-m+1){
  Min=min(Min,a[i+m-1]-a[i]);
  }
  cout<<Min<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

vector<P> input[100005];

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

    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int p, y;
        cin >> p >> y;
        input[p].push_back(P(y, i));
    }
    vector<P> output(m);
    for(int i = 1; i <= n; ++i){
        if(input[i].size() == 0)    continue;
        sort(input[i].begin(), input[i].end());
        int sz = input[i].size();
        for(int j = 0; j < sz; ++j){
            int id = input[i][j].second;
            output[id] = P(i, j+1);
        }
    }
    cout << fixed << setfill('0') << right << setw(6);
    for(int i = 0; i < m; ++i){
        cout << setfill('0') << right << setw(6) << output[i].first;
        cout << setfill('0') << right << setw(6) << output[i].second << "\n";
    }
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
int main()
{
  map<string,int>m;
  int n;
  cin>>n;
  while(n--)
  {
    string s;
    cin>>s;
     m[s]++;
  }
  cout<<"AC x "<<m["AC"]<<endl;
  cout<<"WA x "<<m["WA"]<<endl;
   cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int X;
int Y;
int A[500][500];
int ress;
int res1[250000];
int res2[250000];
int res3[250000];
int res4[250000];
void doit(int a, int b, int c, int d){
  if(A[a][b]%2==0){
    return;
  }
  A[c][d]++;
  A[a][b]--;
  res1[ress] = a+1;
  res2[ress] = b+1;
  res3[ress] = c+1;
  res4[ress] = d+1;
  ress++;
}
int main(){
  int i, j, k;
  rd(X);
  rd(Y);
  for(i=0;i<X;i++){
    for(j=0;j<Y;j++){
      rd(A[i][j]);
    }
  }
  for(i=0;i<X;i++){
    for(j=0;j<Y;j++){
      if(i==X-1 && j==Y-1){
        continue;
      }
      if(i%2==0){
        if(j==Y-1){
          doit(i,j,i+1,j);
        }
        else{
          doit(i,j,i,j+1);
        }
      }
      if(i%2==1){
        if(j==Y-1){
          doit(i,0,i+1,0);
        }
        else{
          doit(i,Y-1-j,i,Y-2-j);
        }
      }
    }
  }
  wt_L(ress);
  wt_L('\n');
  for(i=0;i<ress;i++){
    wt_L(res1[i]);
    wt_L(' ');
    wt_L(res2[i]);
    wt_L(' ');
    wt_L(res3[i]);
    wt_L(' ');
    wt_L(res4[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int X, Y, A[500][500];
// 
// int ress, res1[25d4], res2[25d4], res3[25d4], res4[25d4];
// 
// void doit(int a, int b, int c, int d){
//   if(A[a][b]%2==0) return;
//   A[c][d]++;
//   A[a][b]--;
//   res1[ress] = a+1;
//   res2[ress] = b+1;
//   res3[ress] = c+1;
//   res4[ress] = d+1;
//   ress++;
// }
// 
// {
//   int i, j, k;
//   rd(X,Y);
//   rep(i,X) rep(j,Y) rd(A[i][j]);
// 
//   rep(i,X) rep(j,Y){
//     if(i==X-1 && j==Y-1) continue;
//     if(i%2==0){
//       if(j==Y-1) doit(i,j,i+1,j);
//       else       doit(i,j,i,j+1);
//     }
//     if(i%2==1){
//       if(j==Y-1) doit(i,0,i+1,0);
//       else       doit(i,Y-1-j,i,Y-2-j);
//     }
//   }
// 
//   wt(ress);
//   rep(i,ress) wt(res1[i], res2[i], res3[i], res4[i]);
// }


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define watch(x) cout << #x << " is " << x << endl
#define print(a, l, r) \
    for (int i = l; i < r; i++) cout << a[i] << (i == (r - 1) ? endl : " ");
const ll M = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;

    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] != a[j])
                for (int k = j + 1; k < n; k++) {
                    if (a[j] != a[k] && a[i] != a[k] && (a[i] + a[j]) > a[k] && (a[i] + a[k]) > a[j] && (a[k] + a[j]) > a[i]) {
                        ans++;
                    }
                }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<set>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 30;

ll P[101010];
ll pos[101010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    rep(i, 0, N) {
        cin >> P[i];
        pos[P[i]] = i;
    }
    ll ans = 0;
    set<ll> pos_idx, neg_idx;
    pos_idx.insert(N);
    neg_idx.insert(1);
    rrep(p, N + 1, 1) {
        // 降順に見ていく
        auto one = pos_idx.upper_bound(pos[p]);
        ll idx1 = *one;
        ll idx2 = N;
        if (idx1 < N) {
            auto two = pos_idx.upper_bound(idx1);
            idx2 = *two;
        }
        auto three = neg_idx.upper_bound(-pos[p]);
        ll idx3 = -1 * (*three);
        ll idx4 = -1;
        if (idx3 >= 0) {
            auto four = neg_idx.upper_bound(-idx3);
            idx4 = -1 * (*four);
        }
        // P[idx3]が最大
        ll l = idx3 - idx4;
        ll r = idx1 - pos[p];
        ans += l * r * (ll)p;
        // P[idx1]が最大
        l = pos[p] - idx3;
        r = idx2 - idx1;
        ans += l * r * (ll)p;
        // idxを追加
        pos_idx.insert(pos[p]);
        neg_idx.insert(-pos[p]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

ll MOD = 1000000007;

map<int, int> get_factors(ll M) {
    int n = 2;
    map<int, int> ret;
    while(M != 1) {
        int cnt = 0;
        while (M % n == 0) {
            M /= n;
            ++cnt;
        }
        if (cnt != 0) {
            ret[n] = cnt;
        }
        if (n == 2) n = 3;
        else n += 2;
    }
    return ret;
}

// N個の席に、stone_num個の石を並べる場合の数
// 再帰が深すぎてNG
map<pair<int,int>,ll> cache;
ll func(ll N, int stone_num, int idx) {
    cout << N << "," << stone_num << "," << idx << endl;
    if (cache.count({stone_num,idx})) return cache[{stone_num,idx}];
    ll ans = 0;

    if (idx == N-1) {
        ans = 1;
    }
    else {
        REP(i, stone_num+1) {
            ans += func(N, stone_num - i, idx + 1);
            ans %= MOD;
        }
    }
    return cache[{stone_num,idx}] = ans;
}



// N個の席に、stone_num個の石を並べる場合の数
// 以下のように再帰できる
//   ある桁
//   0個残ってる: a
//   1個残ってる: b
//   2個残ってる: c
//   3個残ってる: d
//   次の桁
//   0個残ってる: a + b + c + d
//   1個残ってる: b + c + d
//   2個残ってる: c + d
//   3個残ってる: d

ll func2(ll N, int stone_num) {
    // [桁位置][残りの石数]
    vector<vector<ll>> dp(N+1, vector<ll>(stone_num + 1));

    dp[0][stone_num] = 1;

    FOR(n, 1, N + 1) {
        ll v = 0;
        for(int s = stone_num; s >= 0; --s) {
            v += dp[n-1][s];
            v %= MOD;
            dp[n][s] = v;
        }
    }
    return dp[N][0];
}

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    map<int, int> factors = get_factors(M);

    // for(auto kv: factors) {
    //     cout << kv.first << ": " << kv.second << endl;
    // }

    // M = 2^3 * 3^5 だとすると
    // 2はどこかに3つ、
    // 3はどこかに5つある
    ll ans = 1;
    for(auto kv: factors) {
        auto n = kv.first;
        auto cnt = kv.second;
        // ans *= func(N, cnt, 0);  // 再帰深すぎ
        ans *= func2(N, cnt);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    
    for (int i=0; i<n; i++) {
        string S; cin >> S;
        
        if (S.size()<4) {
            cout << "NA" << endl;
            continue;
        }
        
        if (S.substr(0, 2)==">'" && S[S.size()-1]=='~') {
            int mark = -1;
            for (int j=2; j<S.size()-1; j++) {
                if (S[j]=='#') mark = j;
            }
            bool flag = true;
            for (int j=2; j<S.size()-1; j++) {
                if (j==mark) continue;
                if (S[j]!='=') flag = false;
            }
            if (flag && mark!=-1 && mark-2==S.size()-2-mark && mark-2>0) cout << 'A' << endl;
            else cout << "NA" << endl;
        }
        else if (S[0]=='>' && S[1]=='^' && S[S.size()-2]=='~' && S[S.size()-1]=='~') {
            int idx = 2, cnt = 0;
            while (true) {
                if (S[idx]=='Q' && S[idx+1]=='=') {
                    cnt++;
                    idx += 2;
                }
                else break;
            }
            if (cnt>0 && idx==S.size()-2) cout << 'B' << endl;
            else cout << "NA" << endl;
        }
        else cout << "NA" << endl;
    }
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N, M, Q;
VI G[100000];
int vis[100000];
void bfs(int u, int d, int c, VI& ans){
  queue<int> q;
  q.push(u);
  if(vis[u] >= d) return;
  vis[u] = d;

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

	if(ans[u] == 0)
	  ans[u] = c;
	if(vis[u] == 0)
	  continue;

	for(int to: G[u]){
	  if(vis[to] >= vis[u] - 1) continue;
	  vis[to] = vis[u] - 1;
	  q.push(to);
	}
  }
}

int main(){
  scanf("%d%d", &N, &M);
  REP(i,M){
	int a, b;
	scanf("%d%d", &a, &b);
	--a;
	--b;
	G[a].PB(b);
	G[b].PB(a);
  }
  cin >> Q;
  VI vs(Q), ds(Q), cs(Q);
  REP(q,Q){
	scanf("%d%d%d", &vs[q], &ds[q], &cs[q]);
	--vs[q];
  }

  fill(ALL(vis), -1);
  VI ans(N);
  for(int q=Q-1;q>=0;--q){
	bfs(vs[q], ds[q], cs[q], ans);
  }
  
  REP(i,N) printf("%d\n", ans[i]);

  return 0;
}


Measured memory_bytes: 8824