akhauriyash/Code-Regression huggingface dataset:
#[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,
    }

    let mut cur = 0;
    for i in 0..n {
        if s[i] == '.' {
            cur += 1;
        }
    }
    let mut ans = cur;

    for i in 0..n {
        if s[i] == '.' {
            cur -= 1;
        }
        if s[i] == '#' {
            cur += 1;
        }
        ans = std::cmp::min(ans, cur);
    }

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


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
 
int main()  {
    int N, K;
    cin>>N>>K;
    int p[N];
    double p1[N];
    for(int i=0;i<N;++i){
        cin>>p[i];
    }
    for(int i=0;i<N;++i){
        if(p[i]%2==0){
            p1[i] = p[i]/2+0.5;
        }
        else {
            p1[i] = p[i]/2+1;
        }
    }
    /**
    for(int i=0;i<N;++i){
        cout<<p1[i]<<" ";
    }
    cout<<endl;
    **/
    double tmp = 0;
    double ans = 0;
    for(int i=0;i<K;++i){
        tmp += p1[i];
        ans += p1[i];
    }
    for(int i=0;i<N-K;++i){
        tmp += p1[K+i] - p1[i];
        if(ans<tmp)ans=tmp;
    }
    cout<<setprecision(10)<<ans<<endl;
}

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

using ll=long long;

int n, m, u, v;

vector<int> edge[100010];
int memo[100010];
bool done[100010];

int dp(int v){
  if(done[v]) return memo[v];
  int ans = 0;
  for(int to: edge[v]){
    ans = max(ans, dp(to) + 1);
  }
  done[v] = true;
  memo[v] = ans; 
  return ans;
}

int main(){
  cin >> n >> m;
  rep(i,m){
    cin >> u >> v;
    u--; v--;
    edge[u].push_back(v);
  }
  
  int ans = 0;
  rep(v,n){
    ans = max(ans, dp(v));
  }
  cout << ans << endl;
  
}

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

N = int(input())
S = input().rstrip()

num = S.count('1')

n1 = num + 1
n2 = num - 1

def count(m):
    ret = 1
    while m != 0:
        k = bin(m).count("1")
        m %= k
        ret += 1
    return ret


if n2 != 0:
    start1 = 0
    start2 = 0
    pow1 = [1]
    pow2 = [1]
    for i in range(N):
        s = int(S[-1-i])
        start1 = (start1 + pow1[-1] * s) % n1
        start2 = (start2 + pow2[-1] * s) % n2
        pow1.append(pow1[-1] * 2 % n1)
        pow2.append(pow2[-1] * 2 % n2)


    ans = []
    for i in range(N):
        s = int(S[i])
        if s == 0:
            l = (start1 + pow1[-i-2]) % n1
            ans.append(count(l))
        else:
            l = (start2 - pow2[-i-2]) % n2
            ans.append(count(l))

    print(*ans, sep="\n")
else:
    start1 = 0
    pow1 = [1]
    for i in range(N):
        s = int(S[-1-i])
        start1 = (start1 + pow1[-1] * s) % n1
        pow1.append(pow1[-1] * 2 % n1)

        


    ans = []
    for i in range(N):
        s = int(S[i])
        if s == 0:
            l = (start1 + pow1[-i-2]) % n1
            ans.append(count(l))
        else:
            ans.append(0)

    print(*ans, sep="\n")

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

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();

        if(s.Count(c => c == 'R') > s.Count(c => c == 'B'))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100001

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

    ll r, d, x;
    cin>>r>>d>>x;
    for(ll i=1; i<=10; i++){
        x = r*x-d;
        print(x);
    }
        
    
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n;
	scanf("%d", &n);

	int i = 1;

	do{

		int x = i;

		if (x % 3 == 0)
		{
			printf(" %d", i);
		}
		else
		{
			for (;;)
			{
				if (x % 10 == 3)
				{
					printf(" %d", i);
					break;
				}
				else
				{
					x = x / 10;
					if (x == 0)
					{
						break;
					}
				}
			}
		}
	}while (++i <= n);

	printf("\n");

	return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;
