akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector<ll> p(A), q(B), r(C);
	for (ll i = 0; i < A; ++i) cin >> p[i];
	for (ll i = 0; i < B; ++i) cin >> q[i];
	for (ll i = 0; i < C; ++i) cin >> r[i];

	vector<P> a;
	for (ll i = 0; i < A; ++i) a.emplace_back(p[i], 0);
	for (ll i = 0; i < B; ++i) a.emplace_back(q[i], 1);
	for (ll i = 0; i < C; ++i) a.emplace_back(r[i], 2);

	sort(a.begin(), a.end(), greater<P>());

	ll pool = 0;
	ll ans = 0;
	for (ll i = 0; i < a.size(); ++i)
	{
		if (a[i].second == 0)
		{
			if (X > 0)
			{
				ans += a[i].first;
				X--;
			}
		}

		if (a[i].second == 1)
		{
			if (Y > 0)
			{
				ans += a[i].first;
				Y--;
			}
		}

		if (a[i].second == 2)
		{
			ans += a[i].first;
			pool++;
		}

		if (X + Y <= pool)
		{
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 13036
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;





int main(){
   
    int N,X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i=0;i<N;i++) cin >> L[i];
    
    int place=0;
    for(int i=0;i<N;i++){
        place += L[i];
        if(place > X){
            cout << i+1 << endl;
            return 0;;
        }
    }
    
    cout << N+1<< endl;
    return 0;
}




Measured memory_bytes: 256
var
  n,m,i,t:longint;
  s,ss:string;
  
 function poss:boolean;
  var
    m,head,tail:longint;
  begin
    head:=1;
    tail:=t;
    while head<=tail do
    begin
      m:=(head+tail) div 2;
      if m=sqrt(t) then exit(true);
      if m<sqrt(t) then head:=m+1
      else tail:=m-1;
    end;
    exit(false);
  end;
  
begin
  read(n,m);
  str(n,s);
  str(m,ss);
  s:=s+ss;
  val(s,t);
  if poss then write('Yes')
  else write('No');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
// order_of_key and *find_by_order
int32_t main()
{
	fast;
	double x;
	cin >> x;
	double in = 100;

	for (int i = 0; i < 4000; i++) {
		in = (in + (in / 100.0));
		in = (int)in;
		if (in >= x)
		{
			cout << i + 1;
			return 0;
		}
	}



}

Measured memory_bytes: 3740
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
	int a,b,cnt = 0;
  	cin >> a >> b;
  	rep(i,0,a+1){
     	rep(j,0,a+1){
         	if((b-i-j) <= a && (b-i-j) >= 0){
				cnt++;
            }
        }
    }
  
  	cout << cnt << endl;
  	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = []
for i in range(m):
  sc.append(list(map(int, input().split())))
for i in range(1000):
  aa = str(i)
  f = True
  if len(aa) != n: continue
  for j in range(m):
    s = sc[j][0]
    c = sc[j][1]
    if aa[s-1] != str(c):
      f = False
  if f:
    print(aa)
    exit()
print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main() {
	bool good = false;

	int N, A, B;
	cin >> N >> A >> B;

	int x1, x2;
	x1 = N*A;
	x2 = B;

	cout << ((x1 < x2) ? x1 : x2) << endl;

	return 0;
}


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


int main() {
    int x,y,z;
	cin >> x>> y>> z;
    int max =x;
    if(max<y)max=y;
    if(max<z)max=z;
    cout << x+y+z-max << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI
#include <numeric>	//gcd

using namespace std;

int main() {

	string S;
	cin >> S;

	switch (S[2]) {
	case 'N': if (S[0] == 'S') {
		cout << 7 << endl;
	}
			else {
		cout << 6 << endl;
	}
			break;
	case 'E': cout << 5 << endl; break;
	case 'D': cout << 4 << endl; break;
	case 'U': cout << 3 << endl; break;
	case 'I': cout << 2 << endl; break;
	case 'T': cout << 1 << endl; break;
	}

	return 0;

}

Measured memory_bytes: 3552
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        n: usize,
        s: chars,
        t: chars,
    }
    let mut ok = true;
    let mut ans = 2*n;
    for i in 0..n {
        ok = true;
        for j in 0..n-i {
            if s[i+j]!=t[j] {
                ok = false;
                // println!("{} {}", i, j);
            }
        }
        if ok {
            ans = n+i;
            break;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
n, k = map(int, input().split())
a = list(map(int, input().split()))

pos, neg = [], []
zero_count = 0

for x in a:
	if x > 0:
		pos.append(x)
	elif x < 0:
		neg.append(x)
	else:
		zero_count += 1

# max_v = pos[0]
# min_v = neg[0]

# max_p_idx = 1
# max_n_idx = 0
# min_p_idx = 0
# min_n_idx = 1

# for kk in range(1, min(k, len(pos) + len(neg))):
# 	if max_p_idx < len(pos):
# 		max_v 


MOD = 10**9 + 7

neg = list(sorted(neg))
pos = list(reversed(sorted(pos)))

if len(pos) >= k:
	#print('case 1')
	pos_res = pos[:k]
	idx = 0
	while idx + 1 < len(neg) and pos_res[k - idx - 1] * pos_res[k - idx - 2] < neg[idx] * neg[idx + 1]:
		idx += 2

	result = 1
	for i in range(idx):
		result = result * neg[i] % MOD

	for i in range(k - idx):
		result = result * pos[i] % MOD

	print(result)

else:
	#print('case 2')
	left = k - len(pos)	
	if left % 2 == 1:
		if len(pos) > 0:
			left += 1
		else:
			left = 1000000000
	if left > len(neg):
		#print('case 3')
		b = list(sorted(map(abs, a)))
		result = 1
		for i in range(k):
			result = result * b[i] % MOD
		print(-result % MOD)
	else:
		#print("left = ", left)
		idx = left
		pos_shift = 0
		while idx + 1 < len(neg) and pos_shift + 1 < len(pos) and pos[len(pos) - pos_shift - 1] * pos[len(pos) - pos_shift - 2] < neg[idx] * neg[idx + 1]:
			idx += 2
			pos_shift += 2

		result = 1
		for i in range(idx):
			result = result * neg[i] % MOD

		for i in range(k - idx):
			result = result * pos[i] % MOD

		print(result)		

Measured memory_bytes: 122832
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;
typedef long long ll;
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9 + 7;

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

typedef long long ll;
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
#define rep(i,s,n)for(ll i = s;i<n;i++)
double vol(double x,double L) {
    return x * (L - x) * (L - x) / 4;
}

double binary_search(double L) {
    double l = 0;
    double r = L;

    double m = (l+r)/2;
    //double v = vol(m, L);
    while (l + 0.0000001 < r) {
        m = (l + r) / 2;
        if (vol(m,L) > vol(m+0.0000001,L)) r = m;
        else l = m;
    }
    //*
    return vol(r,L);
}

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

    printf("%.10f", binary_search(L));

    return 0;
}

//Solution* sol = new Solution();
//vector<int> v1 = { 1,2,3,4 };
//vector<vector<int>> v;
//vector<int> p = { 1,0 };
// Solution* sol = new Solution();


Measured memory_bytes: 256
nm = input().split()
al = input().split()

n = int(nm[0])
m = int(nm[1])

ia = [int(i) for i in al]
sa = sorted(ia,reverse = True)
am = sum(sa)
flg = 'Yes'

for i in range(m):
	if sa[i] < am / (4 * m):
		flg = 'No'

print(flg)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int A, B;
    string S;
    cin >> A >> B >> S;

    for (int i = 0; i < A + B + 1; i++){
        if (i == A && S.at(i) != '-') {
            cout << "No" << endl;
            return 0;
        }
        else if (i == A) {
            continue;
        }
        if (S.at(i) - '0' >= 0 && S.at(i) - '0' <= 9) {
            continue;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>a(n);
    vector<int>b(m);
    vector<long long>suma(n+1);
    vector<long long>sumb(m+1);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0)
        {
            suma[i+1]=a[i];

        }
        else
        {
            suma[i+1]=suma[i]+a[i];
        }
    }
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
        if(i==0)
        {
            sumb[i+1]=b[i];
        }
        else
        {
            sumb[i+1]=sumb[i]+b[i];
        }
    }
    int ans=0;
    for(int i=0;i<n+1;i++)
    {
        if(suma[i]>k)break;
        for(int j=m;j>=0;j--)
        {
            if(suma[i]+sumb[j]<=k)
            {
                ans=max(ans,i+j);
                m=j;
                break;
            }

        }
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 8008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);

	ll n, k; cin >> n >> k;
	int* a = new int[n];
	rep(i, 0, n) cin >> a[i];

	ll ans = 0;
	rep(i, 0, n) {
		ll cnt1 = 0;
		ll cnt2 = 0;
		rep(j, 0, i) if (a[i] > a[j]) ++cnt1;
		rep(j, i, n) if (a[i] > a[j]) ++cnt2;
		ans = (ans + k * cnt2 % MOD + k * (k - 1) / 2 % MOD * (cnt1 + cnt2) % MOD) % MOD;
	}
	cout << ans << '\n';

	delete[] a;
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> v(H);
  for(int i=0;i<H;i++) v[i] = vector<char>(W);
  
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin >> v[i][j];
  
  
  for(int i=0;i<W+2;i++) cout << "#";
  cout << endl;
  
  for(int i=0;i<H;i++) {
  	cout << "#";  
    for(int j=0;j<W;j++)
      cout << v[i][j];
    cout << "#" << endl;
  }
  
  for(int i=0;i<W+2;i++) cout << "#";
  cout << endl;
  
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int max=0;
			for(int i=0; i*i*i<=n; i++){
				for(int j=0; j*(j+1)*(j+2)/6<=n; j++){
					int k=i*i*i+j*(j+1)*(j+2)/6;
					if(k<=n){
						max=max(max, k);
					}
				}
			}
			println(max+"");
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
package main

import (
	"fmt"
)

func minint(a int, b int) int {
	if a < b {
		return a
	}
	return b
}
func main() {
	var s, t string
	var dp [][]int
	fmt.Scan(&s, &t)
	l := len(s)
	tl := len(t)
	for i := 0; i <= l; i++ {
		dp = append(dp, make([]int, l+1))
		dp[i][0] = -1
		for j := 1; j <= l; j++ {
			dp[i][j] = tl + 1
		}
	}
	for i := 1; i <= l; i++ {
		for j := 1; j <= l; j++ {
			ch := tl + 1
			for k := dp[i-1][j-1] + 1; k < tl; k++ {
				if t[k] == s[i-1] {
					ch = k
					break
				}
			}
			dp[i][j] = minint(dp[i-1][j], ch)
		}
	}
	result := ""
	index := 0
	for i := l; i > 0; i-- {
		if dp[l][i] <= tl {
			index = i
			break
		}
	}
	for i := l; i > 0 && index > 0; i-- {
		if dp[i][index] != dp[i-1][index] {
			result = string(s[i-1]) + result
			index--
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 80640
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = sr()
K = ir()
length = len(N)
top = int(N[0])
dp_dec = [[0] * 4 for _ in range(length)] #decided
dp_pen = [[0] * 4 for _ in range(length)] #pending
dp_dec[0][1] = (top-1)
dp_dec[0][0] = 1
dp_pen[0][1] = 1
for i in range(1, length):
    cur = int(N[i])
    if cur == 0:
        dp_pen[i] = dp_pen[i-1][:] #右端に0
    else:
        for k in range(1, 4):
            dp_pen[i][k] = dp_pen[i-1][k-1] #右端にcur

    dp_dec[i] = dp_dec[i-1][:] #0が右端に加わった場合
    for j in range(1, 4):
        dp_dec[i][j] += dp_dec[i-1][j-1] * 9 #1~9が右端に加わった場合
        if cur > 0:
            dp_dec[i][j] += dp_pen[i-1][j-1] * (cur-1) + dp_pen[i-1][j] * 1 # 右端にcur以下の数が加わった場合と0が加わった場合

answer = dp_dec[length-1][K] + dp_pen[length-1][K]
print(answer)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
	using namespace std;
	#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#define file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	#define ll long long int
	#define mod 1000000007
	#define what(x) cerr << #x << " : " << x << endl;
	#define pb push_back
	#define VI vector<int>

	ll mypow(ll a,ll b){
		ll res=1LL;
		while(b){
			if(b&1) res=res*a%mod;
			
			a=a*a%mod;
			b>>=1;
		}
		return res;
	}

	int main(){
		fast

		int t = 1;
		// int t;
		// cin>>t;

		while(t--){
			int n,m;
			cin>>n>>m;

			vector<VI>v(m);
			for(int i=0;i<m;i++){
				int sz;
				cin>>sz;
				while(sz--){
					int a;
					cin>>a;
					a--;
					v[i].pb(a);
				}
			}
			int p[m];
			for(int i=0;i<m;i++){
				cin>>p[i];
			}

			int ttl = 0;
			for(int i=0;i<(1<<n);i++){
				bitset<12>b(i);
				// cout<<b<<" ";
				int gd=0;
				for(int k=0;k<m;k++){
					int cnt = 0;
					for(auto j:v[k]){
						if(b[j] == 1){
							cnt++;
						}
					}
					// cout<<cnt<<" ";
					if(p[k] == cnt%2){
						gd++;
					}
				}
				// cout<<gd<<" ";
				if(gd == m){
					// what(i)
					ttl++;
				}
				// cout<<endl;
			}
			cout<<ttl<<endl;

		}

		return 0;
	}
	

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

int main() {
	int n, k, x;
	scanf("%d%d", &n, &k);
	REP(i, n) {
		int tmp;
		scanf("%d", &tmp);
	}
	cout << max(1, (n - 2) / (k - 1)+1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) { cin >> w[i] >> v[i]; }
    const int V_MAX = 101000;
    vector<vector<ll>> dp(N + 1, vector<ll>(V_MAX, INF));
    // dp[i][j]:=i-1番目まで見て、価値jを達成する最小の重さ
    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < V_MAX; j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if(j + v[i] < V_MAX) {
                dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
            }
        }
    }
    ll res = 0;
    for(ll i = 0; i < V_MAX; i++) {
        if(dp[N][i] <= W)
            res = max(i, res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 84032
#include <stdio.h>
#define Fori(g) for(int i=0;i<g;i++)
#define	Forj(g) for(int j=0;j<g;j++)
#define min(aa,bb) (aa<bb)?aa:bb
#define max(aa,bb) (aa<bb)?bb:aa
//#define gcd(aa,bb) return (!bb)?aa:gcd(bb,aa%bb)

int main(){
	int n,count=0;
	scanf("%d",&n);
	char s[n+1];
	scanf("%s",s);
	int i;
	//printf("%s\n",s);
	for(i=0;i<n;i++){
		while(1){
			//printf("1\n");
			if(s[i]!=s[i+1])break;
			i++;
			}
	//	printf("%d\n",i);	
		count++;
	}
	printf("%d\n",count);
	return 0;
}

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

typedef long long ll;

int main(int argc, char* argv[])
{
  int a, b;
  int cnt = 0;

  std::cin >> a;
  std::cin >> b;

  for (int i = a; i <= b; i++) {
    bool judge = true;
    char c_str[10];
    sprintf(c_str, "%d", i);
    std::string str(c_str);
    
    //std::cout << str << " " << str.size() << std::endl;
    for (int j = 0; j < str.size(); j++) {
      if (str[j] != str[str.size() - j - 1]) {
	judge = false;
      }
    }

    if (judge) {
      cnt++;
    }
  }
  std::cout << cnt << std::endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

void solve() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x)
    yn;
}

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


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

int main(void){
  int N,K;
  cin >>N >> K;
  string S;
  cin >> S;
  
  if(S.at(K-1)=='A') S.at(K-1)='a';
  else if(S.at(K-1)=='B') S.at(K-1)='b';
  else S.at(K-1)='c';
  
  cout << S <<endl;
 return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.HashMap;

public class Main {
	static PrintWriter out;
	static Scanner sc;
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		String vote;
		int max = 0;
		while(n-->0) {
			vote = sc.nextLine();
			int v = map.getOrDefault(vote, 0)+1;			
			map.put(vote, v);
			max = Math.max(max, v);
		}
		PriorityQueue<String> pq = new PriorityQueue<>();
		for(Entry<String, Integer>e:map.entrySet()) {
			if(e.getValue() == max) pq.add(e.getKey());
		}
		while(!pq.isEmpty())
			out.println(pq.poll());
		out.close();
	}
	static class Scanner{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));			
		}
		private String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
	}
}


Measured memory_bytes: 54800
#include<iostream>
#include<cstdio>
//#include<cmath>
//#include<algorithm>
//#include<cstring>
//#include<map>
using namespace std;
inline long long read()
{
    long long p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int main()
{
	long long x=read(),y=read(),s=x;
	int ans=1;
	while(1)
	     {
	      if(2*s<=y){ans++;s*=2;}
	      else break;
	     } 
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.length(); i++) {
		ans += s[i] - '0';
	}
	if(ans % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main () {
int x,y,v,c;
cin>>x>>y;
if (x<y){
    v=x;
    c=y;
}
else {
    v=y;
    c=x;
}
for (int i=0;i<c;i++)
{
    cout<<v;
}



return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> cnt(102);
  for (int i = 0; i < N; i++) {
    cnt.at(A.at(i))++;
  }

  int ans = INF;
  int index = -1;
  for (int i = 0; i <= 101; i++) {
    if (cnt.at(i) > 0 && (i != 0 || i != 101)) continue;
    if (ans > abs(X - i)) {
      ans = abs(X - i);
      index = i;
    }
  }

  cout << index << endl;
}


Measured memory_bytes: 3592
"""
個数無制限ナップザック
大小判定は和が大きいほう→同じなら桁で比較していって先に大きくなった方
"""

N,M = map(int,input().split())

A = list(map(int,input().split()))

lis = [[0] * 10 for i in range(N+1)]
able = [False] * (N+1)
able[0] = True

nums = [0,2,5,5,4,5,6,3,7,6]

for i in A:

    for j in range(N):

        if able[j] and j+nums[i] <= N:

            if not able[j+nums[i]]:
                able[j+nums[i]] = True
                
                for k in range(10):
                    lis[j+nums[i]][k] = lis[j][k]

                lis[j+nums[i]][i] += 1

            else:

                flag = False

                if sum(lis[j+nums[i]]) < sum(lis[j]) + 1:
                    flag = True

                elif sum(lis[j+nums[i]]) == sum(lis[j]) + 1:

                    cp = lis[j].copy()
                    cp[i] += 1

                    for k in range(9,0,-1):

                        if lis[j+nums[i]][k] < cp[k]:
                            flag = True
                            break

                        elif lis[j+nums[i]][k] > cp[k]:
                            break


                if flag:
                    for k in range(10):
                        lis[j+nums[i]][k] = lis[j][k]
                    lis[j+nums[i]][i] += 1


ans = []

for i in range(9,0,-1):

    for j in range(lis[-1][i]):
        ans.append(i)

print ("".join(map(str,ans)))


Measured memory_bytes: 5232
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,s,t,b;
int kai[16][9];
bool visited[16][9];
int dx[]={0,1,0,-1},dy[]={-3,0,3,0};

void dfs(int p,int e){
  visited[e][p]=1;
  if(e==n){
    if(p==t)kai[e][p]=1;
    return;
  }
  for(int i=0;i<4;i++){
    int np=p+dx[i]+dy[i];
    if(dx[i]+p%3<0||dx[i]+p%3>=3||np<0||9<=np||np==b)np=p;
    if(!visited[e+1][np])dfs(np,e+1);
    kai[e][p]+=kai[e+1][np];
  }
}

int main(){
  while(cin>>n&&n!=0){
    char sc,tc,bc;
    for(int i=0;i<16;i++)for(int j=0;j<9;j++)kai[i][j]=0,visited[i][j]=0;
    //   memset(kai,0,16*9);
    //   memset(visited,0,16*9);
    cin>>sc>>tc>>bc;
    s=sc-'A',t=tc-'A',b=bc-'A';
    dfs(s,0);
    printf("%.8f\n",1.0*kai[0][s]/(1<<(n*2)));
  }
  return 0;
}

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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

struct point {
    int x;
    int y;
    int depth;
};

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

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

    int h, w;
    cin >> h >> w;

    vector<vector<char>> v(h, vector<char>(w));

    rep(i, h) rep(j, w) cin >> v[i][j];

    int ans = 0;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            vector<vector<bool>> b(h, vector<bool>(w, false));

            int len = 0;

            if (v[i][j] == '.') {
                queue<point> q;
                point s;
                s.x = j;
                s.y = i;
                s.depth = 0;

                q.push(s);
                b[s.y][s.x] = true;

                while (!q.empty()) {
                    point temp = q.front();
                    q.pop();

                    len = max(len, temp.depth);

                    for (int k = 0; k < 4; k++) {
                        int nx = temp.x + dx[k];
                        int ny = temp.y + dy[k];

                        if (nx >= w)
                            continue;
                        if (nx < 0)
                            continue;
                        if (ny >= h)
                            continue;
                        if (ny < 0)
                            continue;

                        if (b[ny][nx])
                            continue;

                        if (v[ny][nx] == '#')
                            continue;

                        b[ny][nx] = true;

                        point t = {nx, ny, temp.depth + 1};
                        q.push(t);
                    }
                }

                ans = max(ans, len);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-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, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	while (H != 0) {
		int ans = INF;
		pair<int, int> P = make_pair(0, 0);
		FOR(i, 1, 151) {
			FOR(j, 1, 151) {
				if (i >= j)continue;
				bool flag = false;
				if (i * i + j * j > H * H + W * W) {
					flag = true;
				}
				else if (i * i + j * j == H * H + W * W) {
					if (i > H) {
						flag = true;
					}
				}
				if (flag) {
					int cur = i * i + j * j;
					if (ans > cur) {
						ans = cur;
						P = make_pair(i, j);
					}
					else if (ans == cur && i < P.first) {
						ans = cur;
						P = make_pair(i, j);
					}
				}
			}
		}
		cout << P.first << " " << P.second << endl;
		cin >> H >> W;
	}
	return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[200200],y[200200];
string s,str;
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    y[i]=0;
  }
  for(int i=0;i<n;i++){
    cin>>x[i];
    y[x[i]-1]++;
  }
  for(int i=0;i<n;i++){
    ans+=y[i]*(y[i]-1)/2;
  }
  for(int i=0;i<n;i++){
    cout<<ans-(y[x[i]-1]-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 5760
let m = 998244353
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let ds = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let dp = Array.make n 0 in
  let count = Array.make n 0 in
  Array.iter (fun d -> count.(d) <- 1 + count.(d)) ds;
  dp.(0) <- if ds.(0) = 0 then 1 else 0;
  for i = 1 to n - 1 do
    dp.(i) <- power ( *^ ) 1 count.(i - 1) count.(i) *^ dp.(i - 1)
  done;
  Printf.printf "%d\n" @@
  if
    Array.fold_left ( || ) false @@
    Array.init n @@ fun i -> i <> 0 && ds.(i) = 0
  then 0
  else dp.(Array.fold_left max min_int ds)



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

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto& it : a) cin >> it;
    
    ll total = 0;
    ll ans1 = 0;
    for(ll i=0;i<n;i++){
        if(total > 0){
            if(total + a[i] >= 0) {
                ans1 += abs(-total-1 - a[i]);
                total = -1;
            } else total += a[i];
        } else {
            if(total + a[i] <= 0) {
                ans1 += abs(-total+1  - a[i]);
                total = +1;
            } else total += a[i];
        }
    }

    total = 0;
    ll ans2 = 0;
    for(ll i=0;i<n;i++){
        if(total >= 0){
            if(total + a[i] >= 0) {
                ans2 += abs(-total-1 - a[i]);
                total = -1;
            } else total += a[i];
        } else {
            if(total + a[i] <= 0) {
                ans2 += abs(-total+1  - a[i]);
                total = +1;
            } else total += a[i];
        }
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
 
using namespace std;
 
int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  if ((b - a) & 1)
    cout << (b - a) / 2 + min(a - 1, n - b) + 1;
  else cout << (b - a) / 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    a = a / 100000 + a / 10000 % 10 + a / 1000 % 10 + a / 100 % 10  + a / 10 % 10 + a % 10;// 各桁の和
    cout << (a == 1 ? 10 : a);/* aが1であれば10を,1でなければaを出力
                                 if()を書くまでもない時に使います */
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

int main() {
  string cl;
  int a, b;
  while(cin >> cl && cin >> a && cin >> b) {
    cout << cl << " " << a + b << " " << 200 * a + 300 * b << endl;;
  }
  return 0;
}



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

int main() {
    int X;
    cin >> X;
    int ans = 1;
    for (int i = 1; i <= X; ++i) {
        for (int j = 2; j <= 10; ++j) {
            int tmp = pow(i, j);
            if (tmp > X) break;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    H, W = map(int, readline().rstrip().split())
    ans = [['#']*(W+2)] + [['#']+readline().rstrip().split()+['#'] for _ in range(H)] + [['#']*(W+2)]
    ans = [''.join(l) for l in ans]
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>

typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    
    map<int, int> m;
    for(int i=0; i<n; i++)
    {
        m[a[i]] = 0;
    }
    for(int i=0; i<n; i++)
    {
        m[a[i]]++;
    }
    map<int, int>::iterator it;
    ll ans = 0;
    for(it=m.begin(); it!=m.end(); it++)
    {
        if(it->second >= 2)
        {
            ll tmp = it->second;
            ans += tmp*(tmp-1)/2;
        }
    }
    for(int i=0; i<n; i++)
    {
        ll tmp2 = m[a[i]];
        if(tmp2 >= 2)
        {
            ll tmp = ans;
            ans -= tmp2*(tmp2-1)/2;
            ans += (tmp2-1)*(tmp2-2)/2;
            cout << ans <<endl;
            ans = tmp;
        }
        else cout << ans << endl;
    }
}



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

int main() {
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    int z=s.size();
    for(int i=0; i<z-k; i++){
      s.pop_back();
    }
    
    s+="...";
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3628
#P :time a-b
#Q :time b-c
#R :time c-1

#1<=P,Q,R <=100
timelist = [0 for i in range(3)]

timelist[0],timelist[1],timelist[2] = map(int,input().split())
time = 200
for i in range(3):
    for j in range(i+1,3):
        if( time > (timelist[i]+timelist[j]) ):
            time = (timelist[i]+timelist[j])
print(time)



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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> table(300,0);
    FOR(i,1,N+1){
        int x = i;
        while(x<= N){
            table[x] ++;
            x += i;
        }
    }

    int ans = 0;
    REP(i,N+1){
        if(i%2==1 && table[i]==8){
            ans++;
        }
    }

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

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

using namespace std;
 
void Solve();


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}

void Solve(){
  int n,m;
    scanf("%d%d",&n,&m);
  vector<vector<int>> A(m,vector<int>(10));

  for(int i=0;i<m;++i){
    int k;
      scanf("%d",&k);
    for(int j=0;j<k;++j){
      int a;
        scanf("%d",&a);
      A[i][a-1]++;
    }
  }
  vector<int> p(m);
  for(int i=0;i<m;++i){
    scanf("%d",&p[i]);
  }

  int ans=0;
  for(int bit=0;bit<(1<<n);++bit){
    bool b=true;
    for(int i=0;i<m;++i){
      int s=0;
      for(int j=0;j<10;++j){
        if(bit &(1<<j)){
          s+=A[i][j];
        }
      }
      if(s%2!=p[i]){
        b=false;
      }
    }
    if(b){
      ++ans;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<cstring>
#include<string>
#include<ctime>


using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()
const long MOD = pow(10, 9) + 7;

char alfa[] = { 'A','B' ,'C','D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y','Z' };

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

unsigned GetDigit(unsigned num) {
	return log10(num) + 1;
}

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

class Mod {
public:
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}

	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};



template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (ll i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	bool debug = false;
	if (debug) {
		cout << "\x1b[41m" << "Debug Mode " << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}

class man
{
public:
	int A;
	vector<pii> X;
	bool HeIsTrue;
private:

};

inline void Main() {
	ll X, Y, N;
	vector<ll> A;
	ll M1, D1, M2, D2;
	ll ans;
	ll sum = 0, count = 0;
	string S;
	string T;
	string Ans = "";
	int b[60];
	bool flag = false;

	cin >> N ;

	for (ll i = 0; i < N; i++) {
		cin >> X;
		if (count + 1 != X) {
			sum++;
		}
		else {
			count++;
		}
	}

	if (sum == N) {
		cout << -1;
	}
	else {
		cout << sum;
	}


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_H 100
#define MAX_W 100
 
int main(){
    int H,W;
    char ch;
    int arr[MAX_H][MAX_W];
    cin >> H >> W;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    cin >> ch;
	    arr[i][j] = (ch == '.' ? -1 : 0);
	}
    } 
    for(int i = 0 ; i < H ; i++){
	for(int j = 1 ; j < W ; j++){
	    if(arr[i][j-1] == -1) continue;
	    if(arr[i][j] == 0) continue;
	    arr[i][j] = max(arr[i][j],arr[i][j-1]+1);
	}
    }
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    if(j > 0){ cout << " "; }
	    cout << arr[i][j];
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
N = int(input())
A = [0] + list(map(int, input().split()))
B = [[a, i, 1] for i, a in enumerate(A)]
C = sorted(B, reverse=True)
a_max, idx = 0, 0 # [value, idx]
left_max = [[0, 0] for i in range(N+1)] # [value, idx]
for i, a in enumerate(A):
  left_max[i] = [a_max, idx]
  if a > a_max:
    a_max, idx = a, i

ans = [0] * (N+1)
next_i = C[0][1]
for _, i, _ in C:
  a, _, num = B[i]
  if i == next_i:
    next_a, next_i = left_max[i]
    now_i = i
    ans[i] += (a - next_a) * num
    B[next_i][2] += num
  else:
    ans[now_i] += (a - next_a) * num
    B[next_i][2] += num

print(*ans[1:], sep='\n')

Measured memory_bytes: 44808
/*vi:se ts=8 tw=8*/
/*@author tangyida*/
#include<bits/stdc++.h>
const int N = 2e3 + 5;
const long long MOD = 1e9 + 7;
int n,k;
long long f[N][N],fac[N * N],inv[N * N];

inline long long _pow(long long a,long long base)
{
	long long ans = 1;
	for(;base;base >>= 1) {
		if(base  & 1) ans = (ans * a) % MOD;
		a = (a * a) % MOD;
	}
	return ans;
}

inline void pre()
{
	fac[0] = 1;
	for(int i = 1;i <= n * k;i++) fac[i] = (fac[i - 1] * i) % MOD;
	inv[n * k] = _pow(fac[n * k],MOD - 2) % MOD;
	for(int i = n * k - 1;i >= 0;i--) inv[i] = (inv[i + 1] * (i + 1)) % MOD;
}

inline long long C(long long n,long long m)
{ 
	if(n == m) return 1;
	return ((fac[n] * inv[m]) % MOD * inv[n - m]) % MOD;
}

int main()
{
	std::cin >> n >> k;
	if(k == 1) std::cout << 1,exit(0);

	pre();
	f[0][0] = 1;
	for(int i = 1;i <= n;i++) for(int j = 0;j <= i;j++) {
		f[i][j] = f[i - 1][j];
		if(!j) continue;
		(f[i][j] = f[i][j] % MOD + (f[i][j - 1] * (n - j + 1)) % MOD * C(n -
			i + (n - j + 1) * (k - 1) - 1,k - 2)) %= MOD;
	}
	std::cout << f[n][n] % MOD;

	return 0;
}


Measured memory_bytes: 94464
def d_recording(N, C, R):
    # N:録画する番組の数
    # C:テレビが受信できるチャンネルの数
    # R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc]
    from itertools import accumulate
    start = [row[0] for row in R]
    end = [row[1] for row in R]
    channel_num = [row[2] for row in R]

    # いつまで録画機を動かすか。0.5を単位時間とするので*2
    # 時刻を0からスタートさせるので+2
    l = max(end) * 2 + 2
    running_recorder = [0 for _ in range(l)]  # [k]:ある時刻に動作中の録画機の数

    for channel in range(1, C + 1):
        rec = [0 for _ in range(l)]  # [k]:チャンネルkを録画しているか否か
        # 累積和を取る
        for s, t, c in zip(start, end, channel_num):
            if c == channel:
                # 録画開始時刻の0.5前を+1,終了時刻を-1
                # (終了時刻は含まないという録画機の条件より、このようにする)
                rec[s * 2 - 1] += 1
                rec[t * 2] -= 1
        rec = accumulate(rec)
        # あるチャンネルを録画している時間帯では、録画機を1個使わねばならない
        for j, running in enumerate(rec):
            if running > 0:
                running_recorder[j] += 1
    ans = max(running_recorder)
    return ans

N, C = [int(i) for i in input().split()]
R = [[int(i) for i in input().split()] for j in range(N)]
print(d_recording(N, C, R))

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  rep(i, n)
  {
    cin >> t[i];
  }
  sort(t.begin(), t.end(),greater<int>());

  int s = 0;
  rep(i, n-2)
  {
  rep2(j,i+1, n-1)
  {
  rep2(k,j+1, n)
  {
   if(t[i]>=t[j]+t[k]){break;}
   s++;
  }
  }
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.*; 
class Main 
{
public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = Integer.parseInt(sc.nextLine()); 
int AC=0,WA=0,TLE=0,RE=0;
while(n-->0) 
{
String s = sc.nextLine(); 
if(s.equals("AC")) 
{
AC++;
} 
else if(s.equals("WA")) 
{
WA++;
} 
else if(s.equals("TLE")) 
{
TLE++;
} 
else 
{
RE++;
}
} 
System.out.println("AC x "+AC); 
System.out.println("WA x "+WA); 
System.out.println("TLE x "+TLE); 
System.out.println("RE x "+RE);
} 
}

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

int main(){
    int a,b,i;
    cin >>a>>b;
    for(i=1;i<1100;i++){
        if(i*8/100==a&& i/10==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [(int_of_string b)]
    else
      match str.[ct] with
        ' ' -> (int_of_string b)::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let (n,k) = match split (read_line ()) with
        [n;k] -> (n,k)
      | _ -> raise Not_found
  in
  let ws = Array.init n (fun _ -> read_int ()) and
       l = 0 and
       r = 100000*100000
  in
  let rec search (i,j,s,p) =
    if i=n || j=k then i
    else
      if s+ws.(i) <= p then
        search ((i+1), j, (s+ws.(i)), p)
      else
        search (i,(j+1),0,p)
  in
  let rec loop left right =
    if left < right then
      let mid = (left+right)/2 in
      if search (0,0,0,mid) >= n then loop left mid
      else loop (mid+1) right
    else right
  in
  Printf.printf "%d\n" (loop l r)
;;

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

int main(){
int C[3],ans,b,c;
while(cin>>C[0]>>C[1]>>C[2]){
b=C[0]+C[1];
ans=0;
for(int i=1;i<11;i++){
if(i!=C[0]&&i!=C[1]&&i!=C[2]){
c=b;
c+=i;
if(c<=20)ans++;}}
if(ans>=4)cout<<"YES"<<endl;
else cout<<"NO"<<endl;}}

Measured memory_bytes: 1152