akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
//#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 2001; //check the limits, dummy
int N,X,Y;
vi v[MX];
unordered_map<int, int> m;
vi visit(MX);
int nd=-1;
unordered_map<int, int> ct;
int mp(int a,int b)
{
	return (a+b+1)*(a+b)/2+a;
}
int mod(int x)
{
	if(x<0)
		return -x;
	else
		return x;
}

void calc(int S,int level)
{
//	 if(m.find(mp(S,nd))!=m.end())
//	 {
//	 	return;
//	 }
//	if(S!=nd)
//		m[mp(nd,S)]=mod(nd-S)>level?level:mod(nd-S);
	visit[S]=1;
	if(m.find(mp(nd,S))==m.end())
	{
		m[mp(nd,S)]=min(level,mod(nd-S));
	}
	else
	{
		int val=m[mp(nd,S)];
		if(level<val)
			m[mp(nd,S)]=level;
	}
	for(int x=0;x<v[S].size();x++)
	{
		if(/*v[S][x]>S && */visit[v[S][x]]==0)
		{
			calc(v[S][x],level+1);
		}
	}
	visit[S]=0;
	return;
}
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    cin>>N>>X>>Y;
	FOR(x,1,N)
	{
		v[x].pb(x+1);
		v[x+1].pb(x);
	}
	v[X].pb(Y);
	v[Y].pb(X);
	FOR(x,1,N+1)
	{
		nd=x;
		calc(x,0);
		FOR(y,x+1,N+1)
		{
			if(x!=y)
			{
				ct[m[mp(x,y)]]++;
			}
		}
	}
	F0R(x,N-1)
	{
		cout<<ct[x+1]<<endl;
	}
	return 0;
}
 


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);
}

const int N = 1e5 + 9, M = 2e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int ok[N];
int main(){
    init();

    int n, k;   cin >> n >> k;
    for(int i = 0;i < k;i++){
        int d;  cin >> d;
        while(d--){
            int x;  cin >> x;
            ok[x]++;
        }
    }

    int ans = 0;
    for(int i = 1;i <= n;i++)   ans += ok[i] == 0;

    cout << ans;
}




Measured memory_bytes: 3652
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")

#include <cstdio>
#include <vector>
#include <bitset>

using namespace std;

using int64 = long long;

template<class T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

int main() {
  int n; int64 k; fastin(n); fastin(k);
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) fastin(a[i]);

  vector<int> dp(60, 0);
  // dp[i] : i 桁目の bit が立っている a_i がいくつあるか

  for (int i = 0; i < n; ++i) {
    bitset<50> bit(a[i]);
    for (int j = 0; j < 50; ++j) {
      if (bit.test(j)) {
        ++dp[j];
      }
    }
  }

  int64 ans = 0;
  int64 tmp = 0;
  for (int i = 0; i < n; ++i) {
    tmp += (a[i] ^ k);
  }

  ans = tmp;

  for (int i = 49; i >= 0; --i) {
    bitset<50> kbit(k);
    if (kbit.test(i)) {
      kbit.reset(i);
      for (int j = i - 1; j >= 0; --j) {
        if (dp[j] > n - dp[j]) {
          kbit[j] = 0;
        } else {
          kbit[j] = 1;
        }
      }
      int64 best = kbit.to_ullong();
      int64 t = 0;
      for (int j = 0; j < n; ++j) {
        t += (best ^ a[j]);
      }
      ans = max(ans, t);
    }
  }
  
  printf("%lld\n", ans);

  return 0;
}

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

using ll = long long;
using P = pair<int,int>;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(obj) sort((obj).begin(), (obj).end())
#define impact_limit first
#define quantity second