namespace Regular_Contest_066
{
    class Program
    {
        static void Main(string[] args)
        {
            /* string a = (Console.ReadLine());
             
             string a3 = a.Substring(4);
             int h = Int32.Parse("" + a1 + "");
             int g = Int32.Parse("" + a3 + "");
             if (a2 == "+") { Console.WriteLine(h+g); }
             else
             {
                 Console.WriteLine(h-g);
             }*/
            string[] a = Console.ReadLine().Split(' ').ToArray();
            int h = Int32.Parse(a[0]);
            int g = int.Parse(a[2]);
            if (a[1] == "+") { Console.WriteLine(h + g); }
            else
            {
                Console.WriteLine(h - g);
            }
            
        }
    }
}


Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
int dp[111][11111],N,W,c[111],d[111],bnu;
int kei(int i,int j){
    if(dp[i][j])return dp[i][j];
    if(i==N){return 0;}
    if(j<d[i]){return kei(i+1,j);}
    return dp[i][j]=bnu=max(kei(i+1,j),kei(i+1,j-d[i])+c[i]);
}
int main(){
    cin>>N>>W;
    for(int i=0;i<N;i++)cin>>c[i]>>d[i];
    cout<<kei(0,W)<<endl;
}

Measured memory_bytes: 6856
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    # Failed to predict input format
    r, D, x = readIntN()
    for i in range(10):
        x = r * x - D
        print(x)

if __name__ == '__main__':
    main()


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

vector<int> vec = {7, 6, 5, 3, 4, 2, 1, 0};

string to_binary(int num, int len) {
	string res;
	while(len--) {
		res.push_back(char('0' + (num & 1)));
		num >>= 1;
	}
	return string(res.rbegin(), res.rend());
}

string more(string a) {
	sort(a.begin(), a.end());
	return a.substr(1, 1);
}

string MX(string a, string b) {
	int cnt1 = 0, cnt2 = 0;
	for (char c: a)
		cnt1 += (c == '1');
	for (char c: b)
		cnt2 += (c == '1');	
	if(cnt1 > cnt2)
		return a;
	if(cnt2 > cnt1)
		return b;
	return max(a, b);
}

void get(string s, vector<int> &a) {
	a.push_back(0);
	vector<int> b;
	for (char c: s) {
		b.clear();
		for (int num: a) {
			if(c != '0')
				b.push_back((num << 1) | 1);
			if(c != '1')
				b.push_back(num << 1);
		}
		a = b;
	}
}

int to_num(string s) {
	int num = 0;
	for (char c: s)
		num = (num << 1) | (c - '0');
	return num;
}

int best(int a, int b) {
	string s = to_binary(a, 3) + to_binary(b, 2);
	string ans;
	for (int i = 0; i <= 2; i++)
		ans = MX(ans, s.substr(0, i) + more(s.substr(i, 3)) + s.substr(i + 3));
	return to_num(ans);
}

const int N = 3e5 + 100, M = 10, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if(a < 0)
		a += MOD;
	else if(a >= MOD)
		a -= MOD;
	return a;
}

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

int n, dp[N][M], BEST[M][M];
string s;

