akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)

ll wi[102],vi[102];
ll n,w;
ll dp[101][100001];
ll fn(ll pos,ll rem){
    if(pos==n || rem>w)  return 0;

    if(dp[pos][rem]!=-1) return dp[pos][rem];

    ll ans = 0;
    if(rem+wi[pos]<=w)  ans = vi[pos] + fn(pos+1,rem+wi[pos]);
    ans = max(ans,fn(pos+1,rem));
    return dp[pos][rem] = ans;
}


int main(){
int t,tc = 0;

scanf("%lld%lld",&n,&w);
memset(dp,-1,sizeof dp);
for(ll i = 0; i<n; i++) scanf("%lld%lld",&wi[i],&vi[i]);
ll ans = fn(0,0);
printf("%lld\n",ans);

return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	vector<ll> s(n);
	s[0] = a[0];
	for (int i = 1; i < n; i++) s[i] = s[i - 1] + a[i];

	map<ll, ll> nums;
	nums[0] = 1;
	for (int i = 0; i < n; i++) {
		if (nums.count(s[i])) nums[s[i]]++;
		else nums[s[i]] = 1;
	}

	ll res = 0;
	for (const auto& item : nums) {
		res += item.second * (item.second - 1) / 2;
	}
	cout << res << endl;
}


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

def main():
    n = int(input())
    for i in range(n, 1000):
        s = str(i)
        if s[0] == s[1] and s[1] == s[2]:
            print(i)
            break
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
def knapsack(items, num, weight):
    C = [0] * (weight + 1)
    for i in items:
        item_v, item_w = i
        for w in range(weight, item_w - 1, -1):
            v1 = item_v + C[w - item_w]
            v2 = C[w]
            C[w] = max(v1, v2)
    return C[weight]

import sys

file_input = sys.stdin

N, W = map(int, file_input.readline().split())

items = [map(int, line.split()) for line in file_input]

ans = knapsack(items, N, W)

print(ans)

Measured memory_bytes: 7964
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

int solve(int a, int b)
{
  return a * b;
}

int main()
{
  int a, b;
  std::cin >> a >> b;

  std::cout << std::setprecision(20);
  std::cout << solve(a, b) << std::endl;
}


Measured memory_bytes: 3596
INF = 10**12
n = gets.to_i
arr = gets.split.map(&:to_i)
sum = arr.inject(:+)
sum1 = 0
ans = INF
# binding.pry
(arr.size - 1).times do |i|
  sum1 += arr[i]
  sum -= arr[i]
  ans = [ans, (sum - sum1).abs].min
end
p ans

Measured memory_bytes: 19204
#include<stdio.h>

int main()
{
	int a,b,c,i,count=0;
	
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++)
		if(c%i==0) count++;
	printf("%d\n",count);
	
	return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    int a, b;
    cin >> a >> b;

    cout << a * b << endl;

    return 0;
    
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n):
    tmp=0
    for j in range(m):
        tmp+=a[i][j]*b[j]
    if tmp+c>0:
        cnt+=1
print(cnt)


Measured memory_bytes: 3064
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0 for _ in range(n)]
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
	dp[i] = dp[i-1] + abs(h[i] - h[i-1])
	for j in range(1, min(i, k)+1):
		dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))

print(dp[-1])

Measured memory_bytes: 56544
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long in = sc.nextLong();
    long out = 1L;
    while(in != 0){
      in /= 2;
      out *= 2;
    }
    System.out.println(out - 1);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAX_N = 1000005;

bool isPrime[MAX_N];
vector<int> primeDivisors[MAX_N];

