akhauriyash/Code-Regression huggingface dataset:
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;
#[allow(dead_code)]
const N_PRIME : i64 = 1000000007;

////////////////////////////////////////////////

fn main(){
    let n = read_int() as usize;
    let mut xs = {
        let mut temp = vec![];
        for i in 0..n{
            let inputs = read_ints();
            let (a,b) = (inputs[0],inputs[1]);
            temp.push((a,b));
        }

        temp
    };

    xs.sort_by_key(|x|x.1);
    let mut now_time = 0;
    for x in xs{
        let (a,b) = x;
        now_time += a;
        if now_time > b{
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 9284
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <iostream>
#include <vector>
#include <deque>
#include <tuple>
#include <algorithm>
#include <iterator> // std::back_inserter
#include <climits>
#include <sstream>

using namespace std;

typedef long long ll;

#define m (1000000007L)
int main()
{
    ll n;
    cin >> n;
 
    ll a10N = 1;
    ll a9N = 1;
    ll a8N = 1;
    for (ll i=0; i<n; i++) {
       a10N = (a10N * 10) % m;
       a9N = (a9N * 9) % m;
       a8N = (a8N * 8) % m;
    }
    cout << (((a10N - ((2 * a9N) % m)) % m + a8N) + m )% m << endl;
//    cout << (((a10N - a9N) % m - a9N) %m + a8N) % m << endl;
//    cout << (((a10N + a8N) % m - a9N) %m - a9N) % m << endl;
 
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<Pi,int> Pii;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll a,b,c;
	ll total=0;

	cin>>a>>b>>c;

	if((a+b)<c){
		total=a+b+1;
		cout<<total+b<<endl;
	}else if((a+b)==c){
		cout<<c+b<<endl;
	}else if((a+b)>c){
		total=c;
		cout<<total+b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<32>(n);
    string s = ss.str();
    return s;
}
int main(){
    ll a, b;
    cin >> a >> b;
    
    cout << to_bin_string(a&b) << endl;
    cout << to_bin_string(a|b) << endl;
    cout << to_bin_string(a^b) << endl;
    return 0;
}


Measured memory_bytes: 3208
X = int(input())

if X >= 400 and X <= 599:
  print(8)
if X >= 600 and X <= 799:
  print(7)
if X >= 800 and X <= 999:
  print(6)
if X >= 1000 and X <= 1199:
  print(5)
if X >= 1200 and X <= 1399:
  print(4)
if X >= 1400 and X <= 1599:
  print(3)
if X >= 1600 and X <= 1799:
  print(2)
if X >= 1800 and X <= 1999:
  print(1)


Measured memory_bytes: 9120
#-------------------- fast io --------------------
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ns = lambda: stdin.readline().strip()
na = lambda: list(map(int, stdin.readline().split()))
ni = lambda: int(ns())

m = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
n = ni()
for i in range(n):
    m[ns()] += 1

print(f"AC x {m['AC']}")
print(f"WA x {m['WA']}")
print(f"TLE x {m['TLE']}")
print(f"RE x {m['RE']}")


Measured memory_bytes: 73648
N = int(input())
S = input()
#N = 12
#S = 'WEWEWEEEWWWE'


min = 1000000
e = S.count('E')
w = 0

for i in range(0,N):
    flag = 0
    now = S[i]
    if now == 'E':
        e = e - 1
    else:
        flag = 1
    sum = w + e
    if min > sum:
        min = sum
    if flag:
        w = w + 1
print(min)


Measured memory_bytes: 3700
#include <iostream>
#include <vector>

int main()
{
    int n,m;
    std::cin>>n>>m;
    std::vector<unsigned long long int> h(n);
    for (int i=0; i<n; i++) std::cin>>h[i];
    std::vector<bool> good(n,true);
    for (int i=0; i<m; i++)
    {
        int a,b;
        std::cin>>a>>b;
        if (h[b-1]>=h[a-1]) good[a-1]=false;
        if (h[a-1]>=h[b-1]) good[b-1]=false;
    }
    int cnt=0;
    for (int i=0; i<n; i++)
        if (good[i]) cnt++;
    std::cout<<cnt;
    return 0;
}

Measured memory_bytes: 3988
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

int a[100010];
//dp[i][j]:=i番目の子供にj個のあめを配る場合の数
ll dp[110][100010];
int sum[100010];

//解説AC
//https://atcoder.jp/contests/dp/submissions/4362880

int
main(void){  
  int n, k;
  cin >> n >> k;
  REP(i, n) cin >> a[i];

  /*
  dp[0][0] = 1;
  REP(i, n) REP(j, k){
    REP(l, a[i]+1){
      if(j-l >= 0){
	dp[i+1][j] += dp[i][j-l];
	dp[i+1][j] %= MOD;
      }
    }
  }
  */
  /*
  dp[0][0] = 1;
  FOR(i,1,n+1){
    sum[0] = 0;
    FOR(j,1,k+1) sum[j] = (sum[j-1]+dp[i-1][j-1])%MOD;
    //sum[j] = dp[i-1][0] + dp[i-1][1] + ... + dp[i-1][j-1]
    REP(j, k+1) dp[i][j] = (sum[j+1]-sum[max(0,j-a[i])]+MOD)%MOD;
  }
  */

  FOR(i, 0, a[0]+1) dp[0][i] = 1;
  FOR(i, 1, n){
    dp[i][0] = dp[i-1][0];
    FOR(j, 1, a[i]+1){
      dp[i][j] = (dp[i][j-1] + dp[i-1][j])%MOD;
    }
    FOR(j, a[i]+1, k+1){
      dp[i][j] = (dp[i][j-1]+dp[i-1][j])%MOD;
      dp[i][j] -= (dp[i-1][j-a[i]-1]);
      dp[i][j]%=MOD;
      if(dp[i][j] < 0) dp[i][j] += MOD;
    }
  }
  
  cout << dp[n-1][k] << endl;
  return 0;
}


Measured memory_bytes: 79744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
const int N=1e3+5;
const int S=1e4+5;
ll dp[N][S];
int w[N],s[N],v[N];
ll calc(int tr,int sss)
{
    if(tr==-1)
        return 0;
    if(dp[tr][sss]!=-1)
        return dp[tr][sss];
    dp[tr][sss]=calc(tr-1,sss);
    int ss=sss;
    if(ss==S-1)
        ss=s[tr];
    else
        ss=min(ss-w[tr],s[tr]);
    if(ss>=0)
        dp[tr][sss]=max(dp[tr][sss],v[tr]+calc(tr-1,ss));
    return dp[tr][sss];
}

int main()
{
    memset(dp,-1,sizeof(dp));
    int n;
    scanf("%i",&n);
    vector<pair<pair<int,int>,pair<int,int> > > lol(n);
    for(int i=0;i<n;i++)
        scanf("%i %i %i",&lol[i].s.f,&lol[i].f.s,&lol[i].s.s),lol[i].f.f=lol[i].f.s+lol[i].s.f;
    sort(all(lol));
    for(int i=0;i<n;i++)
    {
        w[i]=lol[i].s.f;
        s[i]=lol[i].f.s;
        v[i]=lol[i].s.s;
    }
    printf("%lld\n",calc(n-1,S-1));
    return 0;
}


Measured memory_bytes: 78848
#include <iostream>

using namespace std;
int main(void) {
  double sum = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    double value;
    string cur;
    cin >> value >> cur;
    sum += cur == "JPY" ? value : value * 380000.0;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

template <class T>
class point {
public:
    T x, y;
};

pair<point<double>, point<double>> sol(pair<point<double>, double> a, pair<point<double>, double> b) {
    double c[7] = {1, -2 * a.first.x, a.first.x * a.first.x, 1, -2 * a.first.y, a.first.y * a.first.y, a.second * a.second};
    double d[7] = {1, -2 * b.first.x, b.first.x * b.first.x, 1, -2 * b.first.y, b.first.y * b.first.y, b.second * b.second};
    for (int i = 0; i < 7; i++) c[i] = -c[i];
    for (int i = 0; i < 7; i++) c[i] += d[i];
    c[6] -= c[2]; c[6] -= c[5];
    //c[1] += 1e-12; c[4] += 1e-12;
    c[4] /= c[1]; c[6] /= c[1]; c[1] = 1;
    double e[10] = {c[6] * c[6], -2 * c[4] * c[6], c[4] * c[4], -2 * a.first.x * c[6], 2 * a.first.x * c[4], a.first.x * a.first.x, 1, -2 * a.first.y, a.first.y * a.first.y, a.second * a.second};
    double f[3] = {e[2] + e[6], e[1] + e[4] + e[7], e[0] + e[3] + e[5] + e[8] - e[9]};
    double g[2] = {(-f[1] + sqrt(f[1] * f[1] - 4 * f[0] * f[2] + 1e-12)) / (2 * f[0] + 1e-12), (-f[1] - sqrt(f[1] * f[1] - 4 * f[0] * f[2] + 1e-12)) / (2 * f[0] + 1e-12)};
    double h[2] = {c[6] - c[4] * g[0], c[6] - c[4] * g[1]};
    return {{h[0], g[0]}, {h[1], g[1]}};
}

int main() {
    ios::sync_with_stdio(false);
    int n, k, c[64] = {};
    double x[64] = {}, y[64] = {}, u = 0, v = 200000;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> c[i];
    for (int t = 0; t < 100; t++) {
        double m = (u + v) / 2, r[64] = {};
        int z = 0;
        for (int i = 0; i < n; i++) r[i] = m / c[i];
        for (int i = 0; i < n; i++) {
            int b = 0;
            for (int j = 0; j < n; j++) {
                if (hypot(x[i] - x[j], y[i] - y[j]) < r[j] + 1e-15) b++;
            }
            z = max(z, b);
            for (int j = 0; j < n; j++) if (j != i) {
                double d = hypot(x[i] - x[j], y[i] - y[j]);
                if (d < r[i] + r[j] - 1e-9) {
                    if (d > abs(r[i] - r[j]) + 1e-9) {
                        pair<point<double>, point<double>> w = sol({{x[i], y[i]}, r[i]}, {{x[j], y[j]}, r[j]});
                        //cout << r[i] << ' ' << r[j] << ' ' << i << ' ' << j << ' ' << w.first.x << ' ' << w.first.y << ' ' << w.second.x << ' ' << w.second.y << '\n';
                        b = 0;
                        for (int l = 0; l < n; l++) {
                            if (hypot(w.first.x - x[l], w.first.y - y[l]) < r[l] + 1e-9) b++;
                        }
                        z = max(z, b);
                        b = 0;
                        for (int l = 0; l < n; l++) {
                            if (hypot(w.second.x - x[l], w.second.y - y[l]) < r[l] + 1e-9) b++;
                        }
                        z = max(z, b);
                    }
                }
            }
        }
        if (z >= k) v = m;
        else u = m;
    }
    cout << setprecision(13) << u;
}


Measured memory_bytes: 3864
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()

  val y = s.split("/").getOrElse(0) { "" }.toInt()
  val m = s.split("/").getOrElse(1) { "" }.toInt()
  val d = s.split("/").getOrElse(2) { "" }.toInt()


  if (y <= 2019 && m <= 4 && d <= 30) {
    println("Heisei")
    return
  }

  println("TBD")

}


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

bool comp(ll a, ll b) {
  return a>=b;
}

int main()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> A(N);
  for(int i=0; i<N; i++){
    scanf("%lld",&A[i]);
  }

  deque<ll> d;
  for (int i=0; i<N; i++) {
    int p = lower_bound(d.begin(), d.end(), A[i]) - d.begin();
    if (p == 0) d.push_front(A[i]);
    else d[p-1] = A[i];
  }
  cout << d.size() << endl;

  return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;
  int count = s.size() - t.size() + 1;
  vector<long long int> wa(count);
  int size = t.size();
  rep(i, count){
    rep(j, t.size()){
      char S, T;
      S = s.at(i + j); T = t.at(j);
      if(S != T) wa[i]++;
    }
  }
  Vsort(wa);
  cout << wa[0] << endl;
}


Measured memory_bytes: 3580
#include <stdio.h>

int main(void){
    char s[4];
    scanf("%s", s);
    int ans = 0;
    for (int i = 0; i < 3; i++){
        if(s[i] == 'o') ans += 1;
    }
    printf("%d\n", ans * 100 + 700);
    return 0; 
}

Measured memory_bytes: 128
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**9 + 7

def main():
  s = input().strip()
  p = 13
  dp = [[0]*p for _ in range(len(s))]
  remains = [[0]*p for _ in range(6)]
  for i in range(6):
    for j in range(p):
      remains[i][j] = ((10 ** i) * j) % p
    
  if s[-1] == '?':
    dp[0][:10] = [1] * 10
  else:
    dp[0][int(s[-1])] = 1
    
  for i, c in enumerate(s[::-1][1:], 1):
    if c == '?':
      for c in range(10):
        for j in range(p):
          dp[i][(remains[i%6][c] + j) % p] += (dp[i-1][j] % MAX) 
    else:
      c = int(c)
      for j in range(p):
        dp[i][(remains[i%6][c] + j) % p] += (dp[i-1][j] % MAX) 
        
  print(dp[-1][5] % MAX)
  
if __name__=='__main__':
  main()



Measured memory_bytes: 62684
package main

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

func main() {
	N := getStdinInt()
	c := getStdin()

	ridx := N - 1
	widx := 0
	cnt := 0
	for i := 0; widx < N && ridx >= 0; i++ {
		if widx > ridx {
			break
		}

		w := -1
		if c[widx] == 'W' {
			w = widx
		} else {
			widx++
		}

		r := -1
		if c[ridx] == 'R' {
			r = ridx
		} else {
			ridx--
		}

		if r != -1 && w != -1 {
			widx++
			ridx--
			cnt++
		}
	}

	fmt.Printf("%d\n", cnt)
}

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

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2788
N = int(input())
S = input()

alBlack = S.count('.')
alWhite = S.count('#')

#どこで区切るかの問題

#累積和

accumB = [] #N個目の石までに含まれる黒の数
#[0]～[N-1]で取り出す

cnt = 0
for i in range(N): #0~N-1でN回ループする
  if S[i] == '#': #黒なら+1,白ならそのまま格納
    cnt += 1
  accumB.append(cnt)

minRev = N #最小ひっくり返し数。ただし端は考えない
for i in range(1, N, 1): #スライサーは1～N-1
  #左側と右側のひっくり返し数
  leftRev = accumB[i-1] #すぐ左の累積黒
  rightRev = N - accumB[N-1] - (i - accumB[i-1])
  #右端の累積白-すぐ左の累積白
  # = 文字数-右端の累積黒 - (スライサー-すぐ左の累積黒)
  minRev = min(minRev, leftRev+rightRev)
  
print(min(minRev,alBlack,alWhite))

Measured memory_bytes: 11368
H, W = map(int, input().split())
l = [input() for i in range(H)]

result = []
for h in range(H):
    result.append([])
    for w in range(W):
        count = 0
        if l[h][w] == '#':
            result[h].append('#')
            continue

        # 対象の右
        if W - 1 != w and l[h][w + 1] == '#':
            count += 1

        # 対象の右下
        if W - 1 != w and H - 1 != h and l[h + 1][w + 1] == '#':
            count += 1

        # 対象の下
        if H - 1 != h and l[h + 1][w] == '#':
            count += 1

        # 対象の左下
        if 0 < w and H - 1 != h and l[h + 1][w - 1] == '#':
            count += 1

        # 対象の左
        if 0 < w and l[h][w - 1] == '#':
            count += 1

        # 対象の左上
        if 0 < w and 0 < h and l[h - 1][w - 1] == '#':
            count += 1

        # 対象の上
        if 0 < h and l[h - 1][w] == '#':
            count += 1

        # 対象の右上
        if W - 1 != w and 0 < h and l[h - 1][w + 1] == '#':
            count += 1

        result[h].append(str(count))
    print(''.join(result[h]))

Measured memory_bytes: 3188
def main():
    n=int(input())
    x=list(map(int,input().split()))
    sx = sorted(x)
    lx = len(x)//2
    m = sx[lx]
    _m = sx[lx-1] if 0 < m-1 else sx[0]
    for i in x:
        print(m if i<m else _m)

if __name__ == "__main__":
    main()

Measured memory_bytes: 30820
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;

void file() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    if (freopen("input.txt", "r", stdin));
    if (freopen("output.txt", "w", stdout));
#endif
}


ll n, w;
vector < pair < ll, int > > v;
ll mem[101][100001];

ll solve(int idx, int still) {
    if (idx == n && !still)return 0;
    if (idx == n)return 1e10;

    ll& ret = mem[idx][still];
    if (~ret)
        return ret;

    ret = 1e10;
    ret = min(ret,solve(idx + 1, still));
    if (v[idx].second <= still)
        ret = min(ret, solve(idx + 1, still - v[idx].second) + v[idx].first);

    return ret;
}

int main() {
    //file();

    memset(mem, -1, sizeof mem);
    cin >> n >> w;
    v.resize(n);
    for (auto& e : v)
        cin >> e.first >> e.second;

    for(int i = 1e5 ; i >= 0 ;i--)
        if(solve(0,i)<=w)stop(i)

}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
int main() {
    ll n;
    cin >> n;
    vector<ll> r(n);
    vector<ll> c(n);
    rep(i,n){
        cin >> r[i] >> c[i];
    }

    vector<vector<ll>> dp(n,vector<ll>(n,INF));
    rep(i,n){
        dp[i][i] = 0;
    }
    rep(i,n){
        rep(j,n-i-1){
            rep(k,i+1){
                chmin(dp[j][j+i+1],dp[j][j+k]+dp[j+k+1][j+i+1] + r[j]*c[j+k]*c[j+i+1]);
                //chmin(dp[i][j],dp[i][i+k]+dp[i+k+1][j] + r[i]*c[i+k]*c[j]);
            }
        }

    }

    cout <<dp[0][n-1]<<endl;;
    return 0;
    

}


Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h>
int main(void){
    double r;
    double a,b;
    
    scanf("%lf",&r);

    /*面積aを求める*/
    a = r * r * M_PI;

    /*円周bを求める*/
    b = 2 * r * M_PI;

    printf("%lf %lf\n",a,b);

    return 0;
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
#include<typeinfo>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
//#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 
lli mod;
lli power(lli x,lli y)
{
     lli res=1;
     while(y>0)
     {
        if(y&1)res = ((res%mod)*(x%mod))%mod;
        y>>=1;
        x= ((x%mod)*(x%mod))%mod;
     }
     return res;
}

int main()
{
   
         

    fio

    lli n,x,m;
    cin>>n>>x>>m;

    
    mod=m;
    

    map<lli,lli> h;
    lli dp[100010]={0};

    lli start=-1,end=-1;
    h[x]=0;
    dp[0]=x%m;
    fr(i,0,n-1)
    {
       lli o = power(x,2);
       if(h.count(o)==0){h[o]=i+1;dp[i+1]=o;}
       else {start=h[o],end=i+1;break;}
       x=o;
       //cout<<x<<'\n';
    }

    lli ans=0;
    if(start==-1)
        {for(auto z:h)ans+=z.first;cout<<ans<<'\n';}
    else
    {

        //cout<<start<<" "<<end<<'\n';
       n=n-start;
       lli o =0;
       fr(i,0,start)ans+=dp[i];
       fr(i,start,end)o+=dp[i];
       lli z=(n%(end-start));
       ans+=(n/(end-start))*o;
       fr(i,start,z+start)ans+=dp[i];
       cout<<ans;
    }





  
     

    


     

     


    
      




 

return 0;}

Measured memory_bytes: 7508
I=lambda:map(int,input().split())
N=0xfffff
n,q=I()
c=list(I())
Q=[]
for i in range(q):l,r=I();Q.append(l<<40|r<<20|i)
Q.sort()
A=[[]for i in range(N)]
for i in range(n):A[c[i]].append(i)
B=[0]*N
def P(i,x):
	i+=1
	while i<=n:B[i]+=x;i+=i&-i
def G(i):
	s=0
	while i:s+=B[i];i-=i&-i
	return s
for i in A:
	if i:P(i[0],1);i.reverse()
t=0
o=[0]*q
for x in Q:
	l=x>>40
	r=x>>20&N
	i=x&N
	while t+1<l:
		b=A[c[t]]
		P(b[-1],-1)
		b.pop()
		if b:P(b[-1],1)
		t+=1
	o[i]=G(r)-G(l-1)
for i in o:print(i)

Measured memory_bytes: 248656
import sys

mp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = sorted(input().split(), reverse=True)

    dp = [-10007] * (n + 1)
    dp[0] = 0
    for i in a:
        step = mp[int(i)]
        for j in range(step, n + 1):
            dp[j] = max(dp[j - step] + 1, dp[j])

    i = n
    while i > 0:
        for x in a:
            step = mp[int(x)]
            if i >= step and dp[i - step] == dp[i] - 1:
                sys.stdout.write(x)
                i -= step
                break
    print()


Measured memory_bytes: 3828
#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>;

vector<int> g[100010];
int res[100010];
vector<int> C(100010);
int n,m;

void dfs(int v,int c){
  if(C[v]==-1){
    C[v]=c;
    res[c]++;
    for(auto e:g[v]) dfs(e,c^1);
  }else	if(C[v]!=-1) {
		if(C[v]!=c) {
			cout<<1LL*n*(n-1)/2-m<<endl;
			exit(0);
		}
	}
}

int main(){
  cin >>n>>m;
  fill(C.begin(),C.end(),-1);
  rep(i,m){
    int a,b;
    cin >> a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0,0);
  cout<<1LL*res[0]*res[1]-m<<endl;
}

Measured memory_bytes: 9156
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(ll a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);


ll foo(ll a ,ll b)
{
    ll z = a*a*a*a + a*a*a*b + a*a*b*b +a*b*b*b +b*b*b*b;
    return z;
}





// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(x)
    ve(ll) factors;
    ll temp = x;
    f(i,2,sqrt(temp))
    {
        if(temp % i == 0)
        {
            factors.push_back(i);
            factors.push_back(temp / i);
        }
    }
    if(sqrt(temp) * sqrt(temp)  == temp) factors.push_back(sqrt(temp));
    // foto(xx,factors)
    // {
    //     ll rem = x/xx;
    //     f(a,0,1e3)
    //     {
    //         ll b = a - xx;
    //         if(foo(a,b) == rem)
    //         {
    //             cout<<a<<" "<<b;
    //             break;
    //         }
    //     }
    // }

    f(a, -1000 , 1000)
    {
        // ll c = a*a*a*a*a;
        // c = c - x ;
        f(b, -1000 , 1000)
        {
            if((a*a*a*a*a - b*b*b*b*b) == x)
            {
                cout<<a<<" "<<b;
                return 0 ;
            }
        }
    }
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


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

int main() {
  int N;
  cin >> N;
  int rest = N;
  
  int divisor = 0;
  while (rest > 0) {
    int remainder;
    remainder = rest % 10;
    divisor += remainder;
    rest /= 10;
  }
  
  if (N % divisor == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 100000000000000000
#define mod 1000000007
#define omarshagar                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL); //freopen("output.txt","w",stdout);freopen("b_small.in","r",stdin);
using namespace std;
 
	int n;
	ll arr[100005][3];
	ll memo[100005][3];
 ll solve(int row,int col)
 {
	 if(col<0||col>2)return -INF;
	 if(row==n)return 0;
	 if(memo[row][col]!=-1)return memo[row][col];
	 return memo[row][col]=max(max(solve(row+1,col+1),solve(row+1,col-1)),max(solve(row+1,col+2),solve(row+1,col-2)))+arr[row][col];
 }
int main()
{
	omarshagar;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int ii=0;ii<3;ii++)
		{
			cin>>arr[i][ii];
			memo[i][ii]=-1;
		}
	}
	ll mx=-1;
	for(int i=0;i<3;i++)
	{
		mx=max(mx,solve(0,i));
	}
	cout<<mx<<endl;
	
		return 0;
}

Measured memory_bytes: 12800
def make_divisors(n):
    '''
    nの約数の配列を返す
    '''
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def solve():
    N = int(input())
    D = make_divisors(N)
    ans = N - 1
    for d in D:
        ans = min(ans, N // d - 1 + d - 1)
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 65624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  int T;
  int num = 1e7;
  
  cin >> N >> T;
  
  vector<int> c(N);
  vector<int> t(N);
  
  for(int i = 0;i < N;++i){
    cin >> c[i] >> t[i];
  }
  
  for(int i = 0;i < N;++i){
    if(t[i] <= T){
     num = min(num,c[i]);
    }
  }
  
  if(num == 1e7){
    cout << "TLE" << endl;
  }
  else{
    cout << num << endl;
  }
      
}



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

int main() {
  int N;

  cin >> N;
  for(int i=1;i<=N;++i){
    int s = (int)(i*1.08);
    if(s==N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

int main()
{
ll n ;
cin >> n ;
vector<ll> x(n+1);
rep(i, n){
  cin >> x[i];
}
x[n]=INF;
ll l , q ;
cin >> l >> q ;
vector<vector<ll>> dub(20, vector<ll>(n,0) );
ll st=0,en=1;
rep(i,n-1){
  while(en!=n-1&&x[en+1]-x[i]<=l)en++;
  dub[0][i]=en;
}
dub[0][n-1]=-1;
ll dep;
rep(i,19){
  rep(j,n){
    if(dub[i][j]==-1)dub[i+1][j]=-1;
    else dub[i+1][j]=dub[i][dub[i][j]];
  }
  if(dub[i+1][0]==-1){
    dep=i;
    break;
  }
}

vector<ll> anss;
rep(ii,q){
  ll a , b ;
  cin >> a >> b ;
  a--;b--;
  if(a>b)swap(a,b);
  ll ans=0;
  for (ll i = dep; i >= 0; i--)
  {
    if(0<dub[i][a] && x[dub[i][a]] <x[b]){
      ans+=1LL<<i;
      a=dub[i][a];
    }
  }
  anss.push_back(ans+1);
}
for(auto an:anss){
  cout << an << endl;
  
}
return 0;
}

Measured memory_bytes: 19056
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n+1];
        h[0] = 0;
        for(int i = 1; i < n + 1; i++){
            h[i] = sc.nextInt();
        }

        int[] dp = new int[100005];

        for(int i = 2; i< n+1; i++){
            dp[i] = dp[i-1]+Math.abs(h[i-1]-h[i]);

            for(int j = 2; j < k+1; j++){
                if(i-j>=1){
                    dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(h[i-j]-h[i]));
                }
            }
        }

        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 50800
#include <stdio.h>

int main(void) {
    int a,b,c,n,count=0;
    scanf("%d %d %d",&a,&b,&c);
    for (n = a; n <= b ;n++){
        if (c % n == 0) count++;
    }
    printf("%d\n",count);
    return 0;
}

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

const int MAXN = 105;
char s[MAXN][MAXN];
int d[MAXN][MAXN];
int dx[] = {0, 1};
int dy[] = {1, 0};

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }
    memset(d, 0x3f, sizeof(d));

    std::deque<int> q;
    q.push_back(0);
    d[0][0] = s[0][0] == '#';
    while (!q.empty()) {
        int u = q.front();
        int x = u / m, y = u % m;
        q.pop_front();
        for (int i = 0; i < 2; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx >= n || ny >= m) continue;
            if (s[x][y] == '.' && s[nx][ny] == '#') {
                if (d[nx][ny] > d[x][y] + 1) {
                    d[nx][ny] = d[x][y] + 1;
                    q.push_back(nx * m + ny);
                }
            } else {
                if (d[nx][ny] > d[x][y]) {
                    q.push_front(nx * m + ny);
                    d[nx][ny] = d[x][y];
                }
            }
        }
    }
    printf("%d\n", d[n - 1][m - 1]);
}

Measured memory_bytes: 256
#include<cstdio>
const int maxn=1000010,maxm=1000010;
int n,m,a[maxm],b[maxm];
bool G[1111][1111];
int bf(){
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)G[i][j]=0;
	for(int i=0;i<m;i++)G[a[i]][b[i]]=1,ans++;
	for(;;){
		bool fl=1;
		for(int x=0;x<n;x++)for(int y=0;y<n;y++)if(!G[x][y]){
			for(int z=0;z<n&&!G[x][y];z++)if(G[y][z]&&G[z][x])G[x][y]=1,fl=0,ans++;
		}
		if(fl)break;
	}
	return ans;
}
struct edge{int to,w;edge*next;}E[maxm*2],*ne,*fir[maxn];
void link(int u,int v,int w){*ne=(edge){v,w,fir[u]};fir[u]=ne++;}
int vis[maxn];
int dfs(int i,int j,int*sz){
	sz[vis[i]=j]++;
	int es=0,tmp;
	for(edge*e=fir[i];e;e=e->next,es<0?1:es++){
		if(vis[e->to]<0)(tmp=dfs(e->to,(j+e->w)%3,sz))<0||es<0?es=-1:es+=tmp;
		else if(vis[e->to]!=(j+e->w)%3)es=-1;
	}
	return es;
}
long long solve(){
	ne=E;
	for(int i=0;i<n;i++)fir[i]=0,vis[i]=-1;
	for(int i=0;i<m;i++){
		link(a[i],b[i],1);
		link(b[i],a[i],2);
	}
	long long s=0;
	for(int i=0;i<n;i++)if(vis[i]<0){
		int sz[3]={0};
		int es=dfs(i,0,sz);
		if(es<0)s+=1ll*(sz[0]+sz[1]+sz[2])*(sz[0]+sz[1]+sz[2]);
		else if(!sz[1]||!sz[2])s+=es/2;
		else s+=1ll*sz[0]*(sz[1]+sz[2])+1ll*sz[1]*sz[2];
	}
	return s;
}
int main(){
	//freopen("in.txt","r",stdin);
	while(scanf("%d%d",&n,&m)==2){
		for(int i=0;i<m;i++)scanf("%d%d",a+i,b+i),--a[i],--b[i];
		/*
		if(bf()!=solve()){
			printf("%d %d\n",n,m);
			for(int i=0;i<m;i++)printf("%d %d\n",a[i]+1,b[i]+1);
			printf("%d\n%lld\n",bf(),solve());
			return 0;
		}
		*/
		printf("%lld\n",solve());
	}
	//printf("ok\n");
}

