akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }


	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one
}

int main() {

	int h, w;
	cin >> h >> w;
	vector<vector<int>> s(h, vector<int>(w));
	rep(i, h) {
		rep(j, w) {
			char c = inp1;
			if (c == '#') s[i][j] = 1;
			else s[i][j] = 0;
		}
	}

	// 全ルート探索する
	int ans = inf;

	queue<tuple<int, int, int>> que;
	que.emplace(0, 0, s[0][0]);
	vector<vector<vector<int>>> dist(h, vector<vector<int>>(w, vector<int>(2, inf)));
	dist[0][0][s[0][0]] = s[0][0];
	
	while (!que.empty()) {
		int x, y, p;
		// tie でtupleの要素をまとめて取り出せる　便利
		tie(y, x, p) = que.front(); que.pop();
		rep(i, 2) {
			int tx = x + dx[i];
			int ty = y - dy[i];

			if (tx >= w || ty >= h) continue;
			int tc = dist[y][x][p], tp = p;
			// 白から黒に行くときは加算
			if (p == 0 && s[ty][tx] == 1) {
				++tc;
			}
			tp = s[ty][tx];
			if (dist[ty][tx][tp] > tc) {
				dist[ty][tx][tp] = tc;
				que.emplace(ty, tx, tp);
			}
		}
	}

	Cout(dist[h - 1][w - 1][s[h - 1][w - 1]]);

	return 0;
}


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

int a[3];
int main(){
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    a[s[i]-'a']++;
  }
  for (int i = 0; i < 3; i++) {
    if (a[i] == 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(void){
  long long n, u = 0;

  cin >> n;
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  
  long long f;
  f = n / 500;
  u += f * 1000;
  n -= 500 * f;
  f = n/5;
  u += f * 5;
  
  cout << u << endl;
  
  return 0;
}

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

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    bool rev = false;
    deque<char> deq;
	for(auto e:S) deq.push_back(e);
    rep(i, Q) {
        int q = 0;
        cin >> q;
        if (q == 1) {
            rev = !rev;
            continue;
        }
        int F;
        char C;
        cin >> F >> C;
        if (!rev) {
            if (F == 1)
                deq.push_front(C);
            else
                deq.push_back(C);

        } else {
            if (F == 1)
                deq.push_back(C);
            else
                deq.push_front(C);
        }
    }

    if(!rev){
		for(auto e:deq) cout << e;
	} else {
        reverse(all(deq));
		for(auto e:deq) cout << e;
	}
	cout << endl;
}

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

int main() {
  vector<vector<int>> bingo_card(3, vector<int>(3));
  vector<vector<bool>> bingo(3, vector<bool>(3, false));

  cin >> bingo_card.at(0).at(0) >> bingo_card.at(0).at(1) >> bingo_card.at(0).at(2);
  cin >> bingo_card.at(1).at(0) >> bingo_card.at(1).at(1) >> bingo_card.at(1).at(2);
  cin >> bingo_card.at(2).at(0) >> bingo_card.at(2).at(1) >> bingo_card.at(2).at(2);

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    int choose;
    cin >> choose;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (bingo_card.at(j).at(k) == choose) {
          bingo.at(j).at(k) = true;
        }
      }
    }
  }

  bool flag = false;
  for (int i = 0; i < 3; i++) {
    int row_count = 0;
    for (int j = 0; j < 3; j++) {
      if (bingo.at(i).at(j)) {
        row_count++;
      }
      if (row_count == 3) {
        flag = true;
      }

      if (i == 1 && j == 1) {  // 斜め
        if (bingo.at(i - 1).at(j - 1) && bingo.at(i).at(j) &&
            bingo.at(i + 1).at(j + 1)) {
          flag = true;
        } else if (bingo.at(i - 1).at(j + 1) && bingo.at(i).at(j) &&
                   bingo.at(i + 1).at(j - 1)) {
          flag = true;
        }
      } else if (i == 1) {  // 縦
        if (bingo.at(i - 1).at(j) && bingo.at(i).at(j) &&
            bingo.at(i + 1).at(j)) {
          flag = true;
        }
      }
    }

    if (flag) {
      cout << "Yes" << endl;
      break;
    }
  }
  if(!flag) {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
#define CO(a, b, c) ((a) ? (b) : (c))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

int main(void)
{

    long double n, ans, f;
    cin >> n >> f;
    ans = (n * f);
    printf("%.0Lf", floorl(ans));

    return 0;
}

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

void prians(bool answer) {
  if(answer)
    cout << "first" << endl;
  else
    cout << "second" << endl;
}

bool solve();

int n;
int a[100005] = {0};
bool ch = 0;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i)
    if(a[i] % 2 == 1) ch = 1;
  prians(ch);
  return 0;
}


