akhauriyash/Code-Regression huggingface dataset:
#ifdef __GNUC__ 
#include <bits/stdc++.h>
auto & in = std::cin;
#else
std::istringstream in;
#endif
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/dynamic_bitset.hpp>
using namespace std;
#define ALL(v) std::begin(v),std::end(v)
using u6 = std::uint64_t;
using u3 = std::uint32_t;
constexpr u6 moduloNo = 1'000'000'000+7; //'

struct State {
	array<u3, 3> buf;
	//State() :buf{ 1,0,1 } {}
	State() {}
	State(u3 zerocount) :buf{ 1,0,zerocount } { addX(zerocount); }
	void addX(u3 zero) {
		if (zero != buf[2]){
			u6 zerodiff = zero - buf[2];
			buf[0] = (u3)(((u6)buf[0] + zerodiff * buf[1])%moduloNo);
			buf[2] = zero;

		}
		
		buf[1] = buf[0]+buf[1];
		buf[1] = (buf[1] >= moduloNo) ?buf[1] - moduloNo: buf[1];
	}
};
u6 pow2(u6 n) {
	if (n < 64)return (u6(1) << n)% moduloNo;
	else if (n == 64)return (u6(0) - moduloNo) % moduloNo;
	u6 tmp = pow2(n / 2);
	tmp=tmp * tmp;
	if (n & 1)tmp *= 2;
	return tmp % moduloNo;
}

struct Calc {
	u6 N;
	
	unordered_map<u3, State> stmap;
	Calc() {
		in >> N;
	}
	u6 calc() {
		u3 st = 0;
		u3 tmp;
		u3 zerocount = 0;
		for (u3 index = 0; index < N; ++index) {
			in >> tmp;
			st ^= tmp;
			if (!st) {
				++zerocount;
				//cout << index << endl;
			}
			else {
				auto ite = stmap.find(st);
				if (ite == stmap.end()) {
					stmap.emplace(st, zerocount);
				}
				else {					
					ite->second.addX(zerocount);
				}
			}
		}
		if (st != 0) {
			return stmap[st].buf[0];
		}
		else {
			u6 result = pow2(zerocount-1);
			for (auto & stv: stmap) {
				result = (result + stv.second.buf[1])%moduloNo;
			}
			
			/*u6 sum0 = 0, sum1 = 0;
			for (auto & stv : stmap) {
				cout << stv.second.buf[0] << " " << stv.second.buf[1]  <<  " " << stv.second.buf[2] << endl;
				sum0 += stv.second.buf[0];
				sum1 += stv.second.buf[1];
			}
			cout << sum0 << " " << sum1 << endl;*/
			return result;
		}
	}
};

int main() {

#ifndef __GNUC__ 
	in.str("32\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0");
#endif
	Calc calc;

	cout << calc.calc() << endl;
	/*
	u6 i = 0; u6 maxnum = 0;
	for (auto & v : tbl.buf) {
		for (auto n : v.buf) {
			if (n > maxnum)maxnum = n;
		}
	}
	cout << maxnum << endl;
	for (auto & v : tbl.buf) {
		cout << i << "=" << v << endl;
		++i;
	}
	cout << maxnum << endl;*/
}


