akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int a, b, c, d, e;
   cin >> a >> b >> c >> d >> e;
   int ans = 0;
   if (a % 10 == 0) ans += a;
   else ans += (a / 10 + 1) * 10;
   if (b % 10 == 0) ans += b;
   else ans += (b / 10 + 1) * 10;
   if (c % 10 == 0) ans += c;
   else ans += (c / 10 + 1) * 10;
   if (d % 10 == 0) ans += d;
   else ans += (d / 10 + 1) * 10;
   if (e % 10 == 0) ans += e;
   else ans += (e / 10 + 1) * 10;
   int tmp = 10;
   if (a % 10 != 0 && a % 10 < tmp) tmp = a % 10;
   if (b % 10 != 0 && b % 10 < tmp) tmp = b % 10;
   if (c % 10 != 0 && c % 10 < tmp) tmp = c % 10;
   if (d % 10 != 0 && d % 10 < tmp) tmp = d % 10;
   if (e % 10 != 0 && e % 10 < tmp) tmp = e % 10;
    
   cout << ans - 10 + tmp << endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		int n = Integer.parseInt(line1);

		String line2 = sc.nextLine();
		int R0 = Integer.parseInt(line2);
		
		String line3 = sc.nextLine();
		int R1 = Integer.parseInt(line3);
		
		int min = Math.min(R0, R1);
		int answer = R1 - R0;		
		
		for (int i = 2; i < n; i++) {
			String next = sc.nextLine();
			int R = Integer.parseInt(next);
			
			answer = Math.max(answer, R-min);
			min = Math.min(min, R);
		}
		
		System.out.println(answer);

	}

}

Measured memory_bytes: 166372
#include<stdio.h>
int main(void) {
	int n, cnt = 1, t = 0;
	scanf("%d", &n);
	int* h = new int[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	for (int i = 1; i < n; i++) {
		t = 0;
		for (int j = 0; j < i; j++) {
			if (h[j] > h[i])t = 1;
		}
		if (t == 0)cnt++;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 256
s = str(input())

if s == 'SUN':
    print(7)
if s == 'MON':
    print(6)
if s == 'TUE':
    print(5)
if s == 'WED':
    print(4)
if s == 'THU':
    print(3)
if s == 'FRI':
    print(2)
if s == 'SAT':
    print(1)


Measured memory_bytes: 2940
n=int(input())
L=list(map(int,input().split()))
L.sort()
ans=[]
for i in range(1,n-1):
  if L[i]>0:
    ans.append((L[0],L[i]))
    L[0]-=L[i]
for i in range(n):
  if L[i]>0 or len(ans) == n-1:
    break
  else:
    ans.append((L[n-1],L[i]))
    L[n-1]-=L[i]
print(L[n-1])
for a in ans:
  x,y=a
  print(x,y)


Measured memory_bytes: 19588
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=3e5+5;
vector<ll> g[N];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		ll n,m;
		cin>>n>>m;
		ll a[n];
		ll i,j;
		priority_queue<ll,vector<ll>> pq;
		rep(i,0,n){
			cin>>a[i];
			pq.push(a[i]);
		}
		ll sm=0;
		while(m>0)
		{
			ll tp=pq.top();
			pq.pop();
			tp/=2;
			m--;
			if(tp>0)
			pq.push(tp);
			if(pq.empty())
			break;
		}
		while(!pq.empty())
		{
			sm+=pq.top();
			pq.pop();
		}
		cout<<sm<<'\n';
		
	}
	return 0;
}


Measured memory_bytes: 8952
while 1:
 a=[list(map(int,input()))for _ in[0]*8]
 y=[sum(r)for r in a]
 x=[sum(c)for c in zip(*a)]
 if 4 in x:s='B'
 elif 4 in y:s='C'
 elif 1 in y:s='DF'[a[y.index(1)][x.index(2)]]
 elif 1 in x:s='GE'[a[y.index(2)][x.index(1)]]
 else:s='A'
 print(s)
 try:input()
 except:break


Measured memory_bytes: 5612
/* C */
// ?????\??? P89

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int n;
int q;
int loop0;
char name[100001][11];
int time[100001];

void queue(void){

	int curr = 0;
	int elapsedTime = 0;
	int end = n;
	int flag = 1;

	while(flag){
		if( time[curr] - q <= 0 ){
			//???????????????
			elapsedTime += time[curr];
			printf("%s %d\n", name[curr] ,elapsedTime );
			if((end-1) == curr)
				break;
		}else{
			// ??????????????????????????£???
			elapsedTime += q;
			strcpy( name[end], name[curr]);
			time[end] = time[curr] - q;
			end++;
			if(end == 100001)
				end = 0;
		}
		curr++;
		if(curr == 100001)
			curr = 0;
	}
}

int main(int argc, char const *argv[])
{
	scanf("%d %d", &n, &q);

	for (loop0 = 0; loop0 < n; ++loop0)
	{
		scanf("%s %d", name[loop0], time+loop0);
	}

	queue();

//	printf("========== END!! (^o^)/ ==========\n");

	return 0;
}

Measured memory_bytes: 2076
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

map<ll, ll> prime_factor(ll n) {  // 素因数分解 (o(√N)){{{
    map<ll, ll> res;  // vectorで持つことも考えられる。
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            dump(n,i);
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] += 1;
    return res;
}
// (参考)http://pakapa104.hatenablog.com/entry/2016/02/09/230443
//}}}

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

    auto ps = prime_factor(n);
    dump(n%3==0);
    dump(ps);
    dump(prime_factor(1870919));
    dump(prime_factor(89));

    ll ans = 0;
    each(el, ps){
        int c = el.second;

        int m = 0;
        while(true){
            if (m * (m+1) > 2*c) break;
            m++;
        }
        dump(m);
        ans += m-1;
    }
    cout << ans << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