Measured memory_bytes: 640
// Your code here!
func gcd(_ a: Int, _ b: Int) -> Int {
   let r = a % b
   if r != 0 {
       return gcd(b, r)
   } else {
       return b
   }
}
var num = Int(readLine()!)!
var ans:Int = 0
for i in 1...num{
    for j in 1...num{
        for k in 1...num{
        var n:Int = 0
            n += gcd(i,j)
            ans += gcd(k,n)
        }
    }
}
print(ans)

Measured memory_bytes: 7800
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long n;
    scanf("%ld", &n);
    long ia[60] = {0};
    for(long i = 0; i < n; i++){
        long a;
        scanf("%ld", &a);
        for (int j = 0; j < 60; j++){
            ia[59 - j] += a % 2;
            a /= 2;
        }
    }
    long iTwoPow[60];
    iTwoPow[0] = 1;
    for(int i = 1; i < 60; i++){
        iTwoPow[i] = 2 * iTwoPow[i - 1];
        iTwoPow[i] %= 1000000007;
    }
    long nAns = 0;
    for(int i = 0; i < 60; i++){
        long iA = (ia[59 - i]) * (n - ia[59 - i]);
        iA %= 1000000007;
        iA *= iTwoPow[i];
        iA %= 1000000007;
        nAns += iA;
        nAns %= 1000000007;
    }
    
    printf("%ld",nAns);
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';
ll i, j, le;