Measured memory_bytes: 14280
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, m;
int a[15], used[15], res;
char s[15][15];
void f(int cur) {
	if(cur == n + 1) {
		bool usedMiddle = 0;
		for(int i=1; i<=m; i++) used[i] = 0;
		for(int i=1; i<=m; i++) {
			if(used[i]) continue;
			bool found = 0;
			for(int j=i+1; j<=m; j++) {
				if(used[j]) continue;
				bool flag = 1;
				for(int k=1; k<=n; k++)
					if(s[k][i] != s[a[k]][j] || s[a[k]][i] != s[k][j])
						{ flag = 0; break; }
				if(flag) {
					used[i] = used[j] = 1;
					found = 1;
					break;
				}
			}
			if(!found) {
				if(m % 2 == 0) return;
				if(usedMiddle) return;
				bool flag = 1;
				for(int k=1; k<=n; k++)
					if(s[k][i] != s[a[k]][i])
						{ flag = 0; break; }
				if(!flag) return;
				used[i] = 1;
				usedMiddle = 1;
			}
		}
		res = 1;
		return;
	}
	if(a[cur] != 0) {
		f(cur + 1);
		return;
	}
	for(int i=cur+1; i<=n; i++) {
		if(a[i] != 0) continue;
		a[cur] = i;
		a[i] = cur;
		f(cur + 1);
		a[cur] = a[i] = 0;
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++)
		scanf("%s", &s[i][1]);
	if(n & 1) {
		for(int i=1; i<=n; i++) {
			a[i] = i;
			f(1);
			a[i] = 0;
		}
	} else f(1);
	puts(res ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
// C Program to convert decimal to any given base 
#include <stdio.h> 
#include <string.h> 
#include<bits/stdc++.h>
using namespace std;
// To return char for a value. For example '2' 
// is returned for 2. 'A' is returned for 10. 'B' 
// for 11 
char reVal(int num) 
{ 
	if (num >= 0 && num <= 9) 
		return (char)(num + '0'); 
	else
		return (char)(num - 10 + 'A'); 
} 

// Utility function to reverse a string 
void strev(char *str) 
{ 
	int len = strlen(str); 
	int i; 
	for (i = 0; i < len/2; i++) 
	{ 
		char temp = str[i]; 
		str[i] = str[len-i-1]; 
		str[len-i-1] = temp; 
	} 
} 

// Function to convert a given decimal number 
// to a base 'base' and 
char* fromDeci(char res[], int base, int inputNum) 
{ 
	int index = 0; // Initialize index of result 

	// Convert input number is given base by repeatedly 
	// dividing it by base and taking remainder 
	while (inputNum > 0) 
	{ 
		res[index++] = reVal(inputNum % base); 
		inputNum /= base; 
	} 
	res[index] = '\0'; 

	// Reverse the result 
	strev(res); 

	return res; 
} 

// Driver program 
int main() 
{ 
	int n, b;
	cin >> n >> b;
	
	char res[500];
	string s = fromDeci(res, b, n);
	cout << s.size() << '\n';

	return 0; 
} 


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int P[100100];
    int _P[100010];
    rep(i, N) cin >> P[i];
    rep(i, N) _P[P[i]] = i + 1;
    multiset<int> S, T;
    S.insert(0); S.insert(0);
    T.insert(N + 1); T.insert(N + 1);
    int ans = 0;
    RREP(i, N, 1) {
        auto itr1 = T.upper_bound(_P[i]);
        int y = *itr1;
        int z = *(++itr1);

        auto itr2 = S.lower_bound(_P[i]);
        int x = *(--itr2);
        int w = *(--itr2);
        S.insert(_P[i]);
        T.insert(_P[i]);

        ans += (x - w) * (y - _P[i]) * i;
        ans += (_P[i] - x) * (z - y) * i;
        //cout << w <<  " " << x << " " << _P[i] << " " << y << " " << z << " " << ans << endl;
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 12416
#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N = int(input())
B = [int(x) for x in input().split()]

can_solve = True
ans = []
for _i in range(N):
    #print(B)
    for i in range(len(B)-1,-1,-1):
        b = B[i]
        if i + 1 == b:
            B.pop(i)
            ans.insert(0, b)
            break
    else:
        can_solve = False
        break
if can_solve:
    print("\n".join(map(str,ans)))
else:
    print(-1)

Measured memory_bytes: 23704
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

struct Point {
    double x, y;
    Point(double x = 0, double y = 0) : x(x), y(y) {}
    Point operator+(const Point &p) { return Point{x + p.x, y + p.y}; }
    Point operator-(const Point &p) { return Point{x - p.x, y - p.y}; }
    Point operator*(const double k) { return Point{x * k, y * k}; }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }
};

typedef Point Vector;
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

struct Segment {
    Point p1, p2;
};

typedef Segment Line;
bool isOrthogonal(Line l1, Line l2) {
    return dot(l1.p2 - l1.p1, l2.p2 - l2.p1) == 0;
}
bool isParallel(Line l1, Line l2) {
    return cross(l1.p2 - l1.p1, l2.p2 - l2.p1) == 0;
}
Point project(Line l, Point p) {
    Vector base = l.p2 - l.p1;
    double r = dot(p - l.p1, base) / base.norm();
    return l.p1 + base * r;
}
Point reflect(Line l, Point p) { return p + (project(l, p) - p) * 2.0; }

struct Circle {
    Point c;
    double r;
    Circle(Point c = Point(), double r = 0) : c(c), r(r) {}
};

typedef vector<Point> Polygon;

int main() {
    Line l;
    cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y;
    int n;
    cin >> n;
    while(n--) {
        Point p;
        cin >> p.x >> p.y;
        Point ret = reflect(l, p);
        printf("%.10f %.10f\n", ret.x, ret.y);
    }
}


Measured memory_bytes: 3292
#include<iostream>
#include<algorithm>
#include<map>
const long long MOD=1e9+7;


long long modpow(long long a, long long n){
  long long r = 1;
  while (n) {
    r = r * ( (n%2)?a:1 ) %MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return r;
}
 
int main(){
  int N;
  std::cin>>N;
  long long A[N];
  for(int i=0;i<N;i++) std::cin>>A[i];
  std::map<int,int> mpL;
  for(int i=0;i<N;i++){
    long long tmp=A[i];
    std::map<int,int> mpA;
    for(int j=2;j*j<=tmp;j++){
      while(tmp%j==0&&tmp>1){
        mpA[j]++;
        tmp/=j;
      }
    }
    if(tmp>1) mpA[tmp]++;
    for(auto& m:mpA)
      mpL[m.first]=std::max(mpL[m.first],m.second);
  }
  long long LCM=1;
  for(auto& m:mpL) (LCM*=modpow(m.first,m.second))%=MOD;
  long long ans=0;
  for(int i=0;i<N;i++){
    (ans+=LCM*modpow(A[i],MOD-2)%MOD)%=MOD;
  }
  std::cout<<ans<<std::endl;
  return 0;
}

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

using namespace std;

int main() {
	int T, X;
	cin >> T >> X;
	double time = T * 1.0 / X;
	cout << fixed << setprecision(3) << time << endl;
	return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> cake(h);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c;
            cin >> c;
            if(c == '#'){
                cake[i].push_back(j + 1);
            }
        }
    }
    int cnt = 1;
    vector<vector<int>> ans(h, vector<int>(w, 0));
    vector<bool> emp(h, true);
    for(int i = 0; i < h; i++){
        int p = 0;
        for(auto&& j : cake[i]){
            for(int k = p; k < j; k++){
                ans[i][k] = cnt;
            }
            cnt++;
            p = j;
            emp[i] = false;
        }
        if(cake.size() && p <= w - 1){
            for(int k = p; k < w; k++){
                ans[i][k] = ans[i][k - 1];
            }
        }
    }
    for(int i = 1; i < h; i++){
        if(emp[i]){
            ans[i] = ans[i - 1];
        }
    }
    for(int i = h - 2; i >= 0; i--){
        if(emp[i]){
            ans[i] = ans[i + 1];
        }
    }
    for(auto&& i : ans){
        cout << i[0];
        for(int j = 1; j < w; j++){
            cout << " " << i[j];
        }
        cout << "\n";
    }
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;
 
int main() {
	int N;
	scanf("%d", &N);
	int best = 0;
	int *H = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", H + i);
	}
	int c = 0;
	for (int i = 0; i < N - 1; i++) {
		if (H[i] >= H[i + 1])c++;
		else {
			if (best < c) {
				best = c;
			}
				c = 0;
		}
	}
	if (best < c)best = c;
	printf("%d", best);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    int m, f, r;
    while(1){
        cin >> m;
        cin >> f;
        cin >> r;
        if ( ( m == -1 ) && ( f == -1 ) && ( r == -1 ) ) {
            break;
        }

        if ( m == -1 or f == -1 ) {
            cout << 'F' << endl;
        } else if ( m + f >= 80 ) {
            cout << 'A' << endl;
        } else if ( m + f >= 65 ) {
            cout << 'B' << endl;
        } else if ( m + f >= 50 ) {
            cout << 'C' << endl;
        } else if ( m + f >= 30) {
            if ( r >= 50 ) {
                cout << 'C' << endl;
            } else {
                cout << 'D' << endl;
            }
        } else {
            cout << 'F' << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define forit(it, st) for(auto it : st)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
void solve(){
	int a, b;
	cin >> a >> b;
	cout << (days[a] == b ? 1 : 0);
}	

 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}


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

int main() {
  int a,b,c,d,e;cin >> a >> b >> c;
  d = b - a;
  e = c - b;
  if(d==e){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
from collections import deque
n,k=map(int,input().split())
if n==1 and k==1:
    print(1)
    exit()
if k==1:
    print(0)
    exit()
g=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
mod=10**9+7
ans=k
q=deque([0])
v=[0]*n
v[0]=1
vc=1
while q and vc<n:
    s=q.popleft()
    c=0
    if s==0:
        kai=k-1
    else:
        kai=k-2
    for es in g[s]:
        if v[es]==0:
            v[es]=1
            vc+=1
            c+=1
            q.append(es)
            ans*=kai
            ans%=mod
            kai-=1
print(ans%mod)


Measured memory_bytes: 25112
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
int read(){
    int s = 0,ne = 1; char c = getchar();
    while(c < '0' || c > '9') ne = c == '-' ? -1 : 1, c = getchar();
    while(c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - '0', c = getchar();
    return s * ne;
}
int n, a[81], f[81];
signed main()
{
    // freopen("_in.in", "r", stdin);
    n = read(); for(int i = 1; i <= n; i++) a[i] = read();
    f[1] = 1000;
    for(int i = 2; i <= n; i++){
        f[i] = f[i - 1];
        for(int j = 1; j < i; j++) f[i] = max(f[i], f[j] + (f[j] / a[j]) * (a[i] - a[j]));
    }    
    printf("%lld", f[n]);
}

Measured memory_bytes: 3720
using System;

namespace OnlineJudge
{
    class ITP1_2_B
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            if (str.Length < 3)
                return;
            var a = int.Parse(str[0]);
            var b = int.Parse(str[1]);
            var c = int.Parse(str[2]);

            Console.WriteLine(a < b && b < c ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 8868
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    REP(i, N)cin >> m[i];
    sort(ALL(m));
    int ans = 0;
    REP(i, N) {
        ans++;
        X -= m[i];
    }
    ans += X / m[0];
    cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
//MohK
//22/02/2020 ..... 2,5.
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b;
    cin>>a>>b;
    if(a>=10)cout<<b<<endl;
    else {
        ll c=100*(10-a);
        ll d=b+c;
        cout<<d<<endl;
    }

    return 0;
}




Measured memory_bytes: 256
def solve(X):
    N = len(X)
    X = sorted((x,i) for i,x in enumerate(X, start=1))
    L = N**2
    res = [-1]*L
    i = 0
    for x,n in X:
        r = n-1
        while r > 0 and i < x:
            if res[i] < 0:
                res[i] = n
                r -= 1
            i += 1
        if res[x] > 0 or r > 0:
            return None
        else:
            res[x] = n
    i = L
    for x,n in reversed(X):
        r = N-n
        while r > 0 and i > x:
            if res[i-1] < 0:
                res[i-1] = n
                r -= 1
            i -= 1
        if r > 0:
            return None

    return res

from itertools import permutations

def naive(X):
    N = len(X)
    for a in permutations(list(range(N))*N):

        for i,x in enumerate(X):
            if not (a[x] == i and sum(v==i for v in a[:x]) == i):
                break
        else:
            return [v+1 for v in a]
    return None

from random import shuffle

if __name__ == '__main__':

    # N = 3
    # for _ in range(1000):
    #     X = list(range(N**2))
    #     shuffle(X)
    #     X = X[:N]

    #     r1 = solve(X)
    #     r2 = naive(X)
    #     if (r1 is None) != (r2 is None):
    #         print(X)
    #         print(r1)
    #         print(r2)
    #         break

    N = int(input())
    X = [int(x)-1 for x in input().split()]
    r = solve(X)
    if r is None:
        print('No')
    else:
        print('Yes')
        print(*r)


Measured memory_bytes: 95044
def solve(a,b,c):
    scores = [int(input()) for i in range(a)]
    gap = scores[b-1] - scores[b]
    tmpans = b-1
    for i in range(b-1,c):
        tmpgap = scores[i] - scores[i+1]
        if gap <= tmpgap:
            tmpans = i
            gap = tmpgap
    print(tmpans+1)
while True:
    a,b,c = map(int,input().split())
    if a == b == c and a == 0:
        exit()
    else:
        solve(a,b,c)


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));

    // 
    int ok = 0, ng = 1e9;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        ll cnt = 0;
        rep(i, N) {
            cnt += A.end() - lower_bound(all(A), mid - A[i]);
        }
        (cnt >= M ? ok : ng) = mid;
    }

    ll ans = 0, cnt = 0;
    vector<ll> sums(N+1);
    rep(i, N) sums[i+1] = sums[i] + A[i];
    rep(i, N) {
        int x = upper_bound(all(A), ok - A[i]) - A.begin();
        ans += (N - x) * A[i] + sums[N] - sums[x];
        cnt += N - x;
    }
    ans += (M - cnt) * ok;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll n,a;
    cin >> n >> a;
    ll z = 0;
    vector<ll> p;
    vector<ll> m;
    for (int i = 0; i < n; i++) {
        ll h;
        cin >> h;
        h -= a;
        if (h == 0)z++;
        else if (h > 0)p.push_back(h);
        else m.push_back(h * -1);
    }
    vector<ll> pdp(3000);
    pdp.at(0) = 1;
    vector<ll> mdp(3000);
    mdp.at(0) = 1;
    for (int i = 0; i < p.size(); i++) {
        for (int j = 2600; j >= 0; j--) {
            pdp.at(j + p.at(i)) += pdp.at(j);
        }
    }
    for (int i = 0; i < m.size(); i++) {
        for (int j = 2600; j >= 0; j--) {
            mdp.at(j + m.at(i)) += mdp.at(j);
        }
    }
    ll ans = 0;
    for (int i = 0; i < 2600; i++) {
        ans += pdp.at(i) * mdp.at(i);
    }
    for (int i = 0; i < z; i++) {
        ans *= 2;
    }
    ans--;
    cout << ans << endl;
}

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


int main(void){
  
	double d, t, s;
  	cin>>d>>t>>s;
  
    if(d/s<=t){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
  
	
}

Measured memory_bytes: 3688
#include <iostream>
#include <queue>
#define ll long long
using namespace std;

ll a[110];

int main() {
	int Q;
	cin >> Q;
	ll sum=0, smallSum=0, largeSum=0;
	ll cnt=0;
	priority_queue<ll> small;
	priority_queue<ll, vector<ll>, greater<ll>> large;
	for(int t=0; t<Q; ++t){
		int dum;
		cin >> dum;
		if(dum==1){
			ll a, b;
			cin >> a >> b;
			sum += b;
			if(cnt==0){
				smallSum=a;
				small.push(a);
			}
			else if(cnt%2==0){
				if(a<=large.top()){
					smallSum += a;
					small.push(a);
				}else{
					smallSum += large.top();
					largeSum += a-large.top();
					small.push(large.top());
					large.pop();
					large.push(a);
				}
			}else{
				if(small.top()<=a){
					largeSum += a;
					large.push(a);
				}else{
					largeSum += small.top();
					smallSum += a-small.top();
					large.push(small.top());
					small.pop();
					small.push(a);
				}
			}
			++cnt;
		}else{
			ll half=(cnt+1)/2;
			ll ans=sum+(small.top()*half-smallSum)+(largeSum-small.top()*(cnt-half));
			cout << small.top() << ' ' << ans << endl;
		}
	}
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

ll da[300001],db[300001],v[300001];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  rep(i,3*N){
    cin >> v[i];
  }
  priority_queue<ll,vector<ll>,greater<ll>> a;
  ll A = 0,B = 0;
  rep(i, N * 2){
    A += v[i];
    a.push(v[i]);
    if(i >= N){
      ll k = a.top(); a.pop();
      A -= k;
    }
    if(i >= N -1){
      da[i] = A;
    }
  }
  priority_queue<ll> b;
  for(int i = 3*N - 1; i >= N; i--){
    B += v[i];
    b.push(v[i]);
    if(i < 2 * N){
      ll k = b.top(); b.pop();
      B -= k;
    }
    if(i <= 2 * N){
      db[i] = B;
    }
  }
  ll ans = -10e17;
  for(int i = N - 1; i < 2 * N; i++){
    /* cout << da[i] << ' ' << db[i+1] << endl; */
    ans = max(ans,da[i]-db[i+1]) ;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8820
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  double a, b, x;
  cin >> a >> b >> x;

  double th = a*a*b/2.0;  

  double ans;
  if(x <= th){
    ans = atan(a*b*b/x/2.0);
  } else {
    ans = atan(2.0/a*(b - x/(a*a)));
  }
  ans *= 180.0/M_PI;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4096
n = int(input())

a = round(n / 1.08)
flag = 0
ans = 0
for i in range(a-2, a+3):
    if i + int(i * 0.08) == n:
        ans = i
        flag = 1
        break

if n < 13:
    print(n)
elif flag:
    print(ans)
else:
    print(':(')

Measured memory_bytes: 3064
N,M=list(map(int,input().split()))
kslst=[list(map(int,input().split())) for _ in range(M)]
p=list(map(int,input().split()))

mbit=[0]*M
allon=2**M-1

ret=0

for i,ks in enumerate(kslst):
    k=ks[0]
    for j in range(1,k+1):
        mbit[i]+=2**(ks[j]-1)

for i in range(2**N):
    cstate=0
    for j in range(M):
        cnt=0
        for k in range(N):
            if (i>>k)&1==1 and (mbit[j]>>k)&1==1:
                cnt+=1
        
        cstate+=2**j if cnt%2==p[j] else 0
    
    if cstate&allon==allon:
        ret+=1

print(ret)

Measured memory_bytes: 42480
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b;
	long long maxx,minn;
	cin>>n>>a>>b;
	maxx=a+b*(n-1),minn=b+a*(n-1);
	if(a>b)
	{
		printf("0\n");
		return 0;
	}
	if(n==1)
	{
		if(a==b)
		{
			puts("1");
			return 0;
		}
		puts("0");
		return 0;
	}
	printf("%lld\n",maxx-minn+1);
	return 0;
}

Measured memory_bytes: 256
while True:
  n, x = map(int, [_ for _ in input().split()])
  cnt = 0
  if n == x == 0:
    break

  for n1 in range(1, n+1):
    for n2 in range(n1+1, n+1):
      for n3 in range(n2+1, n+1):
        if n1 != n2 and n2 != n3 and n3 != n1:
          if n1+n2+n3 == x:
            cnt += 1

  print(cnt)

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

int main()
{
    fastio;
    string s;
    cin>>s;
    int n=s.length();
    vi ans(n,0);

    for(int i=0;i<n;){
        if(s[i]=='L')i++;
        else{
            int j;
            int c1=0,c2=0;
            while(i<n && s[i]=='R')c1++,i++;
            j=i-1;
            while(i<n && s[i]=='L')c2++,i++;

            if(c1 && c2){
                int t=c1/2;
                ans[j+1]+=t;
                c1-=t;
                ans[j]+=c1;

                t=c2/2;
                ans[j]+=t;
                c2-=t;
                ans[j+1]+=c2;
            }
        }
    }

    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    nl;
}

Measured memory_bytes: 1104
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
l=[list() for i in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    l[a-1].append((b-1,c))
    l[b-1].append((a-1,c))
Q,K=map(int,input().split())
L=[None]*N
L[K-1]=0
t=1
s={K-1}
while t<N:
    g=set()
    for i in s:
        for j in l[i]:
            if L[j[0]]==None:
                L[j[0]]=L[i]+j[1]
                g.add(j[0])
                t+=1
    s=g
for _ in range(Q):
    x,y=map(int,input().split())
    print(L[x-1]+L[y-1])

Measured memory_bytes: 44452
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
   int h,w;
   cin>>h>>w;
   vector<string> vs(h);
   for(auto&s:vs)cin>>s;
   
   queue<pair<int,int>> q;
   q.push({0,0});
   vector<vector<int>> dist(h,vector<int>(w,-1));
   dist[0][0]=0;
   while(q.size()){
       auto p=q.front();
       q.pop();
       int x=p.first, y=p.second;
       for(int i=max(0,x-1); i<=min(h-1, x+1); i++){
           for(int j=max(0,y-1); j<=min(w-1, y+1); j++){
               if((i==x || j==y) && dist[i][j]==-1 && vs[i][j]=='.'){
                   dist[i][j]=dist[x][y]+1;
                   q.push({i,j});
               }
           }
       }
   }
   
   //cout<<dist[h-1][w-1]<<endl;
    if(dist[h-1][w-1]==-1){
        cout<<-1;
        return 0;
    }
    int wct=0;
    for(auto s:vs){
        for(char ch:s) wct+=ch=='.';
    }
    
    cout<<wct-dist[h-1][w-1]-1;
   
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  string s;
  vi a(26);
  while (getline(cin, s)) {
    int x = 0;
    for (auto &c : s) {
      if (isalpha(c)) a[tolower(c) - 'a']++;
    }
  }
  rep(i, a.size()) cout << char(i + 'a') << " : " << a[i] << endl;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N;
  cin>>N;
  vector<string> W(N);
  for(int i=0;i<N;i++){
    cin>>W.at(i);
  }

  bool flag=true;
  for(int i=1;i<N;i++){
    if(W.at(i-1).at(W.at(i-1).size()-1)!=W.at(i).at(0)){
      flag=false;
      break;
    }
    for(int j=0;j<i;j++){
      if(W.at(i)==W.at(j)){
        flag=false;
        break;
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main()
 {
 	int n,a,b;
 	cin>>n;
 	if(n%1000==0)
 		b=0;
 	else
 	{
	 
	 
 	a=n%1000;
 	b=1000-a;
 }
 	cout<<b<<endl;
	 
 	return 0;
}
 	
 					

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

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

using namespace std;

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

ll n,a,b,c,d;


int main()
{
	cin >> n >> a >> b >> c >> d;
	
	int xl = 0,xr = 0;
	ll fi = a;
	REP(i,n-1)
	{
		if(a < b){a += c;xr++;}
		else {a -= c;xl++;}
	}
	
	ll r,l;
	r = a + (d-c)*xr;
	l = a - (d-c)*xl;
	
	
	//cout << l << ' ' << r << endl;
	cout << ((b <= r && b >= l)?"YES":"NO") << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int a,b,sum=0;
	cin>>a;
	f(i,a){
		cin>>b;
		sum+=b;
	}
	cout<<sum-a*(a+1)/2<<endl;
}




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

int main() {
  int H, W;
  cin >> H >> W;
  string edge;
  for (int i = 0; i < W+2; i++) {
    edge += "#";
  }
  cout << edge << endl;
  for (int i = 0; i < H; i++) {
    string r;
    cin >> r;
    string R = "#";
    for (int k =0; k < W; k++) {
      R += r.at(k);
    }
    R += "#";
    cout << R << endl;
  }
  cout << edge <<endl;
}


Measured memory_bytes: 256
import math
a,x = 0,0
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int,input().split()))
    for i in s:
        a += i
    h = a/n
    for i in s:
        x += (i-h)**2
    print(math.sqrt(x/n))
    a,x = 0,0
    


Measured memory_bytes: 5700
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 200000 + 9;
ll n,q,mod = 998244353,sum[N];

ll val[N*5],laz[N*5];
void lazy(int p,int s,int e)
{
    int mid = (s+e)/2;
    val[p*2]=((sum[mid] - sum[s-1]) % mod  * laz[p]) % mod;
    laz[p*2]=laz[p];
    val[p*2+1]=((sum[e] - sum[mid]) % mod  * laz[p]) % mod;
    laz[p*2+1]=laz[p];
    laz[p]=0;
}
void up(int s,int e,int p,int l,int r,ll v)
{
    if(s>=l&&e<=r)
    {
        val[p]=((sum[e] - sum[s-1]) % mod  * v) % mod;
        laz[p]=v;
        return;
    }
    int mid=(s+e)/2;
    if(laz[p])lazy(p,s,e);

    if(r<=mid) up(s,mid,p*2,l,r,v);
    else if(l>mid) up(mid+1,e,p*2+1,l,r,v);
    else
    {
        up(s,mid,p*2,l,r,v);
        up(mid+1,e,p*2+1,l,r,v);
    }
    val[p]=(val[p*2]+val[p*2+1])%mod;
}

 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>n>>q;

        ll f =1;
        sum[0] = 1;
        forr(i,1,n-1)
        {
            f*=10LL;
            f%=mod;
            sum[i] = (f + sum[i-1]) %mod;
        }

        forr(i,0,n-1)up(0,n-1,1,i,i,1);

        int l,r,d;
        while(q--)
        {
            cin>>l>>r>>d;
            l--,r--;
            int L = n-1-r;
            int R = n-1-l;
            up(0,n-1,1,L,R,d);
            cout<<(val[1]+mod)%mod<<endl;

        }









return 0;
}


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

using namespace std;

#define sp << " " <<

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,w,s=0;
    cin >> n >> w;
    long long d[n],p[n];
    for(int i=0;i<n;i++)
    {
        cin >> d[i] >> p[i];
        s+=p[i];
    }
    long long dp[n+1][s+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=s;j++)
            dp[i][j]=INT_MAX;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=s;j++)
        {
            if(!j)
                dp[i][j]=0;
            else if(!i)
            {

            }
            else if(j>=p[i-1])
            {
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-p[i-1]]+d[i-1]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    for(int i=s;i>=0;i--)
    {
        if(dp[n][i]<=w)
        {
            cout << i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 79232
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double sum = 0;
    double money;
    String s;
    for(int i=0; i<n; i++){
      money = sc.nextDouble();
      s = sc.next();
      if(s.equals("JPY")){
        sum += money;
      }else{
        sum += money*380000.0;
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 24144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		boolean[] d = new boolean[10];
		
		for(int i = 0; i < k; i++) {
			d[sc.nextInt()] = true;
		}
		sc.close();
		
		mainloop:
		for(; n < 99999; n++) {
			for(int i = 1; i <= 10000; i*=10) {
				if(n < i) break;
				int l = (n%(i*10))/i;
				if(d[l]) {
					continue mainloop;
				}
			}
			break;
		}
		
		System.out.println(n);
	}
	
}

Measured memory_bytes: 9556
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    cout << n * n * n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int K,S;
long long ans;
int main(){
    cin>>K>>S;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if(i+j<=S&&S-i-j<=K){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int i, n, m, x, mod1=1000000007;
	cin >> n >> m;
	int ans[n+1];
	for(i=0; i<=n; i+=1)
		ans[i]=1;
	for(i=0; i<m; i+=1)
	{
		cin >> x;
		ans[x]=0;
	}
	for(i=2; i<=n; i+=1)
	{
		if(ans[i]!=0)
			ans[i]=(ans[i-1]+ans[i-2])%mod1;
	}
	cout << ans[n] << endl;
}

Measured memory_bytes: 640
<?php
$result = array();
fscanf(STDIN, "%d %d",$n, $l);
for ($i = 0; $i < $n; $i++) {
  $result[] += $l + $i;
}
$min = abs(min($result));

for ($i = 0; $i < $n; $i++) {
  if(abs($min) > abs($result[$i])){
    $min = $result[$i];
  }
}
echo array_sum($result) - $min,PHP_EOL;

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

typedef long long LL;

const int N=100000,M=200000,INF=1000000000;

int n,m,d[N+9];
struct side{
  int y,next,ans;
}e[M*2+9];
int lin[N+9],cs;

void Ins(int x,int y){e[++cs].y=y;e[cs].next=lin[x];lin[x]=cs;}
void Ins2(int x,int y){Ins(x,y);Ins(y,x);}

void into(){
  scanf("%d%d",&n,&m);
  cs=1;
  for (int i=1;i<=n;++i)
	scanf("%d",&d[i]);
  for (int i=1;i<=m;++i){
	int x,y;
	scanf("%d%d",&x,&y);
	Ins2(x,y);
  }
}

int ans[N+9],vis[N+9];

void Dfs_ans(int k,int c){
  ans[k]=c;
  vis[k]=1;
  for (int i=lin[k];i;i=e[i].next)
	if (!vis[e[i].y]&&e[i].ans) Dfs_ans(e[i].y,c^d[k]==d[e[i].y]);
}

void Get_ans(){
  for (int i=1;i<=n;++i){
	int mn=lin[i];
	for (int j=lin[i];j;j=e[j].next)
	  if (d[e[j].y]<d[e[mn].y]) mn=j;
    if (d[i]<d[e[mn].y]) {ans[0]=-1;return;}
	e[mn].ans=e[mn^1].ans=d[i]==d[e[mn].y]?d[i]:d[i]-d[e[mn].y];
  }
  for (int i=1;i<=n;++i)
	if (!vis[i]) Dfs_ans(i,0);
}

void work(){
  Get_ans();
}

void outo(){
  if (ans[0]==-1) puts("-1");
  else{
	for (int i=1;i<=n;++i)
	  putchar(ans[i]?'B':'W');
	puts("");
	for (int i=2;i<=m<<1;i+=2)
	  printf("%d\n",e[i].ans?e[i].ans:INF);
	puts("");
  }
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 9928
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n=0,k=0,ans=0;
	string s,t;
	cin>>s>>t;
	n=s.length();
	k=t.length();
	ans=k;
	for(int i=0;i<=n-k;i++){
		ll cnt=0;
		for(ll j=0;j<k;j++){
			if(s[i+j]!=t[j]) cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<'\n';
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

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

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[a[i] - 1] == i + 1) {
			cnt++;
		}
	}

	out(cnt / 2);

	return 0;
}

Measured memory_bytes: 640