akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

ll X, Y, Z, K;
vector<ll> A, B, C;

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

  // input
  cin >> X >> Y >> Z >> K;
  A.resize(X);
  for (int i = 0; i < X; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<ll>());
  B.resize(Y);
  for (int i = 0; i < Y; i++) {
    cin >> B[i];
  }
  sort(B.begin(), B.end(), greater<ll>());
  C.resize(Z);
  for (int i = 0; i < Z; i++) {
    cin >> C[i];
  }
  sort(C.begin(), C.end(), greater<ll>());

  // AB
  vector<ll> AB(X * Y);
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      AB[i * Y + j] = A[i] + B[j];
    }
  }
  sort(AB.begin(), AB.end(), greater<ll>());

  // ABC
  ll max_ab = min(K, X * Y);
  vector<ll> ABC(K * Z);
  for (int i = 0; i < max_ab; i++) {
    for (int j = 0; j < Z; j++) {
      ABC[i * Z + j] = AB[i] + C[j];
    }
  }
  sort(ABC.begin(), ABC.end(), greater<ll>());

  // output
  for (int i = 0; i < K; i++) {
    cout << ABC[i] << endl;
  }

  return 0;
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;

    rep(i,5){
        int in;
        cin>>in;
        if(in==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3644
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

long extgcd(long a, long b, ref long x, ref long y) {
    long g = a; x = 1; y = 0;
    if (b != 0) {
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    return g;
}

void main() {
    int a, b; scanf("%d %d\n", &a, &b);
    long x, y; extgcd(a, b, x, y);
    writeln(x, " ", y);
}

Measured memory_bytes: 2432
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>



int main(int argc, char *argv[])
{
	int s,w;
	cin>>s>>w;
	cout<<(w>=s ? "unsafe":"safe")<<endl;
	return 0;
}



Measured memory_bytes: 3636
n=int(input())
S=input()

ans=0
for i in range(1000):
  i=str(i).zfill(3)
  idx=S.find(i[0])
  if idx==-1: continue
  idx=S.find(i[1],idx+1)
  if idx==-1: continue
  idx=S.find(i[2],idx+1)
  if idx==-1: continue
  ans+=1
print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

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

    ans = 1
    N -= K
    ans += (N + K - 2)//(K - 1)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,x; cin>>n>>x;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll ans=0;
    rep(i,n-1){
        if(a[i]+a[i+1]>x){
            ans+=a[i]+a[i+1]-x;
            if(a[i]>x){
                a[i+1]=0;
            }else{
                a[i+1]=x-a[i];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int a, b, h, m; std::cin >> a >> b >> h >> m;
  double m_theta = 6 * m;
  double h_theta = 30 * h + m / 2.0;
  double theta = std::abs(m_theta - h_theta);
  if (theta > 180) theta = 360 - theta;
  double c_squ = a*a + b*b - 2*a*b*std::cos(theta * 3.1415926535897932 / 180.0);
  double c = sqrt(c_squ);

  printf("%.11lf\n", c);
  return 0;
  
}


Measured memory_bytes: 4128
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e17;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

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

//vector<ll>v;
//vector<ll>::iterator it;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll n;
        cin>>n;
        ll a[n+1];
        for(ll x=0; x<=n; x++){
            cin>>a[x];
        }
        ll b[n+1];
        b[n]=a[n];
        for(ll x=n-1; x>=0; x--){
            b[x]=a[x]+b[x+1];
        }
        ll ans=0;
        ll c[n+1];
       c[0]=1;
        //ans+=c[0];
        for(ll x=1; x<=n; x++){
          c[x]=min(b[x],2*(c[x-1]-a[x-1]));
        }
     
      for(ll x=0; x<n+1; x++){
        ans+=c[x];
       if(c[x]<a[x]){
         ans=-1;
         break;
       }
      }
        cout<<ans<<"\n";
        //v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}


Measured memory_bytes: 5984
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

class BinTree {
private:
    vector<vector<int>> adjlist, invlist;
    bool hasParent(int node);
    int getParent(int node);
    bool hasLeftChild(int node);
    bool hasRightChild(int node);
    int getLeftChild(int node);
    int getRightChild(int node);
    
public:
    BinTree(int n);
    void addChild(int parent, int child);
    int getRoot();
    void preorder(int node);
    void inorder(int node);
    void postorder(int node);
};

BinTree::BinTree(int n) {
    REP(i,n) {
        vector<int> v;
        adjlist.push_back(v);
        invlist.push_back(v);
    }
}

void BinTree::addChild(int parent, int child) {
    adjlist[parent].push_back(child);
    if (child != -1) {
        invlist[child].push_back(parent);
    }
}

bool BinTree::hasParent(int node) {
    if (invlist[node].empty()) return false;
    return true;
}

int BinTree::getParent(int node) {
    return invlist[node][0];
}

int BinTree::getRoot() {
    REP(i,invlist.size()) {
        if (invlist[i].size() == 0) return i;
    }
    return -1;
}

bool BinTree::hasLeftChild(int node) {
    if (adjlist[node][0] != -1) return true;
    return false;
}

bool BinTree::hasRightChild(int node) {
    if (adjlist[node][1] != -1) return true;
    return false;
}

int BinTree::getLeftChild(int node) {
    return adjlist[node][0];
}

int BinTree::getRightChild(int node) {
    return adjlist[node][1];
}

void BinTree::preorder(int node) {
    cout << " " << node;
    if (hasLeftChild(node)) {
        preorder(getLeftChild(node));
    }
    if (hasRightChild(node)) {
        preorder(getRightChild(node));
    }
}

void BinTree::inorder(int node) {
    if (hasLeftChild(node)) {
        inorder(getLeftChild(node));
    }
    cout << " " << node;
    if (hasRightChild(node)) {
        inorder(getRightChild(node));
    }
}

void BinTree::postorder(int node) {
    if (hasLeftChild(node)) {
        postorder(getLeftChild(node));
    }
    if (hasRightChild(node)) {
        postorder(getRightChild(node));
    }
    cout << " " << node;
}

int main() {
    int n;
    cin >> n;
    BinTree binTree = BinTree(n);
    REP(i,n) {
        int node, child1, child2;
        cin >> node >> child1 >> child2;
        binTree.addChild(node, child1);
        binTree.addChild(node, child2);
    }
    int root = binTree.getRoot();
    cout << "Preorder" << endl;
    binTree.preorder(root);
    cout << endl << "Inorder" << endl;
    binTree.inorder(root);
    cout << endl << "Postorder" << endl;
    binTree.postorder(root);
    cout << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;
string db("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	while(cin >> n, n){
		vi d(n);
		REP(i, n) cin >> d[i];
		string s;
		cin >> s;
		REP(i, s.size()){
			int j = find(ALL(db), s[i]) - db.begin();
			j = (j + 52 - d[i%n]) % 52;
			putchar(db[j]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

int H, W;
int c[10][10];
int A[210][210];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W;
  rep(i, 0, 10) rep(j, 0, 10) cin >> c[i][j];
  rep(i, 0, H) rep(j, 0, W) cin >> A[i][j];
  rep(k, 0, 10) rep(i, 0, 10) rep(j, 0, 10) {
    c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
  }
  int ans = 0;
  rep(i, 0, H) rep(j, 0, W) if (A[i][j] >= 0) {
    ans += c[A[i][j]][1];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,b[200];
int main() {
  cin>>n; for (int i=1; i<=n-1; ++i) cin>>b[i];
  int ans=b[1]+b[n-1]; //a[1]+a[n]
  for (int i=2; i<=n-1; ++i)
    ans += min(b[i], b[i-1]);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace  std;
typedef long long int ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define filla(a,k,n) memset(a,k,sizeof(a[0])*n)
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
v64 a[100005];
ll dp[100005];
void solve(ll n)
{
	if(dp[n]!=-1)
	{
		return;
	}
	if(a[n].size()==0)
	{
		dp[n]=0;
		return ;
	}
	ll i;
	for(i=0;i<(a[n]).size();i++)
	{
		solve(a[n][i]);
		dp[n]=max(dp[n],dp[a[n][i]]+1);
	}
	return;
}
int main()
{
	ll n,m,k,t,i;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>k>>t;
		(a[k]).pb(t);
	}
	memset(dp,-1,sizeof(dp));
	ll max1=0;
	for(i=1;i<=n;i++)
	{
		solve(i);
		max1=max(max1,dp[i]);
	}
	cout<<max1;



}


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

using namespace std;

typedef long long ll;

#define for(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((int)(x).size())
#define inf          1<<25

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

//typedef vector<int> vi;
//typedef vector<long long> vl;
//typedef vector<double> vd;
//typedef pair<int,int> pii;
//typedef pair<long,long> pll;
//typedef long long ll;

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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a % 2 == 0 || b % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

double calc(int32 water, int32 sugar)
{
    return ((double)sugar/((double)water+(double)sugar))*(double)100;
}
void func(void)
{
//DEBUG_OUT("----\n");
    int32 a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    double max = calc(100, e);

    int32 maxWaterSugar = -1;
    int32 maxSugar = -1;
    double maxNode = -1.0;

    for(int32 i=0; i<=f; i+=100*a){
        for(int32 j=0; j<=f; j+=100*b){
            if(i+j > f){ break; }
            for(int32 k=0; i+j+k<=f; k+=c){
                for(int32 l=0; i+j+k+l<=f; l+=d){
                    double node = calc(i+j, k+l);
                    if(node > max){ break; }
                    if(node > maxNode){
                        maxWaterSugar = i+j+k+l;
                        maxSugar = k+l;
                        maxNode = node;
                    }
                }
            }
        }
    }

    cout << maxWaterSugar << " " << maxSugar << endl;

    return;
}



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

int calc(string &s,int &i){
  int res=0;
  while(1){
    if(isdigit(s[i]))res=s[i++]-'0';
    else if(s[i]=='('){res=calc(s,++i),i++;}
    else if(s[i]=='+')res+=calc(s,++i);
    else if(s[i]=='-')res-=calc(s,++i);
    else break;
  }
  return res;
}

map<string,int> mem[2];
int dfs(string s,int f){
  if(mem[f].count(s))return mem[f][s];

  int j=0,res=calc(s,j),n=s.size(),d=-1;
  for(int i=0;i<n;i++) d+=(s[i]=='+'||s[i]=='-');
  
  for(int i=0,c=0,cnt=0;i<n;i++,cnt++,d--){
    while(1){
      while(s[i]=='('||s[i]==')')c+=(s[i]=='(')-(s[i]==')'),i++;
      if(i>=n||s[i]=='+'||s[i]=='-') break;
      i++;
    }
    if(i>=n||(cnt&&s[i-2]=='(')||(d&&s[i+2]==')'))continue;
    string a=s.substr(0,i),b=s.substr(i+1,n-i-1);
    int t=c,ch=s[i];
    while(t--)a+=')',b='('+b;
    int mxa=dfs(a,0),mna=dfs(a,1);
    int mxb=dfs(b,0),mnb=dfs(b,1);
    if(f==0&&ch=='+') res=max(res, mxa+mxb);
    if(f==0&&ch=='-') res=max(res, mxa-mnb);
    if(f==1&&ch=='+') res=min(res, mna+mnb);
    if(f==1&&ch=='-') res=min(res, mna-mxb);
  }
  return mem[f][s]=res;
}

int main(){
  string S;
  cin>>S;
  cout <<dfs(S,0)<<endl;
  return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ

//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π

using namespace std;

//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//#include "./lib/generic/search.h"

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double th = double(h*60+m)/720 * 2*PI;
    double tm = double(m)/60 *2*PI;
    double xh = a*cos(th), yh = a*sin(th);
    double xm = b*cos(tm), ym = b*sin(tm);
    double dx = xh-xm, dy = yh-ym;
    double ans = sqrt(dx*dx + dy*dy);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
using namespace std;
int n;
int d[51];
int sum=0,ans=0;
main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		scanf("%d",&d[i]);
		sum+=d[i];
	}
	for(int i=1;i<=n;++i)
		ans+=(sum-d[i])*d[i];
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n=kbd.nextInt();
   int[] A= new int[n];
   int[] B= new int[n];
   int a=0;
   if(n%2==0){
   for(int i=0;i<n/2;i++){
     A[i]=kbd.nextInt();
     B[i]=kbd.nextInt();
     if(A[i]%2!=0){
       a++;
   }
 }
}else{
  for(int i=0;i<n/2;i++){
    A[i]=kbd.nextInt();
     B[i]=kbd.nextInt();
    if(A[i]%2!=0){
      a++;
  }
}
     int x=kbd.nextInt();
if(x%2!=0){
  a++;
}
}
 System.out.println(a);
}
}

Measured memory_bytes: 35796
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
map<pair<string,string>,ll> f(string st){
    int n=st.size();
    map<pair<string,string>,ll> res;
    REP(i,1<<n){
        string a,b;
        REP(j,n){
            if(i&(1<<j)){
                a+=st[j];
            }else{
                b+=st[j];
            }
        }
        res[make_pair(a,b)]++;
    }
    return res;
}
int main(){
    int n;
    string st;
    cin>>n>>st;
    string p=st.substr(0,n);
    string q=st.substr(n,n);
    reverse(all(q));
    auto a=f(p);
    auto b=f(q);
    ll ans=0;
    for(auto itr:a){
        ans+=b[itr.fi]*itr.se;
    }
    cout<<ans<<endl;
    return 0;
}

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


int n, m;
int s[5], c[5];

bool check(int x) {
	vector<int> xs;
	if (x == 0) {
		xs.push_back(0);
	}
	else {
		while (x > 0) {
			xs.push_back(x % 10);
			x /= 10;
		}
	}
	
	if (xs.size() != n) return false;
	
	for(int i=0;i<m;i++) {
		if (xs[n-s[i]] != c[i]) return false;
	}
	return true;
}

int main() {
	int i;
	
	cin >> n >> m;
	rep(i, m) { cin >> s[i] >> c[i]; }
	
	rep(i, 1000) {
		if (check(i)) { cout << i << endl; return 0; }
	}
	
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;

const int N = 2e5 + 1;
ll dp[N], a[N];
int n, m;
void solve(){
    cin >> n >> m;
    ll ans = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        dp[i] = a[i];
        ans += a[i];
    }
    for (int i = 1; i <= n - 1; i++){
        
        for (int j = 0; j < n; j++){
            int from = (j - i + n) % n;
            dp[j] = min(dp[j], a[from]);
        }
        ll res = 0;
        for (int j = 0; j < n; j++) res += dp[j];
        res += (m * 1ll * i);
        ans = min(ans, res);
    }
    cout << ans << endl;
    
}   
int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(10);
    //freopen("input.txt", "r", stdin);//freopen("output1.txt", "w", stdout);
    //freopen("icecream.in","r",stdin);// freopen("exam.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 3688
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=true;

      string str;

  cin>>n;

  ll ara[n+2];

  input(ara,n);

  for(i=1; i<n-1; i++)
  {
    vector<ll>v;

      v.eb(ara[i]);
      v.eb(ara[i-1]);
      v.eb(ara[i+1]);

      sort(vll(v));

      if(v[1]==ara[i])ans++;
  }

  cout<<ans<<endl;





}



Measured memory_bytes: 3652
N,W=map(int,input().split())

DP=[[0]*(W+1) for i in range(N+1)]

for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j-w>=0:
            DP[i+1][j]=max(DP[i][j],DP[i][j-w]+v)
        DP[i+1][j]=max(DP[i+1][j],DP[i][j])
print(max(DP[N]))



Measured memory_bytes: 121196
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/ped_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
//#define ordered_set ped<ll , null_type, less<ll>, rb_ped_tag, ped_order_statistics_node_update>

typedef long long ll;


int main()
{
   run;
   ll n;
   string s;
   cin>>s;
   if(s=="MON")
   {
       cout<<6;
   }else if(s=="TUE")
   {
       
       cout<<5;
   }
   else if(s=="WED")
   {
       
       cout<<4;
   }else if(s=="THU")
   {
       
       cout<<3;
   }else if(s=="FRI")
   {
       cout<<2;
   }else if(s=="SAT")
   {
       cout<<1;
   }else{
   cout<<7;}
   

   







    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sides[] = new int[3];
		int rank[] = new int[3];

		for(int i=0;i<N;i++){
			sides[0]=sc.nextInt();
			sides[1]=sc.nextInt();
			sides[2]=sc.nextInt();
			rank[0]=sides[0];
			rank[1]=sides[1];
			rank[2]=sides[2];

			for(int j=0;j<2;j++){
				if(sides[j]<sides[j+1]){
					rank[j]=sides[j+1];
					rank[j+1]=sides[j];
				}
			}
			if(rank[0]<rank[1]){
				rank[0]=rank[1];
				rank[1]=sides[0];
			}

			if(rank[0]*rank[0]==rank[1]*rank[1]+rank[2]*rank[2]){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}

	}
}


Measured memory_bytes: 33092
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 410;
ll dp[maxn][maxn], n;
ll arr[maxn], pref[maxn];

ll recursion(int l, int r) {
    if(l == r) return arr[l];
    if(dp[l][r] != -1) return dp[l][r];
    dp[l][r] = LLONG_MAX;
    ll cost = pref[r] - pref[l-1];
    for(int i=l;i<r;i++) {
        dp[l][r] = min(dp[l][r], recursion(l, i) + recursion(i+1, r) + cost);
    }
    return dp[l][r];
}

int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
        pref[i] = pref[i-1] + arr[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<recursion(1, n) - pref[n]<<"\n";
    return 0;
}


Measured memory_bytes: 1536
def inpl(): return list(map(int, input().split()))

H, W = inpl()
A = [inpl() for _ in range(H)]
B = [inpl() for _ in range(H)]

DP = [[0 for _ in range(W+1)] for _ in range(H+1)]
DP[0][0] = 1 << 12800

for h in range(H):
    for w in range(W):
        d = abs(A[h][w] - B[h][w])
        DP[h+1][w] |= DP[h][w] >> d
        DP[h+1][w] |= DP[h][w] << d
        DP[h][w+1] |= DP[h][w] >> d
        DP[h][w+1] |= DP[h][w] << d
l = 1 << 12800
r = 1 << 12800
for i in range(12801):
    if (DP[-1][-2]& l) | (DP[-1][-2] & r):
        print(i)
        break
    l = l << 1
    r = r >> 1

Measured memory_bytes: 21364
O = input()
E = input()
oc = len(O)
oe = len(E)
word = "" 
if oc < oe:
    for i in range (oc):
        word = word+O[i]+E[i]
    word = word+E[oc:oe]
    print(word)
elif oc > oe:
    for i in range (oe):
        word = word+O[i]+E[i]
    word = word+O[oe:oc]
    print(word)
else:
    for i in range (oe):
        word = word+O[i]+E[i]
    print(word)

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

int main () {
  
  string ACGT = "ACGT";
  string S;
  cin >> S;
  
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    
    int count = 0;
    for (int j = i; j < S.size(); j++) {
      
      bool flag = false;
      for (int k = 0; k < ACGT.size(); k++) {
        if (S[j] == ACGT[k]) {
          flag = true;
        }
      }
      if (flag == true) {
        count++;
        ans = max(ans, count);
      } else {
        break;
      }
      
    }
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
count_odd = 0
count_4 = 0
count_2 = 0
for a in A:
    if a % 4 == 2:
        count_2 += 1
    elif a % 4 == 0:
        count_4 += 1
    else:
        count_odd += 1
if count_odd == count_4+1 and count_2 == 0 or count_odd <= count_4:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll n, t;
    cin >> n >> t;
    ll M = 0, S = 0;
    for (int i = 0; i < n; ++i) {
        ll x;
        scanf("%lld", &x);
        M = max(M, x);
        if(t <= S) puts("1");
        else printf("%lld\n", (t-S+M-x)/M+1);
        S += x;
    }
    return 0;
}


Measured memory_bytes: 3208
#include <stdio.h>
#define MAX 2000000

int n,K[MAX+1];

void swap(int *x,int *y){
  int  work;        /* 作業用 */

   work = *x;        /* xの値を一時保存 */
   *x = *y;          /* xの値をyの値に書き換える */
   *y = work;        /* yの値をxの値に書き換える */
}

void maxHeapify(int i){
  int l,r,max;
  l=2*i;
  r=2*i+1;
  if(l<=n && K[l]>K[i]) max=l;
  else max=i;
  if(r<=n && K[r]>K[max]) max=r;

  if(max !=i){
    swap(&K[i],&K[max]);
    maxHeapify(max);
  }
}


int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++) {
    scanf("%d",&K[i]);
}
for(i=n/2;i>=1;i--) {
  maxHeapify(i);
}
for(i=1;i<=n;i++) {
  printf(" %d",K[i]);
}
printf("\n");

return 0;
}



Measured memory_bytes: 3696
<?php
list($n, $l) = ints();
$a = ints();
$max = 0;
$maxpos = -1;
for($i = 0; $i < $n-1; $i++){
    $sum = $a[$i] + $a[$i+1];
    if($max < $sum){
        $max = $sum;
        $maxpos = $i + 1;
    }
}

if($max >= $l){
    echo "Possible\n";
    for($i = 1; $i < $maxpos;$i++){
        echo $i,"\n";
    }
    for($i = $n - 1 ; $i >= $maxpos;$i--){
        echo $i,"\n";
    }
}else{
    echo "Impossible\n";
}

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 16884
#include <bits/stdc++.h>
using namespace std;
const int N=4005,mod=998244353;
int n,k,C[N][N],pw2[N];
int c(int n,int m){
	if (m>n||m<0)
		return 0;
	return C[n][m];
}
int calc(int m,int n){return c(n+m-1,m-1);}
int Get(int v,int n,int k){
	int ans=0;
	int lim=max(0,v/2-max(0,v-1-k));
	for (int i=0;i<=lim;i++)
		ans=(1LL*pw2[i]*C[lim][i]%mod*calc(k-lim*2+i,n-i)+ans)%mod;
	return ans;
}
int main(){
	pw2[0]=1;
	for (int i=1;i<N;i++)
		pw2[i]=pw2[i-1]*2%mod;
	for (int i=0;i<N;i++)
		C[i][0]=C[i][i]=1;
	for (int i=1;i<N;i++)
		for (int j=1;j<i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	scanf("%d%d",&k,&n);
	for (int i=2;i<=2*k;i++)
		if (i&1)
			printf("%d\n",Get(i,n,k));
		else
			printf("%d\n",(Get(i-1,n,k-1)+Get(i-1,n-1,k-1))%mod);
	return 0;
}

Measured memory_bytes: 61440
#include<iostream>
#include<map>
#include<algorithm> 
using namespace std;
typedef long long ll;

int main()
{
	int t;cin>>t;
	map<string,int> mp;
	while(t--){
		string s;cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3596
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N : usize, K : usize,
        V : [i64; N]
    }
    let mut max_score = 0i64;
    for mut l in 0..K + 1 {
        for mut r in 0..K - l + 1 {
            if N < l + r {break;}

            let mut hand : Vec<i64> = Vec::new();
            // 左から取り出す
            hand.extend(&V[..l]);
            // 右から取り出す
            hand.extend(&V[N - r..]);
            // 手元から捨てる
            if hand.is_empty() {continue;}
            let mut count = 0;
            hand.sort();
            for n in 0..min(hand.len(), K - l - r) {
                if hand[n] < 0 {count += 1; continue;}
                break;
            }
            let mut score = 0i64;
            for x in &hand[count..] {
                score += *x;
            }
            max_score = max(max_score, score);
            //println!("{:?} {:?} {}", V, hand, max_score);
        }
        //println!("");
    }
    println!("{}", max_score);
}


Measured memory_bytes: 4352
import java.util.*

fun main(args: Array<String> ) {
    val sc = Scanner( System.`in` )
    val A = sc.nextInt()
    val B = sc.nextInt()
    val C = sc.nextInt()
    val D = sc.nextInt()
    val E = sc.nextInt()
    val F = sc.nextInt()
    val water = BooleanArray( F + 1, { it % ( 100 * A ) == 0 } )
    for ( i in water.indices ) {
        if ( water[i] && i + 100 * B < water.size ) water[i + 100 * B] = true
    }
    val sugar = BooleanArray( F + 1, { it % C == 0 } )
    for ( i in sugar.indices ) {
        if ( sugar[i] && i + D < sugar.size ) sugar[i + D] = true
    }

    var bestSugar = 0
    var bestTotal = 100 * A
    for ( w in 1 .. F ) {
        if ( ! water[w] ) continue
        for ( s in 1 .. F - w ) {
            if ( ! sugar[s] ) continue
            if ( s > E * w / 100 ) break
            if ( s * bestTotal > bestSugar * ( s + w ) ) {
                bestSugar = s
                bestTotal = s + w
            }
        }
    }
    println( "$bestTotal $bestSugar" )
}

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

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i<N; i++){
        cin >> L[i]; 
    }
    int m =0;
    for(int i=0;i<N;i++){
        m = max(L[i],m);
    }
    int k = 0;
    for(int i=0;i<N;i++){
        k += L[i];
    } 
    
    if(k>2*m){
        cout << "Yes";
    }  
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int a,b;
  char c;
  cin>>a>>c>>b;
  if(c=='+') cout<<a+b<<endl;
  else cout<<a-b<<endl;

  return 0;
}


Measured memory_bytes: 256
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [(int_of_string b)]
    else
      match str.[ct] with
        ' ' -> (int_of_string b)::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let (n,k) = match split (read_line ()) with
        [n;k] -> (n,k)
      | _ -> raise Not_found
  in
  let ws = Array.init n (fun _ -> read_int ()) and
       l = 0 and
       r = 100000*100000
  in
  let rec search (i,j,s,p) =
    if i=n || j=k then i
    else
      if s+ws.(i) <= p then
        search ((i+1), j, (s+ws.(i)), p)
      else
        search (i,(j+1),0,p)
  in
  let rec loop left right =
    if left < right then
      let mid = (left+right)/2 in
      if search (0,0,0,mid) >= n then loop left mid
      else loop (mid+1) right
    else right
  in
  Printf.printf "%d\n" (loop l r)
;;

Measured memory_bytes: 5700
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int n, m;cin>>n>>m;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(), a.end());
  vector<pair<ll, int>> op(m);
  for(int i=0;i<m;i++){
    int b;ll c;cin>>b>>c;
    op[i]=make_pair(c, b);
  }
  sort(op.begin(), op.end(), greater<pair<ll, int>>());
  int l=0;
  for(int i=0;i<m;i++){
    auto it = lower_bound(a.begin()+l, a.end(), op[i].first);
    int index = it - a.begin();
    if(l>=index)continue;
    for(int j=l;j<min(l+op[i].second, index);j++){
      a[j]=op[i].first;
    }
    l=min(l+op[i].second, index);
    if(l==n)break;
  }
  ll ans=0;
  for(int x:a){
    ans+=x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#define V 10000
 
int main(){
  int i, j, n, *A, *B, C[V+1];
  scanf("%d", &n);
   
  A=(int *)malloc(sizeof(int)*n+1);
  B=(int *)malloc(sizeof(int)*n+1);
   
 
  for(i=0; i<=V; i++){
    C[i]=0;
  }
   
  for(i=0; i<n; i++){
    scanf("%d", &A[i+1]);
    C[A[i+1]]++;
  }
   
  for(i=1; i<=V; i++){
    C[i]=C[i]+C[i-1];
  }
   
  for(j=n; j>=1; j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
   
   
  for(i=1; i<=n; i++){
    if(i>1) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
   
  free(A);
  free(B);
  return 0;
}

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

int N;
int A[100];

void disp(void)
{
  for (int i=0; i<N; ++i) {
    cout << A[i];
    if (i != (N-1)) {
      cout << " ";
    } else {
      cout << "\n";
    }
  }
}

int main(void)
{
  cin >> N;
  for (int i=0; i<N; ++i) {
    cin >> A[i];
  }
  int count = 0;
  int flag = 1;
  while (flag) {
    flag = 0;
    for (int j=N-1; j>=1; --j) {
      if (A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        flag = 1;
        count++;
      }
    }
  }

  disp();
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int main() {
    int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin>>k;
    cout<<arr[k-1];
    return 0;
}


Measured memory_bytes: 256
/*
ID: cyxoier1
TASK: c
PROG: c.cpp
LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;

template<typename T>
inline void Read(T &n){
	char ch; bool flag=0;
	while(!isdigit(ch=getchar()))if(ch=='-')flag=1;
	for(n=ch^48;isdigit(ch=getchar());n=(n<<1)+(n<<3)+(ch^48));
	if(flag)n=-n;
}

int n;

int a[16][16][2], num[16];

int main(){
	Read(n);
	for(register int i=1; i<=n; i++){
		Read(num[i]);
		for(register int j=1; j<=num[i]; j++)
			Read(a[i][j][0]), Read(a[i][j][1]);
	}
	int ans=0, top=(1<<n)-1;
	for(register int i=0; i<=top; i++){
		bool tr=true;
		for(register int j=1; j<=n; j++){
			if((i&(1<<(j-1)))==0) continue;
			for(register int k=1; k<=num[j]; k++)
				if(((i&(1<<(a[j][k][0]-1)))!=0)!=a[j][k][1]){
					tr=false;
					break;
				}
			if(tr==false) break;
		}
		if(tr==true){
			int temp=0;
			for(register int j=1; j<=n; j++)
				if((i&(1<<(j-1)))!=0)
					temp++;
			ans = max(ans,temp);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int a;
    cin >> a;
    int trash;
    cin >> trash;
  vector<string> v(a);
  for(int i=0;i<a;i++)cin >> v[i];
  sort(v.begin(), v.end());
  string b = "";
  for(int i=0;i<a;i++) b += v[i];
  cout << b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a[101]={},num,max=0,i;
    while(scanf("%d",&num)!=EOF)
    {
        a[num]++;
    }
    for(i=1;i<=100;i++)
    {
        if(a[i]>max)
        {
            max=a[i];
        }
    }
    for(i=1;i<=100;i++)
    {
        if(a[i]==max)
        {
            printf("%d\n",i);
        }
    }
    return 0;
}



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

int main() {
	int k;
	string s;
	cin>>s>>k;
	
	int tmp=s.length();
	int l=min(k,tmp);
	int ans=1;
	for(int i=0;i<l;i++) {
		if(s[i]!='1') {
			ans=s[i];
			ans-=48;
			break;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int S, s, m, h;

  scanf("%d",&S);

  if(S<=86400 && S>=0)
  {
    h = S / 3600;
    m = (S - h*3600) / 60;
    s = S - (h*3600 + m*60);
  }

  printf("%d:%d:%d\n",h,m,s);

  return 0;

}


Measured memory_bytes: 2104
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
task = [LIST() for _ in range(N)]
task = sorted(task, key=lambda x: (x[1], x[0]))
task = [list(x) for x in zip(*task)]

now_time = 0
for i in range(N):
    now_time += task[0][i]
    if now_time > task[1][i]:
        print("No")
        exit()

print("Yes")

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

int N,A,B;
int res = 0;

int main() {
  cin >>N>>A>>B;
  for (int i=0;i<N+1;i++) {
    int s = i/10000;
    int t = i%10000/1000;
    int k = i%1000/100;
    int l = i%100/10;
    int m = i%10;
      if(s+t+m+l+k>=A && s+t+l+m+k<=B){
        res+=i;
     }}
  
 cout<<res<<endl;

}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int w;
	while (cin >> w) {
		int i(1),cnt(0);
		while (w) {
			if (w & 1) {
				if (cnt++)cout << " ";
				cout << i;
			}
			i *= 2;
			w >>= 1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3060