using namespace std;

vector<tuple<int, int>> ab;

signed main()
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		ab.push_back(tuple<int, int>(a, b));
	}
	sort(ab.begin(), ab.end(), [](const auto& l, const auto& r) {return get<0>(l) < get<0>(r); });

	int ans = -1;
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		ans = get<0>(ab[i]);
		cnt += get<1>(ab[i]);
		if (cnt >= K) break;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(vector<T> &x) {
	int n = x.size();
	rep(i,n) {
		cout << x[i];
		if (i!=n-1) cout<<" ";
		else cout << endl;
	}
}

template<typename T>
void print(vector<vector<T>> &x) {
	int n = x.size();
	rep(i,n) {
		rep(j,x[i].size()) {
			cout << x[i][j] << " ";
		}
		cout << endl;
	}
}

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; }


int main(int argc, char const *argv[]) {
	int n; cin>>n;
	vector<int> d;
	map<int,int> mp;
	rep(i,n) {
		int a; scanf("%d",&a);
		mp[a]++;
		if (mp[a]>=2) continue;
		d.push_back(a);
	}

	n = d.size();
	int ans = 0;
	for (int mask = 0; mask < (1<<n); ++mask) {
		int tmp = INF;
		vector<int> a;
		rep(j,n) {
			int x = d[j];
			if (mask&(1<<j) && x!=0) x = 24-x;
			a.push_back(x);
		}
		a.push_back(0);
		for (auto &&e: mp) {
			if (e.second>=2) rep(l,e.second-1) a.push_back(e.first);
		}    
		sort(a.begin(), a.end());

		rep(j,a.size()-1) {
			if (j == 0) tmp = min(a[j+1],24-a[j+1]);
			else chmin(tmp,abs(a[j]-a[j+1]));
		}
		for (int j = 1; j < a.size(); ++j) chmin(tmp,min(a[j],24-a[j]));
		chmax(ans,tmp);
	}

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

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

int main(void){
    vector<int> v;
    int i;
    while(cin >> i){
        if(i == 0){
            cout << v[v.size() - 1] << endl;
            v.pop_back();
        } else {
            v.push_back(i);
        }
    }
}

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int Maxn=2e5+5;
int n,vis[2][Maxn];
long long a[Maxn],f[Maxn],dp[2][Maxn];
long long findou(int nowy)
{
	if(nowy==n+1)return 0;
	if(vis[0][nowy])return dp[0][nowy];
	else vis[0][nowy]=1;
	return dp[0][nowy]=max(a[nowy]+findou(nowy+2),f[nowy+1]);
}
long long findji(int nowy)
{
	if(nowy==n)return 0;
	if(vis[1][nowy])return dp[1][nowy];
	else vis[1][nowy]=1;
	return dp[1][nowy]=max(a[nowy]+findji(nowy+2),findou(nowy+1));
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=n;i>=1;i-=2)
		f[i]=f[i+2]+a[i];
	if(n%2)cout<<findji(1);
	else cout<<findou(1);
	return 0;
}

Measured memory_bytes: 14468
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI 3.14159265358979323846264338327950L

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b){
    if(a % b == 0){
        return(b);
    }
    else{
        return(gcd(b, a % b));
    }
}

bool isPalindrome(string s){
    REP(i, s.length() / 2){
        if(s[i] != s[(s.length() - 1) - i]){
            return false;
        }
    }
    return true;
}

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

 ll N, M, K, Q, i, j, k, l, tmp, ans;