int main()
{
	IOS;
	int t;
	t = 1;
	while (t--)
	{
		ll ans = -1;
		ll n2;
		cin>>n2;
		 if (n2 % 2 == 0 || n2 % 5 == 0)
		{
			cout << -1 << e;
		}
		else 
		{
			ans = 1;
			ll num = 7;
			while (num % n2 != 0)
			{
				num = (num * 10 + 7) % n2;
				ans++;
			}
			cout << ans << e;
		}
	
	}
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
     
int main() {
 int a , b , t , o;
 cin >> a >> b >> t >> o;
  b=a/100 ;
  a=a%100 ;
  t=a/10  ;
  a=a%10  ;
  o=a     ;
 cout << b + o + t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll n,x;
    cin>>n>>x;
    ll l[n];
    for(int i=0;i<n;++i){
        cin>>l[i];
    }
    ll now=0;
    ll sum=0;
    for(int i=0;i<=n;++i){
        now+=l[i];
        if(now<=x){
            sum+=1;
        }else{
            break;
        }
    }
    cout<<sum+1<<endl;
}

Measured memory_bytes: 256
from collections import Counter
N=int(input())
D=list(map(int,input().split()))
mod=998244353
if D[0] != 0:
    print(0)
else:
    ans=1
    del D[0]
    if 0 in D:
        print(0)
    else:
        numbers=Counter(D)
        for n in range(2,max(numbers.keys())+1):
            if numbers[n]==None:
                ans=0
                break
            ans*=numbers[n-1]**numbers[n]
        print(ans%mod)
        

Measured memory_bytes: 98960
N,P = map(int, input().split())
A = list(map(int, input().split()))
in_odd = False
for i in range(N):
    if A[i]%2:
        in_odd = True
        break
if not in_odd:
    if P:
        print(0)
    else:
        print(2**N)
else:
    print(2**(N-1))

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<stdlib.h>

using namespace std;

int fact(int n)
{
    int f=1;
    for(int i=n;i>0;--i) f*=i;
    return f;
}
int main()
{
    int n;
    cin>>n;
    vector<int> ar(n),ar2(n);
    for(int i=0;i<n;++i) cin>>ar[i];
    for(int i=0;i<n;++i) cin>>ar2[i];

    int s1=0,s2=0,c1,c2,d;
    for(int i=0;i<n;++i)
    {
        c1=c2=0;
        for(int j=i-1;j>=0;--j)
        {
            if(ar[i]>ar[j])
                ++c1;
            if(ar2[i]>ar2[j])
                ++c2;
        }
        s1+=(ar[i]-1-c1)*fact(n-i-1);
        s2+=(ar2[i]-1-c2)*fact(n-i-1);
    }
    d=abs((++s1)-(++s2));
    cout<<d;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

X,Y,A,B,C = inputIL()
p = inputIL()+[0]*X
q = inputIL()+[0]*Y
r = inputIL()

p.sort(reverse=True)
q.sort(reverse=True)
r.sort()

p = p[:X]
q = q[:Y]

a = p+q+r

a.sort(reverse=True)

print(sum(a[:X+Y]))


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

inline int inv(int a, int m) {
	int i = 1, j = 0;
	for (int b = m; a > 1; swap(i, j), swap(a, b)) {
		j = (j + b / a * long(m - i)) % m;
		b %= a;
	}
	return i;
}
long f[222222] = { 1 };
int main() {
	int n, m, k, p = 1e9 + 7;
	cin >> n >> m >> k;
	for (int i = 0; i < n*m; i++)
		f[i + 1] = (i + 1)*f[i] % p;
	long a = inv(f[n*m - k] * f[k] % p, p)*f[n*m] % p;
	long b = inv(6, p)*long(k - 1) % p;
	(b *= k) %= p;
	cout << (a*(m + n) % p)*b%p << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int a,b,c,n;
    int count_n = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(n = a; n <= b; n++) {
  if(c % n == 0) {
    count_n += 1;
  }
}
  printf("%d\n", count_n);  
  
  return 0;
}



Measured memory_bytes: 2140
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int n;
int wt[107];
lli val[107];
lli dp[107][100007];
int vis[107][100007];
lli fn(int i,int w) {
	if(i>n) return 0;
	if(vis[i][w]) return dp[i][w];
	vis[i][w]=1;
	lli tmp,ans=fn(i+1,w);
	if(wt[i] <= w) ans=max(ans,val[i]+fn(i+1,w-wt[i]));
	return dp[i][w]=ans;
}
void TestingChaluKarEyy() {
	int w;
	cin>>n>>w;
	fr(i, 1, n) cin>>wt[i]>>val[i];
	cout << fn(1,w);
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	jaldiKarNe;
	int TestingKaravvuChhe = 1;
	// cin >> TestingKaravvuChhe;
	while (TestingKaravvuChhe--) {
		TestingChaluKarEyy();
	}
}


Measured memory_bytes: 111928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  string S, T;
  cin >> N >> S >> T;
  
  int i = 0;
  
  while (i < N){
    cout << S.at(i);
    cout << T.at(i);
    i++;
  }
  
  
  
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() (arr string) {
	sc.Scan()
	arr = sc.Text()
	return
}

func printLine(arr []int) {
	for i := 0; i < len(arr); i++ {
		fmt.Print(arr[i])
		if i != (len(arr) - 1) {
			fmt.Print(" ")
		}
	}
	fmt.Print("\n")
}

func stringToInt(arr []string) (arr2 []int) {
	for _, val := range arr {
		val2, _ := strconv.Atoi(val)
		arr2 = append(arr2, val2)
	}
	return
}

func insertionSort(arr []int) {
	for i := 0; i < len(arr); i++ {
		v := arr[i]
		j := i - 1
		for {
			if j < 0 || arr[j] <= v {
				break
			}
			arr[j+1] = arr[j]
			j--
		}
		arr[j+1] = v
		printLine(arr)
	}
	return
}

func main() {
	var n int
	fmt.Scan(&n)

	line := nextLine()
	arrString := strings.Split(line, " ")
	arr := stringToInt(arrString)

	insertionSort(arr)
}



Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
int H,W,w,h;
const int INF =2333;
main()
{
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if (H%h==0&&W%w==0) return printf("No"),0;
	printf("Yes\n");
	for (int i=1;i<=H;++i)
		for (int j=1;j<=W;++j)
	      printf("%d%c",(i%h==0&&j%w==0?(1-h*w)*INF-1:INF),j==W?'\n':' ');
	return 0;
}

Measured memory_bytes: 1536
import java.io.*;
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    double p[] = new double[n];
    for(int i=0;i<n;i++) p[i] = in.nextDouble();
    double dp[][]=  new double[n][n+2];
    dp[0][1] = 1-p[0];
    dp[0][2] = p[0];
    for(int i=1;i<dp.length;i++)
      for(int j=1;j<dp[i].length;j++)
        dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
    double ans = 0;
    for(int i=(int)Math.ceil(n/2) + 2;i<=n+1;i++)
      ans += dp[n-1][i];
 
    System.out.println(ans);
  }

  public static void print(double a[][]){
    for(int i=0;i<a.length;i++)
      System.out.println(Arrays.toString(a[i]));
  }
}

