akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ld, ld>                                  pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

//const ll md = 1e9 + 7;//998244353;
const int xn = 1e5 + 10;
const int xm = -20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int Md[3] = {1000000007, 987654319, 1000000009};
const int TM = 3;
const int Base = 257;

int n, Root = 1;
vector <int> adj[xn];
string s;

int main(){
    InTheNameOfGod;
    
    cin >> s;
    n = SZ(s);
    s = '.' + s;
    if (s[1] == '0' || s[n] == '1')		kill(-1);
    for (int i = 1; i < n; ++ i)	if (s[i] != s[n - i]) kill(-1);
    for (int i = 1; i < n; ++ i){
    	adj[Root].push_back(i + 1);
    	if (s[i] == '1')	Root = i + 1;
	}
	for (int v = 1; v <= n; ++ v) for (int u : adj[v])	cout << v << sep << u << endl;
	
    return 0;
}


Measured memory_bytes: 7020
#include<stdio.h>
#include<math.h>

int main(){
  int q,i;
  long long int a,b,t,s,an;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%ld %ld",&a,&b);
    t=a*b;
    s=sqrt(t);
    if(s*s==t) an=2*s-2;
    else if(s*(s+1)>=t) an=2*s-1;
    else an=2*s;
    if(a!=b) an--;
    printf("%ld\n",an);
  }
}

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