int n;
int a[MAX_N];
bool primeUsed[MAX_N];

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	for (int i = 2; i < MAX_N; i++)
		isPrime[i] = true;
	for (int i = 2; i * i < MAX_N; i++)
		if (isPrime[i])
			for (int j = i * i; j < MAX_N; j += i)
				isPrime[j] = false;

	for (int i = 2; i < MAX_N; i++)
		if (isPrime[i])
			for (int j = i; j < MAX_N; j += i)
				primeDivisors[j].push_back(i);

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	bool res1 = true;
	for (int i = 0; res1 && i < n; i++)
		for (int p : primeDivisors[a[i]])
		{
			if (primeUsed[p])
			{
				res1 = false;
				break;
			}
			primeUsed[p] = true;
		}
	if (res1)
	{
		cout << "pairwise coprime\n";
		return 0;
	}

	ll res2 = a[0];
	for (int i = 1; i < n; i++)
		res2 = gcd(res2, a[i]);
	if (res2 == 1)
	{
		cout << "setwise coprime\n";
		return 0;
	}

	cout << "not coprime\n";

	return 0;
}

Measured memory_bytes: 63912
import numpy as np

# 1つ前で何をしていたかのみに依存する
def main():
	N = int(input())

	dp = np.zeros((N, 3), dtype=int)

	h = list(map(int, input().split(" ")))
	dp[0,0], dp[0,1], dp[0,2] = h

	for i in range(1,N):
		h = list(map(int, input().split(" ")))
		dp[i,0] = max(dp[i-1,1]+h[0], dp[i-1,2]+h[0])
		dp[i,1] = max(dp[i-1,0]+h[1], dp[i-1,2]+h[1])
		dp[i,2] = max(dp[i-1,0]+h[2], dp[i-1,1]+h[2])

	print(max(dp[N-1,:]))

if __name__ == '__main__':
	main()

Measured memory_bytes: 14796
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll dp[2][101010];

int main() {
  string l;
  cin >> l;
  int n = l.size();
  dp[1][0] = 1;
  REP(i, n) {
    if (l[i] == '0') {
      // i+1桁目を0にする場合
      {
        dp[0][i + 1] += dp[0][i];
        dp[0][i + 1] %= MOD;
        dp[1][i + 1] += dp[1][i];
        dp[1][i + 1] %= MOD;
      }
      // i+1桁目を1にする場合
      {
        dp[0][i + 1] += (2 * dp[0][i]) % MOD;
        dp[0][i + 1] %= MOD;
      }
    } else {
      // i+1桁目を0にする場合
      {
        dp[0][i + 1] += dp[0][i];
        dp[0][i + 1] %= MOD;
        dp[0][i + 1] += dp[1][i];
        dp[0][i + 1] %= MOD;
      }
      // i+1桁目を1にする場合
      {
        dp[0][i + 1] += (2 * dp[0][i]) % MOD;
        dp[0][i + 1] %= MOD;
        dp[1][i + 1] += (2 * dp[1][i]) % MOD;
        dp[1][i + 1] %= MOD;
      }
    }
  }
  cout << (dp[0][n] + dp[1][n]) % MOD << endl;
  return 0;
}

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

int main() {
 int n,bobcnt=0,alicnt=0;
 cin >> n;
 vector<int> num(n);
 for(int i=0;i<n;i++){
  cin >> num[i];
 }
 sort(num.begin(),num.end());

  if(n%2==0){
   for(int i=0;i<n/2;i++){
    bobcnt = bobcnt + num[2*i];
    alicnt = alicnt + num[2*i+1];
   }
  }
  else{
   for(int i=0;i<(n-1)/2;i++){
   bobcnt = bobcnt + num[2*i+1];
   alicnt = alicnt + num[2*i];
   }
   alicnt = alicnt +num[n-1];
  }

  cout << alicnt - bobcnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,m,wa=0,ac=0;
map<int,int> mpwa;
map<int,bool> mpac;

int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(15);
	cin>>n>>m;
	string s;
	if (m){
		for (int i=0,p;i<m;i++){
			cin>>p>>s;
			if (s=="WA"){
				if (!mpac[p]){
					mpwa[p]++;
				}
			}
			else {
				if (!mpac[p]){
					wa+=mpwa[p];
					mpac[p]=true;
					ac++;
				}
			}
		}
	}
	cout<<ac<<" "<<wa;
	return 0;
}

