akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int k,f[29][29],numcnt,numlst,tmp,tmp1,ix35txdy;

void dp(){
	for(int i=1;i<=20;i++){
		for(int j=0;j<=9;j++){
			if(i==1){f[i][j]=1;}
			else{
				if(j==0){f[i][0]=f[i-1][0]+f[i-1][1];}
				else if(j==9){f[i][9]=f[i-1][8]+f[i-1][9];}
				else{f[i][j]=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1];}
			}
		}
	}
	for(int i=1;i<=20;i++){
		for(int j=1;j<=9;j++){
			tmp1=tmp, tmp+=f[i][j];
			if(tmp>=k&&numcnt==0) numcnt=i,numlst=j,ix35txdy=k-tmp1;
		}
	}
}
signed main(){
	cin>>k;
	dp(); cout<<numlst;
	for(int i=numcnt-1;i>=1;i--){
		if(numlst==9){
			if(f[i][8]<ix35txdy) numlst=9,ix35txdy-=f[i][8]; else numlst=8;
		}else{
			int x1=numlst-1,x2=numlst,x3=numlst+1;
			if(f[i][x1]+f[i][x2]<ix35txdy) numlst++,ix35txdy-=(f[i][x2]+f[i][x1]);
			else if(f[i][x1]<ix35txdy) ix35txdy-=f[i][x1];
			else numlst--;
		}
		cout<<numlst;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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


/* ACL */

//using namespace atcoder;

//MAXR=10^5であることに注意
#define PN 1 //素数のマークは1
#define MAXR 1000000

vector<ll> PN_chk(MAXR+1,PN);//0-indexed(0~MAXR)

//素因数分解で出てきた素数を全て挿入する
vector<ll> prime;

vector<bool> isAlready(MAXR+1,false);

//O(MAXR)
void init_eratosthenes(){
    ll MAXRR=sqrt(MAXR)+1;
    //2以上の数の素因数分解をするので無視して良い
    PN_chk[0]=0;PN_chk[1]=0;
    rep2(i,2,MAXRR){
        //たどり着いた時に素数と仮定されているなら素数
        //ある素数の倍数はその素数で割り切れるのでマークづけ
        if(PN_chk[i]==1) rep2(j,i,ll(MAXR/i)){PN_chk[j*i]=i;}
    }
}

//O(logn)
//primeは整列されていない
bool prime_factorize(ll n){
    if(n<=1) return true;
    //1の場合はnは素数
    if(PN_chk[n]==1){
        //prime.push_back(n);
        //return true;
        PN_chk[n] = n;
    }
    //マークされている数は素数
    prime.push_back(PN_chk[n]);

    if(isAlready.at(PN_chk[n])){
        return false;
    }
    isAlready.at(PN_chk[n]) = true;

    ll next_n = n;
    while(next_n % PN_chk[n] == 0){
        next_n /= PN_chk[n];
    }
    //マークされている数でnを割った数を考える
    return prime_factorize(ll(next_n));
}


int main(){
    int N;
    cin >> N;

    vector<int> list_A(N);
    init_eratosthenes();

    rep(i,N){
        int a;
        cin >> a;
        list_A.at(i) = a;
    }

    int r = accumulate(list_A.begin(), list_A.end(), 0, [](int m, int n) {
        return gcd(m, n);
    });

    if(r != 1){
        cout << "not coprime" << endl;
        return 0;
    }

    bool isP = true;
    rep(i,N){
        isP &= prime_factorize(list_A.at(i));
    }

    if(isP){
        cout << "pairwise coprime" << endl;
    }else{
        cout << "setwise coprime" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 23316
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int H = cin.nextint;
        int W = cin.nextint;
        var A = new int[H][];
        for (int i = 0; i < H; i++)
        {
            A[i] = cin.scanint;
        }

        int cnt = 0;
        var SB = new StringBuilder();
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (A[i][j] % 2 == 1)
                {
                    if (j == W - 1)
                    {
                        if (i != H - 1)
                        {
                            cnt++;
                            SB.AppendLine($"{i + 1} {j + 1} {i + 2} {j + 1}");
                            A[i + 1][j]++;
                        }
                    }
                    else
                    {
                        cnt++;
                        SB.AppendLine($"{i + 1} {j + 1} {i + 1} {j + 2}");
                        A[i][j + 1]++;
                    }
                }
 
            }
        }
        WriteLine(cnt);
        Write(SB);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 27692
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  string S, T; cin >> S >> T;
  
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != T[i]) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    //int n,x,t;cin>>n>>x>>t;
    // int a,b,c;cin>>a>>b>>c;
  int n;
    cin>>n;
    cout<<pow(n,3);

    //cout<<cnt;


    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {};
    ll z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], a[i] += n - i;
    sort(a, a + n);
    for (int i = 0; i < n; i++) z += abs(a[n / 2] - a[i]);
    cout << z;
}