int main() {
	
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(M),b(M);
  for(int i=0;i<M;i++)cin >> a[i] >> b[i];
  vector<pair<int,int>> p(M);
  for(int i=0;i<M;i++)p[i]=make_pair(b[i],a[i]);
  sort(p.begin(),p.end());
  for(int i=0;i<M;i++){b[i]=p[i].first; a[i]=p[i].second;}
  int cnt=1; int x=b[0];
  for(int i=1;i<M;i++){
    if(a[i]>=x){cnt++; x=b[i];}
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  map<string,int> cnt;
  int N;
  cin >> N;
  vector<string> data(N);
  rep(i,0,N){
      cin >> data[i];
  }
  for(string S: data){
      
      if(cnt.count(S)){
          cnt.at(S)++;
      }else{
          cnt[S]=1;
      }
  }

  int max=0;
  for(string S:data){
      if(max<cnt.at(S)){
          max=cnt.at(S);
      }
  }
  for(auto x:cnt){
      if(x.second==max){
          cout << x.first << endl;
      }
  }


  return 0;
}

Measured memory_bytes: 27904
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int n, k; cin >> n >> k;
  vector<int> h(n);
  for(int i=0; i<n; i++) cin >> h[i];
  
  int ans = 0;
  for(auto hi: h)
    if(hi >= k) ans++;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<typename Func>
double findMaxReal(double L, double R, Func f) { //[L, R)
    double left = L, right = R;

    for (int loop = 0; loop < 101; ++loop) {
        if (f((left * 2 + right) / 3) > f((left + right * 2) / 3)) {
            right = (left + right * 2) / 3;
        }
        else {
            left = (left * 2 + right) / 3;
        }
    }
    return (right + left) * 0.5;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, X[101010], R[101010];
//---------------------------------------------------------------------------------------------------
double f(double x) {
    double res = inf;
    rep(i, 0, N) {
        // d^2 + y^2 = R^2
        double d = abs(x - X[i]);
        double yy = 1.0 * R[i] * R[i] - d * d;
        double y = sqrt(yy);
        chmin(res, y);
    }
    return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> X[i] >> R[i];

    double a = -inf, b = inf;
    rep(i, 0, N) {
        chmax(a, (double)(X[i] - R[i]));
        chmin(b, (double)(X[i] + R[i]));
    }

    double t = findMaxReal(a, b, f);
    double ans = f(t);
    printf("%.10f\n", ans);
}


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

long long dp[51][2501];

int main() {
	for (int i = 0; i <= 50; ++i) {
		for (int j = 0; j <= 2500; ++j) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	int n, a;
	scanf("%d %d", &n, &a);
	for (int it = 0; it < n; ++it) {
		int val;
		scanf("%d", &val);
		for (int i = 49; i >= 0; --i) {
			for (int j = 0; j <= 2500; ++j) {
				if (dp[i][j] == -1)
					continue;
				dp[i + 1][j + val] += dp[i][j];
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i <= 50; ++i) {
		ans += dp[i][a * i];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
	int A, B, r;
	scanf("%d %d", &A, &B);
	
	int ans = -1;
	
	for(r=0; r<10 && ans == -1; r++){
		if((10*B + r)*2/25 == A) ans = 10*B+r;
	}
	
	printf("%d", ans);

		return 0;
	
}

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

#define MOD 1000000007

int main(){
  long long a,b,c,n,ans = 0;
  cin >> n;
  for(a = 1;a <= n;a++){
    ans += n / a;
    if(n % a == 0)ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
  vector<int> a(5);
  rep(i, 0, 5) cin>>a[i];
  int k; cin >> k;
  sort(a.begin(), a.end());
  if(a[4] - a[0] <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>b;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pw 1000000000
#define pi 3.141592653589793238

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
       int n,m,sum=0;
       cin>>n>>m;
       //string s;
       int a[m];
       f(i,0,m)
       cin>>a[i];
       f(i,0,m)
       sum+=a[i];
       if(sum<=n)
        cout<<n-sum;
       else
        cout<<-1;
       //sort(a,a+n);
       cout<<endl;
    }
    return 0;
}


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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int lt, lx, ly;

int main () {
    cin >> n;
    For (i, 1, n) {
        int t, x, y;
        cin >> t >> x >> y;
        if (abs(lx - x) + abs(y - ly) > t - lt || (t - lt - abs(lx - x) + abs(y - ly)) % 2) {
            cout << "No";
            exit(0);
        }
        lt = t, lx = x, ly = y;
    }
    
    cout << "Yes";
	return Accepted;
}

// Coded By OB

Measured memory_bytes: 18688
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_ll.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_ll;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

struct range_minimum_query{
  ll fnc(ll a,ll b){
    ll ans = a+b;
    return ans;
  }

  ll n,INF;
  vector<ll> segtree;
  range_minimum_query(ll sz,ll inf=MOD){
    INF=inf;
    for(n = 1; n<sz;) n <<= 1;
    segtree.assign(2*n-1,INF);
  }
  ll find(ll l, ll r){return find(l,r,0,n,0);}
  ll find(ll l, ll r, ll a, ll b, ll k){
    if(b<=l || r<=a) return INF;
    else if(l<=a && b<=r) return segtree[k];
    else return fnc(find(l,r,a,(a+b)/2,2*k+1), find(l,r,(a+b)/2,b,2*k+2));
  }
  void update(ll i, ll x){
    i += n-1;
    segtree[i] += x;
    while(i>0){
      i = (i-1)/2;
      segtree[i] = fnc(segtree[2*i+1], segtree[2*i+2]);
    }
  }
};

int main(){
  ll n,q;
  cin>>n>>q;
  range_minimum_query rmq(n,0);
  for(ll i=0;i<q;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    b--;
    if(a==0)rmq.update(b,c);
    else cout<<rmq.find(b,c)<<endl;
  }
}



Measured memory_bytes: 4940
#include<cstdio>
const int mod=1000000007;
int f[4010][2010],g[4010][2010];
int F(int i,int j){return j<0?0:f[i][j];}
int G(int i,int j){return j<0?0:g[i][j];}
int main(){
	int N,M,K,T;
	scanf("%d%d%d",&N,&M,&K);
	T=(N+M-1)/(K-1);
	for(int i=0;i<=T;i++){
		for(int j=0;j<=M;j++){
			if(!i)f[i][j]=1,g[i][j]=j%(K-1)==0;
			else{
				f[i][j]=((F(i,j-1)+F(i-1,j))%mod+mod-F(i-1,j-K))%mod;
				g[i][j]=((G(i,j-K+1)+F(i-1,j))%mod+mod-F(i-1,j-K))%mod;
			}
		}
	}
	int S=0;
	for(int i=0;i<T;i++){
		int s=(K-1)*i+K,l=s-N,r=M;
		while(r>s-1)r-=K-1;
		while(l<0)l+=K-1;
		l-=K-1;
		if(l<r)for(int j=1;j<K;j++){
			(S+=G(i,r-j))%=mod;
			(S+=mod-G(i,l-j))%=mod;
		}
	}
	printf("%d\n",S);
}

Measured memory_bytes: 63104
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 200000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
int X[MAX_N];
int Y[MAX_N];

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

  cin >> N;
  REP(i, N) cin >> X[i];
  REP(i, N) Y[i] = X[i];
  sort(Y, Y + N);

  int mid = ((N - 1) + 1) / 2;

  for (int i = 0; i < N; i++) {
    if (X[i] < Y[mid]) {
      cout << Y[mid] << endl;
    }
    else {
      cout << Y[mid - 1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    for(int i=0; i<n; i++) cin >> a[i] >> b[i];
    for(int i=0; i<m; i++) cin >> c[i] >> d[i];
    for(int i=0; i<n; i++){
        int mincost=inf, minidx=-1;
        for(int j=0; j<m; j++){
            int dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(dist < mincost){
                mincost = dist;
                minidx = j;
            }
        }
        cout << minidx+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    if l[i]!=l[j]:
      for k in range(j+1,n):
        if l[k]!=l[j] and l[k]!=l[i] and l[i]+l[j]>l[k]:
          ans=ans+1
print(ans)


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

int main() {
  int q;
  cin >> q;
  deque<int> dq;
  for (int i = 0; i < q; i++) {
    int a, d, x;
    cin >> a;
    if (a == 0) {
      cin >> d >> x;
      if (d == 0)
      dq.push_front(x);
      if (d == 1)
      dq.push_back(x);
    }
    if (a == 1) {
      cin >> x;
      cout << dq.at(x) << endl;
    }
    if (a == 2) {
      cin >> d;
      if (d == 0)
      dq.pop_front();
      if (d == 1)
      dq.pop_back();
    }
  }
}



Measured memory_bytes: 4572
L=10**6
X=gets.to_i
h={}
L.times do |i|
  n=i**5
  [n+X,n-X].each do |x|
    next unless h[x]
    puts [i,h[x]]*" "
    exit 0
  end
  h[n],h[-n]=i,-i
end
exit 1

Measured memory_bytes: 14300
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] cost = new int[n];
		cost[0]= 0;
		for(int i =0; i< n; i++){
			arr[i]= sc.nextInt();
		}
		cost[1]= Math.abs(arr[1]-arr[0]);
		for(int i = 2; i<n;i++ ){
			if(i==2){
				cost[2]= Math.min(Math.abs(arr[2]-arr[0]),Math.abs(arr[2]-arr[1])+cost[1]);
			}else{
				cost= minval(cost,arr,i);
			}
		}

		System.out.println(cost[n-1]);
		//try loops

	}
	public static int[] minval (int cost[],int arr[], int pos){
		cost[pos] = Math.min(Math.abs(arr[pos-2]-arr[pos])+cost[pos-2],Math.abs(arr[pos-1]-arr[pos])+cost[pos-1]);
		return cost;
	}

}


Measured memory_bytes: 62936
L, R = map(int, input().split())

if (L // 2019) == (R //2019):
    LL = L % 2019
    RR = R % 2019
    ans = 2019
    for i in range(LL, RR):
        for j in range(i+1, RR+1):
            ans = min(((i * j) % 2019), ans)
else:
    ans = 0

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    bool flag=false;
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(i*j%n == 0) flag = true;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";


}

Measured memory_bytes: 256
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include <bits/stdc++.h>
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
typedef long long int lli;
template <typename T>
void out(vector <T> v){
    for(lli i = 0; i < v.size(); i++){
        cout << v[i] << " ";
    }
    cout << endl;
}
void solve(){
    lli n;
    cin >> n;
    lli ret = 0;
    lli x = n / 500;
    lli rem = n - (x * 500);
    ret = x * 1000 + (rem / 5 * 5);
    cout << ret << endl;
}
int main(){
    #ifdef zanj0
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    lli t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
#define f(i,start,end) for(i=start;i<=end;i++)
#define min_heap priority_queue<int, vector<int>, greater<int> >
#define max_heap priority_queue<int>

int dp[12][13];
int res = -1;
void dfs(int ind, int n, int m, int arr[], int x, int sum)
{
    bool b = true;
    for(int i=0; i<m; i++) {
        if(arr[i]<x) {
            b=false;
            break;
        }
    }
    if(b) {
        if(res==-1) res = sum;
        else res = (sum<res)? sum: res;
        //cout << sum << nl;
        return;
    }
    if(ind==n) return;

    dfs(ind+1, n,m,arr,x,sum);
    sum += dp[ind][0];
    int brr[m];
    for(int i=0; i<m; i++) brr[i] = arr[i] + dp[ind][i+1];
    dfs(ind+1, n,m, brr, x, sum);

}

int main()
{
    fast;
//int t=0,tc=0; cin >> tc; f(t,1,tc) //testcases
    {
        int i=0, j=0, tmp=0;
        int n,m,x;
        cin >> n >> m >> x;
        f(i, 0, n-1)
        f(j, 0, m)
        cin >> dp[i][j];
        int ar[m];
        for(int i=0; i<m; i++) ar[i] = 0;
        int ind = 0, sum = 0;
        dfs(0, n, m, ar, x, sum);

        cout << res  << nl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <queue>

using namespace std;
const string TASK = "";

const int maxn = 3e5+1;
int n,i,a[maxn];
long long l[maxn],r[maxn],res;

void Enter()
{
    cin >> n;
    for (i=1;i<=3*n;++i)
        cin >> a[i];
}

void Init_left()
{
    priority_queue <int,vector<int>,greater<int> > pq;
    l[n] = 0;
    for (i=1;i<=n;++i) {
        l[n] += a[i];
        pq.push(a[i]);
    }
    for (i=n+1;i<=2*n;++i) {
        pq.push(a[i]);
        l[i] = l[i-1] - pq.top() + a[i];
        pq.pop();
    }
}

void Init_right()
{
    priority_queue <int,vector<int>,less<int> > pq;
    r[2*n+1] = 0;
    for (i=3*n;i>=2*n+1;--i) {
        r[2*n+1] += a[i];
        pq.push(a[i]);
    }
    for (i=2*n;i>=n+1;--i) {
        pq.push(a[i]);
        r[i] = r[i+1] - pq.top() + a[i];
        pq.pop();
    }
}

void Solve()
{
    res = -1e18;
    for (i=n;i<=2*n;++i)
        res = max(res,l[i]-r[i+1]);
    cout << res;
}

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

    //freopen((TASK+".INP").c_str(),"r",stdin);
    //freopen((TASK+".OUT").c_str(),"w",stdout);

    Enter();
    Init_left();
    Init_right();
    Solve();
}


Measured memory_bytes: 5232
#include<iostream>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;
#include <map>

using ll = long long;
using namespace std;


int main(){
    ll n,count=0;
    cin >> n;
    
    for(int i=1; i<=n; i++){
        if(i%3==0&&i%5==0) continue;
        else if(i%3==0) continue;
        else if(i%5==0) continue;
        else count+=i;
    }
    cout << count << endl;
}

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

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

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

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

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

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

int main(){
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	
	int a = abs(a1 - a2);
	int b = abs(a2 - a3);
	int c = abs(a3 - a1);
	int ans = a + b + c - max({a,b,c});

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
input_line = input().split(" ")
X=input_line[0]
Y=input_line[1]
Z=input_line[2]

ram=X
X=Y
Y=ram

ram=X
X=Z
Z=ram



input_line[0]=X
input_line[1]=Y
input_line[2]=Z

input_line=' '.join(input_line)
print(input_line)

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

int main(){
    int n;
    int a[100];
    int v;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        v = a[i];
        int j = i-1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        for(int k = 0; k < n; k++){
            cout << a[k];
            if (k != n-1) cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll di=1e9+7;
ll n,m;
const int maxn=1e5+9;
ll arr[maxn],ar[maxn];
int main(){
    ll a,b,c,d,e,f,g,h;
    ios::sync_with_stdio(0);
    while(cin>>n>>m){
        for(int i=0;i<n;i++)cin>>arr[i];
        for(int i=0;i<m;i++)cin>>ar[i];
        ll hang=0;
        for(ll i=1;i<m;i++){
            e=ar[i]-ar[i-1];
            e*=i;
            e%=di;
            e*=m-i;
            e%=di;
            hang+=e;
            hang%=di;
        }
        ll ans=0;
        for(ll i=1;i<n;i++){
            f=arr[i]-arr[i-1];
            f*=i;
            f%=di;
            f*=n-i;
            f%=di;
            ans+=f*hang;
            ans%=di;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
 
int main(){
 
unsigned char N[1000];
 
while(scanf("%s",N)==0);
  int  l=strlen(N)-1;
if(N[l]=='3'){
  printf("bon");
}else if((N[l]=='0')||(N[l]=='6')||(N[l]=='1')||(N[l]=='8')){
  printf("pon");
}else{
  printf("hon");
}
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>






const int N=5010;
ll n,h[N],p[N],idx[N],mn[N],res;
bool b[N];


bool cmp(int i,int j)
{
	return h[i]+p[i]<h[j]+p[j];
}




void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i]>>p[i];
		idx[i]=i;
		mn[i]=1e18;
	}
	sort(idx+1,idx+n+1,cmp);
	mn[0]=0;
	res=0;
	for(int k=1,i;k<=n;k++)
	{
		i=idx[k];
		for(int j=1;j<=k;j++)b[j]=0;
		for(int j=k;j>=1;j--)
		{
			if(mn[j-1]<=h[i])
			{
				b[j]=1;
				mn[j]=min(mn[j],p[i]+mn[j-1]);
			}
			if(b[j])res=max(res,(ll)j);
		}
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 384
import math

def koch(a1, a2, b1, b2, n):
    if n <= 0:
        return 0

    s1 = 2.0/3.0*a1 + 1.0/3.0*b1
    s2 = 2.0/3.0*a2 + 1.0/3.0*b2
    t1 = 1.0/3.0*a1 + 2.0/3.0*b1
    t2 = 1.0/3.0*a2 + 2.0/3.0*b2
    u1 = 1.0/6.0*(3.0*a1 + 3.0*b1 + math.sqrt(3.0)*a2 - math.sqrt(3.0)*b2)
    u2 = 1.0/6.0*(-1.0*math.sqrt(3.0)*a1 + math.sqrt(3.0)*b1 + 3.0*a2 + 3.0*b2)
    
    koch(a1, a2, s1, s2, n-1)
    print s1, s2
    koch(s1, s2, u1, u2, n-1)
    print u1, u2
    koch(u1, u2, t1, t2, n-1)
    print t1, t2
    koch(t1, t2, b1, b2, n-1)
    
if __name__ == '__main__':
    n = int(raw_input())
    a1, a2, b1, b2 = 0.0, 0.0, 100.0, 0.0
    print a1, a2
    koch(a1, a2, b1, b2, n)
    print b1, b2

Measured memory_bytes: 6428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int b = sc.NextInt();
        var p = new List<Tuple<int, int, int>>();
        for (int i = 0; i < n; i++)
            p.Add(Tuple.Create(sc.NextInt() * 2 - 1, sc.NextInt() * 2, sc.NextInt()));
        int TMAX = 200002;
        int[] t = new int[TMAX];
        int[] r = new int[TMAX];
        for (int i = 1; i <= b; i++)
        {
            for (int j = 0; j < TMAX; j++) t[j] = 0;
            for (int j = 0; j < n; j++)
            {
                if (p[j].Item3 != i) continue;
                t[p[j].Item1]++;
                t[p[j].Item2]--;
            }
            for (int j = 1; j < TMAX;j++) t[j] += t[j - 1];
            for (int j = 0; j < TMAX; j++)
                if (t[j] > 0) r[j]++;
        }
        int res = 0;
        for (int i = 0; i < TMAX; i++) if (r[i] > res) res = r[i];
        Console.WriteLine(res);
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

class PriorityQueue
{
    public List<int> list;
    public int Count { get { return list.Count; } }

    public PriorityQueue()
    {
        list = new List<int>();
    }

    public PriorityQueue(int count)
    {
        list = new List<int>(count);
    }


    public void Enqueue(int x)
    {
        list.Add(x);
        int i = Count - 1;

        while (i > 0)
        {
            int p = (i - 1) / 2;
            if (list[p] <= x) break;

            list[i] = list[p];
            i = p;
        }

        if (Count > 0) list[i] = x;
    }

    public int Dequeue()
    {
        int min = Peek();
        int root = list[Count - 1];
        list.RemoveAt(Count - 1);

        int i = 0;
        while (i * 2 + 1 < Count)
        {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            int c = b < Count && list[b] < list[a] ? b : a;

            if (list[c] >= root) break;
            list[i] = list[c];
            i = c;
        }

        if (Count > 0) list[i] = root;
        return min;
    }

    public int Peek()
    {
        if (Count == 0) throw new InvalidOperationException("Queue is empty.");
        return list[0];
    }

    public void Clear()
    {
        list.Clear();
    }
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int dp[105][4][2];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int K;
  cin >> K;

  dp[0][0][0] = 1;
  rep(i,n) rep(j,4) rep(k,2) {
    int nd = s[i] - '0';
    rep(d, 10) {
      int ni = i+1, nj = j, nk = k;
      if (d != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
	if (d > nd) continue;;
	if (d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}


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

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int N;
bool edge[9][9];
bool visited[9];

int dfs(int v, int c) {
	if (visited[v]) return 0;
	if (c == N) return 1;
	visited[v] = true;
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		if (!edge[v][i]) continue;
		sum += dfs(i, c + 1);
	}
	visited[v] = false;
	return sum;
}

int main(int argc, char *argv[]) {
	cin >> N;
	int M;
	cin >> M;

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		edge[a][b] = edge[b][a] = true;
	}

	cout << dfs(1, 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	vector<ll> v(70,0);
	int n;
	cin >> n;
	vector<ll> num(n,0);
	rep(i,n) cin >> num[i];
	rep(i,62){
		rep(j,n){
			if((num[j]>>i)&1){
				v[i]++;
			}
		}
	}
	ll ans = 0;
	rep(i,62){
		ll num2 = v[i]*(n-v[i])%MOD;
		for(ll j=0;j<i;j++){
			num2 *= 2;
			num2 %= MOD;
		}
		ans += num2;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	int H[101];
	int A[101]={};
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>H[i];
		A[i]=0;
	}
	for(int i=1;i<N;i++){
		for(int j=0;j<i;j++){
			if(H[i]<H[j]){
				A[i]=1;
				break;
			}
		}
	}
	int R=N;
	for(int i=0;i<N;i++){
		if(A[i]==1)R--;
	}
	cout<<R<<endl;
	return 0;
}


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

using namespace std;
 int a[123456],b[123456],c[123456];
 int dp[123456][3];
int solve(int index,int v)
{
    if(index == 0)
    {
        if(v==0)
        return a[0];
        else if(v==1)
        return b[0];
        else
        return c[0];
    }
    if(dp[index][v] > 0)
    return dp[index][v];
    
    int ans=0;
    
    if(v==0)
    {
        ans = a[index] + max(solve(index-1,1),solve(index-1,2));
    }
    else if(v==1)
    {
        ans = b[index] + max(solve(index-1,2),solve(index-1,0));
    }
    else
    {
        ans = c[index] + max(solve(index-1,1),solve(index-1,0));
    }
    return dp[index][v] = ans;
}

int main()
{
    int n;
    cin>>n;
    
   
    
    int i,j;
    
    for(i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
    
   // int dp[n][3];
    
    for(i=0;i<n;i++)
    dp[i][0]=dp[i][1]=dp[i][2]=0;
    
    cout<<max(max(solve(n-1,0),solve(n-1,1)),solve(n-1,2));
    return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;

    ll r = 0, g = 0, b = 0, ng = 0;
    rep(i, n) {
        s[i] == 'R' ? r++ : s[i] == 'G' ? g++ : b++;
        for (int j = i + 1; j < n - 1; j++) {
            int k = 2 * j - i;
            if (k >= n) break;
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ng++;
        }
    }

    cout << r * g * b - ng << endl;
    return 0;
}


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

void solve(ll x) {
    ll M = 4200;
    for (ll a = -M; a <= M; a++) {
        for (ll b = -M; b <= M; b++) {
            if ((a*a*a*a*a) - (b*b*b*b*b) == x) {
                cout << a << " " << b << endl;
                return;
            }
        }
    }
    assert(false);
}

int main(void){
    ll x;
    cin >> x;
    solve(x);
    return 0;
}


Measured memory_bytes: 3532
X, K, D = map(int, input().split())
X = abs(X)

if K*D <= X:
    print(abs(X - K*D))
else:
    m = X // D
    re = K - m
    if re % 2 == 0:
        print(abs(X - D*m))
    else:
        print(abs(X - D*(m+1)))


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    m1 += h1 * 60;
    m2 += h2 * 60;
    cout << m2 - m1 - k << endl;
    return 0;
}

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

int n, a, b, col = 1;
vector<int> adj[200001];
int color[200001];
int ans[200001];

void dfs(int cur) {
	for (auto nxt : adj[cur]) {
		if (color[nxt] == -1) {
			color[nxt] = !color[cur];
			dfs(nxt);
		}
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	memset(color, -1, sizeof(color));
	color[1] = 0;
	dfs(1);

	for (int i = 1; i <= n; i++)
		color[i] ? a++ : b++;
	if (a > b) swap(a, b), col = 0;

	if (a <= n / 3) {
		int temp1 = 3, temp2 = 1;
		for (int i = 1; i <= n && temp2 <= n; i++) {
			if (color[i] == col) 
				ans[i] = temp1, temp1 += 3;
			else if (temp2 % 3 == 1)
				ans[i] = temp2, temp2 += 1;
			else ans[i] = temp2, temp2 += 2;
		}
		for (int i = 1; i <= n; i++) {
			if (!ans[i])
				ans[i] = temp1, temp1 += 3;
		}
	} else {
		int temp1 = 1, temp2 = 2, temp3 = 3;
		for (int i = 1; i <= n && temp1 <= n; i++) {
			if (color[i] == col)
				ans[i] = temp1, temp1 += 3;
		}
		for (int i = 1; i <= n && temp2 <= n; i++) {
			if (color[i] != col)
				ans[i] = temp2, temp2 += 3;
		}
		for (int i = 1; i <= n; i++) {
			if (!ans[i]) ans[i] = temp3, temp3 += 3;
		}
	}
	for (int i = 1; i <= n; i++)
		cout << ans[i] << ' ';
}

Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
string s;int n;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>s;
    int a=0,b=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')a++;
        else b++;
    }
    if(a>b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a); i > (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		long double a,b=6.28318530717958623200;
		cin>>a;
		cout<<fixed<<setprecision(10);
		cout<<a*b;
	}
	return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
const int N = 1e5 + 5;
 
int n, m, k;
int x11, y11, x2, y2;
int dx[4]={-1, +1, 0, 0};
int dy[4]={0, 0, +1, -1};
vector<vector<char> > a;
vector<vector<int> > vis, ways, dist;
 
void bfs(int x, int y)
{
	queue<pair<int, int> > q;
	q.push({x, y});
	vis[x][y] = 1;
	dist[x][y] = 0;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int dir=0;dir<4;dir++)
		{
			for(int len = 1; len <= k; len++)
			{
				int nx=x+dx[dir] * len;
				int ny=y+dy[dir] * len;
				if(nx<1 || ny<1 || nx>n || ny>m)
					break;
				if(vis[nx][ny] && dist[x][y] + 1 > dist[nx][ny])
					break;
				if(a[nx][ny] == '@')
					break;
				if(vis[nx][ny])
					continue;
				dist[nx][ny]=dist[x][y]+1;
				vis[nx][ny]=1;
				q.push({nx, ny});
			}
		}
	}
}
 
int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	cin >> x11 >> y11 >> x2 >> y2;
	a = vector<vector<char> > (n + 1, vector<char> (m + 1));
	vis = ways = dist = vector<vector<int> > (n + 1, vector<int> (m + 1, 0));
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> a[i][j];
	bfs(x11, y11);
	if(!vis[x2][y2])
		cout << -1;
	else
		cout << dist[x2][y2];
	return 0;
}

Measured memory_bytes: 32520
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=998244353;
typedef map<LL,LL>::iterator Itr;
/*ここから*/
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*ここまで*/

int main()
{ 

    // 前処理
    COMinit();
    string s;
    cin>>s;
    LL K;
    cin>>K;
    LL n=s.size();
    LL n0=0;
    for(int i=0;i<n;i++){
        if(s[i]=='0'){n0++;}
    }
    if(n0==0){cout<<1<<endl;return 0;}
    LL n1[n0];
    LL n1_l=0;
    LL dp2[310][310];
    LL dp[310][310];
    for(int k=0;k<310;k++){
        for(int i=0;i<310;i++){
                dp[k][i]=0;
        }
    }
    LL cnt1=0;
    LL cnt2=0;
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            cnt1++;
        }
        else{
            n1[cnt2]=cnt1;
            cnt1=0;
            cnt2++;
        }
    }
    n1_l=cnt1;
    for(int i=0;i<n0;i++){
        for(int k=0;k<310;k++){
            LL sum=0;
            for(int j=309;j>=0;j--){
                dp2[j][k]=dp[j][k];
                sum=(sum+dp[j][k])%MOD;
                dp[j][k]=sum;
            }
        }
        if(i==0){
            for(int j=0;j<=n1_l;j++){
                dp[j][j]=1;
            }
        }
        else{
            for(int j=0;j<310;j++){
                for(int k=0;k<310;k++){
                    for(int l=0;l<=n1[n0-i];l++){
                        if(l==0){}
                        else{
                            if(j+l<310&&k+l<310){
                                dp[j+l][k+l]=(dp[j+l][k+l]+dp2[j][k])%MOD;
                            }
                        }
                    }
                }
            }
        }
        /*for(int j=0;j<6;j++){
            for(int k=0;k<6;k++){
                cout<<dp[j][k]<<' ';
            }
            cout<<endl;
        }
        cout<<endl;*/
    }
    LL ans=0;
    if(K>305){K=305;}
    for(int i=0;i<=K;i++){
        for(int j=0;j<310;j++)
        ans=(ans+dp[j][i])%MOD;
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 52004
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> L;
  for(int i=0; i<N; i++){
    int l;
    cin >> l;
    L.push_back(l);
  }
  sort(L.begin(), L.end(), greater<int>());
  int ret = 0;
  for(int i=0; i<K; i++)
    ret += L[i];
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, t;
	scanf("%d %d", &n, &t);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int min[100005];
	min[0] = a[0];
	for (i = 1; i < n; i++)
	{
		if (min[i - 1] < a[i])
			min[i] = min[i - 1];
		else
			min[i] = a[i];
	}
	int max = 0;
	for (i = 1; i < n; i++)
		if (max < a[i] - min[i - 1])
			max = a[i] - min[i - 1];
	int ans = 0;
	for (i = 1; i < n; i++)
		if (max == a[i] - min[i - 1])
			ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),H=in();
	vector<pair<int,int>> P(N);
	int MA=0;
	REP(i,N){
		P[i].first=in();
		P[i].second=in();
		MA=max(MA,P[i].first);
	}

	sort(ALL(P),PAIRCOMP(second,>));

	int skip_index=-1,minB;
	REP(i,N){
		if(P[i].first==MA){
			if(skip_index==-1){
				skip_index=i;
				minB=P[i].second;
			}
			else if(P[i].second<=minB){
				skip_index=i;
				minB=P[i].second;
			}
		}
	}

	int num=0;
	REP(i,N){
		if(skip_index!=i && P[i].second>=MA){
			H-=P[i].second;
			num++;
			if(H<=0){
				out(num);
				return 0;
			}
		}
		if(P[i].second<MA) break;
	}

	if(P[skip_index].first<P[skip_index].second){
		H -= P[skip_index].second;
		num++;
		num += ceil((double)H/P[skip_index].first);
	}
	else{
		num += ceil((double)H/P[skip_index].first);
	}

	out(num);
	return 0;
}


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

int main(void)
{
    int N,a,b,imin = 10000000,sum;
    cin >> N;

    for(int i = 1;i < N;i++){
        sum = 0;
        a = i;
        b = N-i;
        while(a > 0){
            sum += a%10;
            a /= 10;
        }
        while(b > 0){
            sum += b%10;
            b /= 10;
        }

        imin = min(imin,sum);

    }

    cout << imin << endl;

    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

ll V;
vector<vector<ll>> G;
vector<ll> match;
vector<int> used;

void add_edge(ll u, ll v) {
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(ll v) {
	used[v] = 1;
	for (int i = 0; i < G[v].size(); i++) {
		ll u = G[v][i], w = match[u];
		if (w < 0 || ((used[w] == 0) && dfs(w))) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

ll bipartite_matching() {
	ll res = 0;
	for (int i = 0; i < (int)match.size();i++)match[i] = -1;
	for (int v = 0;v < V;v++) {
		if (match[v] < 0) {
			for (int i = 0; i < (int)used.size();i++)used[i] = 0;
			if (dfs(v))res++;
		}
	}
	return res;
}

/* use example */
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll X, Y, E; cin >> X >> Y >> E;
	V = X + Y + 1; // initialize V [0..index]
	G.resize(V); used.resize(V); match.resize(V); // initialize G used match
	for (int i = 0; i < E;i++) {
		ll x, y; cin >> x >> y;
		add_edge(x, y + X);
	}
	cout << bipartite_matching() << endl;
	return 0;
}



Measured memory_bytes: 3336
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

ll n;
ll a[200000];
ll k;

ll gcd(int n,int m){
    if(n < m)
        swap(n,m);
    if(n % m == 0)
        return m;
    return gcd(m,n % m);
}

int main(){
    scanf("%lld%lld",&n,&k);
    REP(i,n){
        scanf("%lld",&a[i]);
    }

    REP(i,n){
        if(k == a[i]){
            printf("POSSIBLE\n");
            return 0;
        }
    }
    if(n == 1){
        printf("IMPOSSIBLE\n");
        return 0;
    }
    ll maxi = 0;
    REP(i,n){
        if(a[i] > maxi)
            maxi = a[i];
    }
    if(k > maxi){
        printf("IMPOSSIBLE\n");
        return 0;
    }
    ll g = a[0];
    FOR(i,1,n)
        g = gcd(g,a[i]);
    if(k % g == 0)
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}



Measured memory_bytes: 1024