Measured memory_bytes: 19584
#include <stdlib.h>
#include <stdio.h>

int main() {
  int n, cnt;
  while (scanf("%d", &n) == 1) {
    cnt = 0;
    for (int a = 0; a < 10; a++) {
      for (int b = 0; b < 10; b++) {
        for (int c = 0; c < 10; c++) {
          for (int d = 0; d < 10; d++) {
            if ((a + b + c + d) == n) {
              cnt++;
            }
          }
        }
      }
    }

    printf("%d\n", cnt);
  }
}

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

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

using namespace std;

int main(){
  ll n;cin>>n;

  map<pair<int, int>, int>m;
  rep(i,n){
    int c=i+1;
    if(c%10==0)continue;

    int r = c%10;
    int l = (int)(to_string(c)[0] - '0');
    m[make_pair(l, r)]++;
  }

  ll result=0;
  rep(i,n){
    int c=i+1;
    if(c%10==0)continue;
    int r = c%10;
    int l = (int)(to_string(c)[0] - '0');
    result+=m[make_pair(r, l)];
  }

  cout<<result;

  return 0;
}

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

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,t;
    cin>>x>>t;
    (x-t<=0) ? cout<<0 : cout<<x-t;
    cout<<endl;
}

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

int main(){
    int N;
    string S;
    std::map<std::string, int> dic;
    int max = 0;
    string tmp;
    int tmp_i;

    std::cin >> N;

    for(int i = 0; i < N; i++){
        std::cin >> S;

        if(dic.count(S)){
            dic[S] = dic[S] + 1;
        }else{
            dic[S] = 1;
        }
        if(dic[S] > max){
            max = dic[S];
        }
    }

    //std::cout << "------------------" << "\n";

    auto iter = dic.begin();
    N = dic.size();
    for(int i = 0; i < N; i++){
        tmp_i = iter->second;
        if(tmp_i == max){
            std::cout << iter->first << "\n";
        }
        iter = std::next(iter,1);
    }


}