Measured memory_bytes: 1024
package main

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

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

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

//func fib(n int) int {
//	fmt.Println(n)
//	if n == 0 {
//		return 0
//	}
//	if n == 1 {
//		return 1
//	}
//	if done[n] {
//		fmt.Println("done" + fmt.Sprint(n))
//		return memo[n]
//	}
//	done[n] = true
//	memo[n] = fib(n-1) + fib(n-2)
//	return memo[n]
//}

var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

//var dp []int = make([]int, n)

//func fib(n int) int {
//	dp[0] = 0
//	dp[1] = 1
//	for i := 2; i <= n; i++ {
//		dp[i] = dp[i-1] + dp[i-2]
//	}
//	return dp[n]
//}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	n := nextInt()
	ns := nextInts(n)

	sort.Ints(ns)
	di := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			di += ns[i] * ns[j]
			//	fmt.Print(fmt.Sprint(ns[i]))
			//	fmt.Println(fmt.Sprint(ns[j]))
		}
	}
	fmt.Fprint(out, di)
}

Measured memory_bytes: 640
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	String str;
	while((str=input.readLine())!=null)
	    {
		String str_ary[]=str.split(",");
		int n=Integer.parseInt(str_ary[0]);
		
		Double a[]=new Double[2];
		for(int i=0;i<2;i++)
		    {
			a[i]=Double.parseDouble(str_ary[i+1]);
		    }
		
		if(a[0]/Math.pow(a[1],2)>=25)System.out.println(n);
	    }
    }
}

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

#define ll long long
#define Ok puts("OK");

using namespace std;

const int N = (int)123;

int n;
int a[N];

main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  double ans = a[0];
  for (int i = 1; i < n; i++) {
    ans = (ans + a[i]) / 2.0;
  }
  cout << fixed << setprecision(12) << ans;
}


Measured memory_bytes: 256
N = int(input())
 
alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
 
def solve(n):
    if n == 1:
        return ['a']
    elif n == 2:
        return ['aa', 'ab']
    else:
        chars = alphabets[0:n]
        result = []
        for retsu in solve(n - 1):
            done = False
            for char in chars:
                if char in retsu:
                    result.append(retsu + char)
                else:
                    if not done:
                        result.append(retsu + char)
                        done = True
                    else:
                        break
        return result
 
print("\n".join(solve(N)))

Measured memory_bytes: 12936
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n,m;cin>>n>>m;
  vector<pair<ll,ll>>v;
  rep(i,n){
    ll a;cin>>a;
    v.push_back(make_pair(a,1));
  }
  rep(i,m){
    ll b,c;cin>>b>>c;
    v.push_back(make_pair(c,b));
  }
  sort(all(v),greater<>());

  ll num=0;
  ll ans=0;
  for(ll i=0;num!=n;i++){
    // cout<<v[i].first<<endl;
    if(v[i].second+num<n){
      num+=v[i].second;
      ans+=v[i].first*v[i].second;
    }else{
      ans+=v[i].first*(n-num);
      num=n;
    }
  }
  cout<<ans<<endl;
  return false;
}

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


Measured memory_bytes: 6512
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n, k;
string s;

int a[200010];

int it = 0;