Measured memory_bytes: 9600
n=int(input())
dp=[[[[0,0,0,0] for _ in range(4)] for _ in range(4)] for _ in range(101)]
mod=10**9+7
for i in range(4):
  for j in range(4):
    for k in range(4):
      dp[3][i][j][k]=1
dp[3][1][2][0]=0
dp[3][2][1][0]=0
dp[3][1][0][2]=0
#a:0,c:1,g:2,t:3
for m in range(4,n+1):
  for i in range(4):
    for j in range(4):
      for k in range(4):
        if i==0:
          for l in range(4):
            dp[m][i][j][k]+=dp[m-1][j][k][l]
          dp[m][i][j][k]%=mod
        elif i==1:
          if j==2 and k==0:
            dp[m][i][j][k]=0
          elif j==0 and k==2:
            dp[m][i][j][k]=0
          elif j==2 and k!=0:
            for l in range(4):
              if l==0:
                continue
              dp[m][i][j][k]+=dp[m-1][j][k][l]
            dp[m][i][j][k]%=mod
          elif j!=0 and k==2:
            for l in range(4):
              if l==0:
                continue
              dp[m][i][j][k]+=dp[m-1][j][k][l]
            dp[m][i][j][k]%=mod
          else:
            for l in range(4):
              dp[m][i][j][k]+=dp[m-1][j][k][l]
            dp[m][i][j][k]%=mod
        elif i==2:
          if j==1 and k==0:
            dp[m][i][j][k]=0
          else:
            for l in range(4):
              dp[m][i][j][k]+=dp[m-1][j][k][l]
            dp[m][i][j][k]%=mod
        elif i==3:
          for l in range(4):
            dp[m][i][j][k]+=dp[m-1][j][k][l]
          dp[m][i][j][k]%=mod
ans=0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans+=dp[n][i][j][k]
      ans%=mod
print(ans%mod)

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

using namespace std;

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