Measured memory_bytes: 124044
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[5];
	for (int i = 0; i < 5; i++){
		cin >> a[i];
	}
	sort(a, a + 5);
	for (int i = 4; i > 0; i--){
		cout << a[i] << " ";
	}
	cout << a[0]<<endl;
}

Measured memory_bytes: 1176
import java.io.*;

class Main {
    public static void main (String[ ] args) throws IOException {
         
        BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
        String str = input.readLine( );
    	int num = Integer.parseInt(str);
         
        System.out.println(num*num*num);
    }
}

Measured memory_bytes: 16876
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<algorithm>
#include<vector>
using namespace std;

const int N = 4e5;
int a[N+3];
int d[N+3];
int dp[N+3][10];
vector<int> b;
int n;

bool cmp(int x,int y) {return x>y;}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	int pos = 0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]>=i && a[i+1]<=i) {pos = i; break;}
	}
//	printf("pos=%d\n",pos);
	int len1 = 0;
	for(int i=pos+1; i<=n; i++) {if(a[i]>pos-1) len1++;}
	int len2 = a[pos]-pos;
//	printf("len1=%d len2=%d\n",len1,len2);
	if((!(len1&1)) && (!(len2&1))) printf("Second");
	else printf("First");
	return 0;
}

Measured memory_bytes: 2304
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    x, k, d = _ia()
    x = abs(x)
    xm = x % d
    n = (x-xm)//d

    if k >= n:
        if n % 2 == k % 2:
            return xm
        else:
            return -xm + d
    else:
        return x - k * d


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 61836
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N;
	cin >> N;
	vector<int> a(N + 1, -1);//a[0]=-1, a[1]から始まるとして考える
	rep(i, N) {
		cin >> a[i + 1];
	}
	vector<int> b(N + 1, -1);
	for (int i = N; i > N / 2; i--) {
		b[i] = a[i];
	}
	int tmp_sum;
	for (int i = N / 2; i > 0; i--) {
		tmp_sum = 0;
		for (int k = 2; k <= N / i; k++) {
			tmp_sum += b[i * k] % 2;
		}
		b[i] = (tmp_sum + a[i]) % 2;
	}
	int cnt = 0;
	rep1(i, N + 1) {
		if (b[i] == 1) {
			cnt++;
		}
	}
	cout << cnt << endl;
	rep1(i, N + 1) {
		if (b[i] == 1) {
			cout << i << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 2432
N,K = map(int,input().split())
A = list(map(int,input().split()))

A = [A[i] for i in range(N) if A[i]!=0]
c = (N+len(A)-1)*(N-len(A))
N = len(A)
A.sort()
B = A[::-1]

def count(m):
    res = 0
    if m>=0:
        res += c
        j = N
        for i in range(N):
            if A[i]>0:
                break
            while j>0:
                if A[i]*A[j-1]<=m:
                    j -= 1
                else:
                    break
            res += N-j
        if A[i]>0:
            j = N-1
            for i in range(i,N):
                while j>=0:
                    if A[i]*A[j]>m:
                        j -= 1
                    else:
                        break
                res += j+1
    else:
        j = 0
        for i in range(N):
            if B[i]<0:
                break
            while j<N:
                if B[i]*B[j]>m:
                    j += 1
                else:
                    break
            res += N-j
        if B[i]<0:
            j = -1
            for i in range(i,N):
                while j<N-1:
                    if B[i]*B[j+1]<=m:
                        j += 1
                    else:
                        break
                res += j+1
    for i in range(N):
        if A[i]*A[i]<=m:
            res -= 1
    res //= 2
    return res

ng = -10**18
ok = 10**18
m = (ng+ok)//2
if N==0:
    ans = 0
else:
    for n in range(100):
        if count(m)<K:
            ng = m
        else:
            ok = m
        m = (ng+ok)//2
    ans = int(ok)
print(ans)

Measured memory_bytes: 98436
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
    int q;
    map<string, int> mp;
    cin >> q;
    for(int i=0;i<q;i++){
        int c, x;
        string key;
        cin >> c >> key;
        if(c==0){
            cin >> x;
            mp[key] = x;
        }
        else if(c==1){
            if(mp.count(key)){
                cout << mp[key] << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
        else{
            mp.erase(key);
        }
    }
    return 0;
}



Measured memory_bytes: 27728
n,a,b=map(int,input().split())
ct=0
for i in range(1,n+1):
    num=0
    flag=0
    for j in range(len(str(i))):
        num+=int(str(i)[j])
        if num>b:
            flag=1
            break
    if a>num:
        flag=1
    if flag==0:
        ct+=i
print(ct)

Measured memory_bytes: 40684
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int n;
string names[100001];

int main() {
  cin >> n;
  rep(i,n) cin >> names[i];

  ll m = 0, a = 0, r = 0, c = 0, h = 0;
  for (int i = 0; i < n; ++i) {
    if(names[i][0] == 'M') ++m;
    else if (names[i][0] == 'A') ++a;
    else if (names[i][0] == 'R') ++r;
    else if (names[i][0] == 'C') ++c;
    else if (names[i][0] == 'H') ++h;
  }

  ll num[5] = {m, a, r, c , h};
  ll ans = 0;
  for (int i = 0; i < 5; ++i) {
    for (int j = i+1; j < 5; ++j) {
      for (int k = j+1; k < 5; ++k) {
        ans += num[i] * num[j] * num[k];
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int s,d,n;
	char c;
	string st;
	cin>>n;
	for(int i=0;i<n;i++){
	s=0;d=0;
	int cur=0;
	cin>>st;
	while(cur<st.size()){
		s+=st[cur++]-'0';
		d+=1;
	}
	if(((s-1)/9+d)%2==0)cout<<"Fabre wins."<<endl;
	else cout<<"Audrey wins."<<endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

const int inf = 1e8;

int dist[100010][3] ;

int main(){
  
  int N,M; cin >> N >> M;
  
  vector<vector<int>> to(N);
  
  for(int i = 0; i < M; i++){
    int u,v; cin >> u >> v; u--; v--;
    to[u].push_back(v);}
  
  int start,goal; cin >> start >> goal; start--; goal--;
  
  for(int i = 0; i < 100010; i++){
    for(int j = 0; j < 3; j++){
      dist[i][j] = inf;}}
  
  queue<pair<int,int>> Q; Q.push(make_pair(start,0));
  dist[start][0] = 0;
  while(!Q.empty()){
    pair<int,int> p = Q.front(); Q.pop();
    int s = p.first; int t = p.second; //sがノード、tが３で割ったmod
    for(int i = 0; i < to[s].size(); i++){
      int r = to[s][i]; int nt = (t + 1) % 3; //pから繋がるノードを探索 
      if( dist[r][nt] != inf){ continue;}
      else{ dist[r][nt] = dist[s][t] + 1; Q.push(make_pair(r,nt));}}}
  
  int answer = dist[goal][0];
  if(answer == inf){ answer = -1;}
  else{ answer /= 3;}
cout << answer << endl; return 0;}
  


Measured memory_bytes: 6912
import numpy as np
N = int(input())

dp = np.zeros((N+1,4,4,4),dtype="int")

dp[0,3,3,3] = 1
mod = 10**9+7


for l in range(N):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                if dp[l,c3,c2,c1] == 0:
                    continue
                for c0 in range(4):
                    if c0 == 1 and c1 == 2 and c2 == 0:
                        continue
                    if c0 == 2 and c1 == 1 and c2 == 0:
                        continue
                    if c0 == 2 and c1 == 0 and c2 == 1:
                        continue
                    if c0 == 2 and c1 == 1 and c3 == 0:
                        continue
                    if c0 == 2 and c2 == 1 and c3 == 0:
                        continue
                    dp[l+1,c2,c1,c0] += dp[l,c3,c2,c1]
                    dp[l + 1, c2, c1, c0] %= mod
                    
ans = 0
for c1 in range(4):
    for c2 in range(4):
        for c3 in range(4):
            ans += dp[N,c3,c2,c1]
            ans %= mod
print(ans%mod)

Measured memory_bytes: 12488
#!/usr/bin/env ruby

a, b, c, x = readlines.map { |v| v.strip.to_i }

cnt = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      cnt += 1 if (500 * i + 100 * j + 50 * k) === x
    end
  end
end
puts cnt

Measured memory_bytes: 1788
//          ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define ull unsigned long long int
#define ll long long int
#define ui unsigned int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e9
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007 
                              //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}

vector<int> parent(200005);
vector<int> s(200005);

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}


int main() {
    
    fastio;
    int n, m;
    cin >> n >> m;
    int grps = 1;
    for(int i=1;i<=n;i++)
    {
        parent[i] = i;
        s[i] = 1;
    }
    while(m--)
    {
        int a, b;
        cin >> a >> b;
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (s[a] < s[b])
                swap(a, b);
            parent[b] = a;
            s[a] += s[b];
        }
    }
    fr(i, 1, n)
    {
        int y = find_set(i);
        grps = max(grps, s[y]);
    }
    cout << grps;




    return 0; 
}

Measured memory_bytes: 4656
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		int k=ir.nextInt();
		int[] a=ir.nextIntArray(n);
		Arrays.sort(a);
		int ret=0;
		for(int i=0;i<k;i++)
			ret+=a[n-1-i];
		out.println(ret);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21204
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N = d_in()
cost = []
for _ in range(N):
    cost.append(d_in())

print(sum(cost) - max(cost)//2)


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(m); REP(i, m) cin >> a[i];
  cout << max(n - accumulate(ALL(a), 0), - 1) << '\n';
  return 0;
}


Measured memory_bytes: 3656
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var result = Lcm(input[0], input[1]);
            Console.WriteLine(result);
        }

        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        public static long Gcd(long a, long b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var r = a % b;
                a = b;
                b = r;
            }
            return a;
        }
    }
}

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

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

struct fast_io {
    static constexpr int size_in = 1 << 26, size_out = 1 << 26;
    char data_in[size_in], data_out[size_out], *p_in, *p_out, s[30];
    fast_io() { fread(data_in, 1, size_in, stdin), p_in = data_in, p_out = data_out; }
    ~fast_io() { fwrite(data_out, 1, p_out - data_out, stdout); }
    void putchar(char x) { *p_out++ = x; }
    template<typename T> void putint(T x) {
        if (x < 0) { *p_out++ = '-', x = -x; }
        int i = 0;
        do { s[i++] = x % 10 + '0'; } while (x /= 10);
        while (i--) { *p_out++ = s[i]; }
    }
    template<typename T=int> T getint() {
        while (!isdigit(*p_in) && *p_in != '-') { p_in++; }
        bool negative = *p_in == '-';
        T ret = negative ? 0 : *p_in - '0';
        while (isdigit(*++p_in)) { (ret *= 10) += *p_in - '0'; };
        return negative ? -ret : ret;
    }
} io;

int main() {
    int N = io.getint(), M = io.getint();
    using bset = bitset<300>;
    vector<bset> src(N);
    rep(i, N) {
        rep(j, M) {
            int a = io.getint();
            src[i][j] = a;
        }
    }
    int rank = 0;
    for (int i = 0; i < src.size(); i++) {
        for (int j = src.size() - 1; j > i; j--) {
            int x = src[j]._Find_first(), y = src[j - 1]._Find_first();
            if (x < y) { src[j - 1] ^= src[j]; }
            if (x <= y) { src[j] ^= src[j - 1]; }
        }
        if (src[i].none()) { break; }
        rank++;
    }
    constexpr int MOD = 998244353;
    auto mpow = [&](int n) {
        long long ret = 1, mul = 2;
        while (n) {
            if (n & 1) { (ret *= mul) %= MOD; }
            (mul *= mul) %= MOD;
            n >>= 1;
        }
        return ret;
    };
    io.putint((mpow(N + M - 1) - mpow(N + M - rank - 1) + MOD) % MOD);
}

Measured memory_bytes: 3804
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int n , k ;
const int M = 1e5 + 9 ;
int a[M];
int dp[M];
int main ()
{
    scanf ("%d%d" , &n ,&k);
    for (int i=0 ; i < n ;i++)
        scanf ("%d" ,a+i );
    int st = 1 ;
    for (int i = 1; i <= k ;i++)
        dp[i] = 1;
    for (int i =0 , j = k-1 ; j < n ; st++)
    {
        dp[  j+1 ] = st ;

        i = j ;
        j = i+k-1;
    }
    for (int i = n ; i > k ;i--)
    {
        if (dp[i] == 0 )dp[i] = dp[i+1];
    }
    int ans =0 ;
            for (int i =0 , j = k - 1 ; j < n ; )
            {
                //cout << i + 1<<" " << j + 1 <<"\n";
                ans++;
                if (j == n-1 )break;
                i = j;
                j = i+k-1;
                if (j >= n )
                {
                    ans++;
                    break ;
                }
            }
    dp[n] = ans ;
    //for (int i = 1; i <=n ; i++)
     //   cout << dp[i] <<" ";
   // cout <<"\n";
    if (n == k )
    {
        printf ("1\n");
    }else
    {
        int id = 0 ;
        for (int i =0 ; i < n ;i++)if (a[i] == 1 )id = i ;
        int ans = n + 20;
        for (int i =0 ; i + k <= n ;i++)
        {
            if (id >= i && id <= i+k-1 ){
            //cout <<"Cost Left " << dp[i + (i != 0 )] <<" " << "cost Right " << dp[ n - (i+k)+1  ]<<"\n";
            //cout << i <<" " << n-(i+k)+1 <<" " << 1 + (i != n-1 ) * dp[i + (i!=0)] + dp[n - (i+k)+1] <<"\n";
           // cout <<"id "  << i+1 <<" " << i+k <<"\n";
            ans = min (ans , 1 + dp[i+ (i!=0)] + (i+k-1 != n-1)*dp[n-(i+k)+1]);
            }
        }
        cout << ans <<"\n";
    }

}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
int N;
vi H;

int main(int argc, char** argv) {
  cin >> N;
  H.resize(N);

  for (int i=0; i<N; i++) {
    cin >> H[i];
  }

  bool ret = true;

  H[0]--;
  for (int i=1; i<N; i++) {
    if (H[i-1] < H[i]) {
      H[i]--;
    } else if (H[i-1] == H[i]) {
      // do nothing
    } else {
      ret = false;
      break;
    }
  }

  cout << (ret ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }
const char ok = 'o';

int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    if (n == 1) { cout << 1 << endl; return 0; }
    
    
    int cnt = 0;
    vector<int> a(n, 0), b(n, 0);
    for (int i = 0; i < n; i++) {
        a[i] = cnt;
        if (s[i] == ok) {
            cnt++; a[i]++;
            for (int j = i + 1; j <= min(n-1, i + c); j++) {
                a[j] = a[j-1];
            }
            i += c;
        }
    }
    cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
        b[i] = cnt;
        if (s[i] == ok) {
            cnt++; b[i]++;
            for (int j = i - 1; j >= max(0, i - c); j--) {
                b[j] = b[j+1];
            }
            i -= c;
        }
    }
    
    vector<int> ans;
    for (int i = 0; i < n; i++) if (s[i] == ok) {
        int res = 0;
        if (0 < i) res += a[i-1];
        if (i < n - 1) res += b[i+1];
        if (res < k) ans.emplace_back(i + 1);
    }
    for (auto &e : ans) cout << e << endl;
    return 0;
}

Measured memory_bytes: 4216
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
  int i;
  char s[11];
  long long times[11] = {};
  scanf("%s", s);
  times[strlen(s)-1] = 2;
  if (strlen(s) == 1) {
    printf("%d", s[0]-'0');
  } else {
    for (i = strlen(s)-2; i >= 0; i--) {
      times[i] = times[i+1]*5+1;
    }
    long long ans = 0;
    for (i = strlen(s)-1; i >= 0; i--) {
      ans += (s[i] - '0') * times[i] * pow(2, strlen(s)-2);
    }
    //for (i = 0; i < 11; i++) {
    //  printf("%f ", times[i]*pow(2, strlen(s)-2));
    //}
    printf("%lld", ans);
  }
  return 0;
}


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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var x = int.Parse(list[0]);
        var a = int.Parse(list[1]);

        Console.WriteLine(x < a ? 0 : 10);
    }

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int n,m,k;
int d[16],v[100][100];