int main(){

  n = in();
  k = in();
  s = stin();

  REP( i , n ){
    if( s[i] == 'A' ){
      a[i] = 0;
    } else {
      a[i] = 1;
    }
  }
  a[n] = 1;
  
  while( k > 0 ){
    if( it == n ){
      if( n % 2 == 1 and k % 2 == 1 ){
        a[n] = 0;
      }
      break;
    }
    if( ( a[it] + it ) % 2 == 0 ){
      a[it] = 1 - a[it];
    } else {
      it++;
    }
    k--;
  }
  
  REP( i , n ){
    int c = it + i;
    int x;
    if( c > n ){
      x = ( c - n + 1 + it )% 2;
    } else {
      x = ( a[c] + it ) % 2;
    }
    if( x == 0 ){
      printf( "A" );
    } else {
      printf( "B" );
    }
  }
  printf( "\n" );
  
  return 0;
}


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

n = int(input())
L = [int(x) for x in input().split()]
cnt = 0

def Merge(S, l, m, r):
    global cnt
    cnt += r - l
    L = S[l:m] + [float('inf')]
    R = S[m:r] + [float('inf')]
    i, j = 0, 0
    for k in range(l, r):
        if L[i] < R[j]:
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1
    return

def MergeSort(S, l, r):
    if r - l > 1:
        m = (l + r) // 2
        MergeSort(S, l, m)
        MergeSort(S, m, r)
        Merge(S, l, m, r)
    return

MergeSort(L, 0, n)
print(*L)
print(cnt)


Measured memory_bytes: 61648
#include <bits/stdc++.h>
using namespace std; 
   
int countFreq(string &pat, string &txt, int kkk) 
{ 
    int M = pat.length(); 
    int N = kkk; 
    int res = 0; 
    
    /* A loop to slide pat[] one by one */
    for (int i = 0; i <= N - M; i++) 
    {  
        /* For current index i, check for  
           pattern match */
        int j; 
        for (j = 0; j < M; j++) 
            if (txt[i+j] != pat[j]) 
                break; 
   
        // if pat[0...M-1] = txt[i, i+1, ...i+M-1] 
        if (j == M)   
        { 
           res++; 
           j = 0; 
        } 
    } 
    return res; 
} 
    
/* Driver program to test above function */
int main() 
{ 
   int n;
   cin>>n;
   string txt ;
   cin>>txt;
   string pat = "ABC"; 
   cout << countFreq(pat, txt, n); 
   return 0; 
} 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;
const ll INF = 1e18;

int main(int argc, char* argv[])
{
  ll N;
  ll T = 0;
  std::cin >> N;

  std::vector< ll > vt_s(N, 0);
  std::vector< ll > vt_e(N, 0);
  std::vector< double > vv(N, 0.0);

  for (ll i = 0; i < N; i++) {
    ll t;
    std::cin >> t;
    vt_s[i] = T;
    T += t;
    vt_e[i] = T;
  }
  for (ll i = 0; i < N; i++) {
    std::cin >> vv[i];
  }  

  double ans   = 0.0;
  double pre_v = 0.0;
  for (double t = 0.5; t <= T; t += 0.5) {
    double min_v = 100.0;
    min_v = std::min(min_v, t);
    min_v = std::min(min_v, T - t);

    for (ll i = 0; i < N; i++) {
      if (vt_s[i] <= t && t <= vt_e[i]) {
	min_v = std::min(min_v, vv[i]);
      }

      if (t < vt_s[i]) {
	min_v = std::min(min_v, vv[i] + (vt_s[i] - t));
      }
      
      if (vt_e[i] < t) {
	min_v = std::min(min_v, vv[i] + (t - vt_e[i]));
      }
    }

    ans += (pre_v + min_v) * 0.25;
    pre_v = min_v;
  }

  printf("%.15f\n", ans);
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	while (a != 0 && b != 0)
	{
		if (a >= b)
		{
			a %= b;
		}
		else
		{
			b %= a;
		}
	}
	if (a >= b)
	{
		cout << a << endl;
	}
	else
	{
		cout << b << endl;
	}
}