Measured memory_bytes: 19256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

ll modpow(ll a, ll n, ll mod) {
  ll res(1);
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

void solve(ll N) {
  ll ans = modpow(10, N, MOD) - 2 * modpow(9, N, MOD) + modpow(8, N, MOD);
  ans %= MOD;
  if (ans < 0)
    ans += MOD;
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  solve(N);

  return 0;
}


Measured memory_bytes: 3640
s=gets.chomp
t=s.delete(?x)
res=0
if t.reverse == t
  i=0
  j=1
  l=s.size
  while(i+j < l)do
    while(s[i]!=s[-j]) do
      res+=1
      (s[i]== ?x) ? i+=1 : j+=1
    end
    i+=1
    j+=1
  end
  p res
else
  p -1
end


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

int main() {
  int N, K;
  int number = 1;
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    if(number > K) {
      number += K;
    }
    else {
      number *= 2;
    }
  }
  cout << number << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BFoodsLovedByEveryone {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] arr = new int[m + 1];
            for (int i = 0; i < n; i++) {
                int k = in.nextInt();
                for (int j = 0; j < k; j++) {
                    arr[in.nextInt()]++;
                }
            }
            int count = 0;
            for (int i = 0; i <= m; i++) {
                if (arr[i] == n) {
                    count++;
                }
            }
            out.println(count);

        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 22740
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n: usize, s: chars);
    let mut nxt = vec![[n; 10]; n + 2];
    for i in (0..n).rev() {
        nxt[i] = nxt[i + 1];
        let c = (s[i] as u8 - b'0') as usize;
        nxt[i][c] = i;
    }
    let mut ans = 0;
    for i in 0..1000 {
        let mut cur = 0;
        let mut v = i;
        for _ in 0..3 {
            let idx = v % 10;
            v = v / 10;
            cur = nxt[cur][idx] + 1;
        }
        if cur <= n {
            ans += 1;
        }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

int main(){
  char A[100] ,B[100] , C[100];

  cin >> A >> B >> C;

  char D[100];

  D[0] = 'A';
  D[1] = B[0];
  D[2] = 'C';

  cout << D <<endl;
}

									   
  


Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
const int nax = 1e6 + 5;
int child[nax][26];
bool is_end[nax];
int nxt = 1;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> in(n);
    vector<vector<int>> paths(n);
    for(int who = 0; who < n; ++who) {
        string& s = in[who];
        cin >> s;
        reverse(s.begin(), s.end());
        int node = 0;
        for(char ch : s) {
            paths[who].push_back(node);
            if(child[node][ch-'a'] == 0) {
                child[node][ch-'a'] = nxt++;
            }
            node = child[node][ch-'a'];
        }
        is_end[node] = true;
    }
    long long answer = 0; // 'int' is enough
    for(int who = 0; who < n; ++who) {
        string& s = in[who];
        set<char> suffix;
        for(int i = (int) s.length() - 1; i >= 0; --i) {
            suffix.insert(s[i]);
            int node = paths[who][i];
            for(char ch : suffix) {
                answer += is_end[child[node][ch-'a']];
            }
        }
    }
    printf("%lld\n", answer - n); // subtract pairs (s[i], s[i])
}

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