signed main() {
  int n, bomb_impact_range, one_bomb_power;
  cin >> n >> bomb_impact_range >> one_bomb_power;
  bomb_impact_range *= 2;
  vector<P> foxes(n);
  
  REP(i,n) {
    int position, hp;
    cin >> position >> hp;
    foxes[i] = P(position, hp);
  }
  SORT(foxes);
  
  ll ans = 0;
  queue<P> current_bombs; // impact_limit quantity
  ll current_bomb_power = 0;

  REP(i, n) {
    int current_position = foxes[i].first;
    int hp = foxes[i].second;
    while(true) {
      if(current_bombs.empty()) break;
      if(current_bombs.front().impact_limit >= current_position) break;

      current_bomb_power -= one_bomb_power * current_bombs.front().quantity;
      current_bombs.pop();
    }
    hp -= current_bomb_power;
    if(hp <= 0) continue;
    
    int extra_bombs = ceil((double) hp / one_bomb_power);
    ans += extra_bombs;
    
    current_bombs.push(P(current_position+bomb_impact_range, extra_bombs));
    current_bomb_power += one_bomb_power * extra_bombs;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 2688
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

n = int(input())
prime_factors = factorization(n)
# print(prime_factors)

if n == 1:
  print(0)
  exit()

counter = 0
for factor in prime_factors:
  factor_num = factor[1]
  power = 1
  while factor_num - power >= 0:
    factor_num -= power
    counter += 1
    power += 1

print(counter)

Measured memory_bytes: 9492
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`


				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	s := next()
	t := next()

	if t[:len(t)-1] == s {
		fmt.Fprintln(out, "Yes")
	} else {
		fmt.Fprintln(out, "No")
	}

	//fmt.Fprintln(out, "[DEBUG]", d)
	//fmt.Fprintln(out, "[DEBUG]", time.Now())
	//fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

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

	for( int i=1; i<=n ; i++ ) {
		x = i;
		if( x % 3 == 0 ) { cout << " " << i; continue; }
		while( x ) {
			if( x % 10 == 3 ) { cout << " " << i; break; } 
			x /= 10;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3116
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(`in`: String) = solve(Scanner(`in`))


fun solve(sc: Scanner): String {
    val N = sc.nextInt()
    val AB = (1 until N).map { Pair(sc.nextInt(), sc.nextInt()) }
    val ans = Array(N - 1) { -1 }

    val T = Array(N) { mutableSetOf<Pair<Int, Int>>() }
    (0 until (N - 1)).forEach { wi ->
        val a = AB[wi].first - 1
        val b = AB[wi].second - 1
        T[a].add(Pair(b, wi))
        T[b].add(Pair(a, wi))
    }

    fun dfs(i: Int, color: Int = 0, prev: Int = -1) {
        var c = 0
        T[i].forEach { t ->
            val pi = t.first
            val wi = t.second
            if (pi != prev) {
                c++
                if (c == color) {
                    c++
                }
                ans[wi] = c
                dfs(pi, c, i)
            }
        }
    }
    dfs(0)

    return "${ans.max()}\n${ans.joinToString("\n")}"
}


Measured memory_bytes: 105480
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	ll res = 0;
	REP(i, n) {
		int a;
		cin >> a;
		q.push(a);
	}
	REP(i, m) {
		int p = q.top();
		q.pop();
		q.push(p / 2);
	}
	REP(i, n) {
		res += q.top();
		q.pop();
	}
	put(res);
	return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
int main(void) {
    int mo,af,i;
    char class[16];
    for (i=0; i<9; i++) {
        scanf("%s %d %d\n",class,&mo,&af);
        printf("%s %d %d\n",class,mo+af,mo*200+af*300);
    }
    return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
// experiment
/*
	int N; printf("N? "); scanf("%d",&N);
	while(1){
		int n; printf("n? "); scanf("%d",&n);
		puts((n<=N && to_string(n)<=to_string(N))
		   ||(n> N && to_string(n)> to_string(N))?"Yes":"No");
	}
*/
	int e; // find e s.t. 10^e <= answer < 10^(e+1)
	puts("? 10000000000");
	fflush(stdout);
	char in; scanf(" %c",&in);
	if(in=='Y'){ // answer = 10^something
		int lo=0,hi=10;
		while(hi-lo>1){
			int mi=(lo+hi)/2;
			printf("? %s\n",string(mi,'9').c_str());
			fflush(stdout);

			scanf(" %c",&in);
			if(in=='Y') hi=mi;
			else        lo=mi;
		}
		e=lo;
	}
	else{
		int lo=0,hi=10;
		while(hi-lo>1){
			int mi=(lo+hi)/2;
			printf("? 1%s\n",string(mi,'0').c_str());
			fflush(stdout);

			scanf(" %c",&in);
			if(in=='Y') lo=mi;
			else        hi=mi;
		}
		e=lo;
	}

	lint lo=lint(pow(10,e)-1+0.5);
	lint hi=lint(pow(10,e+1)-1+0.5);
	while(hi-lo>1){
		lint mi=(lo+hi)/2;
		printf("? %lld0\n",mi);
		fflush(stdout);

		scanf(" %c",&in);
		if(in=='Y') hi=mi;
		else        lo=mi;
	}
	printf("! %lld\n",hi);

	return 0;
}


Measured memory_bytes: 596
use std::io;
use std::io::BufRead;

fn main() {
	let stdin = io::stdin();
	for line in stdin.lock().lines() {
		let v: Vec<usize> = line.unwrap().split_whitespace()
			.map(|s| s.parse().unwrap()).collect();
		if v == [0, 0] {break;}
		let (h, w) = (v[0], v[1]);
		let mut row1 = "#.".repeat(w/2+w%2);
		let mut row2 = ".#".repeat(w/2+w%2);
		if w%2==1 {
			row1.pop();
			row2.pop();
		}
		let mut rect = (row1 + "\n" + &row2 + "\n").repeat(h/2+h%2);
		if h%2==1 {
			for _ in 0..w+1 {rect.pop();}
		}
		println!("{}", rect);
	}
}


Measured memory_bytes: 5040
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	char A[N], B[N];
	for (int i = 0; i < N; ++i) scanf(" %c", &A[i]);
	for (int i = 0; i < N; ++i) scanf(" %c", &B[i]);
	for (int i = 0; i < N; ++i) printf("%c%c", A[i], B[i]);
	return 0;
}

Measured memory_bytes: 128
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	n, k := scanInt(), scanInt()
	a := scanInts(n)
	for i := 0; i < n; i++ {
		a[i]--
	}

	visited := make([]bool, n)
	var s int
	for i := 0; !visited[i]; {
		visited[i] = true
		i, s = a[i], i
	}

	path := make([]int, 0, n)
	for i := 0; i != s; i = a[i] {
		path = append(path, i)
	}

	loop := make([]int, 0, n)
	loop = append(loop, s)
	for i := a[s]; i != s; i = a[i] {
		loop = append(loop, i)
	}

	var ans int
	if k < len(path) {
		ans = path[k]
	} else {
		k -= len(path)
		k %= len(loop)
		ans = loop[k]
	}
	fmt.Println(ans + 1)
}


Measured memory_bytes: 7984
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll dectobin(ll n,ll p[])
{
    ll i=0 ;
    while(n!=0)
    {
        p[i]=n%2 ;
        n/=2 ;
        i++ ;
    }
    return(i-1) ;
}
ll binarySearchCount(ll arr[], ll n, ll key) 
{ 
    ll left = 0; 
    ll right = n - 1; 
  
    ll count = 0; 
  
    while (left <= right) { 
        int mid = (right + left) / 2; 
  
        // Check if middle element is 
        // less than or equal to key 
        if (arr[mid] < key) { 
  
            // At least (mid + 1) elements are there 
            // whose values are less than 
            // or equal to key 
            count = mid + 1; 
            left = mid + 1; 
        } 
  
        // If key is smaller, ignore right half 
        else
            right = mid - 1; 
    } 
  
    return count; 
} 
void printDivisors(ll n,ll k) 
{  ll temp=1  ;
    // Note that this loop runs till square root 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
                {
                	if(i<=k && i>temp)
                	temp=i ;
				}
  
            else // Otherwise print both 
                
                {
                if(i<=k && i>temp)
                	temp=i ;
                if(n/i<=k && n/i>temp)
                temp=n/i ;
				}
        } 
    }
	cout<<n/temp<<"\n" ;
	return ; 
} 

int main(int argc, char** argv)
{   sws ;

// tcase
{   
  ll n ;
  cin>>n ;
  ll h[n],val[n] ;
  forn(i,n)
  {
  cin>>h[i] ;
  val[i]=INF;
  }
  val[0]=0 ;
  val[1]=abs(h[1]-h[0]) ;
  for(int i=2;i<n;i++ )
  {
  	val[i]=min(val[i-1]+abs(h[i]-h[i-1]),val[i-2]+abs(h[i]-h[i-2])) ;
  }
  cout<<val[n-1]<<"\n";
}
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
    char ch; int sign = 1;
    while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
    n = ch - '0';
    while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
    n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const int N = 122222;
ll n, c;
ll x[N], v[N], s[N], f[N], g[N];

int main(){
    read(n), read(c);
    rep(i, 1, n) read(x[i]), read(v[i]);
    rep(i, 1, n) s[i] = s[i-1] + v[i];
    ll ans = 0;
    per(i, n, 1) g[i] = max(g[i+1], s[n] - s[i-1] - (c - x[i]));
    rep(i, 1, n) ans = max(ans, max(s[i] - x[i], s[i] - 2 * x[i] + g[i+1]));
    rep(i, 1, n) f[i] = max(f[i-1], s[i] - x[i]);
    rep(i, 1, n) ans = max(ans, max(s[n] - s[i-1] - (c - x[i]), s[n] - s[i-1] - 2 * (c - x[i]) + f[i-1]));
    cout << ans << endl;
    return 0;
}


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

w_cusum_list = []
w = 0
for i in range(N):
  if S[i] == 'W':
    w += 1
  w_cusum_list.append(w)
    
e_cusum_list = []
e = 0
for i in range(1, N):
  if S[-i] == 'E':
    e += 1
  e_cusum_list.append(e)

minn = min(w_cusum_list[-1], e_cusum_list[-1])
for i in range(1, N):
  sumn = w_cusum_list[i-1] + e_cusum_list[N-i-1]
  if minn > sumn:
    minn = sumn

print(minn)

Measured memory_bytes: 17872
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26524
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  int t = (n - 1) / 2 + 1;
  cout << fixed << setprecision(10) << (double)(1.0 * t / n) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x[5];
    int k,i,j;
    for (i=0;i<5;i++){
        scanf("%d",&x[i]);
    }
    scanf("%d",&k);

    for(i=0;i<5;i++){
        for(j=i+1;j<5;j++){
            if(x[j]-x[i]>k){
                printf(":(");                
                return 0; 
            }
        }
    }
    printf("Yay!");
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for (int i = 0; i < N; i++)
    cin >> a.at(i);
  
  int x = 0;
  int j = 0;
  vector<int> a_count(N,0);
  
  for (int i = 0; i < N + 1; i++) {
  	if (i == N) 
      x = -1;
    else if (a_count.at(j) == 1) {
      x = -1;
      break;
    }
    else {
      a_count.at(j)++;
      j = a.at(j) - 1;
      x++;
      if (j == 1)
        break;
    }
  }
  
  cout << x << endl;
}


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

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#else
#define print(...)
#endif


void solve() {
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    ll ans = 0;
    vector<bool> win(T.size(), false);
    rep(i, T.size()) {
        if (i - K >= 0 && T[i - K] == T[i] && win[i-K]) continue;
        if (T[i] == 'r') {
            ans += P;
        }
        if (T[i] == 's') {
            ans += R;
        }
        if (T[i] == 'p') {
            ans += S;
        }
        win[i] =true;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int n, m, a[10000], b[10000], cnt, sum;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < m; i++) {
		cnt = i;
		for (int j = 0; j < n; j++) {
			if (a[j] == b[cnt]) {
				cnt++;
			}
		}
		sum = max(sum, cnt - i);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1208
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

vector<vector<ll>> c;

void mk_c(){
    c.resize(2100);
    for(int i=1;i<2100;i++){
        c[i].resize(2100);
        c[i][0]=1;
        c[i][i]=1;
        for(int t=1;t<i;t++){
            c[i][t]=(c[i-1][t-1]+c[i-1][t])%MOD;
        }
    }
}

int main(){
    ll n,k;
    cin>>n>>k;
    mk_c();
    cout<<c[n+k-1][k-1]<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 37408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
	// TODO Auto-generated method stub
		calc();
	}
 
	private static void calc() {
		int[]	curtbl = null;
		int[]	pretbl = null;
 
		while ((curtbl = parseParams()) != null) {
			if (pretbl == null) {
				pretbl = curtbl;
			}
			else {
				int[]	tmptbl = new int[curtbl.length];
				for(int i = 0; i < tmptbl.length; i++) {
					if (0 <= i && i < pretbl.length) {
						tmptbl[i] = Math.max(tmptbl[i], pretbl[i] + curtbl[i]);
					}

					if (tmptbl.length > pretbl.length) {
						if (0 <= i-1 && i-1 < pretbl.length) {
							tmptbl[i] = Math.max(tmptbl[i], pretbl[i-1] + curtbl[i]);
						}
					}
					else {
						if (0 <= i+1 && i+1 < pretbl.length) {
							tmptbl[i] = Math.max(tmptbl[i], pretbl[i+1] + curtbl[i]);
						}
					}
				}
				pretbl = tmptbl;
			}
		}

		System.out.println(pretbl[0]);
	}
 
	private static int[] parseParams() {
        int[]	params = null;
        String  strin  = null;

        if ((strin = parseStdin()) != null) {
        	String[]	lines = strin.split(",");
        	params = new int[lines.length];
        	for (int index = 0; index < lines.length; index++) {
        		params[index] = Integer.parseInt(lines[index]);
        	}
        }
 
        return params;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	stdin = br.readLine();
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 19424
#include <cstdio>
#include <vector>
#include <complex>
#include <cmath>
using namespace std;

typedef double D;
typedef complex<D> P;
typedef const P &rP;

const D EPS = 1e-10;

D dot(rP a, rP b){
	return real(a) * real(b) + imag(a) * imag(b);
}

void intrcc(rP p1, D r1, rP p2, D r2, vector<P> &res){
	D d = abs(p2 - p1);
	D phi = arg(p2 - p1);
	D costheta = (d * d + r1 * r1 - r2 * r2) / (2.0 * d * r1);
	if( abs(costheta) > 1.0 ){	return;	}
	D theta = acos(costheta);
	res.push_back(p1 + polar(r1, phi + theta));
	res.push_back(p1 + polar(r1, phi - theta));
}

void intrlc(rP p1, rP p2, rP pc, D r, vector<P> &res){
	P v12 = p2 - p1;
	P v1c = pc - p1;

	D a = norm(v12);
	D b = -dot(v12, v1c);
	D c = norm(v1c) - r * r;

	D d = b * b - a * c;
	if(abs(a) < EPS || d < EPS){
		return;
	}
	d = sqrt(d);
	D t1 = (-b + d) / a;
	D t2 = (-b - d) / a;
	res.push_back(p1 + v12 * t1);
	res.push_back(p1 + v12 * t2);
}

D rtod(D h, D r){
	if(r <= h){ return r; }
	D th = asin((r - h) / r);
	return r * cos(th);
}

vector<P> ps;
vector<D> hs;
vector<D> ds;
D wl;

bool check(D r){
	D lx = rtod(wl, r);
	D rx = 100.0 - lx;
	
	P fld[4];
	fld[0] = P(lx, lx);
	fld[1] = P(lx, rx);
	fld[2] = P(rx, rx);
	fld[3] = P(rx, lx);
	
	vector<P> cand(fld, fld + 4);

	ds.resize(hs.size());
	for(size_t i = 0; i < hs.size(); ++i){
		ds[i] = rtod(hs[i], r);
	}
	
	for(size_t i = 0; i < hs.size(); ++i){
		for(int j = 0; j < 4; ++j){
			intrlc(fld[j], fld[(j + 1) & 3], ps[i], ds[i], cand);
		}
		for(size_t j = 0; j < i; ++j){
			intrcc(ps[i], ds[i], ps[j], ds[j], cand);
		}
	}
	
	for(size_t i = 0; i < cand.size(); ++i){
		D x = real(cand[i]), y = imag(cand[i]);
		if(x > lx - EPS && x < rx + EPS && y > lx - EPS && y < rx + EPS){
			bool ok = true;
			for(size_t j = 0; j < ds.size(); ++j){
				if(abs(cand[i] - ps[j]) < ds[j] - EPS){
					ok = false;
					break;
				}
			}
			if(ok){
				return true;
			}
		}
	}
	return false;
}

int main(){
	int n;
	D x, y;
	while(scanf("%d%lf", &n, &wl), n){
		ps.resize(n);
		hs.resize(n);
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf", &x, &y, &hs[i]);
			ps[i] = P(x, y);
		}
		
		D left = 0.0, right = 200.0;
		for(int ttt = 200; ttt--; ){
			D mid = (left + right) * 0.5;
			if(check(mid)){
				left = mid;
			}
			else{
				right = mid;
			}
		}
		printf("%.9f\n", left);
	}
}

Measured memory_bytes: 1260
#include<stdio.h>

int main(){
  int x, y;
  scanf("%d%d",&x,&y);
  int d;
  d = gcd(x,y);
  printf("%d\n",d);
  
  return 0;
}

int gcd(int x, int y){
  int r;
  int temp;
  if(x<y){
    temp = x;
    x = y;
    y = temp;
  }

  while(y>0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
  



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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

ll D(ll a){
  ll res = 0;
  while(a){
    res += a % 10;
    a /= 10;
  }
  return res;
}

int main(){
  /*ll N,M;cin >> N >> M;
  vector<tuple<ll,ll,ll>> edges;
  for(int i = 0;i < M;i++){
    int a,b,c;cin >> a >> b >> c;
    a--;b--;
    c = -c;
    edges.emplace_back(a,b,c);
  }
  bool upd = true;
  vector<ll> d(N,INF);
  d[0] = 0;
  ll step = 0;
  vector<bool> NEG(N,0);
  while(upd){
    upd = false;
    for(int i = 0;i < M;i++){
      ll a,b,c;
      tie(a,b,c) = edges[i];
      if(NEG[a]){
        NEG[b] = 1;
      }
      ll newD = d[a] + c;
      if(d[b] > newD){
        upd = true;
        d[b] = newD;
        NEG[b] = 1;
      }
    }
    step++;
    if(step > N * 2){
      cout << "inf" << endl;
      return 0;
    }
  }
  cout << -d[N-1] << endl;*/
  ll N;cin >> N;
  ll ans = INF;
  for(int i = 1;i < N;i++){
    ans = min(ans,D(i)+D(N-i));
  }
  cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}




Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;


int main()
{
    ll n, ww;
    cin >> n >> ww;
    map<ll,ll> dp;
    dp[0] = 0;
    ll maxValue = 0;
    for(int i = 0;i < n;i++)
    {
        ll w,v;
        cin >> w >> v;
        for(auto e = dp.rbegin(); e != dp.rend();e++)
        {
            ll nw = e->first + w;
            ll nv = e->second + v;
            if(nw <= ww)
            {
                ll c = dp[nw];
                dp[nw] = max(c, nv);
                maxValue = max(maxValue, dp[nw]);
            }
        }
    }
    cout << maxValue << endl;
    return 0;
}

Measured memory_bytes: 384
n,m,x,y = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
a = 0

for i in range(x+1,y+1):
  if i > max(X):
    if i <= min(Y):
      a = 1
      break
  else:
    pass
  
if a == 1:
  print('No War')
else:
  print('War')
    

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S, T, U;
	int A, B;
	cin >>S >>T >>A >>B >>U;
	if (S==U)
		A--;
	else
		B--;

	cout <<A <<' ' <<B <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

/*******                      *******/

void end(){
    cout << -1 << endl;
}

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n; cin >> n;
    int gyou[MAX] ;
    int retu[MAX];
    int flag[MAX];
    fill(gyou, gyou+n, -1);
    fill(retu, retu+n, -1);
    fill(flag, flag+n, -1);
    rep(i, n){
        int r, c;
        cin >> r >> c;
        r--; c--;
        if(gyou[r] != -1 || retu[c] != -1){
            end();
            return 0;
        }
        gyou[r] = c;
        retu[c] = r;
    }
    
    vector<int> v;
    rep(i, n){
        if(gyou[i] != i && flag[i] == -1){
            int cnt = 1;
            int u = i+1;
            flag[i] = u;
            int k = gyou[i];
            while(flag[k] == -1){
                flag[k] = u;
                k = gyou[k];
                cnt++;
            }
            v.push_back(cnt);
        }
    }
    
    ll res = 0;
    while(!v.empty()){
        int group_num = v[0];
        if(group_num == 2)res++;
        else res += group_num-1;
        v.erase(v.begin());
    }
    
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 4296
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.AbstractQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * 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);
        AOrPlusMax solver = new AOrPlusMax();
        solver.solve(1, in, out);
        out.close();
    }

    static class AOrPlusMax {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int[] arr = new int[1 << n];
            for (int i = 0; i < 1 << n; i++)
                arr[i] = sc.nextInt();
            PriorityQueue<Integer>[] pq = new PriorityQueue[1 << n];
            for (int i = 0; i < 1 << n; i++) {
                pq[i] = new PriorityQueue<>();
                pq[i].add(arr[i]);
            }
            for (int i = 0; i < n; i++)
                for (int j = 0; j < 1 << n; j++) {
                    if ((j & 1 << i) != 0)
                        continue;
                    pq[j | 1 << i].addAll(pq[j]);
                    while (pq[j | 1 << i].size() > 2)
                        pq[j | 1 << i].poll();
                }
            int max = 0;
            for (int i = 1; i < 1 << n; i++) {
                max = Math.max(pq[i].poll() + pq[i].poll(), max);
                pw.println(max);
            }
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}



Measured memory_bytes: 92588
#include <iostream>

using namespace std;

int main(void) {
	int H,W;


	while (true)
	{
		cin >> H >> W;
		if (H == 0 && W == 0)
		{
			break;
		}

		for (int i = 0; i < H; i++)
		{			
			for (int j = 0; j < W; j++)
			{
				if ((i + j) % 2 == 0)
				{
					cout << "#";
				}
				else
				{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}



	return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

#define rep(i, s, n) for(int i = s;i<n;i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<int> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

int main(void) {
    int n, k;
    cin >> n >> k;
    if (k > 1) {
        cout << n - k << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
from collections import Counter
#a,b = map(int,input().split())
#L = list(map(int,input().split()))
def pr(n):
    L = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            L.append(i)
            n = n//i
    if n != 1:
        L.append(n)
    return L
dic = {1:1,2:1,3:2,4:2,5:2,6:3,7:3,8:3,9:3,10:4,11:4,12:4,13:4,14:4,15:5,16:5,17:5,18:5,19:5,20:5,21:6,22:6,23:6,24:6,25:6,27:6,28:7,29:7,30:7,31:7,32:7,33:7,34:7,35:7,36:8,39:8,40:8}
L = pr(n)
#print(L)
L = Counter(L)
num = 0
for k,v in L.items():
    num +=dic[v]
print(num)

Measured memory_bytes: 9732
#include <iostream>
#include <vector>
#include <climits>
#include <set>
using namespace std;
typedef long long int ll;

int c[1000]={0};
 
int main()
{
	string s; cin>>s;
	vector<int> x;
	for(int i=0;i<4;i++){
		if(c[s[i]] == 0){
			c[s[i]]++;
			x.push_back(s[i]);
		}
		else c[s[i]]++;
	}

	if(x.size() == 2 and c[x[0]] == 2 and c[x[1]]  == 2) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>


int main(){
  
  // read problem
  long long int N, M, tmp;
  std::priority_queue<long long int> A;
  scanf("%lld%lld", &N, &M);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    A.push(tmp);
  }
  
  for(long long int i = 0; i < M; i++){
    tmp = A.top();
    //std::cerr << tmp << std::endl;
    A.pop();
    A.push(tmp/2);
  }
  
  long long int ans = 0;
  for(long long int i = 0; i < N; i++){
    ans += A.top();
    A.pop();
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<string> s(n);
	for(int i=0;i<n;i++){
		cin >> s[i];
		vector<char> v;
		for(int j=0;j<10;j++){
			v.push_back(s[i][j]);
		}
		sort(v.begin(),v.end());
		string t="";
		for(int j=0;j<10;j++){
			t+=v[j];
		}
        s[i]=t;
	}
	sort(s.begin(),s.end());
	ll ans=0;
	for(int i=0;i<n;i++){
		string cp=s[i];
		ll cnt=0;
		while(i<n&&cp==s[i]){
			cnt++;
			i++;
		}
		i--;
		ans+=(cnt-1)*cnt/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

//preorder ??¨ inorder ?????? postorder ????§????
vector<int> reconstruct_tree(const vector<int> &pre, const vector<int> &in) {
	vector<int> post;
	int pos = 0;
	function<void(int, int)> rec = [&](int l, int r) {
		if (l >= r)return;
		int root = pre[pos++];
		int m = distance(in.begin(), find(in.begin(), in.end(), root));
		rec(l, m);
		rec(m + 1, r);
		post.emplace_back(root);
	};
	rec(0, pre.size());
	return post;
}

signed main() {
	int n; cin >> n;
	vector<int> pre(n), in(n);
	rep(i, 0, n)cin >> pre[i];
	rep(i, 0, n)cin >> in[i];
	vector<int> post = reconstruct_tree(pre, in);
	cout << post[0]; rep(i, 1, post.size()) { cout << " " << post[i]; } cout << endl;
	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

int main(void)
{
    int k, x;
    cin >> k >> x;
    if (500 * k >= x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main(void){
    double n, k;
    scanf("%lf %lf", &n, &k);
    int ans = (int)round(ceil(log(n)/log(k)));
    if(pow(k, ans)==n) ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n;
string s;
int r[30300][20];
bool checked[20][20];

signed main() {

    cin >> n;
    cin >> s;

    for(int i = 0; i < n; i++) {
        s[i] = s[i]-'0';
        for(int j = 0; j < 10; j++) r[i+1][j] = r[i][j];
        r[i+1][s[i]]++;
    }
    
    vector<int> v[15][15];

    for(int i = 0; i < 10; i++)
        for(int j = 0; j < 10; j++)
            for(int k = 0; k < 10; k++)
                v[i][j].bash(k);

    int sum = 0;
    
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            if(checked[s[i]][s[j]]) continue;
            checked[s[i]][s[j]] = true;
            for(int k = 0; k < 10; k++) {
                if(r[n][k] - r[j+1][k]) 
                    sum++;
            }
        }
    }

    cout << sum << endl;
    
  
    return 0;
}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define All(v) (v).begin(),(v).end()
int main(){
    string s,ans;
    cin>>s;
    int n=s.size();
    rep(i,n){
        if(i%2==0)ans+=s.at(i);
    }
    cout<<ans<<endl;
}


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

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	map<ll,ll> cnt,mini;
	int N;
	cin >> N;
	ll gg = 0;
	ll ans[N+5],sum = 0;
	memset(ans,0,sizeof ans);
	for(ll i=1;i<=N;i++){
		ll a;
		cin >> a;
		gg = max(gg,a);
		if(mini[a] == 0)
		mini[a] = i;
		else mini[a] = min(mini[a],i);
		cnt[a]++;
	}
	cnt[0] = 1;
	mini[0] = 1;
	ll ban = cnt[gg];
	ll mi = mini[gg];
	ll pos = gg;
	map<ll,ll>::iterator it = mini.end();
	it--;
	it--;
	for(;;it--){
		int r = it->first,t = it->second;
		ans[mi] += (pos-r) * ban;
	//	cout << pos << " " << r << " " << ban << mi << " " << ans[mi]<< "\n";
		pos = r;
		ban += cnt[pos];
		mi  = min(mi,mini[pos]);
	//	cout << ban << " " << mi << " " << pos << " " << r << "\n";
		if(it == mini.begin())break;
	}
	for(int i=1;i<=N;i++){
		cout << ans[i]  << "\n";
	}
	//cout << "\n";
}



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

int main()
{
    int n,q;
    vector<int>S,T;
    cin >> n;
    S.resize(n);
    for(int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    cin >> q;
    T.resize(q);
    for(int i = 0; i < q; i++)
    {
        cin >> T[i];
    }
    int count = 0;
    for(int i = 0; i < q; i++)
    {
        if(binary_search(S.begin(),S.end(),T[i])) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3392
A = int(input())
B = int(input())
C = int(input())
X = int(input())
counter = 0

for i in range(int(X/500) + 1 ):
    if i > A :continue
    remain_100 = X - 500 * i

    for j in range(int(remain_100/100) + 1):
        if j > B :continue
        remain_50 = remain_100 - (100 * j)

        if int(remain_50/50) > C:continue
        counter += 1

print(counter)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const int INF = 1001001001;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> d(n, vector<int>(n, INF));
  rep(i, n) d.at(i).at(i) = 0;
  vector<tuple<int, int, int>> vt(m);
  rep(i, m){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    d.at(a).at(b) = c;
    d.at(b).at(a) = c;
    vt.at(i) = {a, b, c};
  }
  rep(k, n)rep(i, n)rep(j, n) d.at(i).at(j) = min(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
  int ans = 0;
  for(auto t : vt){
    auto [a, b, c] = t;
    if(d.at(a).at(b) != c) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652