Measured memory_bytes: 3108
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if (a[i] == i + 1) {
      ans++;
      swap(a[i], a[i + 1]);
    }
  }
  Cout(ans);
  return 0;
}


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

struct edge {
    int to, cap, rev;
};

using edges = vector<edge>;
using graph = vector<edges>;

void add_edge(graph& g, int from, int to, int cap) {
    g[from].push_back(edge{to, cap, (int)g[to].size()});
    g[to].push_back(edge{from, 0, (int)g[from].size()-1});
}

int dfs(graph& g, vector<bool>& used, int v, int t, int f) {
    if(v == t) {
        return f;
    }
    used[v] = true;
    for(int i=0; i<g[v].size(); ++i) {
        edge& e = g[v][i];
        if(!used[e.to] && e.cap > 0) {
            int d = dfs(g, used, e.to, t, min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(graph& g, int s, int t) {
    int flow = 0;
    int INF = 1e9;
    vector<bool> used(g.size());
    while(true) {
        fill(used.begin(), used.end(), false);
        int f = dfs(g, used, s, t, INF);
        if(f == 0) {
            return flow;
        }
        flow += f;
    }
}

int main() {
    int H, W, C, M, Nw, Nc, Nm;
    while(cin >> H >> W >> C >> M >> Nw >> Nc >> Nm, H != -1) {
        const int V = H + 2*(W + 1) + 2*(C + 1) + (M + 1) + 1 + 1;
        const int w0 = H;
        const int w1 = w0 + (W + 1);
        const int c0 = w1 + (W + 1);
        const int c1 = c0 + (C + 1);
        const int m0 = c1 + (C + 1);
        //const int m1 = m0 + (M + 1);
        const int source = m0 + (M + 1);
        const int dest = source + 1;
        graph g(V);
        for(int i=0; i<H; ++i) {
            add_edge(g, i, w0, 1); // h -> dummy w
        }
        for(int i=0; i<W; ++i) {
            int n;
            cin >> n;
            for(int j=0; j<n; ++j) {
                int h;
                cin >> h;
                h--;
                add_edge(g, h, w0+i+1, 1); // h -> w
            }
            add_edge(g, w0+i+1, w1+i+1, 1); // w -> w
            add_edge(g, w1+i+1, c0, 1); // w -> dummy c
        }
        add_edge(g, w0, w1, Nw); // dummy w -> dummy w
        for(int i=0; i<C; ++i) {
            int n;
            cin >> n;
            for(int j=0; j<n; ++j) {
                int w;
                cin >> w;
                add_edge(g, w1 + w, c0 + i + 1, 1); // w -> c
            }
            add_edge(g, w1, c0 + i + 1, 1); // dummy w -> c
            add_edge(g, c0 + i + 1, c1 + i + 1, 1); // c -> c
            add_edge(g, c1 + i + 1, m0, 1); // c -> dummy m
        }
        add_edge(g, c0, c1, Nc); // dummy c -> dummy c
        for(int i=0; i<M; ++i) {
            int n;
            cin >> n;
            for(int j=0; j<n; ++j) {
                int c;
                cin >> c;
                add_edge(g, c1 + c, m0 + i + 1, 1);
            }
            add_edge(g, c1, m0 + i + 1, 1); // dummy c -> m
            add_edge(g, m0+i+1, dest, 1); // m -> dest
        }
        add_edge(g, m0, dest, Nm);

        for(int i=0; i<H; ++i) {
            add_edge(g, source, i, 1); // source -> hero
        }

        cout << max_flow(g, source, dest) << endl;
    }
}


Measured memory_bytes: 3232
#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long ull;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000

// Knapsack 1: Atcoder Educational DP contest
int n, peso, wi;
ll v;
vi wes;
vector<ll> utils;
ll dpUtility[110][1000010];


ll knapsack()
{
    for(int i = 0; i <= n; ++i)
    {
        for (int w = 0; w <= peso; ++w)
        {
            if (i == 0 || w == 0) dpUtility[i][w] = 0;
            else if (wes[i-1] <= w) dpUtility[i][w] = max(dpUtility[i-1][w], dpUtility[i-1][w-wes[i-1]] + utils[i-1]);
            else dpUtility[i][w] = dpUtility[i-1][w];
        }
    }
    return dpUtility[n][peso];
}



int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> peso;

    for(int i = 0; i < n; ++i)
    {
        cin >> wi >> v;
        wes.push_back(wi);
        utils.push_back(v);
    }

    cout << knapsack() << endl;
    return 0;
}

Measured memory_bytes: 287872
#include <cstdio>
#include <cstdlib>
#include <algorithm>

typedef long long LL;

double ans;

double calc(LL n,double sum)
{
	if(n == 1) return sum / (2 * n);
	else return calc(n - 1, sum - sum / (n * n)) + sum / (2 * n);
}
int main()
{
	LL n, d, x;
	
	scanf("%lld%lld%lld", &n, &d, &x);
	printf("%.10lf", calc(n, (2 * d + (2 * n - 1) * x) * n));
	return 0;
}

Measured memory_bytes: 6400
n, m=map(int, input().split())
ship=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    ship[a-1].append(b-1)
    ship[b-1].append(a-1)

ans="IMPOSSIBLE"
for i in ship[0]:
    if n-1 in ship[i]:
        ans="POSSIBLE"
        break
print(ans)

Measured memory_bytes: 38320
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]

lst=[]
for w,v in WV:
    for i in range(len(lst)):
        w1,v1=lst[i]
        if w1:
            lst.append([w1+w,v1+v])
    lst.append([w,v])

    lst=sorted(lst,key=lambda x:x[0],reverse=True)
    while lst and lst[-1][0]==0:
        lst.pop()

    w,v=lst[-1]
    for i in range(len(lst)-1)[::-1]:
        w1,v1=lst[i]
        if v1<=v:
            lst[i][0]=0
            lst[i][1]=0
        else:
            v=v1
    #print(lst)
print(max([v for w,v in lst if w<=W]))


Measured memory_bytes: 123480
#include <stdio.h>

int main() {
	int a, b, c, x, i, j, k, cnt;

	scanf("%d%d%d%d", &a, &b, &c, &x);
	cnt = 0;
	for (i = 0; i <= a; i++)
		for (j = 0; j <= b; j++)
			for (k = 0; k <= c; k++)
				if (i * 500 + j * 100 + k * 50 == x)
					cnt++;
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int total = 0;
        for (int i=1; i<=n; i++){
            total+=i;
        }
        System.out.println(total);

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}



Measured memory_bytes: 21460
#include <iostream>

using namespace std;

int main() {
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++) {
		char c = s[i];
		if (islower(c)) {
			c = toupper(c);
			s[i] = c;
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  int a,b,c,d;
  int x;
  int p,q,r;
  int cost[111][111];
  int time[111][111];
  while(1){
    cin >> n >> m;
    if(n==0 && m==0)break;
    for(int i=0;i<111;i++){
      for(int j=0;j<111;j++){
	cost[i][j]=9999999;
	time[i][j]=9999999;
      }
    }
    for(int i=0;i<n;i++){
      cin >> a >> b >> c >> d;
      cost[a-1][b-1]=cost[b-1][a-1]=c;
      time[a-1][b-1]=time[b-1][a-1]=d;
    }
    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
	for(int j=0;j<m;j++){
	  cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
	  time[i][j]=min(time[i][j],time[i][k]+time[k][j]);
	}
      }
    }
    cin >> x;
    for(int i=0;i<x;i++){
      cin >> p >> q >> r;
      cout << (r==0 ? cost[p-1][q-1] : time[p-1][q-1]) << endl;
    }
  }
}

Measured memory_bytes: 1256
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xlList = mutableListOf<Pair<Long, Long>>()
    val lrList = mutableListOf<Triple<Long, Long, Long>>()
    (1..n).forEach {
        val (x, l) = readLine()!!.split(' ').map(String::toLong)
        xlList.add(Pair(x, l))
        lrList.add(Triple(x - l, x + l, l))
    }
    xlList.sortBy { it.first }
    lrList.sortBy { it.first }

    if (n == 1) {
        println(1)
        return
    }

    val queue = ArrayDeque(lrList)
    val ansQueue = ArrayDeque<Triple<Long, Long, Long>>()
    var ans = 0
    while (queue.isNotEmpty()) {
        if (queue.size == 1) {
            ans++
            break
        }
        val p1 = queue.pollFirst()
        val p2 = queue.pollFirst()
        if (p1.second > p2.first) {
            //delete
            if (p1.second > p2.second) {
                queue.addFirst(p2)
            } else {
                queue.addFirst(p1)
            }
        } else {
            queue.addFirst(p2)
            ans++
        }
    }
    println(ans)

}

