akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// idx, (未処理、偶数左、奇数、偶数右)
const int VARI = 5;
int dp[200010][VARI];
signed main() {
    int N; cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++) {
        cin >> v[i];
    }

    // DP
    const int M1 = 0;
    const int M2 = 1;
    const int E1 = 2;
    const int E2 = 3;
    const int O  = 4;
    fill(dp[0], dp[N+1], INF);
    dp[0][M1] = 0;
    for(int i=0; i<N; i++) {
        /*
        vector<string> vs = {"M1", "M2", "E1", "E2", "O "};
        for(int k=0; k<VARI; k++) {
            fprintf(stderr, "dp[%lld][%s] = %lld\n", i, vs[k].c_str(), dp[i][k]);
        }
        */
        
        // 未処理左 (未処理左につづく)
        chmin(dp[i+1][M1], dp[i][M1] + v[i]);

        // 偶数左 (偶数左か未処理左につづく)
        int cost1 = (v[i] == 0 ? 2 : (v[i] % 2));
        chmin(dp[i+1][E1], min(dp[i][E1], dp[i][M1]) + cost1);

        // 偶数右 (奇数か偶数右につづく)
        int cost2 = (v[i] == 0 ? 2 : (v[i] % 2));
        chmin(dp[i+1][E2], min(dp[i][O], dp[i][E2]) + cost2);

        // 奇数 (偶数左か奇数か未処理左につづく)
        int cost3 = 1 - (v[i] % 2);
        int mi = min({dp[i][E1], dp[i][O], dp[i][M1]});
        chmin(dp[i+1][O], mi + cost3);

        // 未処理右 (未処理左以外のすべてにつづく)
        int mi2 = min({dp[i][E1], dp[i][E2], dp[i][O], dp[i][M2]});
        chmin(dp[i+1][M2], mi2 + v[i]);
    }

    int ans = INF;
    for(int i=0; i<VARI; i++) {
        chmin(ans, dp[N][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
n = int(input())
*a, = [input().split() for i in range(n)]

for i in range(n):
    a[i].append(i+1)

a_point = sorted(a, key = lambda x: int(x[1]), reverse = True)

a_name = sorted(a_point, key = lambda x: x[0])

ans = []

for i in a_name:
    print(i[2])

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

def main():
    N,T = map(int,input().split())
    t = list(map(int,input().split()))
    
    push,time,ans = 0,T,0
    for i in range(N):
        if t[i] <= time:
            time = t[i] + T
        else:
            ans += (time-t[push])
            push = i
            time = t[i]+T
        
    ans += (time - t[push])
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 25104
N = int(input())


def is_male(res):
    return True if res == 'Male' else False

l = 0
h = N
print(l)
prev_sex = is_male(input())
while True:
    print((h + l) // 2)
    res = input()
    if res == 'Vacant':
        break
    sex = is_male(res)
    if (((h + l) // 2 - l) % 2 == 0 and sex != prev_sex) or (((h + l) // 2 - l) % 2 == 1 and sex == prev_sex):
        h = (h + l) // 2
    else:
        l = (h + l) // 2
        prev_sex = sex


Measured memory_bytes: 3660
int main(void){

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

        int k[n],p[n],win[n],i;
        for(i=0; i<n; i++)
                scanf("%d %d",&k[i],&p[i]);

        for(i=0; i<n; i++){
                win[i]=k[i]%p[i];
                if(win[i]==0)
                        win[i]=p[i];
                printf("%d\n",win[i]);
        }

        return 0;

}

Measured memory_bytes: 596
A, B, C, D = map(int, input().split())

x = C-A
y = D-B
first = 'U'*y+'R'*x
second = 'D'+"L"*(x-1)+'D'*(y-1)+'L'
third = 'LU'+first+'RD'
last = 'RD'+second+'LU'

print(first+second+third+last)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int f(int x, int a, int b, int W) {
	if (x < a)return 1;
	if (b < x)return 1;
	if (b == W)return -1;
	return b + 2 - x;
}

int ff(string S, string T) {

	//答えansを仮置きする。
	//これが十分に大きくないと不正解となるので、
	//この値なら絶対に正しい答えが出る、という値を仮置きすること
	int ans = T.size();

	//Sの何文字目から調べるかを全探索する
	for (int start = 0; start <= S.size() - T.size(); start++)
	{
		int diff = 0;
		for (int i = 0; i < T.size(); i++)
		{
			if (T[i] != S[start + i]) {
				diff++;
			}
		}
		ans = min(ans, diff);
	}

	return ans;
}

int f(string s, string t) {
	int ans = 1000000;
	for (int i = 0; i <= s.size() - t.size(); ++i) {
		int c = 0;
		for (int j = 0; j < t.size(); ++j) {
			if (s[i + j] != t[j]) ++c;
		}
		ans = min(ans, c);
	}
	return ans;
}
int main() {
	string s, t;
	cin >> s >> t;
	PRI(f(s, t));
	return 0;
}




Measured memory_bytes: 3644
intCount, intBase = map(int, input().split())

intSum = 0
# everythins is minus
if intBase + intCount -1 < 0:
    intSum += -1 * (intBase + intCount -1)
# everything is plus
## --miss-- elif intBase > 1:
elif intBase >= 1:
    intSum -= intBase

for intTmp in range(1, intCount+1):
    intSum += intBase + intTmp -1

print(intSum)

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

#define MAX 100000

int main() {
	long long N, A[MAX], cum[MAX];
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	cum[0] = A[0];
	for (int i = 1; i < N; i++) {
		cum[i] = cum[i - 1] + A[i];
	}
	ans++;	// Max A[i] creature can eat every other creature
	for (int i = N - 2; i >= 0; i--) {
		if (2 * cum[i] >= A[i + 1]) {
			ans++;
		} else {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		while ( sc.hasNext() ) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int sum = a + b;

			int count = 0;
			while (sum != 0) {
				sum = sum / 10;
				count++;
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 26016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC092B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var line1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int D = line1[0];
            int X = line1[1];

            int ans = X;
            for(int i = 0; i < N; i++)
            {
                var line = int.Parse(Console.ReadLine());
                ans += (D - 1) / line + 1;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX
const int N=2e5+5;
const int M=1e9+7;


void solve(){
	string s;
	cin>>s;

	if(s[1]=='B'){
		s[1]='R';
	}
	else
		s[1]='B';

	cout<<s;
}



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

Measured memory_bytes: 3628
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

MAX_INT = 9999999999999999

N,d=gets.chomp.split(' ').map{|n| n.to_i}

def sum_of_digit(i)
	sum = 0
	tmp = i
	while(tmp > 0)
		sum += tmp % 10
		tmp /= 10
	end
	sum
end
min = MAX_INT
1.upto(N-1){|i|
	j = N - i
	tmp = sum_of_digit(i) + sum_of_digit(j)
	dputs "#{i},#{j}:#{tmp}"
	if(min > tmp)
		min = tmp
	end
}
puts min



Measured memory_bytes: 2428
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

x = int(input())
li = []
i = 1
while True:
    a = (1/2)*(i)*(i+1)
    if a>x:
        break
    li.append(int(a))
    i += 1
li.append((1/2)*(i+1)*(i+2))
if x == 1:
    print(1)
    sys.exit()
elif x == 2:
    print(2)
    sys.exit()
else:
    for i in range(len(li)-1):
        if x>li[i] and x<=li[i+1]:
            print(i+2)
            sys.exit()


Measured memory_bytes: 5148
#include <stdio.h>
int main(void){
    int count=0;
    char s[10],t[10];
    scanf("%s",s);
    scanf("%s",t);
    for(int i=0;i<3;i++){
        if(s[i]==t[i])count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
def ans(s, c):
	d, *n = map(str, s)
	for j in range(len(n)):
		if ((c >> j) & 1):
			d = d + '+' + n[j]
		else:
			d = d + '-' + n[j]
	print(d + '=' + '7')

def resolve():
	s = [int(i) for i in input()]
	c = 0

	for i in range(1 << len(s) - 1):
		ts = s[1:]
		k = s[0]
		for j in range(len(s)-1):
			if ((i >> j) & 1):
				k += ts[0]
			else:
				k -= ts[0]
			ts = ts[1:]
		if k == 7:
			c = i
	ans(s, c)

resolve()

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

//---------------------------------------------------------------------------------------------------------
#define error( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) {
    vector<string> v;
    stringstream ss( s);
    string x;
    while ( getline( ss, x, c))
        v.emplace_back( x);
    return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
    err( ++it, args...);
}
//----------------------------------------------------------------------------------------------------------

#define pb push_back
#define pfr push_front
#define eb emplace_back
#define ef emplace_front
#define fi first
#define se second
#define mp make_pair
#define fr(i,j,k) for(i = j; i < (k); i++)
#define bck(i,j,k) for(i = j; i > (k); i--)
#define all(x) x.begin(), x.end()
#define el '\n'

typedef long long int ll;
typedef long double DO;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
//---------------------------  TEMPLATE ENDS, MAKE CHANGES FROM HERE ----------------------------------------

const int mod = 1e9+7;
const ll inf = 2e18;
const DO eps = 1e-9;
const int NN = 1e5 + 2;

int ar[NN];

void solve(){
    int i = 0, j = 0, k = 0, n = 0, m = 0;
    cin >> n >> m;
    int x, y;
    cin >> x >> y;
    j = -100;
    k = 200;
    fr(i, 0, n) {
        int num; cin >> num;
        j = max(j, num);
    }
    fr(i, 0, m) {
        int num;
        cin  >>  num;
        k = min(k, num);
            }
    for(i = j+1; i <= k; i++) {
        if( x < i && i <= y) {
            cout << "No War";
            return;
        }
    }
    cout << "War";
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T = 1, tc;
    fr(tc, 1, T+1){
        solve();
    }
    return 0;
}
/* The judge is never wrong! Your code is buggy 😈
   Look for:
 * * an easier and alternate approach
 * * if concept is corret and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */



Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc166/tasks/abc166_c
use std::io;

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];

    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let h: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();


    let mut obs = [0; 100001];

    for _ in 0..m {
        let mut line = String::new();

        io::stdin()
            .read_line(&mut line)
            .unwrap();

        let words: Vec<usize> =
            line
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();

        let a = words[0] - 1;
        let b = words[1] - 1;
        
        if h[a] > h[b] {
            obs[b] = 1;
        } else if h[b] > h[a] {
            obs[a] = 1;
        } else {
            obs[b] = 1;
            obs[a] = 1;
        }
    }
    let mut ans = 0;
    for i in 0..n as usize {
        if obs[i] == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4240
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char const *argv[])
{
    int n, x, y, t;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> result(n - 1, 0);
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            t = min(j - i, abs(i - x) + abs(j - y) + 1);
            result.at(t - 1)++;
        }
    }
    // cout << a << b << c << endl;
    for (int e : result)
    {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() 
{
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K = 0;
	cin >> K;
	cout << a[K-1] << endl;
	return 0;
}

Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, d;
  cin >> n >> d;
  int ans = n / (2 * d + 1) + !!(n % (2 * d + 1));
  cout << ans << endl;

  return 0;
}

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

int ketasuu(int x){
    int count =0;
    while(x>0){
        x /= 10;
        count ++;
    }
    return count;
}

int main() {
    int N;
    int ans=0;
    cin >>N;
    for(int i=1;i<=N;i++){
        if(ketasuu(i)%2 != 0) ans++;
    }
    cout << ans <<endl;
}

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

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  //bruteforce is ok

  int a, b, k;
  cin >> a >> b >> k;

  for (int i = a; i <= b; ++i) {
    if (i <= a+k-1 || i >= b-k+1) {
      cout << i << endl;
    }
  }

  return 0;
}


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

int main() {

  int a,b,c;
  cin >> a >> b >> c;
  
  int x = b-a;
  
  int y = c-b;
  
  if(x==y)
    cout << "YES";
  
  else
    cout << "NO";
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;



int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7); 

  int a[5];
  REP(i,5){
    int t;
    cin>>t;
    a[i]=t;
  }
  
  sort(a,a+5, greater<int>());
  
  REP(i,5){
    if(i!=0) cout << " ";
    cout << a[i];
  }
  cout << endl;
  
  

  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define VV(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int a, b;
	char op;
	while(true) {
		cin >> a >> op >> b;
		if (op == '?') break;
		if (op == '+') P(a + b);
		else if (op == '-') P(a - b);
		else if (op == '*') P(a * b);
		else if (op == '/') P(a / b);
	}
	return 0;
}

Measured memory_bytes: 3208
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] num = new int[n];
		for (int i = 0; i<n ; i++ ) {
			num[i] = Integer.parseInt(br.readLine());
		}
		int max = num[1] - num[0];
		int min = num[0];
		for (int i = 1; i<n  ; i++) {
			min = Math.min(min,num[i-1]);
			max = Math.max(max,num[i]-min);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 43132
//2019.5.19 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=2e5+10;
const int kcz=1e9+7;
namespace MAIN {
    int n,m,dp[N],p=1,sum[N],ans;
    char str[N];
    inline void add(res &x,const res &y){
        x+=y,x>=kcz?x-=kcz:1;
    }
    inline int Add(const res &x,const res &y){
        return x+y>=kcz?x+y-kcz:x+y;
    }
    inline int mul(const res &x,const res &y){
        return int(1LL*x*y%kcz);
    }
    inline void MAIN(){
        n=read(),m=read(),scanf("%s",str+1);
        for(;p<=m;p++)if(str[p]!=str[1])break;
        res o=p;
        p--,dp[0]=sum[0]=1;
        if(p==m){
            ans=1;
            for(res i=0;i<=n;i++){
                if(i>=2)dp[i]=sum[i-2];
                sum[i]=Add(sum[i-1],dp[i]);
                if(n-i>=2)add(ans,mul(dp[i],n-i));
            }
            printf("%d\n",ans);
            return;
        }
        if(n&1){puts("0");return;}
        if(p%2==0)p++;
        for(res t=0,i=o;i<=m;i++)
            if(str[i]==str[1])t++;
            else {
                if(t&1)p=min(p,t);
                t=0;
            }
        n>>=1,p=(p+1)>>1;
        for(res i=0;i<=n;i++){
            if(i)dp[i]=Add(sum[i-1],kcz-(i-p>0?sum[i-p-1]:0)),sum[i]=Add(sum[i-1],dp[i]);
            if(n-i<=p)add(ans,mul(n-i,dp[i]<<1));
        }
        printf("%d\n",ans);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

#define N 500000

int a;

int parent(int);
int left(int);
int right(int);
void maxHeapify(int*,int);
void buildMaxHeap(int*);

main(){

  int i,A[N];

  scanf("%d",&a);
  for(i = 1; i <= a; i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A);

  for(i = 1; i <= a; i++){
    printf(" %d",A[i]);
  }
    printf("\n");
  
  return 0;
}

int parent(int i){
  return i / 2;
}
int left(int i){
  return 2 * i;
}


int right(int i){
  return 2 * i +1;
}
void maxHeapify(int* A,int i){
  int x,l,r,largest;

  l = left(i);
  r = right(i);

  if(l <= a && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= a && A[r] > A[largest]) largest = r;

  if(largest != i){
    x = A[i];
    A[i] = A[largest];
    A[largest] = x;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int* A){
  int i;
  for(i = a / 2;i >= 1; i--){
    maxHeapify(A,i);
  }
}

Measured memory_bytes: 2552
import sys
import math

A, B, H, M = map(int, input().split())

cA = 360*H/12 + 30 * M/60
cB = 360*M/60
cC = abs(cA - cB)
if cC > 180:
    cC = 360 - cC

coscC = math.cos(math.radians(cC))
C = A**2 + B**2 - 2 * A*B*coscC

print(C**(1/2))


Measured memory_bytes: 9528
def check(n):
    s = str(n)
    if s == s[::-1]:
        return True
    else:
        return False

def main():
    x, y = map(int, input().split())

    ans = 0
    for i in range(x, y + 1):
        if check(i):
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
    # print(check(123))
    # print(check(12321))

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> A(3,vector<int>(3));
  rep(i,3)rep(j,3) cin>>A.at(i).at(j);
  vector<vector<bool>> J(3,vector<bool>(3));
  int n; cin>>n;
  rep(i,n){
    int b=0; cin>>b;
    rep(i,3)rep(j,3) if(b==A.at(i).at(j)) J.at(i).at(j)=1;
  }
  if     (J.at(0).at(0)&&J.at(0).at(1)&&J.at(0).at(2)) cout<<"Yes"<<endl;
  else if(J.at(1).at(0)&&J.at(1).at(1)&&J.at(1).at(2)) cout<<"Yes"<<endl;
  else if(J.at(2).at(0)&&J.at(2).at(1)&&J.at(2).at(2)) cout<<"Yes"<<endl;
  else if(J.at(0).at(0)&&J.at(1).at(0)&&J.at(2).at(0)) cout<<"Yes"<<endl;
  else if(J.at(0).at(1)&&J.at(1).at(1)&&J.at(2).at(1)) cout<<"Yes"<<endl;
  else if(J.at(0).at(2)&&J.at(1).at(2)&&J.at(2).at(2)) cout<<"Yes"<<endl;
  else if(J.at(0).at(0)&&J.at(1).at(1)&&J.at(2).at(2)) cout<<"Yes"<<endl;
  else if(J.at(2).at(0)&&J.at(1).at(1)&&J.at(0).at(2)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll A, B, C; cin >> A >> B >> C;
	
	int ans = 0;
	while (true) {
		if (odd(A) or odd(B) or odd(C)) {
			cout << ans << endl;
			break;
		}
		if (A == B and B == C) {
			cout << "-1" << endl;
			break;
		}
		ll ta = A, tb = B, tc = C;
		A = tb / 2 + tc / 2;
		B = ta / 2 + tc / 2;
		C = ta / 2 + tb / 2;
		ans++;
	}
  
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

map<ll,bool> A;
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    ll res;
    rep(i, N){
        cin >> res;
        if (A.count(res)) {
            A.erase(res);
            ans--;
        } else {
            A.insert(make_pair(res, true));
            ans++;
        }
    }
    cout << ans << endl;

}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  int al = 0;
  rep(i, n){
    al = al ^ a.at(i);
  }
  vector<int> ans(n);
  rep(i, n){
    ans.at(i) = al ^ a.at(i);
  }
  rep(i, n){
    if(i != 0) cout << " ";
    cout << ans.at(i);
  }
  return 0;
}

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

void Main(){
    
}

int main(){
    string S;
    cin>>S;
    if(S=="SUN"){
        puts("7");
    } else if(S=="MON") {
        puts("6");
    } else if(S=="TUE") {
        puts("5");
    } else if(S=="WED") {
        puts("4");
    } else if(S=="THU") {
        puts("3");
    } else if(S=="FRI") {
        puts("2");
    } else if(S=="SAT") {
        puts("1");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


ll fact[101];

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

    fact[0] = 1;
    for(int i = 1; i <= 100; i++){
        fact[i] = fact[i-1]*i;
    }

    ll dp0[n.length()+1][k+1], dp1[n.length()+1][k+1];
    for(int i = 0; i < k+1; i++){
        dp0[0][i] = 0;
        dp1[0][i] = 0;
    }
    dp0[0][0] = 0;
    dp1[0][0] = 1;
    for(int i = 1; i <= n.length(); i++){
        for(int j = 0; j <= k; j++){
            int d = n[i-1]-'0';
            
            dp0[i][j] = dp0[i-1][j];
            if(j != 0){
                dp0[i][j] += dp0[i-1][j-1]*9;
                if(d != 0){
                    dp0[i][j] += dp1[i-1][j-1]*(d-1);
                    dp0[i][j] += dp1[i-1][j];
                }
            } else {
                dp0[i][j] = 1;
            }

            if(d != 0){
                if(j != 0){
                    dp1[i][j] = dp1[i-1][j-1];
                } else {
                    dp1[i][j] = 0;
                }
            } else {
                dp1[i][j] = dp1[i-1][j];
            }
        }
    }

    cout << dp0[n.length()][k] + dp1[n.length()][k] << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

int main() {
  long long N,K;
  cin >> N >> K;
  vector<pair<int, int> > pairs;
  FOR(i,0,N) {
    int a,b;
    cin >> a >> b;
    pairs.push_back({a,b});
  }
  sort(pairs.begin(), pairs.end());
  int x = 0; //最初は一番小さな数
  long long sum = pairs[0].second; //一番小さな数の並びまでは先にカウント
  while(sum < K) {
    x++;
    sum += pairs[x].second;
  }
  cout << pairs[x].first << endl;
  return 0;
}

Measured memory_bytes: 4276
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 200010
int n, m, ans[MAXN];
std::pair<int, int> x[MAXN];
int main() {
    scanf("%d", &n);
    m = n / 2;
    for (int i = 1; i <= n; i++) scanf("%d", &x[i].first), x[i].second = i;
    std::sort(x + 1, x + n + 1);
    for (int i = 1; i <= n; i++) {
        if (i > m)
            ans[x[i].second] = x[m].first;
        else
            ans[x[i].second] = x[n - m + 1].first;
    }
    for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, ans = 0;
	vector<int> a;
	vector<bool> check;	// i番目のボタンを押したかどうか
	
	cin >> n;
	for(int i = 0; i < n; i++){
		int tmp_a;
		cin >> tmp_a;
		a.push_back(tmp_a);
		check.push_back(false);
	}
	
	int idx = 0;	// 次に光るボタンの番号
	while(!check[idx]){
		ans++;
		check[idx] = true;
		idx = a[idx] - 1;
		if(idx == 1){
			cout << ans << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
}

Measured memory_bytes: 3868
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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



ll N;
int main() {
	cin >> N;
	int keta = 0;
	ll c = N;
	while (c > 0) {
		c /= 10;
		keta++;
	}
	ll x = N;
	int A[17];
	int cnt = keta-1;
	while (x > 0) {
		A[cnt] = x % 10;
		x = x / 10;
		cnt--;
	}
	bool ok = true;
	FOR(i, 1, keta) {
		if (A[i] != 9)ok = false;
	}
	int ans = 0;
	if (ok) {
		REP(i, keta)ans += A[i];
		cout << ans << endl;
		return 0;
	}
	if (keta == 1) {
		cout << N << endl;
		return 0;
	}
	else {
		ans = 9 * (keta-1) + (A[0] - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque


def topological(N, LIST): #トポロジカルソート:DAGに適用可
    incnt = [0] * N
    CHILD = [set() for _ in range(N)]
    for a, b in LIST:
        CHILD[a - 1].add(b - 1)
        incnt[b - 1] += 1
    
    TPLGSORT = []
    que = deque([i for i, num in enumerate(incnt) if num == 0])
    while len(que) > 0:
        q = que.popleft()
        for i in CHILD[q]:
            incnt[i] -= 1
            if incnt[i] == 0:
                que.append(i)
        TPLGSORT.append(q)
    return TPLGSORT, CHILD


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n + m - 1)]

tplg, child = topological(n, ab)
ans = [0] * n
for i in tplg:
    for j in child[i]:
        ans[j] = i + 1
print(*ans, sep='\n')


Measured memory_bytes: 129312
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main()  {
	int n,m;
	cin>>n>>m;
	priority_queue<int> q; 
	for(int i=1;i<=n;++i) {
		int x;
		cin>>x;
		q.push(x);
	}
	for(int i=1;i<=m;++i) {
		int t = q.top();
		q.pop();
		q.push(t/2);
	}
	long long ans = 0;
	while(!q.empty()) {
		ans += q.top();
		q.pop();
	}
	cout<<ans;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    LL ans = 0;
    for (int i = 1; i <= n; i++) {
        if(i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int N, tmp;
    cin >> N;
    VI A(N), memo(N, 0);
    REP(i, N) {
        cin >> tmp;
        A[i] = tmp;
        if(i-tmp > 0) {
            memo[i-tmp]++;
        }
    }

    LL ans = 0;
    REP(i, N) {
        ans += (i + A[i] < N ? memo[i + A[i]] : 0);
    }

    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 4848
def resolve():
    K = int(input())
    ans = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(ans[K-1])
resolve()

Measured memory_bytes: 3060
int_s = gets.to_i
s_arr = gets.split(" ").map(&:to_i)
int_t = gets.to_i
t_arr = gets.split(" ").map(&:to_i)

count1 = s_arr.uniq.count

count2 = (s_arr.uniq - t_arr.uniq).count

ans = count1 - count2
puts ans

Measured memory_bytes: 6380
from itertools import accumulate
from bisect import bisect_left,bisect
n, m , k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ruia = [0]
ruia.extend(list(accumulate(a)))
ruib = list(accumulate(b))
ans = 0
for i in range(n+1):
    nokori = k - ruia[i]
    if nokori < 0:
        break
    yomeru = bisect(ruib,nokori)
    ans = max(ans,i+yomeru)
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
	ll x;
	cin >> x;
	int x1, y1, x2, y2, x3, y3;
	x1 = y1 = 0;
	int v = 1e9;
	x2 = 1e9;
	y2 = 1;
	x3 = (v - x % v) % v;
	y3 = (x + x3) / v;
	printf("%d %d %d %d %d %d\n", x1, y1, x2, y2, x3, y3);
	return 0;
}

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

int main(){
  int D;
  cin>>D;
  int C[26];
  map<int,int>mp;
  for(int i=0;i<26;i++){
    cin>>C[i];
    if(C[i]<5){
      mp[i]++;
    }   
  }
  int S[365][26];
  for(int i=0;i<365;i++){
    for(int j=0;j<26;j++){
      cin>>S[i][j];
    }
  }
  
  int flag=1;
  int temp=0;
  int now=0;
  int maxans=0;
  while(temp<365){
    maxans=0;
    now=0;
    for(int i=0;i<26;i++){
      if(S[temp][i]>maxans){
        now=i;
        maxans=S[temp][i];
      }
    }    
    
    if((temp/26)%2 == 1 && mp[temp%26]==0){
      cout<<temp%26+1<<endl;
      temp++;
      continue;
    }

    cout<<now+1<<endl;
    temp++;
  }
  return 0;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define F first
#define S second

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;
/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;cin>>n>>k;
    if(n>=10){
        cout<<k<<"\n";
    }
    else{
        cout<<k+(100*(10-n))<<"\n";
    }
    return 0;
}
*/

void findNumberOfDigits(long n, int base)
{

	int dig = (int)(floor( log(n) /
						log(base)) + 1);

	// printing output
	cout<< dig;
}

// Driver method
int main()
{

	long n ;
	int base ;
	cin>>n>>base;

	findNumberOfDigits(n, base);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
int n;
const int N = 2e5 + 55;
int a[N];
void solve() { 
	cin >> n;
	int can = 1;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (a[i] == can)
			++can;
	}
	--can;
	if (can == 0) {
		cout << -1;
	} else {
		cout << n - can;
	}
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
ll a[100005] = {};
int main() {
	int X;
	cin >> X;
	int time = 0;
	int sum = 0;
	while (sum < X) {
		time++;
		sum = time * (time + 1) / 2;
	}
	cout << time << endl;
	return 0;
}

Measured memory_bytes: 256
// timeout
using System;
using System.Linq;
using System.Collections.Generic;
public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int max = 0;
    for (int i = 0; i < N; i++) {
      max += a[i] - 1;
    }
    Console.WriteLine(max);
  }
}


Measured memory_bytes: 13396
n, m = map(int, input().split())
stores = [[int(j) for j in input().split()]for i in range(n)]
stores.sort()

drinks = 0
cost = 0
for store in stores:
    if drinks + store[1] <= m:
        drinks += store[1]
        cost += store[0]*store[1]
    elif drinks + store[1] > m:
        cost += (m - drinks)*store[0]
        break
print(cost)

Measured memory_bytes: 21604
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    vector<vector<pair<int,bool>>> hoge(3,vector<pair<int,bool>>(3));
    
    for(int i=0;i<3;i++){
        for(int k=0;k<3;k++){
            cin>>hoge.at(i).at(k).first;
            hoge.at(i).at(k).second=false;
        }
    }
    
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(tmp==hoge.at(j).at(k).first) hoge.at(j).at(k).second=true;
            }
        }
    }
    
    string ans="No";
    
    for(int i=0;i<3;i++){
        if(hoge.at(i).at(0).second==true && hoge.at(i).at(1).second==true && hoge.at(i).at(2).second==true) ans="Yes";
        if(hoge.at(0).at(i).second==true && hoge.at(1).at(i).second==true && hoge.at(2).at(i).second==true) ans="Yes";
    }
    
    if(hoge.at(0).at(0).second==true && hoge.at(1).at(1).second==true && hoge.at(2).at(2).second==true) ans="Yes";
    if(hoge.at(0).at(2).second==true && hoge.at(1).at(1).second==true && hoge.at(2).at(0).second==true) ans="Yes";
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
    }
    deque<int> DQ;
    if(N % 2 == 0){
        for(int i = 0;i<N;i++){
            if(i % 2 == 0){
                DQ.push_back(retu.at(i));
            }
            else{
                DQ.push_front(retu.at(i));
            }
        }
    }
    else{
        for(int i = 0;i<N;i++){
            if(i % 2 == 0){
                DQ.push_front(retu.at(i));
            }
            else{
                DQ.push_back(retu.at(i));
            }
        }
    }
    for(int V : DQ) cout << V << endl;
}


Measured memory_bytes: 3840
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		Integer[] a = new Integer[5];

		for (int i = 0; i < 5; i++) {
			a[i] = scan.nextInt();
		}

		scan.close();

		List<Integer> b = Arrays.asList(a);
		b.sort((x,y) -> -x.compareTo(y));
		System.out.println(b.get(0) + " " + b.get(1) + " " + b.get(2) + " " + b.get(3) + " " + b.get(4));
	}
}

Measured memory_bytes: 31864
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 1e6 + 10;
const int LINF = LLONG_MAX;
int maps[N];
int mapa[N];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int>q(n);
    f(i,0,n){
        cin >> q[i];
        maps[q[i]]++;
    }    
    sort(all(q));
    int ans = 0;
    f(I,0,n){
        if(maps[q[I]] > 1){
            mapa[q[I]] = 1;
            continue;
        }
        int r = q[I];
        int c = 1;
        for (int i=1; i<=sqrt(r); i++){   
            if (r%i==0) { 
                if(mapa[r/i] == 1 or mapa[i] == 1){
                    c = 0;
                }
            } 
        } 
        if(c == 1){
           ans++;
        }
        mapa[q[I]] = 1;
    }
    cout << ans << "\n";
    return 0;
}
 


Measured memory_bytes: 20456