int main(){
    int num[4]={};
    int a = 0;
    scanf("%d %d %d %d %d",&num[0],&num[1],&num[2],&num[3],&num[4]);
    for (int i=0;i <= 4;i++){
        if (num[i] == 0){
            a = i + 1;
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<map<int,bool>> t(n);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    for(int ai=0;ai<a;ai++){
      int x;
      bool y;
      cin>>x>>y;
      t.at(i)[x-1]=y;
    }
  }
  vector<bool> h(n);
  int m=0;
  for(int i;i<(1<<n);i++){
    int x=i;
    int s=0;
    bool f=1;
    for(int d=0;d<n;d++){
      h.at(d)=x%2;
      s+=h.at(d);
      x/=2;
    }
    for(int d=0;d<n;d++)
      if(h.at(d))
        for(auto ti:t.at(d))
          if(h.at(ti.first)!=ti.second)
            f=0;
    if(f)
      m=max(m,s);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
N=int(input())
P=[float(i) for i in input().split()]
dp=[[0]*(N+1) for i in range(N+1)]
dp[0][0]=1
for n in range(1,N+1):
    dp[n][0]=dp[n-1][0]*(1-P[n-1])
    for j in range(1,n+1):
        dp[n][j]=dp[n-1][j]*(1-P[n-1])+dp[n-1][j-1]*(P[n-1])
m=N//2
ans=0
for i in range(m+1,N+1):
    ans+=dp[N][i]
print(ans)

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

int main() {
  int N,K;
  cin >> N >> K;
  int a = 1;
  for(int i = 0 ; i < N ; i++) {
    if (a < K)
      a *= 2;
    else
      a += K;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);
        String input = scanner.next();
        scanner.close();
        char[] chr = {input.charAt(0), input.charAt(1), input.charAt(2)};
        if(chr[0]!=chr[1] || chr[0]!=chr[2] || chr[1]!=chr[2]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 22228
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

import qualified Data.Map.Strict as Map

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	m1 <- readMap
	m2 <- readMap
	putStrLn $ which "YES" "NO" $ Map.isSubmapOfBy (<=) m2 m1

readMap :: IO ( Map.Map Int Int )
readMap = getLine >> getList >>= return . foldl' f Map.empty

f m a
	| Map.lookup a m /= Nothing = Map.adjust succ a m
	| otherwise = Map.insert a 1 m


Measured memory_bytes: 66940