int main(){
    cin >> N;
    double A;
    A = N / 3.0;

    cout << fixed << setprecision(15) << A * A * A << endl;

     return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;

int main(){
    multiset<ll> s,t;
  int q;cin>>q;
  ll u,v,x;cin>>u>>v>>x;
    ll sum=x,sums=v,sumt=0;
  s.insert(v);
    rep(j,q-1){
        ll c;cin>>c;
        if(c==1){
            ll a,b;cin>>a>>b;
            sum+=b;
            if(s.size()==t.size()){
                auto it=t.begin();
                if(*it<a){
                    t.insert(a);
                    sumt+=a;
                    sumt-=*it;
                    sums+=*it;
                    s.insert(*it);
                    t.erase(it++);
                }
                else{
                    s.insert(a);
                    sums+=a;
                }
            }
            else{
                auto itk=s.end();
                itk--;
                if(*itk<=a){
                    t.insert(a);
                    sumt+=a;
                }
                else{
                    s.insert(a);
                    sums+=a;
                    sums-=*itk;
                    sumt+=*itk;
                    t.insert(*itk);
                    s.erase(itk++);
                }
            }
        }
        else{
            auto itr=s.end();
            itr--;
            cout<<*itr<<' ';
            if(s.size()==t.size())cout<<sumt-sums+sum<<endl;
          else cout<<sumt-sums+*itr+sum<<endl;
        }
    }
}

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

class Main{
    public void run() throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] arg = br.readLine().split("");
        System.out.printf("%s%d%s\n", arg[0], arg.length - 2, arg[arg.length - 1]);

    }
    public static void main(String... args) throws IOException{
        new Main().run();
    }
}

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

int main(){
    long N,K;
    long A[200000];
    long kosu[200000];
    long sum=0;
    for(int i=0;i<200000;i++){
        kosu[i]=1;
    }
    
    cin >> N;
    cin >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    
    
    int checked=0;
    int i=1;
    int j=0;
    while(i<N)
    {
            
            if(A[i]==A[i-1]){
                kosu[j]++;
            }else{
                j++;
            }
            i++;
        
    }
    
    sort(kosu,kosu+j+1);
    for(int i=0;i<j+1-K;i++){
        sum+=kosu[i];
    }
    cout << sum;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const ll MOD = 1000000007;
int main(){
  ll k = 0;
  ll x;
  cin >> x;
  k = x/11;
  if(11*k == x){
    cout << 2*k << endl;
  }else if(11*k + 6 >= x){
    cout << 2*k + 1 << endl;
  }else if(11*k + 10 >= x){
    cout << 2*k + 2 << endl;
  }else{
    cout << "Error" << endl;
    cout << "x = " << x << "k = "<< k<< endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define int ll
#define Endl endl


signed main(){
    int N;
    int Ans=0;
    vector<int> D;
    cin >> N;
    for(int i=1;i*i<=N;i++){
        if(N%i==0){
            D.push_back(i);
            D.push_back(N/i);
        }
    }
    int d=D.size();
    sort(D.begin(),D.end());
    //REP(i,d){cout << D[i] << " ";}
    REP(i,d){
        int m=D[i];
        if(m==1)continue;
        if((int)(N/(m-1))==N%(m-1)){
            Ans+=m-1;
        }
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 384
using System;

namespace ABC125
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var time = str[2] + 0.5;

            var bisu = Math.Floor(time / str[0]);

            Console.WriteLine(bisu * str[1]);
        }
    }
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> A(M);

  for (int i = 0; i < M; ++i) cin >> A[i];
  int sum = 0;
  for (int i = 0; i < M; ++i) sum += A[i];
  int days = N - sum;
  int ans = days < 0 ? -1 : days;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

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

		double ans = 0;
		for (int i = 1; i <= n; i++) {
			double val = 1;
			int x = i;
			while (x < k) {
				val /= 2;
				x *= 2;
			}
			ans += val;
		}
		ans /= n;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long l=sc.nextLong();
		long r=sc.nextLong();
		long min=Long.MAX_VALUE;
		if((l%2019)>(r%2019) || l==2019 || r-l+1>=2019 || l==0 ){
			System.out.println(0);
		}else{
			for(long i=l; i<=r; i++){
				for(long j=i+1; j<=r; j++){
					min=Math.min(min,((i%2019)*(j%2019))%2019);
				}
			}
			System.out.println(min);
		}
		
		
	}
}




Measured memory_bytes: 22100
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int a[10000], b[10000],i;
    char c[10000];
    i = 1;
    while (1) {
        cin >> a[i] >> c[i] >> b[i];
        if (c[i] == '?' ) { break; }
        else if (c[i] == '+') { printf("%d\n", a[i] + b[i]); }
        else if (c[i] == '-') { printf("%d\n", a[i] - b[i]); }
        else if (c[i] == '*') { printf("%d\n", a[i] * b[i]); }
        else if (c[i] == '/') { printf("%d\n", a[i] / b[i]); }
     
        i++;
    }
    return 0;
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in();
	vector<int>a(n);
	REPC(&i, a)i = in();
	int cnt = 0;
	bool flag;
	do
	{
		flag = false;
		REP(i, n - 1)
		{
			if (a[i] > a[i + 1])
			{
				swap(a[i], a[i + 1]);
				cnt++;
				flag = true;
			}
		}
	} while (flag);
	REP(i, n)
	{
		if (i != 0)cout << ' ';
		cout << a[i];
	}
	cout << endl;
	cout << cnt << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    map<char, int> mp;
    for (char c : s)
    {
        mp[c]++;
    }
    if (mp['S'] && mp['N'] && mp['W'] && mp['E'])
    {
        cout << "Yes" << endl;
    }
    else if (mp['S'] && mp['N'] && mp['W'] == 0 && mp['E'] == 0)
    {
        cout << "Yes" << endl;
    }
    else if (mp['S'] == 0 && mp['N'] == 0 && mp['W'] > 0 && mp['E'] > 0)
    {
        cout << "Yes" << endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int value = scan.nextInt();
		int hour = (value/60)/60;
		int min = (value/60)%60;
		int sec = value%60;
		
		System.out.println(String.format("%s:%s:%s",hour,min,sec));
	}

}