void pre_pro() {
	for (int a = 0; a < M; a++)
		for (int b = 0; b < (M >> 1); b++)
			BEST[a][b] = best(a, b);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	pre_pro();
	cin >> s;
	n = s.length();
	if(n == 1) {
		cout << (s[0] != '0');
		return 0;
	}
	vector<int> a;
	get(s.substr(0, 3), a);
	for (int num: a)
		dp[2][num]++;
	int CNT = 0;
	for (int i = 4; i < n; i += 2) {
		vector<int> a;
		get(s.substr(i - 1, 2), a);
		for (int last = 0; last < M; last++)
			if(dp[i - 2][last])
				for (int now: a) {
					int nxt = BEST[last][now];
					dp[i][nxt] = sum(dp[i][nxt], dp[i - 2][last]);
				}
	}
	int ans = 0;
	for (int i = 0; i < 4; i++)
		ans = sum(ans, dp[n - 1][vec[i]]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 12436
#include<stdio.h>

int main(){
   int i,a,b;
   for(i=1;i<=3000;i++){
       scanf("%d %d",&a,&b);
       if(a==0 && b==0) break;
       if(a <= b){
          printf("%d %d\n",a,b);
       }else if(a > b){
          printf("%d %d\n",b,a);
       }
   }
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M), Y(M), Z(M);
  REP(i, M) {
    cin >> X[i] >> Y[i] >> Z[i];
    --X[i]; --Y[i];
  }

  UnionFind uf(N);
  REP(i, M) uf.unionSet(X[i], Y[i]);

  int ret = 0;
  REP(i, N) if(uf.root(i) == i) ++ret;
  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 1792
(let* ((n (read))
    (s (read-line))
    (ansChar "")
    (ansNum 0))

    (dotimes (i n)
        (if (not (eq ansChar (char s i)))
            (progn
                (incf ansNum)
                (setq ansChar (char s i))
            )
        )
    )
    (princ ansNum)
)

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

int main() {
  int f = 0;
  int c[3][3];
  int a[3] = {1 << 23, 1 << 23, 1 << 23};
  int b[3] = {1 << 23, 1 << 23, 1 << 23};
  
  for ( int i = 0; i < 3; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      cin >> c[i][j];
    }
  }
  
  for ( a[0] = 0; a[0] <= 100 ; a[0]++) {
    for ( a[1] = 0; a[1] <= 100; a[1]++) {
      for ( a[2] = 0; a[2] <= 100; a[2]++) {
        int p = 0;
        
        b[0] = c[0][0] - a[0];
        b[1] = c[1][1] - a[1];
        b[2] = c[2][2] - a[2];

        for ( int i = 0; i < 3; i++) {
          for ( int j = 0; j < 3; j++) {
            if ( a[i] + b[j] != c[i][j] ) {
              p++;
            }
          }
        }

        if ( p == 0 ) {
          f = 1;
        }
      }
    }
  }

  if (f) {
    cout << "Yes" << endl;
  } else {

    cout << "No" << endl;
  }
  
  return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 998244353;



int main(){
    ll N; cin >> N;
    ll cnt = 1;
    ll tmp;
    string S = "";
    char c;
    N = N - 1;
    while(N >= 0){
        tmp = N + cnt;
        tmp = tmp / cnt;
        c = 'a' + ((tmp+25) % 26);
        S += c;
        
        cnt = cnt * 26;
        N -= cnt;


    }
    reverse(ALL(S));
    printf("%s\n", S.c_str());
    
}


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

#define ll long long int

const ll mod=1e9+7;
const int sz=1e6+100;

vector<int> prime;
bool vis[sz];
int siz;
int tot[sz];
int mark[sz];

void seive()
{
    int i,j,k,p,q,sq;

    sq=sqrt(sz);
    for(int i=3;i<sz;i+=2) mark[i]=true;
    for(int i=3;i<=sq;i+=2){
        if(mark[i]){
            for(int j=i*i;j<sz;j+=i) mark[j]=false;
        }
    }

    prime.push_back(2);
   // mark[2]=0;
    for(int i=3;i<sz;i+=2) if(mark[i]) prime.push_back(i);
    siz=prime.size();

    for(i=0;i<siz;i++) mark[prime[i]]=i;
}

void FACT(int p)
{
    int sq=sqrt(p);
    for(int i=0;i<siz && prime[i]<=sq;i++){
        if(p % prime[i]==0){
            tot[i]+=1;
            while(p % prime[i]==0) p/=prime[i];
            sq=sqrt(p);
        }
    }

    if(p>1){
       tot[mark[p]]+=1;
    }
}

int main()
{
    int n,m,p,q,i,j,x;
    cin>>n;

    int ara[n];
    seive();
    for(i=1;i<=n;i++){
        cin>>x;
        FACT(x);
    }

    bool bl=true;
    for(i=0;i<siz;i++){
        if(tot[i]>1){
            bl=false;
            break;
        }
    }

    if(bl) {
        cout<<"pairwise coprime\n";
        return 0;
    }
    bl=true;

    for(i=0;i<siz;i++){
       if(tot[i]>=n){
         bl=false;
         break;
       }
    }

    if(bl) cout<<"setwise coprime\n";
    else cout<<"not coprime\n";
}


Measured memory_bytes: 7944
n,m = map(int,input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for i in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    flag = 0
    for k in range(m):
      for l in range(m):
        if b[k][l] != a[k+j][l+i]:
          flag = 1
          break
      if flag == 1:
        break
    if flag == 0:
      print("Yes")
      break
  if flag == 0:
    break
if flag == 1:
  print("No")


Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int main(void) {
	int a, b, h; cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
def f(ary)
  n = ary.size
  res = Array.new(n)
  n.times do |i|
    res[i] = ary[i] ^ ary[i-1]
  end
  res
end
def mp_table(ary)
  n = ary.size
  res = Array.new(n)
  res[0] = 0
  cnt = 0
  1.upto(n - 1) do |i|
    if ary[cnt] == ary[i]
      cnt += 1
    else
      cnt = 0
    end
    res[i] = cnt
  end
  res.unshift(-1)
end

N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

xa = f(A)
xb = f(B)
xa += xa
mp = mp_table(xb)
cnt = 0
ans = []
i = 0
while i < 2 * N
  if cnt == N
    k = i - N
    ans << [k, A[k] ^ B[0]]
    cnt = mp[cnt]
  end
  
  if xb[cnt] == xa[i]
    cnt += 1
    i += 1
  elsif cnt == 0
    i += 1
  else
    cnt = mp[cnt]
  end
end

puts ans.map{|a| a.join(" ")}.join("\n")

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;cin>>s;
  bool flag=false;
  if(s[2]==s[3] && s[4]==s[5])flag=true;
  flag2func(flag);
}


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

int main(void){
	double d, e;
	double ans = INF;
	while(true){
		cin >> d >> e;
		if(!d&&!e) break;
		ans = INF;
		for(int i = 0; i <= d; ++i){
			ans = min(ans, abs(e - sqrt(i * i + (d-i) * (d-i))));
		}
		printf("%.4lf\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3196
n, q = map(int, input().split())
s = input()
ac = []
last = False
for i in range(n):
    if last and s[i] == "C":
        last = False
        ac.append(1)
    else:
        if s[i] == "A":
            last = True
        else:
            last = False
        ac.append(0)
ac_t = [0]
for i in range(n):
    ac_t.append(ac[i] + ac_t[i])
for i in range(q):
    l, r = map(int, input().split())
    print(ac_t[r] - ac_t[l])

Measured memory_bytes: 8560
#include <bits/stdc++.h>
#define int long long
#define N 110
#define M 10010
using namespace std;
const int INF = 1e9;
int dp[N][M];
int Min(int &a,int b){return a = min(a,b);}
int Max(int &a,int b){return a = max(a,b);}

signed main(){
  int n,K;
  cin>>n>>K;
  int A[N],B[N],C[N];

  for(int i=0;i<n;i++) cin>>A[i]>>B[i]>>C[i];

  for(int i=0;i<N;i++)
    for(int j=0;j<M;j++) dp[i][j] = -1;
  dp[0][0] = 0;
  
  for(int i=0;i<n;i++){
    int a = A[i],b = B[i], c=C[i];
    for(int j=K;j>=0;j--){
      int nK = j + c;
      if(nK > K)continue;
      for(int k=M;k>=0;k--){
	//cout<<i<<" "<<j<<" "<<k<<" "<<dp[j][k]<<endl;
	if(dp[j][k] == -1)continue;
	int d = dp[j][k];
	if(k+a >= d+b)Max(dp[nK][k+a],d+b);
	else Max(dp[nK][d+b],k+a);
	if(k+b >= d+a) Max(dp[nK][k+b],d+a);
	else Max(dp[nK][d+a],k+b);
      }
    }
  }
  int ans = 0;
  for(int i=0;i<=K;i++)
    for(int j=0;j<M;j++){
      Max(ans,dp[i][j]);
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11684
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for (;;) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}

	}

	return 0;
}

Measured memory_bytes: 3600
import itertools

n = int(input())
town = [tuple(map(int,input().split())) for _ in range(n)]
c_town = list(itertools.combinations(town,2))
lp = len(list(itertools.permutations(town)))
sum_road = 0

for i in c_town:
  sum_road += ((i[0][0]-i[1][0])**2 + (i[0][1]-i[1][1])**2)**0.5
  
print(2*sum_road/n)

Measured memory_bytes: 13788
/* A */

#include <iostream>
#include <string>
using namespace std;

int main(){
	int max = 0, min = 123, x, k;

	for (int i = 0; i < 5; ++i)
	{
		cin >> x;
		if(x > max){
			max = x;
		}

		if(x < min){
			min = x;
		}
	}

	cin >> k;

	if(max - min > k){
		printf(":(");
	}else{
		printf("Yay!");
	}

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,t,b,c,d,a,l,r;
    cin>>a>>b>>c;
    if(a%b)
        x=a/b,x++;
        else x=a/b;
    cout<<x*c<<'\n';
}










Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
        
int main(){
    vector<int> alph(26,1);
    int N; char x; cin >> N;
    for( int i = 0; i < N; i++ ){
        cin >> x;
        int k = x - 97;
        alph[k]++;
    }

    long long ans = 1;

    for( int k : alph ){
        ans *= k;
        ans %= 1000000007;
    }

    cout << ans - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int n,i,k,minn=INT_MAX;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(i=1;i<=n-k+1;i++)
		minn=min(minn,a[i+k-1]-a[i]);
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*; 
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        int n = ni();boolean yes = true;
        String s = n();
        TreeSet<String> set = new TreeSet<>();
        set.add(s);
        char prev = s.charAt(s.length()-1);
        for(int i = 1; i< n; i++){
            s = n();
            yes &= s.charAt(0)==prev;
            prev = s.charAt(s.length()-1);
            if(set.contains(s))yes = false;
            else set.add(s);
        }
        pn((yes)?"Yes":"No");
    }
    //SOLUTION ENDS
    long mod = (int)1e9+7, IINF = (long)3e18;
    final int MAX = (int)1e5+1, INF = (int)1e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //long ct = System.currentTimeMillis();
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        //pn(System.currentTimeMillis()-ct);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long lcm(long a, long b){return a*b/gcd(a,b);}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}

Measured memory_bytes: 24788
#include <bits/stdc++.h>
using namespace std;
int INF = 10000;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int ans = INF;
  for (int i = max({A, B, C}); i <= 51; i++){
    int d = (i - A) + (i - B) + (i - C);
    if (d % 2 == 0){
      ans = min(ans, d / 2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;
const int S=20002;

int main(){
	int n,a[S]={},b[S]={};
	LL c=0;
	cin>>n;
	FOR(i,0,n){
		cin>>a[i]>>b[i];
	}
	int f=1;
	FOR(i,0,n){
		if(a[i]!=b[i]){
			f=0;
		}
	}
	if(f){
		cout<<0<<endl;
		return 0;
	}
	LL am=0,rest=0;
	FOR(i,0,n){
		if(a[i]==b[i]){
			c+=a[i];
			a[i]=0;b[i]=0;
		}else if(a[i]<b[i]){
			c+=a[i];
			b[i]-=a[i];
			a[i]-=a[i];
			am+=b[i];
		}else rest++;
	}
	f=1;
	FOR(i,0,n){
		if(a[i]!=b[i]){
			f=0;
		}
	}
	if(f){
		cout<<c<<endl;
		return 0;
	}
	if(rest==1){
		FOR(i,0,n){
			if(a[i]>b[i]){
				c+=a[i]-b[i];
			}
		}

		cout<<c<<endl;
			return 0;
	}
	int mn=mod;
	FOR(i,0,n){
		if(a[i]>b[i]){
			mn=min(mn,b[i]);
		}
	}
	FOR(i,0,n){
		c+=a[i];
	}

	c-=mn;
	/*
	LL v[S]={},w[S]={};
	FOR(i,0,n){
		if(a[i]>b[i]){

		}
	}

	//*/


	cout<<c<<endl;
    return 0;
}


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

int main() {
	string S;
	cin >> S;
	string day[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	for (int i = 0;i < 7;++i) {
		if (day[i] == S) {
			cout << 7 - i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
var
	n,a,i,j,x,L,R:Longint;
	dp:array[0..50,0..5000]of int64;
begin
	read(n,a);
	dp[0,n*a]:=1;
	for i:=1 to n do begin
		for j:=0 to 5000 do dp[i,j]:=dp[i-1,j];
		read(x);
		x:=a-x;
		L:=-x;
		if L<0 then L:=0;
		R:=5000-x;
		if R>5000 then R:=5000;
		for j:=L to R do begin
			inc(dp[i,j+x],dp[i-1,j]);
		end;
	end;
	writeln(dp[n,n*a]-1);
end.


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int,int> ip;

int solve(int W, int N, vector<int>& v, vector<int>& w){
    vector< vector<ip> > dp(N+1, vector<ip>(W+1));
    for(int i = N - 1; i >= 0; i--){
        for(int j = 0; j <= W; j++){
            if(j < w[i]){
                dp[i][j] = dp[i+1][j];
            } else {
                int a = dp[i+1][j].first;
                int b = dp[i+1][j-w[i]].first + v[i];
                if(a >= b) dp[i][j] = dp[i+1][j];
                else {
                    dp[i][j] = make_pair(b, dp[i+1][j-w[i]].second + w[i]);
                }
            }
        }
    }
    cout << dp[0][W].first << endl;
    cout << dp[0][W].second << endl;
}

int main(){
    int W, N;
    char c;
    int cnt = 1;
    while(true){
        cin >> W;
        if(W == 0) break;
        cin >> N;
        vector<int> v(N);
        vector<int> w(N);
        for(int i=0; i<N; ++i){
            cin >> v[i] >> c >> w[i];
        }
        cout << "Case " << cnt++ << ":" << endl;
        solve(W,N,v,w);
    }
}

Measured memory_bytes: 8972
A = set([1,3,5,7,8,10,12])
B = set([4,6,9,11])
C = set([2])

x,y = map(int, input().split())

if x in A and y in A:
    print("Yes")

elif x in B and y in B:
    print("Yes")

elif x in C and y in C:
    print("Yes")

else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
#define PI 3.14159265359
int main(){
    ll n,m;
    cin >> n >> m;
    for (ll i=0;i<m;i++){
        ll a;
        cin >> a;
        n-=a;
    }
    cout << max(-1LL,n) << endl;
    return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <vector>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

int nxtx[] = {1, 0};
int nxty[] = {0, 1};

int main(int argc, char const *argv[]) {
    int q;
    cin >> q;
    string X, Y;
    typedef pair<int, int> pint;
    for (int k = 0; k < q; k ++) {
        cin >> X;
        cin >> Y;
        int lenX = X.size();
        int lenY = Y.size();
        int dp[lenX + 1][lenY + 1];
        for (int i = 0; i <= lenX; i ++) {
            dp[i][0] = 0;
        }
        for (int i = 0; i <= lenY; i ++) {
            dp[0][i] = 0;
        }

        for (int i = 1; i <= lenX; i ++) {
            for (int j = 1; j <= lenY; j ++) {
                if (X[i-1] == Y[j-1]) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                } else {
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
        cout << dp[lenX][lenY] << endl;
    }
    return 0;
}


Measured memory_bytes: 7076
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    string S, T;
    cin >> S >> T;
    T.pop_back();
    if(S == T) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
	int count5 = 0, count7 = 0;
	for (int i = 0; i < 3; ++i) {
		int a;
		cin >> a;
		if (a == 5)
			++count5;
		else if (a == 7)
			++count7;
	}
	if (count5 == 2 && count7 == 1)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

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


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let v = read_t_in_line::<i32>();
    let (a, b, c) = (v[0], v[1], v[2]);
    println!("{}", min(c, b / a));

}


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

using namespace std;

using int64 = long long;

int main() {
  int N, A[100];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];
  int ret = 0;
  for(int i = 1; i < N; i++) {
    if(A[i - 1] == A[i]) {
      A[i] = 114514 + i;
      ++ret;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int a,b,c,x;cin >> a >> b >> c >> x;
	int ans = 0;
	REP(i,a+1)
	{
		REP(j,b+1)
		{
			REP(k,c+1)
			{
				if(i*500 + j*100 + k*50 == x)ans++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N;
	scanf("%d", &N);

	int32_t honest[16];
	memset(honest, 0, sizeof(honest));
	int32_t unkind[16];
	memset(unkind, 0, sizeof(unkind));
	for (int32_t i = 0; i < N; i++) {
		int32_t A;
		scanf("%d", &A);
		for (int32_t j = 0; j < A; j++) {
			int32_t x, y;
			scanf("%d %d", &x, &y);
			x--;
			if (y == 1)
				honest[i] |= (1 << x);
			else
				unkind[i] |= (1 << x);
		}
	}

	int32_t res = 0;
	for (int32_t i = 0; i < (1 << N); i++) {
		int32_t honest_cnt = 0;
		int32_t all_honest = 0;
		int32_t all_unkind = 0;
		for (int32_t j = 0; j < N; j++) {
			if (i & (1 << j)) {
				honest_cnt++;
				all_honest |= honest[j];
				all_unkind |= unkind[j];
			}
		}

		bool ok = true;
		for (int32_t j = 0; j < N; j++)
			if ((all_honest & (1 << j)) && (all_unkind & (1 << j)))
				ok = false;

		for (int32_t j = 0; j < N; j++) {
			if (i & (1 << j)) {
				if ((all_unkind & (1 << j)))
					ok = false;
			} else {
				if ((all_honest & (1 << j)))
					ok = false;
			}
		}

		if (ok)
			res = max(res, honest_cnt);
	}

	printf("%d\n", res);

	return 0;
}


Measured memory_bytes: 256
import math


def f(A, m, K):
    p = sum([a // m for a in A])
    if p > K:
        return False
    else:
        return True


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


left = 0
right = 10 ** 9 + 1

while int(left) != int(right):
    m = (left + right) / 2

    if f(A, m, K):
        right = m
    else:
        left = m


print(math.ceil(m))


Measured memory_bytes: 168900
import math
import copy

#n = int(input())
n, k = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#s = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = [input() for i in range(n)]
#s = input()
#list = list(s)
#dp = [[0 for _ in range(2)] for _ in range(13)]


print(max(n+k,n-k,n*k))

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;
  ll n;
  while(cin>>a>>b>>n){
    a-=(a/b)*b;
    ll o=0;
    ll i,j,k;
    for(i=0;i<n;i++){
      a*=10;
      //cout << a/b << ":";
      o+=a/b;
      a-=(a/b)*b;
      if(a==0) break;
    }
    cout << o << endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> v;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        v.push_back(a + b);
        sum += b;
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll tk = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) tk += v[i];
    }
    cout << tk - sum << endl;
    return 0;
}

Measured memory_bytes: 1400
use io::*;
use std::cmp::min;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let d: usize = sc.next();
    let g: i64 = sc.next();
    let mut v: Vec<(i64, i64)> = (0..d).map(|_| (sc.next(), sc.next())).collect();

    let mut ans = std::i64::MAX;

    for b in (0..1 << d) {
        let mut tot = 0;
        let mut cnt = 0;
        for i in 0..d as i64 {
            if b & (1 << i) != 0 {
                tot += (i + 1) * 100 * v[i as usize].0 + v[i as usize].1;
                cnt += v[i as usize].0;
            }
        }

        if tot >= g {
            ans = min(ans, cnt);
            continue;
        }

        let best = (0, 0);

        for i in (0..d as i64).rev() {
            if b & (1 << i) != 0 {
                continue;
            }

            if tot + (i + 1) * 100 * v[i as usize].0 >= g {
                let u = (g - tot + (i + 1) * 100 - 1) / ((i + 1) * 100);
                cnt += u;
                break;
            }

            cnt += v[i as usize].0;
            tot += (i + 1) * 100 * v[i as usize].0;
        }

        ans = min(ans, cnt);
    }

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

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
#include    <stdio.h>

int main(void)
{
    int	n;
    char    str[4];

    if (fscanf(stdin, "%d", &n) != 1) {
	return 0;
    }

    sprintf(str, "%3d", n);

    for (int i = 0; i < 3; i++) {
	if (str[i] == '7') {
	    printf("Yes\n");
	    return 0;
	}
    }
    printf("No\n");
    return 0;
}

/*
 * vim:smartindent:sw=4:sts=4:co=84:nu:wm=78:
 */


Measured memory_bytes: 1728
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>
#include<tuple>
#include<utility>
#include<cassert>
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define pb push_back
#define PB push_back
#define lb lower_bound
#define LB lower_bound
#define ub upper_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 3 - 1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy8[8] = { -1,-1,-1,0,0,1,1,1 };

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

int mii(int a, int b) { return min(a, b); }
template<typename T>
class segment_tree {
	vector<T> dat;
	int n;
	T e;
	std::function<T(T, T)> f;
	T query_implement(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return e;
		if (a <= l && r <= b) return dat[k];

		T v1 = query_implement(a, b, 2 * k + 1, l, (l + r) / 2);
		T v2 = query_implement(a, b, 2 * k + 2, (l + r) / 2, r);
		return f(v1, v2);
	}
public:
	segment_tree(int n_, T _e, T(*calc)(T lhs, T rhs)) {
		e = _e;
		f = calc;
		n = 1;
		while (n < n_) n *= 2;
		dat.reserve(2 * n - 1);
		for (int i = 0; i < 2 * n - 1; i++)
			dat.push_back(e);
	}

	void update(int k, int a) {
		k += n - 1;
		dat[k] = a;

		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = f(dat[k * 2 + 2], dat[k * 2 + 1]);
		}
	}

	T query(int a, int b) { return query_implement(a, b, 0, 0, n); }
};

int main() {
	int n1;
	long long int x;
	cin >> n1 >> x;
	vi a(n1);
	REP(i, n1)
		cin >> a[i];
	segment_tree<int> s(n1, int(1e9 + 1),mii);
	REP(i, n1)
		s.update(i, a[i]);
	long long int res = 1e15;
	REP(i, n1) {
		long long int sum = 0;
		REP(j, n1)
			if (j - i < 0)
				sum += min(s.query(0, j + 1), s.query(n1 + j - i, n1));
			else
				sum += s.query(j - i, j + 1);
		res = min(res, sum + x*i);

	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 384
from itertools import accumulate

N, Q = map(int, input().split())
S = input()
lst = [0]
idx = 0
for x in range(len(S) - 1):
    if S[x] == 'A' and S[x + 1] == 'C':
        lst.append(1)
    else:
        lst.append(0)

lst2 = list(accumulate(lst))
for x in range(Q):
    a, b = map(int, input().split())
    print(lst2[b-1] - lst2[a-1])

Measured memory_bytes: 8584
#include <stdio.h>

int main(void){

	int x, i, n;

	scanf("%d", &x);

	for(i=1; i<=x; i++) {
		if(i%3 == 0) printf(" %d", i);

		else{
			n = i;

		while(n % 10 != 3 && n) {
			n /= 10;
		}

		if(n){
			printf(" %d", i);
		}
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	
	float avg = (a + b) * 0.5;
	
	cout << ceil(avg) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    if (n > m) swap(n, m);
    for (int r = 0; r <= n; ++r) {
        if (n==2*r && k==r*m) { printf("Yes\n"); exit(0); }
        if ((k-r*m)*(n-2*r)>0 && (k-r*m)%(n-2*r)==0 && (k-r*m)/(n-2*r)<=m) { printf("Yes\n"); exit(0); }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 764