const int INF=123456789;
const int N=1<<16;
int dp[N];
int nxt_mask[N][100];

int main()
{
    scanf(" %d %d %d", &n, &m, &k);
    rep(i,m)
    {
        scanf(" %d", &d[i]);
        --d[i];
    }
    rep(i,n)rep(j,k)
    {
        scanf(" %d", &v[i][j]);
        --v[i][j];
    }

    rep(mask,N)rep(i,k)
    {
        int nx=0;

        rep(j,m)if(mask>>j&1)
        {
            int next_room = v[d[j]][i];
            // printf(" next_room = %d\n", next_room);
            rep(d_idx,m)
            {
                if(d[d_idx] == next_room)
                {
                    nx |= (1<<d_idx);
                    break;
                }
            }
        }

        nxt_mask[mask][i] = nx;
    }

    fill(dp,dp+N,INF);
    int start = (1<<m)-1;
    dp[start] = 0;

    queue<int> que;
    que.push(start);
    while(!que.empty())
    {
        int mask = que.front();
        que.pop();

        rep(i,k)
        {
            int nx = nxt_mask[mask][i];
            if(dp[nx] > dp[mask]+1)
            {
                dp[nx] = dp[mask]+1;
                que.push(nx);
            }
        }
    }

    printf("%d\n", dp[0]);
    return 0;
}