Measured memory_bytes: 26272
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int n,k,ans;
  cin >> n >> k;
  int l[51];
  for(int i=0;i<n;++i) cin >> l[i];
  sort(l,l+n,greater<int>());
  for(int i=0;i<k;++i) {
    ans += l[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]

    def det(x, y, z):
        a = [x[0]-y[0], x[1]-y[1]]
        b = [z[0]-x[0], z[1]-x[1]]
        return a[0]*b[1]-a[1]*b[0]

    def convex_hull(xy):
        q, k = [], 0
        xy.sort(key=lambda x: (x[1], x[0]))
        for i in range(n):
            while k > 1 and det(q[k-1], q[k-2], xy[i]) < 0:
                k -= 1
                q.pop()
            q.append(xy[i])
            k += 1
        t = k
        for i in range(n-2, -1, -1):
            while k > t and det(q[k-1], q[k-2], xy[i]) < 0:
                k -= 1
                q.pop()
            q.append(xy[i])
            k += 1
        return q[:k-1]

    ans = convex_hull(ab)
    print(len(ans))
    for i, j in ans:
        print(i, j)


main()



Measured memory_bytes: 30728
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

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

ans = sum(s)
if ans % 10 != 0:
    print(ans)
    sys.exit(0)

for v in s:
    if v % 10 != 0:
        print(ans - v)
        sys.exit(0)
print(0)


Measured memory_bytes: 61956
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 15;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

bool dp1[5050][5050];
bool dp2[5050][5050];
int in[5050];
int sum[5050];
int main() {
	int N, K, i, j, k;
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);

	dp1[0][0] = true;
	for (i = 1; i <= N; i++) {
		for (j = 0; j <= K; j++) {
			dp1[i][j] = dp1[i - 1][j];
			if (j >= in[i] && dp1[i - 1][j - in[i]]) dp1[i][j] = true;
		}
	}
	dp2[N + 1][0] = true;
	for (i = N; i >= 1; i--) {
		for (j = 0; j <= K; j++) {
			dp2[i][j] = dp2[i + 1][j];
			if (j >= in[i] && dp2[i + 1][j - in[i]]) dp2[i][j] = true;
		}
	}

	int ans = 0;
	for (i = 1; i <= N; i++) {
		sum[0] = 1;
		for (j = 1; j <= K; j++) sum[j] = sum[j - 1] + (int)dp2[i + 1][j];
		
		for (j = 0; j < K; j++) {
			if (!dp1[i-1][j]) continue;
			int st = max(0, K - in[i] - j), en = K - 1 - j;
			if (sum[en] != ((st == 0) ? 0 : sum[st - 1])) break;
		}
		if (j >= K) ans++;
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 49792
typedef long long ll;
typedef long double ld;
#define mod 1000000007
#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		ans = ans ^ a[i]; // take the xor of all the numbers
	}
	for (int i = 0; i < n; ++i) {
		a[i] = ans ^ a[i];
	}
	for (int i = 0; i < n; ++i ) {	// output the array for the answer
		cout << a[i] << " ";
	}
	cout << '\n';
	
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    N %= 10;
    vector<int> hon = {2, 4, 5, 7, 9};
    vector<int> pon = {0, 1, 6, 8};
    for(int a : hon) if( a == N){
        cout << "hon" << endl;
        return 0;
    }
    for(int a : pon) if( a == N){
        cout << "pon" << endl;
        return 0;
    }
    cout << "bon" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
string S,T;
int sum=0;
int main(){
	cin>>S>>T;
	int w=max(S.size(),T.size());
	for(int i=0;i<w;i++){
		if(S[i]!=T[i]){
			sum++;
		}
	}
	cout<<sum;
}

Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
const ll INF = 1e9;

// 変数定義start(vectorはresizeしようね)
ll N, K;
vl h;
// 変数定義end

void solve(){
	cin >> N >> K;
	h.resize(N);
	REP(i, N){
		cin >> h[i];
	}
	ll dp[N];
	dp[0] = 0;
	for(ll i = 1; i < N; i++){
		ll min = INF;
		for(ll l = 1; l <= K && i - l >= 0; l++){
			if(dp[i-l] + abs(h[i] - h[i-l]) < min){
				min = dp[i-l] + abs(h[i] - h[i-l]);
			}
		}
		if(min < INF){
			dp[i] = min;
		} else {
			dp[i] = INF;
		}
	}
	cout << dp[N-1] << endl;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int h,w;
    cin>>h>>w;
    int g[h][w];
    rep(i,h)rep(j,w)cin>>g[i][j];
    int n =0;
    vector<int>ans[250001];
    rep(i,h){
        rep(j,w){
            if(g[i][j]%2!=0){
                if(j==w-1&&i==h-1)continue;
                ans[n].push_back(i+1);
                ans[n].push_back(j+1);
                if(j==w-1&&i!=h-1){
                    ans[n].push_back(i+2);
                    ans[n].push_back(j+1);
                    g[i][j]--;
                    g[i+1][j]++;
                }
                else {
                    ans[n].push_back(i+1);
                    ans[n].push_back(j+2);
                    g[i][j]--;
                    g[i][j+1]++;
                }
                n++;
            }
        }
    }
    cout<<n<<endl;
    rep(i,n){
        rep(j,4){
        if(j!=3)cout<<ans[i][j]<<" ";
            else
            {
                cout<<ans[i][j];
            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 14848
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N;
ll K;
ll A[MAX_N];
ll bit[62];

ll my_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = pow(x*x, n/2);
  if (n & 1) res *= x;
  return res;
}

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

  cin >> N >> K;
  rep(i, N) cin >> A[i];

  for (int i = 0; i < N; ++i) {
      int tmp = 0;
      while ((A[i]>>tmp) > 0) {
          if (((A[i]>>tmp)&1) == 1) ++bit[tmp];
          ++tmp;
      }
  }


  vector<int> flag;
  ll tmp_k = K;
  int tmp_bit = 0;
  while ((tmp_k>>tmp_bit) > 0) {
      if (((tmp_k>>tmp_bit)&1) == 1) flag.push_back(tmp_bit);
      ++tmp_bit;
  }
  ll ans = 0;
  ll tmp_ans = 0;
  for (int i = 0; i < 62; ++i) {
      ans += bit[i] * my_pow(2, i);
  }
  for (int i = 0; i < 62; ++i) {
      if (((K>>i)&1) == 1) {
          tmp_ans += (N-bit[i]) * my_pow(2, i);
      } else {
          tmp_ans += bit[i] * my_pow(2, i);
      }
  }
  ans = max(ans, tmp_ans);

  for (int i = 0; i < flag.size(); ++i) {
     int b = flag[i];
     tmp_ans = 0;
     for (int k = 0; k < 62; ++k) {
         if (k < b) {
             tmp_ans += max(N-bit[k], bit[k]) * my_pow(2, k);
         } else if (k == b) {
             tmp_ans += bit[k] * my_pow(2, k);
         } else {
             if (((K>>k)&1) == 1) {
                 tmp_ans += (N-bit[k]) * my_pow(2, k);
             } else {
                 tmp_ans += bit[k] * my_pow(2, k);
             }
         }
     }
     ans = max(ans, tmp_ans);
  }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int A, B;
const int N = 15;
int dx[N][N], nw[N][N];
int V[N][N];
const int INF = 1e9 + 7;
vector <int> Ai, Bi, Ci;
void add_edge(int a, int b, int c)
{
    Ai.push_back(a);
    Bi.push_back(b);
    Ci.push_back(c);
}
int main()
{
    cin >> A >> B;
    for (int a = 1; a <= A; ++ a)
        for (int b = 1; b <= B; ++ b)
            cin >> dx[a][b], nw[a][b] = INF;
    for (int i = 1; i <= 100; ++ i)
        add_edge(i, i + 1, -1);
    for (int i = 1; i <= 100; ++ i)
        add_edge(101 + i, 101 + i + 1, -2);
    for (int i = 0; i <= 100; ++ i)
        for (int j = 0; j <= 100; ++ j)
        {
            int d = -INF;
            for (int a = 1; a <= A; ++ a)
                for (int b = 1; b <= B; ++ b)
                    d = max(d, dx[a][b] - (i * a + j * b));
            if (d >= 0 && d <= 100)
            {
                add_edge(i + 1, 202 - j, d);
                for (int a = 1; a <= A; ++ a)
                    for (int b = 1; b <= B; ++ b)
                        nw[a][b] = min(nw[a][b], i * a + j * b + d);
            }
        }
    for (int a = 1; a <= A; ++ a)
        for (int b = 1; b <= B; ++ b)
            if (nw[a][b] != dx[a][b])
                return cout << "Impossible" << endl, 0;
    cout << "Possible" << endl;
    cout << 202 << " " << Ci.size() << endl;
    for (int i = 0; i < Ci.size(); ++ i)
    {
        cout << Ai[i] << " " << Bi[i] << " ";
        if (Ci[i] == -1) cout << "X" << endl;
        else if (Ci[i] == -2) cout << "Y" << endl;
        else cout << Ci[i] << endl;
    }
    cout << 1 << " " << 202 << endl;
}


Measured memory_bytes: 384
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
count = []
mx = 0
words_list = list(set(s+t))
for word in words_list :
    count.append([word, 0])
for word in words_list :
    idx = words_list.index(word)
    count[idx][1] += s.count(word)
    count[idx][1] -= t.count(word)
for i in range(len(words_list)) :
      mx = max(mx,count[i][1])
print(mx)


Measured memory_bytes: 9152
## constant

MOD = 100000;

### main

loop do
  w, h = gets.strip.split(' ').map{|s| s.to_i}
  break if (w | h) == 0
  #p [w, h]

  ## 0 = h&v:ok, 1=h&v:ng, 2 = v&h:ok, 3 = v&h:ng
  rts = h.times.map{w.times.map{[0] * 4}}

  (0...h).each{|y| rts[y][0][2] = 1}
  (0...w).each{|x| rts[0][x][0] = 1}

  for y in (1...h)
    for x in (1...w)
      rts[y][x][0] = (rts[y][x - 1][0] + rts[y][x - 1][1]) % MOD
      rts[y][x][1] = rts[y][x - 1][2]
      rts[y][x][2] = (rts[y - 1][x][2] + rts[y - 1][x][3]) % MOD
      rts[y][x][3] = rts[y - 1][x][0]
    end
  end
  #p rts

  sum = 0
  for rt in rts[h - 1][w - 1]
    sum = (sum + rt) % MOD
  end

  puts sum
end

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean atcodeerIsHonest = sc.next().equals("H");
        boolean atcodeersState = sc.next().equals("H");
        System.out.println(atcodeerIsHonest==atcodeersState ? "H" : "D");
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;

namespace cswork
{

    class Program
    {
        public Program() { }

        Scanner cin;

        void Omame()
        {
            cin = new Scanner();

            int n = cin.nextInt();
            int ans = 0;

            for (int i = 105; i <= n; i += 2)
            {
                int tmp = 0;
                for (int j = 1; j <= n; j++)
                {
                    if (i % j == 0)
                    {
                        tmp++;
                    }
                }

                if (tmp == 8)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  ll ac = 0;
  ll wa = 0;
  vector<bool> a(n, false);
  vector<ll> w(n);
  rep(i,m) {
    ll p;
    string s;
    cin >> p >> s;
    if (s == "AC" && a[p-1] == false) {
      a[p-1] = true;
      ++ac;
      wa += w[p-1];
    }
    if (s == "WA" && a[p-1] == false) {
      ++w[p-1];
    }
  }
  cout << ac << ' ' << wa << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

int main() {
    int n, k;
    cin >> n >> k;

    deque<int> data;
    for (int i = 0; i < n; i++){
        int dat;
        cin >> dat;
        data.push_back(dat);
    }

    deque<int> tmp = data;

    int min = n > k ? k : n;
    int64_t max = 0;
    for (int i = 0; i <= min; i++){
        for (int j = 0; j <= min - i; j++){
          tmp = data;
          //cout << i << " " << j << endl;
            vector<int> jwel;

            for (int a = 0; a < i; a++){
                jwel.push_back(tmp.front());
                tmp.pop_front();
            }

            for (int b = 0; b < j; b++){
                jwel.push_back(tmp.back());
                tmp.pop_back();
            }

            sort(jwel.begin(), jwel.end());
          
          //for (int ii = 0; ii < jwel.size(); ii++){
          //cout << jwel.at(ii) <<endl;
          //}
          //cout << endl;

            for (int ii = 0; ii < k - (i + j); ii++){
              if (jwel.size() <= ii){
              	continue;
              }

                if (jwel.at(ii) < 0){
                    jwel.at(ii) = 0;
                }

            }

            if (max < accumulate(jwel.begin(), jwel.end(), 0)){
                max = accumulate(jwel.begin(), jwel.end(), 0);
              //cout << i << " " << j << " " << max << endl;
            }
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, c, T[101][101];
  cin >> r >> c;
  for(int h = 0;h < r;h++){
    for(int w = 0;w < c;w++){
      cin >> T[h][w];
    }
  }
  for(int h = 0;h <= r;h++)T[h][c] = 0;
  for(int w = 0;w <= c;w++)T[r][w] = 0;
  
  for(int h = 0;h < r;h++){
    for(int w = 0;w < c;w++){
      T[h][c]+=T[h][w];
      T[r][w]+=T[h][w];
      T[r][c]+=T[h][w];
    }
  }
  for(int h = 0;h <= r;h++){
    for(int w = 0;w <= c;w++){
      cout << T[h][w];
      if(w == c)cout << endl;
      else cout << " ";
    }
  }
}


Measured memory_bytes: 3096
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
  input! {
    k: usize,
  };

  let mut res = 0;
  for a in 1..=k {
    for b in 1..=k {
      for c in 1..=k {
        res += a.gcd(&b).gcd(&c);
      }
    }
  }
  println!("{}", res);
}


Measured memory_bytes: 2176
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

struct Event {
  int64_t x;
  int64_t num;
};

int main() {
  int N, D, A;
  cin >> N >> D >> A;

  using P = pair<int, int>;
  vector<P> enemy(N);
  rep(i, N) {
    int x, h;
    cin >> x >> h;
    enemy[i] = P(x, h);
  }
  sort(enemy.begin(), enemy.end());

  auto cmp = [](const Event& lh, const Event& rh) { return lh.x > rh.x; };
  priority_queue<Event, vector<Event>, decltype(cmp)> q(cmp);

  int64_t result = 0;
  int64_t cnt = 0;
  rep(i, N) {
    int x, h;
    tie(x, h) = enemy[i];

    while (!q.empty() && q.top().x <= x) {
      cnt -= q.top().num;
      q.pop();
    }

    int64_t res = (h + A - 1) / A - cnt;
    if (res > 0) {
      result += res;
      cnt += res;

      Event bomb = {(int64_t)x + 2 * D + 1, res};
      q.push(bomb);
    }
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 1};
int dy[] = {1, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int H, W, N;

void blockfall(vector<string> &vs) {
    repr(i,H-2,0) rep(j,0,W) {
        int s = i, t = j;
        while(s != H-1) {
            if(vs[s][t] == '.' || vs[s+1][t] != '.') break;
            swap(vs[s][t], vs[s+1][t]);
            s++;
        }
    }
}

bool take(int x, int y, int dir, vector<string> &vs) {
    int s = x, t = y;
    int prev = -1;
    rep(i,0,N) {
        if(s >= H || t >= W) return false;
        if(vs[s][t] == '.') return false;
        if(prev == -1) prev = vs[s][t] - 'A';
        else if(vs[s][t] - 'A' != prev) return false;

        s += dx[dir], t += dy[dir];
    }
    return true;
}

void show_vector(vector<string> vs) {
    rep(i,0,H) cout << vs[i] << endl;
}

bool solve(vector<string> vs) {
    blockfall(vs);
    bool ok = true;
    while(ok) {
        ok = false;
        bool cantake[40][40] = {};
        rep(i,0,H) rep(j,0,W) rep(k,0,2) {
            if(take(i, j, k, vs)) {
                ok = true;
                int s = i, t = j;
                rep(x,0,N) {
                    cantake[s][t] = true;
                    s += dx[k], t += dy[k];
                }
            }
        }
        rep(i,0,H) rep(j,0,W) if(cantake[i][j]) vs[i][j] = '.';
        blockfall(vs);
    }
    // show_vector(vs);
    int ans = 0;
    rep(i,0,H) rep(j,0,W) ans += (vs[i][j] != '.');
    return !ans;
}

signed main() {
    cin >> H >> W >> N;
    vector<string> vs(H);
    rep(i,0,H) cin >> vs[i];

    bool answerFlag = false;
    rep(i,0,H) rep(j,0,W-1) {
        if(vs[i][j] == vs[i][j+1]) continue;
        // printf("swap: (%lld, %lld) and (%lld, %lld)\n", i, j, i, j+1);
        swap(vs[i][j], vs[i][j+1]);
        answerFlag |= solve(vs);
        swap(vs[i][j], vs[i][j+1]);
    }
    cout << (answerFlag ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3216
n,k,q = map(int,input().split())
a = [int(input()) for _ in range(q)]
m = [k-q]*n 
for i in range(q):
  m[a[i]-1] += 1
for j in range(n):
  if m[j] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 55896
#include <bits/stdc++.h>
#define nmax 2005

using namespace std;

int a[nmax][nmax]={};
int dp[nmax][nmax]={}, p[nmax][nmax]={};
int vert[2][nmax][nmax]={}, horz[2][nmax][nmax]={};
int pvert[nmax][nmax]={},phorz[nmax][nmax]={};

int main(){
	int n,m,q; cin >> n >> m >> q;
	for(int i=1;i<=n;i++){
		char c;
		for(int j=1;j<=m;j++){
			cin >> c;
			a[i][j]=c-'0';
			p[i][j]=a[i][j]+p[i][j-1]+p[i-1][j]-p[i-1][j-1];
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int adj=a[i-1][j]+a[i+1][j]+a[i][j-1]+a[i][j+1];
			if(a[i][j])
				dp[i][j]=adj;
			dp[i][j]+=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1];
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int adj;
			adj=a[i-1][j]+a[i+1][j];
			vert[0][i][j]=vert[0][i-1][j]+(adj+a[i][j-1])*a[i][j];
			vert[1][i][j]=vert[1][i-1][j]+(adj+a[i][j+1])*a[i][j];			
		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int adj;
			adj=a[i][j-1]+a[i][j+1];
			
			horz[0][i][j]=horz[0][i][j-1]+(adj+a[i-1][j])*a[i][j];
			horz[1][i][j]=horz[1][i][j-1]+(adj+a[i+1][j])*a[i][j];
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			pvert[i][j]=(a[i-1][j]+a[i+1][j])*a[i][j];
			pvert[i][j]+=pvert[i-1][j];
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			phorz[i][j]=(a[i][j-1]+a[i][j+1])*a[i][j];
			phorz[i][j]+=phorz[i][j-1];
		}
		
	}
	
	while(q--){
		int xa,ya,xb,yb;
		cin >> xa >> ya >> xb >> yb;
		int e=0,v=0;
		v=p[xb][yb]-p[xb][ya-1]-p[xa-1][yb]+p[xa-1][ya-1];
		
		if(xa==xb && ya==yb){
			e=0;
		}
		else if(xa==xb){
			e+=phorz[xa][yb-1]-phorz[xa][ya];
			e+=a[xa][ya]*a[xa][ya+1];
			e+=a[xa][yb]*a[xa][yb-1];
		}
		else if(ya==yb){
			e+=pvert[xb-1][ya]-pvert[xa][ya];
			e+=a[xb][ya]*a[xb-1][ya];
			e+=a[xa][ya]*a[xa+1][ya];
		}
		else{
			xa++; xb--; ya++; yb--;
			if(xa<=xb && ya<=yb){
				e+=(dp[xb][yb]-dp[xb][ya-1]-dp[xa-1][yb]+dp[xa-1][ya-1]);
			}
			
			xa--; xb++; ya--; yb++;
			
			e+=vert[1][xb-1][ya]-vert[1][xa][ya];
			e+=vert[0][xb-1][yb]-vert[0][xa][yb];
			e+=horz[1][xa][yb-1]-horz[1][xa][ya];
			e+=horz[0][xb][yb-1]-horz[0][xb][ya];
		
			e+=(a[xa][ya+1]+a[xa+1][ya])*a[xa][ya];
			e+=(a[xb][ya+1]+a[xb-1][ya])*a[xb][ya];
			e+=(a[xb][yb-1]+a[xb-1][yb])*a[xb][yb];
			e+=(a[xa][yb-1]+a[xa+1][yb])*a[xa][yb];
		}
		cout << v-e/2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 143104