Measured memory_bytes: 144060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1){
        cout<<1<<endl;
    }
    else cout<<(h*w+1)/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

ll INF = 1 << 60;

int main() {
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    multiset<ll> s;

    for (ll i = 0; i < n; ++i) {
        ll now = a[i];
        auto itr = s.lower_bound(now);
        if (itr != s.begin()) s.erase(--itr);
        s.insert(now);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define int long long
#define p pair<int,int>
#define P pair<int,p>
using namespace std;

int x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 };
int f[500][500];
bool i[500][500];
set<p>l,r;
signed main() {
	int a;
	while (cin >> a, a) {
		l.clear(); r.clear();
		l.insert(p(0, 0)); r.insert(p(0, 0));
		int b, c, d, e; cin >> c >> b >> e >> d;
		d--; e--;
		for (int g = 0; g < b; g++) {
			for (int h = 0; h < c; h++) {
				scanf("%lld", &f[g][h]);
			}
		}
		memset(i, true, sizeof(i));
		int sum = 0, MAX = 0;
		priority_queue<P, vector<P>, greater<P>>Q;
		Q.push(P(1, p(d, e)));
		while (Q.size()) {
			P o = Q.top(); Q.pop();
			MAX = o.first; 
			if(i[o.second.first][o.second.second])sum++;
			i[o.second.first][o.second.second] = false;
			queue<p>q;
			q.push(p(o.second.first, o.second.second));
			while (q.size()) {
				p t = q.front(); q.pop();
				for (int i = 0; i < 4; i++) {
					int dx = t.first + x[i], dy = t.second + y[i];
					if (dx >= 0 && dx < b&&dy >= 0 && dy < c&&::i[dx][dy]) {
						if (f[dx][dy] <= o.first) {
							sum++;
							q.push(p(dx,dy));
							::i[dx][dy] = false;
						}
						else {
							Q.push(P(f[dx][dy],p(dx,dy)));
						}
					}
				}
			}
			l.insert(p(sum, MAX));
		}
		cin >> c >> b >> e >> d;
		d--; e--;
		for (int g = 0; g < b; g++) {
			for (int h = 0; h < c; h++) {
				scanf("%lld", &f[g][h]);
			}
		}
		memset(i, true, sizeof(i));
		sum = 0; MAX = 0;
		priority_queue<P, vector<P>, greater<P>>U;
		U.push(P(1, p(d, e)));
		while (U.size()) {
			P o = U.top(); U.pop();
			MAX = o.first;
			if (i[o.second.first][o.second.second])sum++;
			i[o.second.first][o.second.second] = false;
			queue<p>q;
			q.push(p(o.second.first, o.second.second));
			while (q.size()) {
				p t = q.front(); q.pop();
				for (int i = 0; i < 4; i++) {
					int dx = t.first + x[i], dy = t.second + y[i];
					if (dx >= 0 && dx < b&&dy >= 0 && dy < c&&::i[dx][dy]) {
						if (f[dx][dy] <= o.first) {
							sum++;
							q.push(p(dx, dy));
							::i[dx][dy] = false;
						}
						else {
							U.push(P(f[dx][dy], p(dx, dy)));
						}
					}
				}
			}
			r.insert(p(sum, MAX));
		}
		int MIN = LLONG_MAX/3;
		for (auto i = l.begin(); i != l.end(); i++) {
			auto j = r.lower_bound(p(a-(*i).first,0));
			if (j != r.end()) {
				MIN = min(MIN, (*i).second + (*j).second);
			}
		}
		cout << MIN << endl;
	}
}

Measured memory_bytes: 21752
#include <iostream>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF 10000000

typedef long long ll;
typedef pair<ll, ll> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z


int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int n;
    cin >> n;
    int atoz[26]; fill(atoz, atoz+26, INF);
    int apperances[n][26];
    string temps;
    rep(n, i){
        cin >> temps;
        rep(26, j) apperances[i][j] = count(temps.begin(), temps.end(), (char)(j + 'a'));
    }
    rep(26, i) {
        int m = INF;
        rep(n, j) m = min(apperances[j][i], m);
        rep(m, k) cout << (char)(i + 'a');
    }
    cout << '\n';
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
def solve(n, a, b, c, l):
    v = gen(a,b,c,l,n,0,[],[],[])
    print(v)

    
def gen(a,b,c,l,n,idx,al,bl,cl):
    if idx == n:
        if (len(al) > 0) and (len(bl) > 0) and (len(cl) > 0):
            v = calc(a,b,c,al,bl,cl)
            # print(f"{a}:{al}, {b}:{bl}, {c}:{cl} => {v}")
            return v
        else:
            return 3000

    l1 = l[idx]
    nal = al.copy()
    nbl = bl.copy()
    ncl = cl.copy()

    nal.append(l1)
    nbl.append(l1)
    ncl.append(l1)

    va = gen(a, b, c, l, n, (idx+1), nal,bl,cl)
    vb = gen(a, b, c, l, n, (idx+1), al,nbl,cl)
    vc = gen(a, b, c, l, n, (idx+1), al,bl,ncl)
    vn = gen(a, b, c, l, n, (idx+1), al,bl,cl)
    return min(va, vb, vc, vn)

def calc(a,b,c,al,bl,cl):
    mp = 0
    
    t = al
    mp += (len(t) - 1) * 10
    length = sum(t)
    mp += abs(a - length)

    t = bl
    mp += (len(t) - 1) * 10
    length = sum(t)
    mp += abs(b - length)

    t = cl
    mp += (len(t) - 1) * 10
    length = sum(t)
    mp += abs(c - length)

    return mp
    
n, a, b, c = map(int,input().split())
l = []
for i in range(n):
    l.append(int(input()))

solve(n, a, b, c, sorted(l))


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){

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

    int max, min;
    if(A>B)max = B;
    else max = A;

    min = A + B - N;
    if(min<0)min = 0;

    printf("%d %d\n",max, min);

    return 0;
}


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