Measured memory_bytes: 29236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,W;
	cin>>n>>W;
	int w[n],v[n];
	for(int  i=0;i<n;i++)cin>>w[i]>>v[i];
	int possible[W+1];ll ans[W+1];
	memset(ans, 0, sizeof ans);
	memset(possible, 0, sizeof possible);
	possible[0]=1;
	for(int i=0;i<n;i++)
	{
		for(int x=W;x>=0;x--)
		{
			if(possible[x] and x+w[i]<=W)
			{
				possible[x+w[i]]=1;
				ans[x+w[i]]=max(ans[x]+v[i], ans[x+w[i]]);
			}
		}
	}
	ll a=-1;
	for(int i=0;i<=W;i++)
	{
		a=max(a,ans[i]);
	}

	cout<<a;
}

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

int main(void) {
	int n;
	cin >> n;
	vector<double> a(n);
	double sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		sum += 1 / a.at(i);
	}
	cout << 1 / sum << endl;
}

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

int main(void){
    // Your code here!
   int n,m;
   cin >> n >> m;

   int num = 1;
   rep(i,n-1) num *= 10;
   if(num==1) num = 0;
   //int d[n] ={};
   vector <int> d(n,0);
   
   string cou = to_string(num);
   
   int f = 0;
   rep(i,m){
     int a;
     char b;
     cin >> a >> b;

     if(a==1 && b=='0' && n!=1)  f = 1;
     if( d[a-1] ==1 && cou[a-1]!=b) f = 1;
     d[a-1] = 1;
     cou[a-1] = b;
    
   }

   if (f == 1) cout << -1 << endl;
   else cout << cou << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int A, B;
signed main(){
	cin >> A >> B;
	rep(i, 100000){
		if(i*8/100 == A && i*10/100 == B){
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
}

Measured memory_bytes: 256
n = int(input())

max_prime = 1382

primes = [True for i in range(max_prime+1)]

for i in range(2, max_prime):
    if primes[i]:
        for j in range(i+i, max_prime+1, i):
            primes[j] = False

primes[0] = False
primes[1] = False

primes_num = [i for i, el in enumerate(primes) if el]

ans = []

for p in primes_num:
    if p % 10 == 1:
        ans.append(p)

    if len(ans) == n:
        break


for p in ans:
    print(p, end=" ")

print()


Measured memory_bytes: 3064