akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n,m;cin>>n>>m;
	vl a(n),b(m),c(m);
	vll d(m);
	rep(i,n){
		cin>>a[i];
	}
	sort(all(a));
	rep(i,m){
		cin>>b[i]>>c[i];
		d[i].F=c[i];
		d[i].S=b[i];
	}
	sort(all(d));
    reverse(all(d));
	vl e;int cnt=0;
	rep(i,m){
		for(int j=0;j<d[i].S;++j){
			e.PB(d[i].F);
			cnt++;
			if(cnt==n)break;
		}
		if(cnt==n)break;
	}
    while(cnt<n){
        e.PB(0);
        cnt++;
    } 
	ll ans=0;
	rep(i,n){
		ans+=max(a[i],e[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;



int main(){
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    deque<ll> plus;
    deque<ll> minus;
    ll counterp=0,counterm=0;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        if(A[i]>=0)counterp++;
        else counterm++;
    ;}
    if(counterp==0){
        sort(A.begin(), A.end());
        for(ll i=0;i<N-1;i++){
            minus.emplace_back(A[i]);
        ;}
        plus.emplace_back(A[N-1]);
    }
    else if(counterm==0){
        sort(A.begin(), A.end());
        for(ll i=1;i<N;i++){
            plus.emplace_back(A[i]);
        ;}
        minus.emplace_back(A[0]);
    }
    else {
        for(ll i=0;i<N;i++){
            if(A[i]>=0)plus.emplace_back(A[i]);
            else minus.emplace_back(A[i]);
        ;}  
    }
    ll M=0;
    for(ll i=0;i<plus.size();i++){
        M+=plus[i]
    ;}
    for(ll i=0;i<minus.size();i++){
        M-=minus[i]
    ;}
    cout<<M<<endl;
    for(ll i=0;i<N-1;i++){
        if(plus.size()>minus.size()){
            ll x=plus[0];
            ll y=minus[0];
            plus.pop_front();
            minus.pop_front();
            minus.emplace_back(y-x);
            cout<<y<<" "<<x<<endl;
        }
        else if(plus.size()<=minus.size()){
            ll x=plus[0];
            ll y=minus[0];
            plus.pop_front();
            minus.pop_front();
            plus.emplace_back(x-y);
            cout<<x<<" "<<y<<endl;
        }
    ;}



    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 212345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;


int32_t main() {
    $
    int n;
    cin >> n;
    ll sum = 0;
    int qtd = 0, mini = INF;
    ll x;
    forn (0, n) {
        cin >> x;
        if (x < 0) x = -x, ++qtd;
        if (mini > x) mini = x;
        sum += x;
    }
    ll ans = sum;
    if (qtd & 1) {
        ans = sum - 2*mini;
    }
    cout << ans << '\n';
}   



Measured memory_bytes: 256
import java.util.*
import kotlin.collections.ArrayList

fun main(args: Array<String>?): Unit {
    val (h, w) = readLine()!!.trim().split(' ').map(String::toInt)
    val state = Array(h){
        readLine()!!.trim().toCharArray().map{
            when(it){
                '+' -> Cell.Operation.Add
                '*' -> Cell.Operation.Mul
                else -> Cell.Digit(it - '0')
            }
        }.toTypedArray()
    }
    val memo = Array(h){Array(w){-1L as Long?}}
    val res = search(0, 0, state, memo) ?: -1
    println(res)
}

sealed class Cell {
    sealed class Operation(val op: (Long?, Long?) -> Long?): Cell() {//TODO(OVERFLOW)
        object Add: Operation({aa, bb -> aa?.let{a -> bb?.let{b -> a + b}}?.takeIf{it <= 1000000000000000L}})
        object Mul: Operation({aa, bb ->
            if (aa == null || bb == null) null
            else if (java.lang.Math.log10(aa.toDouble()) + java.lang.Math.log10(bb.toDouble()) > 15) null
            else (aa * bb).takeIf{it <= 1000000000000000L}
        })
    }
    data class Digit(val digit: Int): Cell()
}
fun optMax(a: Long?, b: Long?): Long? {
    return if (a == null || b == null) null else java.lang.Math.max(a, b)
}
fun search(i: Int, j: Int, state: Array<Array<Cell>>, memo: Array<Array<Long?>>): Long? {
    if (i !in memo.indices || j !in memo[i].indices) return 0L
    if (memo[i][j] != -1L) return memo[i][j]
    val cache = Array(memo.size){Array(memo.first().size){-1L as Long?}}.also{it[i][j] = (state[i][j] as Cell.Digit).digit.toLong()}
    val queue: Queue<Pair<Int, Int>> = ArrayDeque<Pair<Int, Int>>().apply{add(Pair(i, j))}
    var result = 0L as Long?
    while (queue.isNotEmpty()) {
        val (y, x) = queue.poll()
        val cell = state[y][x]
        when(cell) {
            is Cell.Digit -> {
                result = optMax(result, cache[y][x])
                if (y + 1 in memo.indices) {
                    if (cache[y + 1][x] == -1L) queue.add(Pair(y + 1, x))
                    cache[y + 1][x] = optMax(cache[y + 1][x], cache[y][x])
                }
                if (x + 1 in cache[y].indices) {
                    if (cache[y][x + 1] == -1L) queue.add(Pair(y, x + 1))
                    cache[y][x + 1] = optMax(cache[y][x + 1], cache[y][x])
                }
            }
            is Cell.Operation.Add -> {
                result = optMax(result, optMax(cell.op(cache[y][x], search(y + 1, x, state, memo)), cell.op(cache[y][x], search(y, x + 1, state, memo))))
            }
            is Cell.Operation.Mul -> {
                if (y + 1 in cache.indices) {
                    if (cache[y + 1][x] == -1L) queue.add(Pair(y + 1, x))
                    cache[y + 1][x] = optMax(cache[y + 1][x], cell.op((state[y + 1][x] as Cell.Digit).digit.toLong(), cache[y][x]))
                }
                if (x + 1 in cache[y].indices) {
                    if (cache[y][x + 1] == -1L) queue.add(Pair(y, x + 1))
                    cache[y][x + 1] = optMax(cache[y][x + 1], cell.op((state[y][x + 1] as Cell.Digit).digit.toLong(), cache[y][x]))
                }
            }
        }
    }
    memo[i][j] = result
    return result
}



Measured memory_bytes: 60432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int mod = 1000000007;
//const int mod = 998244353;
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;
  }

  // for prime mod
  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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n, k; cin >> n >> k;
  vector<vector<int>> t(n);
  rep(i, n - 1){
    int a, b; cin >> a >> b;
    a--; b--;
    t[a].push_back(b);
    t[b].push_back(a);
  }

  mint ans = k;
  vector<bool> visited(n, false);
  queue<int> q;
  visited[0] = true;
  int cnt = 0;
  rep(i, t[0].size()){
    int next = t[0][i];
    if(visited[next]) continue;
    q.push(next);
    visited[next] = true;
    ans *= k - 1 - cnt;
    cnt++;
  }
  //cout << ans << endl;
  while(q.size() > 0){
    int now = q.front(); q.pop(), cnt = 0;
    rep(i, t[now].size()){
      int next = t[now][i];
      if(visited[next]) continue;
      q.push(next);
      visited[next] = true;
      ans *= k - 2 - cnt;
      cnt++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9644
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


int main() {
    int n,count=0;
    cin>>n;

    int p[30];
    rep(i,n){
        cin>>p[i];
    }
    for(int i=1;i<n-1;i++){
        int dai=max({p[i-1],p[i],p[i+1]});
        int shou=min({p[i-1],p[i],p[i+1]});
        if(dai!=p[i]&&shou!=p[i]){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;    

const int maxn = 4e6 + 10;
vector<int>G[maxn];
bool vis[maxn];
void dfs(int u,int fa){
    vis[u] = true;
    for(int i = 0; i < G[u].size(); i++){
        int v = G[u][i];
        if(v != fa && !vis[v]){
            dfs(v,u);
        }
    }
}
void solved(){
    int n,m;cin>>n>>m;
    for(int i = 1; i <= m; i++){
        int u,v;cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!vis[i])dfs(i,-1),ans++;
    }
    cout<<ans - 1<<endl;
}
int main(){
    solved();
    return 0;
}

Measured memory_bytes: 101008
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>

int main()
{
    int N, M, K;
    std::cin >> N >> M >> K;

    std::vector<long> A, B;
    A.reserve(N + 1);
    B.reserve(M + 1);

    A.push_back(0);
    std::copy_n(std::istream_iterator<long>{std::cin}, N, std::back_inserter(A));
    B.push_back(0);
    std::copy_n(std::istream_iterator<long>{std::cin}, M, std::back_inserter(B));
    std::partial_sum(A.cbegin(), A.cend(), A.begin());
    std::partial_sum(B.cbegin(), B.cend(), B.begin());

    auto max_read = static_cast<int>(std::upper_bound(A.cbegin(), A.cend(), K) - A.cbegin()) - 1;
    // std::cout << max_read << std::endl;

    auto A_read = max_read;
    for (auto B_read = 1; B_read <= M; B_read++) {
        for (;A.at(A_read) + B.at(B_read) > K && A_read > 0; A_read--) {
        }

        if (A.at(A_read) + B.at(B_read) > K && A_read == 0) {
            break;
        }

        // std::cout << "(A, B)=" << A_read << ", " << B_read << std::endl;
        max_read = std::max(max_read, A_read + B_read);
    }

    std::cout << max_read << std::endl;

    return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
#define N (int)(1e5+1)
void yesno(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
ll power(ll x, ll n, ll m){if(n==0)return 1;ll u=power(x,n/2,m);u=(u*u)%m;if(n%2)u=(u*x)%m;return u;}



int main (){
fastio;

int n;
cin>>n;

int i;
int arr[n];

int cnt[n][31];
memset(cnt,0,sizeof cnt);
int tot=0;
for(i=0;i<n;i++){
    cin>>arr[i];
    int x=arr[i];

    tot^=x;
}

for(i=0;i<n;i++){
    int x=arr[i];
    cout<<(x^tot)<<" ";

}




}


Measured memory_bytes: 28608
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

int used[5000];
//dp[i][j] := i番目の問題まで見たとき、j点取るのに必要な最小の問題数としてDPをする
int dp[11][401010];

signed main() {
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    vector<pair<double, int>> cospa;

    G /= 100;

    rep(i, 11) {
        rep(j, 401010) {
            dp[i][j] = LL_HALFMAX;
        }
    }

    dp[0][0] = 0;
    rep(i, D) {
        cin >> p[i] >> c[i];        
        c[i] /= 100;
    }


    REPS(i, D) {
        rep(point, 201010) {
            //i番目の問題をk問とくとする
            rep(k, p[i - 1]) {
                dp[i][point + i * k] = min(dp[i][point + i * k], dp[i - 1][point] + k);
                
            }
            dp[i][point + i * p[i - 1] + c[i - 1]] = min(dp[i][point + i * p[i - 1] + c[i - 1]], dp[i - 1][point] + p[i - 1]);
            
        }
    }

    int ans = LL_HALFMAX;
    REP(i,G, 201010) {
        chmin(ans, dp[D][i]);
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 34688
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,m;cin>>n>>m;
    vector<tuple<int,int,int>> edge(m);
    rep(i,m){
        int a,b,c;cin>>a>>b>>c;
        edge[i]=make_tuple(a,b,c);
    }
    vll d(n+1,-INF);
    d[1]=0;
    bool update;
    int res=0;
    int tmp;
    while(1){
        res++;
        update=false;
        for(auto e:edge){
            if(d[get<0>(e)]!=-INF&&d[get<1>(e)]<d[get<0>(e)]+(ll)get<2>(e)){
                d[get<1>(e)]=d[get<0>(e)]+(ll)get<2>(e);
                update=true;
            }
        }
        if(!update)break;
        //正のループがあったとしてもそれによってd[n]が大きくできるとは限らないため2n回(ループのノード数は最大でもn)やってd[n]が更新されるか調べる。
        if(res==n-1)tmp=d[n];
        if(res==2*n&&tmp!=d[n]){
            cout<<"inf"<<endl;
            return 0;
        }
        if(res==2*n&&tmp==d[n])break;
    }
    cout<<d[n]<<endl;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,q = MI()
S = S()
lr = LI(q)

ls = [0]*n
count = 0
for i in range(1,n):
    if S[i]!="C":
        ls[i] = count
    else:
        if S[i-1]=="A":
            count += 1
            ls[i] = count
        else:
            ls[i] = count
# print(ls)

for i in range(q):
    l = lr[i][0] - 1
    r = lr[i][1] - 1
    ans = ls[r] - ls[l]
    print(ans)

Measured memory_bytes: 69080
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Map<String, Integer> m = new HashMap<String, Integer>();
		
		String str;
		int c;
		int mc = 0;
		String fre = "";
		String max = "";
		
		while(scan.hasNext()){
			str = scan.next();
			
			if(max.length() < str.length())max = str;
			if(m.containsKey(str)){
				c = m.get(str);
				if(mc < c+1){
					mc = c+1;
					fre = str;
				}
				m.put(str, c+1);
			}
			else{
				if(mc < 1){
					mc = 1;
					fre = str;
				}
				m.put(str, 1);
			}
		}
		System.out.println(fre + " " + max);
	}
}

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

int main(){
    int A,B;
    char s;
    cin >> A >> B;
    for(int i=0; i!=A; i++){
        cin >> s;
        if(s == '-'){
            cout << "No\n";
            return 0;
        }
    }
    cin >> s;
    if(s != '-'){
        cout << "No\n";
        return 0;
    }
    for(int i=0; i!=B; i++){
        cin >> s;
        if(s == '-'){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

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

int a, b, c;
string ans;

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

    if (a < b)
    {
        if (a < c && c < b)
        {
            ans = "Yes";
        } else {
            ans = "No";
        }
    } else {
        if (b < c && c < a)
        {
            ans = "Yes";
        } else {
            ans = "No";
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut aa: [usize; n],
    }

    let mut count = 0;
    let mut prev = 0;

    for a in aa {
        
        count += (prev + a) / 2;
        if a > 0 {
            prev = (prev + a) % 2;
        } else {
            prev = 0;
        }
        
    }

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


Measured memory_bytes: 3672
x,y=map(int,input().split())
a,b,c=map(int,input().split())
n=list(input())
s=0
for i in range(y):
    if n[i]=="r":
        s+=c
    elif n[i]=="s":
        s+=a
    else:
        s+=b
for i in range(y,x):
    if n[i-y]==n[i]:
        n[i]="!"
    else:
        if n[i]=="r":
            s+=c
        elif n[i]=="s":
            s+=a
        elif n[i]=="p":
            s+=b
    #print(s,n[i])        
print(s)            

Measured memory_bytes: 49632
import java.util.*;

class Main {
    public static void main(final String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] v = new int[n];
      for (int i = 0; i < n; i++) {
        v[i] = sc.nextInt();
      }
      int[] c = new int[n];
      for (int i = 0; i < n; i++) {
        c[i] = sc.nextInt();
      }
      int ans = 0;
      for (int j = 0; j < n; j++) {
        int sum = v[j] - c[j];
        if (sum > 0) {
          ans += sum;
        } 
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    a = toupper(a[0]);
    b = toupper(b[0]);
    c = toupper(c[0]);
    cout << a << b << c << endl;

    return 0;
}

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

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    StringBuffer sb = new StringBuffer(a);
    String rev = sb.reverse().toString();
    if(rev.equals(b)){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

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

int main () {
  int A , B , C , D ;
  cin >> A >> B >> C >> D ;
  if ( (A + B) == (C + D) ) {
    cout << "Balanced" << endl;
  }
  else if ( (A + B) < (C + D) ) {
    cout << "Right" << endl;
  }
  else if ( (A + B) > (C + D) ) {
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		ArrayList<Long> al = new ArrayList<>();
		long sum = 0;
		long a = 0;
		for(i=0;i<n;i++) {
			a = parseInt(sc.next());
			sum += a;
			al.add(a);
		}
		sc.close();
		Collections.sort(al, Comparator.reverseOrder());
		ArrayList<Long> dif = new ArrayList<>();
		for (i = 1; i <= 31; i++) {
			long tmp=0;
			long tmp2=0;
			for (j = 0; j < al.size(); j++) {
				tmp2 = al.get(j) >> 1;
				tmp = al.get(j) - tmp2;
				if(tmp == 0) break;
				al.set(j, tmp2);
				dif.add(tmp);
			}
			if(j==0) break;
		}
		Collections.sort(dif, Comparator.reverseOrder());
		long dsum = 0;
		for (i = 0; i < Math.min(m, dif.size()); i++) {
			dsum += dif.get(i);
		}
		out.println(sum - dsum);
	}
}


Measured memory_bytes: 157776
from collections import deque
n,q=map(int,input().split())
edge=[[] for i in range(n)]
cnt=[0 for i in range(n)]
visited=[-1 for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
for i in range(q):
  p,x=map(int,input().split())
  cnt[p-1]+=x
def dfs(edge,cnt,visited):
  stack=deque([0])
  visited[0]=0
  while stack:
    x=stack.pop()
    for i in edge[x]:
      newx=i
      if visited[newx]==-1:
        visited[newx]=0
        cnt[newx]+=cnt[x]
        stack.append(newx)
  return cnt
print(*dfs(edge,cnt,visited))

Measured memory_bytes: 56184
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int a,b;
    cin>>a>>b;
    int g = a;
    if(b <=1) {
      cout<<"0";return 0;
    }
    if(b <= g){
        cout << "1";
        return 0;
    }
    for(int i = 2;;i++){
      g -= 1;
      g += a;    
      if(b <= g){
        cout << i;
        return 0;
      }
    }
    return 0;
}

Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,x,b,s
    
    integer(8):: a(100003)
  
    read(*,*) x
    
    
    do i=1,100003
        a(i)=1
    end do
    a(1)=0
    j=2
    do while(real(j)<=sqrt(real(x)))
       
        if (a(j)==1)then
            do i=1,100003/j
                 a(j*i)=0
            end do
        end if
        j=j+1
    enddo
    do
    if (a(x)==1)then
        write(*,*)x
        stop
    else
        x=x+1
    end if
end do
   


   
       
    
    stop
end program sample
  



Measured memory_bytes: 3640
let () =
  Scanf.scanf "%s" (fun s ->
      let len = String.length s in
      let rec f i =
        match i mod 2 = 0 with
        | _ when i >= len -> ()
        | true ->
            print_char s.[i] ;
            f (i + 1)
        | false -> f (i + 1)
      in
      f 0 ; print_newline () )


Measured memory_bytes: 896
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[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};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


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

    switch(d){
        case 25:
            P("Christmas");
            break;
        case 24:
            P("Christmas Eve");
            break;
        case 23:
            P("Christmas Eve Eve");
            break;
        case 22:
            P("Christmas Eve Eve Eve");
            break;
    }   
    
	return  0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double eps=1e-6;
int n;
double L;
double a[86400],b[86400],c[86400];

bool check(double x){
  double last=0,sum=L;
  for(int i=0;i<n;i++){
    double s=a[i],t=b[i],v=c[i];
    sum=min(L,sum+(s-last)*x);
    sum=min(L,sum+(t-s)*(x-v));
    last=t;
    if(sum<0)return false;
  }
  sum=min(L,sum+(86400.0-last)*x);
  last=0;
  for(int i=0;i<n;i++){
    double s=a[i],t=b[i],v=c[i];
    sum=min(L,sum+(s-last)*x);
    if(sum>=L)return true;
    sum=min(L,sum+(t-s)*(x-v));
    last=t;
    if(sum<0)return false;
  }
  return false;
}

int main(){
  while(1){
    cin>>n>>L;
    if(n==0&&L==0)break;
    for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
    
    double l=0,r=1e6,m;
    for(int i=0;i<100;i++){
      m=(l+r)/2.0;
      if(check(m))r=m;
      else l=m;
    }
    printf("%.10f\n",l);
  }
  return 0;
}

Measured memory_bytes: 3272
num = input().split(" ")

a = int(num[0])
b = int(num[1])
c = int(num[2])

if a > b:
    if a > c:
        max = a
        if b > c:
            mid = b
            min = c
        else:
            mid = c
            min = b
    else:
        max = c
        mid = a
        min = b
        
else:
    if b > c:
        max = b
        if a > c:
            mid = a
            min = c
        else:
            mid = c
            min = a
    else:
        max = c
        mid = b
        min = a
            
    
print('{0} {1} {2}'.format(min, mid, max))
    


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

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  std::string S;
  cin >> S;
  int S_size = S.size();
  bool is_find = false;
  rep(i , S_size) {
    if (S[i] == '7') {
      is_find = true;
      break;
    }
  }
  if (is_find == true) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();

        int[] prime = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
        int[] num = new int[100];
        for(int i=2; i<=n; i++){
            int tmp = i;
            while(tmp != 1){
                for(int j=0; j<prime.length; j++){
                    if(tmp % prime[j] == 0){
                        num[prime[j]]++;
                        tmp /= prime[j];
                    }
                }
            }
        }

        int num75=0, num25=0, num15=0, num5=0, num3=0;
        for(int i=0; i<num.length; i++){
            if(num[i] >= 74) num75++;
            if(num[i] >= 24) num25++;
            if(num[i] >= 14) num15++;
            if(num[i] >= 4) num5++;
            if(num[i] >= 2) num3++;
        }

        long ans = num75;
        ans += num25 * (num3-1);
        ans += num15 * (num5-1);
        ans += num5 * (num5-1) * (num3-2) / 2;

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[330000][2];
int dp[10][330000];
vector<P> task[330000];
vector<int> vs;
vector<P> v1;
const int B=9;
int N;

void check(int pos,int dep){
	if(pos>=N)return;
	int i,j;
	int a,b;
	int n,m;
	if(dep<B){
		for(i=0;i<=1e5;i++){
			dp[dep+1][i]=dp[dep][i];
			if(i>=t[pos][1])dp[dep+1][i]=max(dp[dep+1][i],dp[dep][i-t[pos][1]]+t[pos][0]);
		}
	}else{
		v1.push_back(make_pair(t[pos][0],t[pos][1]));
	}

	for(auto node:task[pos]){
		n=v1.size();
		vector<P> v2;
		v2.push_back(make_pair(0,0));
		for(i=0;i<n;i++){
			m=v2.size();
			for(j=0;j<m;j++){
				a=v2[j].second+v1[i].second;
				if(a>node.second)continue;
				v2.push_back(make_pair(v2[j].first+v1[i].first,a));
			}
		}
		n=v2.size(),m=min(dep+1,B);
		a=0;
		for(i=0;i<n;i++){
			a=max(a,v2[i].first+dp[m][node.second-v2[i].second]);
		}
		vs[node.first]=a;
	}
	check(pos*2+1,dep+1);
	check(pos*2+2,dep+1);
	if(dep>=B)v1.pop_back();
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	N=n;
	for(i=0;i<n;i++){
		cin>>t[i][0]>>t[i][1];
	}
	cin>>m;
	vs.assign(m,0);
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--;
		task[a].push_back(make_pair(i,b));
	}
	check(0,0);
	for(i=0;i<m;i++){
		cout<<vs[i]<<endl;
	}
}

Measured memory_bytes: 20096
n,m = gets.split.map(&:to_i)

ab = m.times.map{a,b = gets.split.map(&:to_i)}.sort{|a,b|a[1]<=>b[1]}

ans = 0
prev = -1
ab.each{|(a,b)|
  if !prev.between?(a+1,b)
    ans += 1
    prev = b
  end
}

p ans

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)

//MIN-MAX
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll solve(ll n,vector<ll>a,vector<ll>b,vector<ll>c)
{
    ll dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(int i=1;i<n;i++)
    {

        for(int j=0;j<3;j++)
        {

            if(j==0)
            {
                dp[i][j]=max(a[i]+ dp[i-1][1],a[i]+dp[i-1][2]);

            }
            else if(j==1)
            {
               dp[i][j]=max(b[i]+ dp[i-1][0],b[i]+dp[i-1][2]);
            }
            else
            {
                dp[i][j]=max(c[i]+ dp[i-1][1],c[i]+dp[i-1][0]);
            }


        }
    }

    ll ans=-1;
    for(int j=0;j<3;j++)
        ans=max(ans,dp[n-1][j]);

    return ans;



}




int main()
{
	FASTIO;

	ll n;
	 cin>>n;
	 vector<ll>a(n);
	 vector<ll>b(n);
	 vector<ll>c(n);

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

     ll ans =solve(n,a,b,c);
     cout<<ans<<"\n";

	return 0;
}













Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int k;
  vector<int> a(5);
  rep(i, 5)
  {
    cin >> a[i];
  }
  cin >> k;
  if (a[4] - a[0] <= k)
  {
    cout << "Yay!" << endl;
  }
  else
  {
    cout << ":(" << endl;
  }
}

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

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	for(string line; getline(cin, line);) {
		string change(line);
		for(int i = 0, n = line.length(); i < n; i++) {
			if(line[i] != ' ' && line[i] != '.') {
				change[i] -= 'a';
			}
		}
		for(int p = -26; p <= 26; p++) {
			string s(change);
			for(int i = 0, n = s.length(); i < n; i++) {
				if(line[i] != ' ' && line[i] != '.') {
					s[i] = (s[i] + p) % 26;
				}
			}
			for(int i = 0, n = s.length(); i < n; i++) {
				if(line[i] != ' ' && line[i] != '.') {
					s[i] += 'a';
				}
			}
			if(s.find("the") != -1 || s.find("this") != -1 || s.find("that") != -1) {
				cout << s << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <climits>
#include <algorithm>

using namespace std;
typedef long long ll;

ll DP[101][(int)1e5 + 1];
vector<pair<int, int>> objects;
ll N, W;

ll Knapsack(int i, int v) {
	if (v <= 0) { return 0; }
	if (DP[i][v] != -1) { return DP[i][v]; }
	if (i >= objects.size()) { return DP[i][v] = LLONG_MAX / 8; }

	ll c1 = Knapsack(i + 1, v);
	ll c2 = Knapsack(i + 1, v - objects[i].second) + objects[i].first;

	DP[i][v] = min(c1, c2);
	return DP[i][v];
}

int main() {
	for (int i = 0; i < 101; i++)
		for (int j = 0; j < (int)1e5 + 1; j++)
			DP[i][j] = -1;

	cin >> N >> W;
	objects.resize(N);
	for (auto &x : objects) { cin >> x.first >> x.second; }

	for (int i = (int)1e5; i >= 0; i--) {
		if (Knapsack(0, i) <= W) { cout << i << endl; break; }
	}
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  map<int,int> mp;
  REP(i, N){
    cin >> A[i];
    mp[A[i]]++;
  }
  
  int flag = 0;
  for(auto x:mp){
    if(x.second>=3){
      flag=1;
    }
    if(x.first==12&&x.second>=2){
      flag=1;
    }
    if(x.first==0){
      flag=1;
    }
  }
  if(flag==1){
    cout << 0 << endl;
  }else{
    int MAX = 0;
    REP(i,1<<11){
      vector<int> vec(24,0);
      vec[0]=1;
      if(mp[12]==1){
        vec[12]=1;
      }
      bitset<11> bs(i);
      for(auto x:mp){
        if(x.first==12||x.first==0) continue;
        if(x.second==2){
          vec[x.first]=1;
          vec[24-x.first]=1;
        }else{
          if(bs[x.first]==0){
            vec[x.first]=1;
          }else{
            vec[24-x.first]=1;
          }
        }
      }
      int now = 0;
      int MIN = INF;
      FOR(j,1,24){
        if(vec[j]==1){
          MIN=min(MIN,j-now);
          now=j;
        }
      }
      MIN=min(MIN,24-now);
      MAX=max(MAX,MIN);
    }
    cout << MAX << endl;
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> p;
	const ll init = n % 10;
	ll x = init;
	do {
		p.push_back(x);
		x = (x * init) % 10;
	} while(x != init);
	ll len = 0, sum = 0, pos = 0;
	do {
		++len;
		sum += p[pos];
		pos = (pos + m) % p.size();
	} while(pos > 0);
	ll answer = sum * (k / len);
	ll i = (k / len) * len;
	while(i < k){
		answer += p[pos];
		pos = (pos + m) % p.size();
		++i;
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 1208
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B;
    cin >> A >> B;
    if (A > 8 || B > 8) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}



int main(){
    ll k = nxt();
    ll ans = 0;
    queue<ll> q;
    for(int i = 1; i <= 9; i++) q.push(i);
    ll x = 0;
    while(k--){
        x = q.front(); q.pop();
        if(x % 10 != 0) q.push(10 * x + x%10 - 1);
        q.push(10 * x + x%10);
        if(x % 10 != 9) q.push(10 * x + x%10 + 1);
    }
    printf("%lld\n", x);
    return 0;
}

Measured memory_bytes: 5248
small=list('abcdefghijklmnopqrstuvwxyz')
s=list(input())
if len(set(s)&set(small))==26:
  print('None')
else:
  q=list(set(s)&set(small))
  for i in small:
    if i in q:
      continue
    else:
      print(i)
      exit()

Measured memory_bytes: 3956
import java.util.*;

public class Main{
	int N;
	Scanner reader = new Scanner(System.in);
	public static void main(String[]args) {
		 Main p = new Main();
		 p.run();
	}

	public void run() {
		N = reader.nextInt();
		String s = reader.next();
		if(s.length()<=N)
			System.out.print(s);
		else
			System.out.print(s.substring(0,N)+"...");
	}
}


Measured memory_bytes: 38628
while True:
    X,Y=map(int,input().split())
    if (X,Y)==(0,0):
        break
    if X>=Y:
        pass
    else:
        t=Y
        Y=X
        X=t
    c=0
    while True:
        if Y==0:
            break
        X%=Y
        t=X
        X=Y
        Y=t
        c+=1
    print(X,c)
    


Measured memory_bytes: 5608
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    int H,W;
    cin >> H >> W;
    string S[H];
    REP(i,H){
        cin >> S[i];
    }
    int HW[H][W];
    REP(i,H){
        REP(j,W){
            HW[i][j]=0;
        }
    }
    REP(i,H){
        REP(j,W){
            if(S[i][j]=='#'){
                FOR(k,-1,2){
                    FOR(l,-1,2){
                        if(i+k<H&&i+k>-1&&j+l<W&&j+l>-1){
                            HW[i+k][j+l] += 1;
                        }
                    }
                }
            }
        }
    }
    REP(i,H){
        REP(j,W){
            if(S[i][j]=='#'){
                cout << '#';
            }else{
                cout << HW[i][j];
            }
            if(j==W-1){
                cout << "\n";
            }
        }
    }
}

Measured memory_bytes: 256
from collections import Counter
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
counts = dict(Counter(a))
counts = list(counts.values())
counts.sort()
count = 0

dev = len(counts)-k
for i in range(dev):
    count += counts[i]
        
print(count)

Measured memory_bytes: 111184
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    
    bool used[31];
    REP(i,31)used[i]=false;
    REP(i,28){
        int t;
        cin>>t;
        used[t]=true;
    }
    
    for(int i=1;i<=30;i++){
        if(!used[i])cout<<i<<endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 3080