int main(){
  int N;
  int K;
  int pass = 0;
  cin >> N >> K;
    
  int h[N];
  for( int i = 0; i < N; i++){
    int tall;
    cin >> tall;
    if(tall >= K){
      pass++;
    }
  }
  cout << pass;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI  = vector<int>;
const static string el = "\n";

int main()
{
  long int n;
  cin >> n;
  
  string result = "";
  while (n > 0) 
  {
    int amari = n % 26;
    if (amari == 0) 
    {
      n--;
      amari = 26;
    }
    amari--;
    
    char tmp = (char)'a' + amari;
    result = tmp + result;
    
    n /= 26;
  }
  cout << result << el;
  return 0;
}


Measured memory_bytes: 3608
using System;
class Qsort
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        long p = long.Parse(str[0]);
        long q = long.Parse(str[1]);
        long r = long.Parse(str[2]);

        if (p >= q && p >= r)
            Console.WriteLine(q + r);
        else if (q >= p && q >= r)
            Console.WriteLine(p + r);
        else
            Console.WriteLine(p + q);

    }


}

Measured memory_bytes: 11092
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner scan =new java.util.Scanner(System.in);
		int n = scan.nextInt();
		String str = scan.next();
		if(n%2==0) {
			for(int i=0;i < n/2; i++) {
				if(str.charAt(i)!=str.charAt((n/2)+i)) {
					System.out.println("No");
					System.exit(0);
				}
			}
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22100
N,A,B = map(int,input().split())
X = list(map(int,input().split()))
tot = 0
for i in range(1,N):
    if (X[i]-X[i-1])*A<=B:
        tot += (X[i]-X[i-1])*A
    else:
        tot += B
print(tot)

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MINF = 0x3f3f3f3f;
const int MAXN = 200007;
const int BASE = 26;
const int MAXS = ( 1 << BASE ) + 7;

int n;
char s[MAXN];
int sta[MAXN];
int pre[MAXS];
int dp[MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%s", s+1 );
}

void work ()
{
	// main work

	n = strlen ( s+1 );
	lpi ( i, 1, n ) sta[i] = sta[i-1] ^ ( 1 << ( s[i] - 'a' ) );

	INIT ( pre, MINF );

	INIT ( dp, MINF );
	dp[0] = 0;
	pre[0] = 0;
	lpi ( i, 1, n ) {
		lp ( j, 0, BASE ) {
			dp[i] = qmin ( dp[i], pre[sta[i]^( 1<<j )] + 1 );
		}
		dp[i] = qmin ( dp[i], pre[sta[i]] + 1 );
		pre[sta[i]] = qmin ( pre[sta[i]], dp[i] );
	}

	cout << dp[n] << endl;
}

Measured memory_bytes: 264320
// Sea the world.

#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// SELF TEMPLATE CODE BGEIN

#define SZ(x) ((int)((x).size()))
#define OUT(x) printf(#x" %d\n", x)
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repf(i,a,b) for (int i = (a); i <= (b); ++i)
#define repd(i,a,b) for (int i = (a); i >= (b); --i)
#define repcase int t, Case = 1; for (scanf ("%d", &t); t; --t)

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

int sgn(double x) { return (x > 1e-8) - (x < -1e-8); }
int count_bit(int x) { return x == 0? 0 : count_bit(x >> 1) + (x & 1); }

template<class T> inline void to_min(T &a, const T b) { if (b < a) a = b; }
template<class T> inline void to_max(T &a, const T b) { if (b > a) a = b; }

// SELF TEMPLATE CODE END

long long solve(long long a, long long b) {
  if (a > b) {
    return solve(b, a);
  }
  long long ret = (2 * (b / a)) * a;
  if (b % a == 0) {
    return ret - a;
  }
  return ret + solve(b % a, a);
}

int main() {
  ios::sync_with_stdio(false);

  long long n, x;
  while (cin >> n >> x) {
    cout << n + solve(x, n - x) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc109/tasks/abc109_b

n = int(input())

words = []
for _ in range(n):
    words.append(input())

pre = words[0]
done = set([pre])
for i in range(1, n):
    w = words[i]
    if pre[-1] == w[0] and w not in done:
        pre = w
        done.add(w)
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 38448
#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>;
const int mod = 1000000007;
const ll INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<int> q;
  ll ans = 0;
  rep(i,n){
    int a;
    cin >> a;
    q.push(a);
  }
  rep(i,m){
    int b = q.top();
    q.pop();
    q.push(b/2);
  }
  while(!q.empty()){
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 3828
tap_list = list(input())
confort = 0
for i in range(len(tap_list)):
  if (i+1) % 2 == 1 and tap_list[i] == "L":
    confort = 1
  elif (i+1) % 2 == 0 and tap_list[i] == "R":
    confort = 1

if confort == 0:
  print("Yes")
elif confort == 1:
  print("No")
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     string str;
     ll cnt=0;
     cin>>str;
     for(int i=0;i<str.size()-1;i++)
     {
         if(str[i]==str[i+1])
         {
             if(str[i+1]=='0')
                str[i+1]='1';
             else
                str[i+1]='0';
            cnt++;
         }
     }
     cout<<cnt<<endl;
}



Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    S = list(input())

    ans = 10 ** 6
    sum_count = S.count('E')
    for s in S:
        aft = 0
        if s == 'W':
            aft = 1
        else:
            sum_count -= 1
        ans = min(ans, sum_count)
        sum_count += aft
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64112