int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if (n * 2 >= m) {
		ans = m / 2;
	} else {
		ll res = m - 2 * n;
		ans = n + res / 4;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn input () -> (usize, usize) {
    let mut a = String::new();
    stdin().read_line(&mut a).unwrap();
    let a: Vec<usize> = a.trim().split_whitespace().flat_map(str::parse).collect();
    (a[0], a[1])
}

fn main () {
    let (a, b) = input();
    let mut c = 1;
    let mut r = 0;

    while c < b {
        c = a + c - 1;
        r += 1;
    }

    println!("{}", r);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int a[100010],b[100010];
int main(){
    int n;
    cin>>n;
    long long sum_a=0,sum_b=0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        sum_a+=a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin>>b[i];
        sum_b+=b[i];
    }
    
    if(sum_a<sum_b){
        cout<<-1<<endl;
        return 0;
    }
    vector<long long>v(n);
    int ans=0;
    long long cnt=0;
    for (int i = 0; i < n; i++)
    {
        v[i]=a[i]-b[i];
        if(v[i]<0) {
            ans+=1;
            cnt+=abs(v[i]);
        }
    }
    if(ans==0){
        cout<<ans<<endl;
        return 0;
    }
    sort(v.rbegin(),v.rend());
    long long sum=0;
    for (int i = 0; i < n; i++)
    {
        sum+=v[i];
        if(sum>=cnt){
            ans+=i+1;
            break;
        }
    
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)

{
	int i,j;

	for (i = 1; i <= 9; i++)
	{
		for (j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}

	return 0;
}

Measured memory_bytes: 524
N=int(input())
if N<10:
  A=N
elif N<100:
  A=9
elif N<1000:
  A=9+N-99
elif N<10000:
  A=9+900
elif N<100000:
  A=9+900+N-9999
else:
  A=9+900+90000  
print(A)

Measured memory_bytes: 2940
package main

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

//scanで一行づつ読み込む
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

//sort
// array := []int{5, 1, 4, 2, 3}
// sort.Sort(sort.IntSlice(array))

func main() {
	// A := strings.Split(nextLine(), " ")

	X := strings.Split(nextLine(), " ")

	// Z := strings.Split(nextLine(), " ")
	// n, _ := strconv.Atoi(input[0])

	N, _ := strconv.Atoi(X[0])
	M, _ := strconv.Atoi(X[1])

	arr := make([]int, M+1)
	ans := 0
	// board := make([]cities, N)

	for i := 0; i < N; i++ {
		Y := strings.Split(nextLine(), " ")
		K, _ := strconv.Atoi(Y[0])
		for j := 1; j < K+1; j++ {
			c, _ := strconv.Atoi(Y[j])
			arr[c]++
		}

	}
	// fmt.Println(arr)

	for i := 1; i < M+1; i++ {
		if arr[i] == N {
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)

	_ = wtr.Flush()
}

func addBuiscket(b int64) int64 {
	return b + 1
}
func exchangeToYen(b int64, rate int64) (rest int64, money int64) {
	return b - rate, 1
}
func exchangeToBuiscket(mone int64, buis int64, rate int64) (b int64, money int64) {
	return buis + rate, mone - 1
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func com(a, b int) int {

	if a > b {
		return 0
	}
	return abs(a - b)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

type block struct {
	x     int
	y     int
	point int
}

type cities []block

func (p cities) Len() int {
	return len(p)
}

func (p cities) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p cities) Less(i, j int) bool {

	return p[i].point > p[j].point //p[i].x+p[i].y > p[j].x+p[j].y
}


Measured memory_bytes: 640
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 1e5 + 10 ;

int n , x , a [ N ] ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> x ;
	for ( int i = 1 ; i <= n ; i++ )
		cin >> a [ i ] ;
	int res = 0 ; 
	for ( int i = 1 ; i < n ; i++ ) {
		if ( a [ i + 1 ] + a [ i ] > x ) {
			int save = a [ i + 1 ] , save1 = a [ i ] ;  
			a [ i + 1 ] = x - a [ i ] ;
			if ( a [ i + 1 ] < 0 ) {
				a [ i + 1 ] = 0 ;
				a [ i ] = x ;
				res += save1 - a [ i ] ; 
			}
			res += save - a [ i + 1 ] ; 
		}
	}
	cout << res << '\n' ; 
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef long double ld;
const double E = 1e-7;
const ll INF = 1e17;
#define forn(i, s, f) for (int i = s; i < f; ++i)
#define ft first                                                 
#define sec second
#define fora(i, n) for (auto i : n)
#define sz(a) (int)(a).size()
#define sort_(a) sort(a.begin(), a.end())
#define pb push_back
#define mp make_pair
#define rsort_(a) sort(a.begin(), a.end()); reverse(a.begin(), a.end())
#define fast_ cin.tie(0), ios_base::sync_with_stdio(false)
// ____________________________________________________________
#define cina(a) forn(i,0,sz(a)) cin >> a[i]
#define cinpr(a) cin >> a.ft >> a.sec 
//--------------------------------------------------------------
#define int long long 

bool f(int m, const vector<int> &a, int k) {
    int ans = 0;
    forn(i,0,a.size()) {
        int cp = a[i];
        int deep = 0;
        if (a[i] > m)
            ans += (a[i] / m);
        /*while (cp > m) {
            ans += (1<<deep);
            deep++;
            cp = cp / 2 + (cp % 2 != 0);
        }*/
    }
    if (ans <= k) return true;
    return false;
} 

signed main() {
    fast_;
    ll n, k; cin >> n >> k;
    vector<int> a(n);
    forn(i,0,n) cin >> a[i];

    int l = 1, r = 1e10;
    while (l + 1 < r) {
        int m = (l + r) / 2;
        if (f(m, a, k)) {
            r = m;
        } else {
            l = m;
        }
    }
    //cout << l << '\n';
    if (f(l, a, k)) cout << l;
    else cout << r << '\n';
}

Measured memory_bytes: 4740
program hi;
var 
    a, b, c, k, i, ans: longint;
    r: array[1..200] of longint;

function gcd(x: longint; y: longint): longint;
begin
    if y = 0 then 
        gcd := x
    else 
        gcd := gcd(y, x mod y);
end;

begin
    readln(k);
    for i := 1 to k do 
        r[i] := i;
    ans := 0;
    for c := 1 to k do 
        for b := 1 to k do 
            for a := 1 to k do 
                ans := ans + gcd(gcd(r[a], r[b]), r[c]);
    writeln(ans);
end.

Measured memory_bytes: 1380
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb(x) push_back(x)

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

void solve(){
    string str1, str2;
    cin >> str1 >> str2;
    if(str1.length() + 1 != str2.length()){
        cout << "No";
        return;
    }

    for(int i = 0; i < str2.length()-1; i++){
        if(str1[i] != str2[i]){
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

}

Measured memory_bytes: 3616
import java.math.BigInteger
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    print(listOf(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)[readInt() - 1])
}


Measured memory_bytes: 33868
import collections
n=int(input())

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

#print(ab)
c = collections.Counter(ab)
#print(c)
score_sorted = sorted(c.items(), key=lambda x:-x[1])
value = 0
count = 0
res = []
for k, i in score_sorted:
    if count == 0:
        res.append(k)
        count += 1
        value = i
    else:
        if value == i:
            res.append(k)
res.sort()
for i in res:
    print(i)

Measured memory_bytes: 120528
s = input()
a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")
    

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

int main()
{
	int n;
	cin>>n;
	bool b=true;
	while(n>0)
	{
	if(n%10==9){cout<<"Yes"<<endl;b=false;break;}
	n=n/10;
}
if(b)cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
// E - Knapsack 2
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;

// void vprn(vl &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
// void dpprn(vl &v, ll inf){
// 	for(int i=0;i<v.size();i++){
// 		if(v[i]==inf) cout<<"∞"; else cout<<v[i];
// 		cout<<(i<v.size()-1?",\t":"\n");
// 	}
// }

int main(){
	int N,W; cin>>N>>W;
	ll VMAX = 1e5; // max(v_i) * max(N) = 1e3 * 1e2
	ll WMAX = 1e9; // max(W)

	vl w(N+1), v(N+1);
	ll vmin = LLONG_MAX, vmax = 0;
	for(int i=1; i<=N; i++){
		cin>>w[i]>>v[i];
		vmin = min(vmin, v[i]);
		vmax = max(vmax, v[i]);
	}
	vmax = min(vmax*N, VMAX);
	// vprn(w);//
	// vprn(v);//

	vl dp(vmax+1, WMAX); dp[0] = 0;

	for(int i=1; i<=N; i++)
		for(int j=vmax; j>=v[i]; j--) dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
	// dpprn(dp,INF);cout<<"---------------------\n";//

	ll ans = 0;
	for(ll i=vmin; i<=vmax; i++) if(dp[i]<=W) ans = max(ans, i);
	cout<< ans <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/numeric>
/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/
using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef vector<int> vi;

bool isPrime(ll q){
    if(q==2) return 1;
    if(q<2 || (q>2 && !isOdd(q))) return 0;

    for(ll i = 2; i*i<=q; i++)
        if(!(q%i)) return 0;

    return 1;
}


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\out.txt", "w", stdout);

    ll n; cin>>n;
    if(isPrime(n)) return cout<<1, 0;
    bool f = 1;
    ll cnt = 0;
    map<ll, bool> mp;
    while(f){
        f = 0;
        for(ll i = 2; i*i<=n; i++){
            if(isPrime(i)){
                ll p = 1;
                for(ll j = 1;  ;j++){
                    if(p*i>n) break;
                    p *= i;
                    if((n%p)==0 && !mp.count(p)){
                        f = 1;
                        n /= p;
                        mp[p] = 1;
                        cnt++;
                        break;
                    }
                }
            }
            if(!f && isPrime(n/i)){
                ll ii = n/i;
                ll p = 1;
                for(ll j = 1;  ;j++){
                    if(p*ii>n) break;
                    p *= ii;
                    if((n%p)==0 && !mp.count(p)){
                        f = 1;
                        n /= p;
                        mp[p] = 1;
                        cnt++;
                        break;
                    }
                }
            }
        }
        if(isPrime(n) && !mp.count(n)){
            cnt++;
            goto safe;
        }
    }
    safe:;
    cout<<cnt;
	return 0;
}


Measured memory_bytes: 3656
n = int(input())
a = list(map(int,input().split()))
b = sum(a)
c = 0
for i in range(len(a)):
  c += a[i]
  if c >= b/2:
    d = i
    sum_b = c
    sumsum_b = c - a[i]
    break
if d == 0:
  ans = 2*a[0] - b
elif d == n-1:
  ans = b - 2*sumsum_b
else:
  e = sum_b
  f = sumsum_b
  if e + f >= b:
    ans = b - 2*f
  else:
    if sum_b - d - 1 < 2*e - b:
      ans = b - 2*f
    else:
      ans = 2*e - b
print(ans)

Measured memory_bytes: 25784
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
 
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
 
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];
 
void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}
 
ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}
 
bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}
 
ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
 
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
 
int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> A >> B >> C;
  vector<ll> max_abc;
  max_abc.push_back(A);
  max_abc.push_back(B);
  max_abc.push_back(C);
  sort(ALL(max_abc));
  cout <<max_abc[2]*10+max_abc[1]+max_abc[0] << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  bool d=false;
  for(int i=1;i<b;i++){
    if(a*i%b==c){
      d=true;
      break;
    }
  }
  if(d){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (ll i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
map<int, int> p;
map<int, int>::iterator it;
int main()
{
    FastRead;
    int n;
    cin >> n;
    int a[n+1], ans[n+1] = {0};
    for (int i = 2; i <= n; i++)
    {
        cin >> a[i];
        ans[a[i]]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=5e5 + 5;
const int M=1e5 + 5;

int arr[N],a[N]; 
 
int main()
{
    ios_base::sync_with_stdio(false);
    int i,n,j;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    for(i=1;i<=n;i++){
        arr[i]=0;
    } 
    for(i=n;i>=1;i--){
        int cnt = 0;
        for(j=2*i;j<=n;j+=i){
            cnt += arr[j];
            cnt%=2;
        }
        if(a[i]!=cnt) arr[i]=1;
        else arr[i]=0;
    }
    vector <int> v;
    for(i=1;i<=n;i++){
        if(arr[i]) v.pb(i);
    }
    cout << v.size() << endl;
    for(i=0;i<v.size();i++) cout << v[i] << " ";
    cout << endl;




 
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

// #define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 1e9+7;
using ll = long long;
struct mint {
  ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
 }
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
vector<mint> fac(MX);
vector<mint> ifac(MX);
mint comp(ll a, ll b) {
    return fac[a]/fac[b]/fac[a-b];
}

int a[2001];

int f(int n) {
    if(n<3) return 0;
    if(n==3) return 1;
    if(a[n-1]==0) a[n-1]=f(n-1);
    if(a[n-3]==0) a[n-3]=f(n-3);
    a[n] = (a[n-1]+a[n-3])%mod;
    return a[n];
}
signed main(){
    int s;
    cin >> s;
    a[3]=1;
    cout << f(s) << endl;
    return 0;

}


Measured memory_bytes: 19020
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
typedef pair<int,int> P;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
	int x;
	cin>>x;
	rep(i,-3000,3001){
		rep(j,-3000,3001){
			int a=i*i*i*i*i;
			int b=j*j*j*j*j;
			if(a-b==x){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	}
}


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

int N;
int main(){
  cin>>N;
  int ans=0;
  for(int i=0; i<=N; i++) {
    if(1<=i && i<10) ans++;
    if(100<=i &&i<1000) ans++;
    if(10000<=i && i<100000) ans++;
  }
  cout<<ans<<endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

map<string,int> memo;
int main()
{
	int N;cin>>N;

    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        memo[s]+=1;
    }
    int sum=0;
    for(const auto& x:memo){
        sum++;
    }
    cout<<sum<<endl;
}

 
    
        







Measured memory_bytes: 19228
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
typedef long long ll;

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

    ll a[n];
    ll numMinus = 0;
    ll res = 0;
    ll minNum = 1000000009;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            numMinus++;
            res -= a[i];
            minNum = (minNum > -a[i]) ? -a[i] : minNum;
        } else {
            res += a[i];
            minNum = (minNum > a[i]) ? a[i] : minNum;
        }
    }

    if (numMinus % 2 == 1) res = res - 2 * minNum;

    cout << res << endl;
}


Measured memory_bytes: 1024
import sys

# A - Two Abbreviations
def get_lcm(a, b):
	import math
	return (a * b) // math.gcd(a, b)


def is_match(X, L):
  global M
  global T

  i = 0
  m = L//M * i

  while m + 1 < L:
    if m+1 in X.keys():
      if X[m+1] != T[i]:
        return False

    i += 1
    m = L//M * i

  return True


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

if S[0] != T[0]:
  print(-1)
else:
  lcm = get_lcm(N, M)

  for i in range(1, 100):
    L = lcm * i
    X = dict()

    j = 0
    n = L//N * j

    while n + 1 < L:
      X[n+1] = S[j]

      j += 1
      n = L//N * j

    if is_match(X, L):
      print(L)
      exit()

  print(-1)

Measured memory_bytes: 265528
#include <stdio.h>

int main(void){
    int flag = 1;
    while(flag){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a==0 && b==0){
            flag=0;
            break;
        }
        int i,j;
        for(i=0;i<a;i++){
            for(j=0;j<b;j++){
                if((i+j)%2==0){
                    printf("#");
                }else{
                    printf(".");
                }
                if(j==b-1){
                    printf("\n");
                }
            }
        }
        printf("\n");
    }
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 998244353;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[3300];
int main(){
  ll n,k,ans=0;
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
  else cout<<"No";
}



Measured memory_bytes: 256
a = input()
if int(a) >= 400 and int(a) <= 599:
  print("8")
elif int(a) >= 600 and int(a) <= 799:
  print("7")
elif int(a) >= 800 and int(a) <= 999:
  print("6")
elif int(a) >= 1000 and int(a) <= 1199:
  print("5")
elif int(a) >= 1200 and int(a) <= 1399:
  print("4")
elif int(a) >= 1400 and int(a) <= 1599:
  print("3")
elif int(a) >= 1600 and int(a) <= 1799:
  print("2")
elif int(a) >= 1800 and int(a) <= 1999:
  print("1")

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll n, c;
    cin >> n >> c;
    vector<ll> v(n), S(n+1, 0), x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> v[i];
        S[i+1] = S[i] + v[i];
    }
    ll ans = 0, a = 0, b = 0;
    for (ll i = n-1; i >= 0; --i) {
        ans = max({ans, S[i+1]-x[i]+a, S[i+1]-2*x[i]+b});
        a = max(a, S[n] - S[i] - 2*(c-x[i]));
        b = max(b, S[n]-S[i]-(c-x[i]));
    }
    cout << max(ans, b) << "\n";
    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
int main(){
    long long a,b,c;scanf("%lld%lld%lld",&a,&b,&c);
    if(c-(a+b)<0){
        printf("No\n");
        return 0;
    }
    long long x=4*a*b;
    long long y=(c-(a+b))*(c-(a+b));
    printf(x<y?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 5005;

int a[MAX_N], sm[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    int id = 0;;
    rep(i,n){
        cin >> a[id];
        if(a[id] < K-1) id++;
    }
    n = id;
    sort(a, a+n, greater<int>());
    rrep(i,n){
        sm[i] = sm[i+1] + a[i];
    }
    int ans = 0;
    bitset<MAX_N> dp;
    dp[0] = true;
    rep(i,n){
        if(K+a[i]-sm[i] > 0){
            bool flag = true;
            srep(j,max(0, K-sm[i]),K+a[i]-sm[i]){
                if(dp[j]) flag = false;
            }
            ans += flag;
        }
        dp |= (dp << a[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll a,b,c;
    cin >> a >> b >> c;
    set<ll> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0

#左からl個、右からr個取り出す
for l in range(K + 1):
    for r in range(K - l + 1):
        if l + r > N: continue
        d = K - l - r
        now = 0
        having = []
        for i in range(l):
            now += V[i]
            having.append(V[i])
        for i in range(N-r, N):
            now += V[i]
            having.append(V[i])

        having.sort()
        #d回まで持っている宝石(価値がマイナス)を戻す
        for i in range(d):
            if i >= len(having): break
            if having[i] >= 0: break
            now -= having[i]
        ans = max(ans, now)

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
    string a,b;
    stringstream ss;
    int c,x=1,y=1;
    cin>>a>>b;
    ss<<a+b;
    ss>>c;
    while(x*y<=c){
        if(x*y==c){
            cout<<"Yes"<<endl;
            break;
        }
        x++;
        y++;
    }
    if(x*y!=c)
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	if(k <= a) ans += k;
	else if(k > a && k-a <= b) ans += a;
	else {
		ans += a;
		ans -=(k-a-b);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int t,n,s,f,nn=0,i,nnn;
    while(1)
    {
        scanf("%d",&t);
        if(t==0)break;
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            scanf("%d %d",&s,&f);
            nn+=f-s;
        }
        if(nn<t)
        {
            nnn=t-nn;
            printf("%d\n",nnn);
        }
        else printf("OK\n");
        nn=0;
    }
    return 0;
}

Measured memory_bytes: 612
from bisect import bisect

n=int(input())
a=sorted(list(map(int,input().split())))

x=a[-1]
if n%2==0:
  mid=x//2
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])
else:
  mid=x//2+1
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])

Measured memory_bytes: 14052
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int n,q;
    cin >> n >> q;
    vector< pair<int,string> > m;
    m.PB(pair<int,string>(0,"kogakubu10gokan"));
    REP(i,n){
	int y;
	string s;
	cin >> y >> s;
	m.PB(pair<int,string>(y,s));
    }
    sort(ALL(m));
    FOR(i,1,n+1){
	if(q < m[i].first){
	    cout << m[i-1].second << endl;
	    break;
	}
	if(i==n){
	    cout << m[m.size()-1].second << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

int main(void){
	int w,h,n,x,y,a,i,xl,xr,yl,yr;
	cin >> w >> h >> n;
	xl = 0; xr = w;
	yl = 0; yr = h;
	for(i=0; i<n; ++i){
		cin >> x >> y >> a;
		switch(a){
			case 1:
				xl = max(xl,x);
				break;
			case 2:
				xr = min(xr,x);
				break;
			case 3:
				yl = max(yl,y);
				break;
			case 4:
				yr = min(yr,y);
				break;
		}
	}
	cout << (max(xr-xl,0)*max(yr-yl,0)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
int main(){
  int n,k,gu,ch,pa;
  int ans=0;
  string robot;
  cin >> n >> k >> gu >> ch >> pa >> robot;
  bool check[n]={false};
	
  auto score = [&](int i){
	if(robot[i] == 'r') return pa;
	else if(robot[i] == 's') return gu;
	else return ch;
  };
	
  rep(i,n){
    if(i<k){
	  ans += score(i);
	  check[i] = true;
    }
	else{
	  if(robot[i]==robot[i-k] && check[i-k]) continue;
      else{
        ans += score(i);
        check[i] = true;
      }
    }
  }
	cout << ans << endl;
}

Measured memory_bytes: 512
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$L) =  explode(" ",trim(fgets(STDIN)));
//$a =  explode(" ",trim(fgets(STDIN)));

$sum=array();;
for($i=0;$i<$N;$i++) {
  $sum[]=$L+1+$i-1;
}
if ($L > 0) {
  $min = $L;
}
else {
  if (max($sum)<0) {
    $min = max($sum);
  }
  else {
    $min=0;
  }
}
printf("%d\n",array_sum($sum)-$min);


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  string s, t;
  cin>>n>>s>>t;
  REP(i, n){
    cout<<s[i]<<t[i];
  }
  cout<<'\n';
  return 0;
}


Measured memory_bytes: 256