akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

#define nextInt(n) scanf("%d",&n)
#define nextLong(n) scanf("%lld",&n)
#define nextDouble(n) scanf("%lf",&n)

ll INF=1LL<<58;
class Main{
public:	
	void run(){
                        int N;cin >> N;
                        vector<int> ts(N);REP(i,N) cin >> ts[i];

                        sort(ALL(ts));
                        ll res=0;

                        int Mi=N-1;
                        for(;Mi-1>=2;Mi-=2){
                            res+=ts[0]+ts[Mi]+min(ts[0]+ts[Mi-1],2*ts[1]);
                        }
                        if(Mi>=2){//odd
                            res+=ts[0]+ts[1]+ts[2];
                        }else if(Mi==1){//even
                            res+=ts[1];    
                        }else{
                            res+=ts[0];
                        }
		cout << res <<endl;
	}
};
 int main(){
 	cout <<fixed<<setprecision(15);
	ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }


Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
int n;
cin>>n;
vector<char>s(n);
rep(i,n)cin>>s[i];
int q;
cin>>q;

  set<int>sc[30];
  rep(i,n){
      int c=s[i]-'a';
      sc[c].insert(i);
  }
  int a;
  rep(i,q){
    cin>>a;
    if(a==1){
      int g;
      char c;
      cin>>g>>c;
      g--;
      int t=s[g]-'a';
      s[g]=c;
      sc[t].erase(g);
      sc[c-'a'].insert(g);
    }
    if(a==2){
      int l,r;
      cin>>l>>r;
      l--;r--;
      int ans=0;
      rep(j,26){
        if(!sc[j].empty()){
          auto idx=sc[j].lower_bound(l);
          if(r>=*idx&&idx!=sc[j].end()){ans++;}
        }
      }
      cout<<ans<<endl;
    }
  }

}


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

#define N 1000
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

typedef struct {
	string a;
	int b, c;
} data;

bool func(data x, data y){
	if(x.a < y.a || (x.a == y.a && x.b > y.b)) return true;
	return false;
}

int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.in", "r", stdin);
    //     freopen("output.out", "w", stdout);
    // #endif
    int n, p;
    string s;
    vector<data> v;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
    	cin >> s >> p;
    	v.push_back({s, p, i});
    }

    sort(v.begin(), v.end(), func);

    for(int i = 0 ; i < n ; i++)
    	cout << v[i].c+1 << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{
    int A,B,C;
    cin>>A>>B>>C;
    if (A>=-100&&A<=100)

    if (B>=-100&&B<=100)

    if (C>=-100&&C<=100)


    if (A==B)
    {
                cout<<C;
    }
    else if (A==C)
    {
        cout<<B;
    }
    else if (B=C)
    {
        cout<<A;
    }
    return 0;

}


Measured memory_bytes: 256
N=int(input())
sum=0


while N>0:
  ai=N
  if (ai % 3 == 0) and (ai % 5 ==0):
   ai = 'FizzBuzz'
  elif (ai % 3 == 0):
   ai = 'Fizz'
  elif (ai % 5 == 0):
   ai = 'Buzz'
  else:
   sum=sum+ai
  N=N-1

print(sum)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int l1 = 0, r1 = (s.size()-1)/2-1, l2 = (s.size()+3)/2-1, r2 = s.size()-1;
  while(l1 < r2) {
    if(l1 < r1) {
      if(s[l1]!=s[r1]||s[l2]!=s[r2]) {
      cout << "No" << endl;
      return 0;
      }
    }
    if(s[l1]!=s[r2]) {
      cout << "No" << endl;
      return 0;
    }
    l1++; r1--;
    l2++; r2--;
  }
  
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0),cin.tie();
int main()
{
	//IOS;
	int t;
	while(cin>>t)
	{
		bool f=1;
		int n;
		while(t--)
		{
			cin>>n;
			if(n%2==0&&n%3&&n%5) f=0;
		}
		if(f) cout<<"APPROVED\n";
		else cout<<"DENIED\n";
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

int cal(int x) {
    if(x == 1) return 300000;
    if(x == 2) return 200000;
    if(x == 3) return 100000;
    return 0;
}

void solve() {
    int n, m;
    SI(n);
    SI(m);
    int ans = 0;
    if(n == m && n == 1) ans += 400000;
    ans += cal(n);
    ans += cal(m);
    printf("%d\n", ans);
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   long long x, y, a, b, c;
   cin >> x >> y >> a >> b >> c;
   vector<long long> p, q, r;
   for (int i = 0; i < a; i++)
   {
      long long x;
      cin >> x;
      p.push_back(x);
   }
   for (int i = 0; i < b; i++)
   {
      long long x;
      cin >> x;
      q.push_back(x);
   }
   for (int i = 0; i < c; i++)
   {
      long long x;
      cin >> x;
      r.push_back(x);
   }
   sort(p.rbegin(), p.rend());
   sort(q.rbegin(), q.rend());
   sort(r.rbegin(), r.rend());
   long long max = 0;
   vector<long long> vc;
   for(int i = 0;i < x;i++) {
      max+=p[i];
      vc.push_back(p[i]);
   }
   for(int i = 0;i < y;i++) {
      max+=q[i];
      vc.push_back(q[i]);
   }
   sort(vc.begin(), vc.end());
   int j = 0;
   for(int i = 0;i < vc.size();i++) {
      if(vc[i]<r[j]) {
         max=max-vc[i]+r[j];
      }
      if(j<r.size()) {
         j++;
      } else {
         break;
      }
   }
   cout << max << endl;
}

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

using namespace std;

int n, m;
string S, T;

int dp[4000][4000];

int solve (int i, int j) {

	if (i < 0 || j < 0) return 0;

	int &p = dp[i][j];
	if (p + 1) return p;

	if (S[i] == T[j]) return p = 1 + solve (i - 1, j - 1);
	else return p = max (solve (i - 1, j), solve (i, j - 1));

}


void path (int i, int j, vector < char >& v) {

	if (i < 0 || j < 0) return;

	int qt = solve (i, j);
	if (qt == solve (i - 1, j)) path(i - 1, j, v);
	else if (qt == solve (i, j - 1)) path(i, j - 1, v);
	else {
		v.push_back(S[i]);
		path(i - 1, j - 1, v);
	}

}




int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	cin >> S >> T;

	n = S.size() - 1;
	m = T.size() - 1;

	memset (dp, -1, sizeof dp);

	solve (n, m);

	vector <char> ans;

	path(n, m, ans);

	reverse (ans.begin(), ans.end());

	if (ans.empty()) cout << ' ';
	else for ( char x : ans ) cout << x;
	
	cout << '\n';


	return 0;
}


Measured memory_bytes: 63104
#include <iostream>
using namespace std;
 
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
    if ( (a + b) > (c + d)) {
      cout << "Left" << endl;
    } else if ( (a + b) < (c + d)) {
      cout << "Right" << endl;
    } else {
      cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    string N;
    cin >> N;
    int ans = 0;
    REP(i,N.size()) {
        ans += N[i] - '0';
        ans %= 9;
    }
    cout << ((ans == 0) ? "Yes" : "No") << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3748
# coding: utf-8
import itertools


n_people = int(input())
testimony_list = []
for i in range(n_people):
    n_testimony = int(input())
    testimony_list.append([])
    for j in range(n_testimony):
        testimony_list[i].append([int(x) for x in input().split(' ')])
        
cases_list = sorted(list(itertools.product([0,1], repeat=n_people)), key=lambda x:x.count(1), reverse = True)

for case in cases_list:
    for i in range(n_people):
        if case[i] == 0:
            continue
        
        for testimony in testimony_list[i]:
            if testimony[1] != case[testimony[0]-1]:
                break
        
        else:
            continue
        break
    
    else:
        print(case.count(1))
        break
    continue


Measured memory_bytes: 9588
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	string a,b;

	cin >> a >> b;

	int num = atoi((a + b).c_str());
	for (int i = 1; i*i <= num; i++) {
		if (num == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 1e5 + 1;
ll parent[N]; 
ll findset(ll a){
    if(parent[a] == a){
        return a;
    }
    return parent[a] = findset(parent[a]);
}
void unionset(ll a, ll b){
    a = findset(a);
    b = findset(b);
    if(a == b){
        return;
    }
    parent[b] = a;
}
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        set<pair<ll,ll>> s;
        for(i = 0; i < n; i++){
            ll a, b;
            cin >> a >> b;
            s.insert({a ,b});
        }
        for(i = 1; i <= n; i++){
            parent[i] = i;
        }
        vector<tuple<ll,ll,ll>> x, y;
        ll cnt = 0;
        for(auto u : s){
            ll a, b, c;
            a = u.ff;
            b = u.ss;
            x.pb({a, b, ++cnt});
            y.pb({b, a, cnt});
        }
        sort(x.begin(), x.end());
        sort(y.begin(), y.end());
        vector<tuple<ll,ll,ll>> edges;
        for(i = 1; i < x.size(); i++){
            ll a, b, c;
            tie(a, b, c) = x[i];
            ll aa, bb ,cc;
            tie(aa ,bb, cc) = x[i - 1];
            ll wt;
            wt = min(abs(aa - a), abs(bb - b));
            edges.pb({wt, c, cc});
        }
        for(i = 1; i < y.size(); i++){
            ll a, b, c;
            tie(a, b, c) = y[i];
            ll aa, bb ,cc;
            tie(aa ,bb, cc) = y[i - 1];
            ll wt;
            wt = min(abs(aa - a), abs(bb - b));
            edges.pb({wt, c, cc});
        }
        ll ans = 0;
        sort(edges.begin(), edges.end());
        for(auto u : edges){
            ll a, b, c;
            tie(a, b, c) = u;
            if(findset(b) == findset(c)){
                continue;
            }
            unionset(b, c);
            ans += a;
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 21240
import sys
sys.setrecursionlimit(10**9)

n = int(input())
G = [[] for _ in range(n+1)]
seen = [-1]*(n+1)
for _ in range(n-1):
  u, v, w = map(int, input().split())
  G[u].append([v, w])
  G[v].append([u, w])

def dfs(v, color):
  seen[v] = color
  for nv, nw in G[v]:
    if seen[nv] == -1:
      dfs(nv, seen[v]^nw%2)

dfs(1, 0)
for i in seen[1:]:
  print(i)

Measured memory_bytes: 85212
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l



int main() {
	int n, m;
	cin >> n >> m;
	int cnt[35] = {0};
	int k[35];
	rep(i, n) {
		cin >> k[i];
		rep(j, k[i]) {
			int a;
			cin >> a;
			a--;
			cnt[a]++;
		}
	}
	int ans = 0;
	rep(i, m) {
		if (cnt[i] == n)ans++;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a, b;
	char op;

	while(1) {
		scanf("%d %c %d", &a, &op, &b);
		
		if(op == '?') break;

		switch (op) {
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		default:
			printf("%d\n", a / b);
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 2040
n, m = map(int, input().split())

a = list(map(int, input().split()))
a.sort()
a = a[::-1]
summ = sum(a)
asikiri = summ / (4 * m)

for i in range(m):
    if a[i] < asikiri:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 2940
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for j in range(M)]
score = []
lst_s_t=list(set(s)|set(t))
for k in lst_s_t:
  score.append(s.count(k)-t.count(k))
if max(score)>0:
  print(max(score))
else:
  print(0)

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    int N;
    cin >> N;
    vector<Vl> dp(N + 1, Vl(N + 1));
    Vl a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i <= N; ++i) {
        for (int j = i; j <= N; ++j) {
            bool f_Taro = ((N - (j - i)) & 1) == 1;
            if (f_Taro) {
                dp[i][j] = L_INF;
            }
            else {
                dp[i][j] = -L_INF;
            }
        }
    }

    for (int i = 0; i <= N; ++i) {
        dp[i][i] = 0;
    }
    for (int len = 0; len < N; ++len) {
        for (int l = 0; l <= N - len; ++l) {
            int r = l + len;
            bool f_Taro = ((N - (r - l)) & 1) == 1;

            int nl, nr;
            if (f_Taro) {
                nl = l - 1;
                nr = r;
                if (nl >= 0) {
                    dp[nl][nr] = max(dp[nl][nr], dp[l][r] + a[nl]);
                }

                nl = l;
                nr = r + 1;
                if (nr <= N) {
                    dp[nl][nr] = max(dp[nl][nr], dp[l][r] + a[nr - 1]);
                }
            }
            else {
                nl = l - 1;
                nr = r;
                if (nl >= 0) {
                    dp[nl][nr] = min(dp[nl][nr], dp[l][r] - a[nl]);
                }

                nl = l;
                nr = r + 1;
                if (nr <= N) {
                    dp[nl][nr] = min(dp[nl][nr], dp[l][r] - a[nr - 1]);
                }
            }
        }
    }

    cout << dp[0][N] << endl;

    return 0;
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            
            if (N == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                int A = int.Parse(Console.ReadLine());
                int B = int.Parse(Console.ReadLine());
                Console.WriteLine(A + B);
            }

        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
 
int main()
{
	string s;
	int k;
	cin >> s >> k;
	
	for(int i = 0;i < s.length();i++)
	{
		if( ('a'-s[i] + 26) % 26 <= k  && s[i] != 'a' )
		{
			int x = ('a'-s[i] + 26) % 26;
			s[i] = 'a';
			k -= x;
		}
		if(k == 0)
		{
			cout << s << endl;
			return 0 ;
		}
	}
	
	k %= 26;
	
	for(int i = s.length()-1;i>=0;i--)
	{
		int x = min(k,'z' - s[i]);
		s[i] += x;
		k -= x;
		
		if(k==0)
		{
			break;
		}
	}
	cout << s << endl;
	return 0 ;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int A=in(),B=in();
	if(A<=5){
		cout << 0 << endl;
	}
	else if(A<=12){
		cout << B/2 << endl;
	}
	else cout << B << endl;
	return 0;
}

Measured memory_bytes: 256
# @author 

import sys

class BMinorChange:
    def solve(self, tc=0):
        s = input()
        t = input()
        ans = 0
        for i in range(len(s)):
            if s[i] != t[i]:
                ans += 1

        print(ans)


solver = BMinorChange()
input = sys.stdin.readline

solver.solve()


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

#define int long long

signed main() {
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'B' ) {
            if (!ans.empty()) ans.pop_back();
            continue;
        }
        ans.push_back(s[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
using ll = long long;

ll t[100010],a[100010];
ll st[100010],sa[100010];
ll s[100010];

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

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

    if(t[n-1]!=a[0])
    {
        cout<<0<<"\n";
        return 0;
    }

    ll b=0;
    int it=0;
    for(int i=0;i<n;i++)
    {
        if(t[i]>b)
        {
            b=t[i];
            st[i]=1;
            it=i;
        }
        else st[i]=t[i];
    }

    b=0;
    int ia=0;
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]>b)
        {
            b=a[i];
            sa[i]=1;
            ia=i;
        }
        else sa[i]=a[i];
    }

    if(it>ia)
    {
        cout<<0<<"\n";
        return 0;
    }

    for(int i=0;i<n;i++)
    {
        s[i]=min(st[i],sa[i]);
    }

    ll ans=1;

    for(int i=0;i<n;i++)
    {
        ans*=s[i];
        ans%=MOD;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 7480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;
using sl = signed long;
using sll = signed long long;
using ll = long long;

int main(int argc, char *argv[])
{
	int N, K;
	cin >> N >> K;
	vector<int> h;
	for(int i =0;i<N;i++){
		int tmp;
		cin >> tmp;
		h.push_back(tmp);
	}

	sort(h.begin(), h.end(), greater<int>());

	int index = N;
	for(auto itr = h.begin(); itr <h.end(); itr++ ){
		if(*itr < K){
			index = distance(h.begin(), itr);
			break;
		}
	}

	cout << index;
	return 0;
}

Measured memory_bytes: 892
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	vector<double> arr(n, 0);
	f(i, 0, n)
	{
		cin >> arr[i];
	}
	sort(all(arr));
	double pre = arr[0];
	f(i, 1, n)
	{
		pre= (double)(pre + arr[i]) / 2.000000;
	}
	cout << pre;
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, m) = input!(u64, u64);

    let ans = match (n, m) {
        (1, 1) => 1,
        (1, m) => m - 2,
        (n, 1) => n - 2,
        (n, m) => (n - 2) * (m - 2)
    };

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

fn main() {
    solve();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define mod (1000000007)
typedef long long ll;
using namespace std;
int a[110000];
int main()
{
	int n,x,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(a[1]==1) {swap(a[1],a[2]);ans++;}
	if(a[n]==n) {swap(a[n-1],a[n]);ans++;}
	for(int i=2;i<n;i++)
	if(a[i]==i)
	{
		ans++;
		swap(a[i],a[i+1]); 
	}
	printf("%d\n",ans);
	return 0;
}

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


int main() {
    int64_t x, k, d;
    cin >> x >> k >> d;

    if (x < 0) x = -x;
    int64_t res = 0;
    if (x / d > k) {
        res =  x - k * d;
        cout << res << endl;
        return 0;
    }

    //　原点はさんでちょこまかするパタン
    int64_t restK = k - abs(x) / d;
    if (restK % 2 == 0) {
        res = abs(x - d * (k - restK));
    } else {
        res = abs(x - d * (k - restK + 1));
    }
    cout << res << endl;
    return 0;

}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; ++i) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
  
int mas[3][3];
int cpy[3][3];
 
  
int main() {
  input();
  printf("%d\n", solve());
  return 0;
}
void input() {
  int i, j;
  for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++)
      scanf("%d", &mas[i][j]);
}
  
void output() {
  int i, j;
  for(i = 0; i < 3; i++) {
    for(j = 0; j < 3; j++) printf("%3d", mas[i][j]);
    puts("");
  }
}
  
void copy(int m[3][3], int t[3][3]) {
  int i, j;
  
  for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++) m[i][j] = t[i][j];
}
  
int calc() {
  int i, sum = 0;
  for(i = 0; i < 9; i++) {
    int v = mas[i/3][i%3];
    if(v) {
      v--;
      sum += abs(i/3-v/3)+abs(i%3-v%3);
    }
  }
  return sum;
}
  
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
  
void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
  
int is_in(int x, int y) {
  return 0<=x&&x<3&&0<=y&&y<3;
}
  
int dfs(int x, int y, int p, int dep, const int lim) {
  int i, h = calc();
  //output();
  if(h == 0) return dep;
  //printf("%d %d %d\n", h, lim, p);
  if(dep+h > lim) return -1;
  
  for(i = 0; i < 4; i++) {
    int nx = x+dx[i], ny = y+dy[i], res;
    if(~p && i == (p+2)%4) continue;
    if(!is_in(nx, ny)) continue;
    swap(&mas[y][x], &mas[ny][nx]);
    res = dfs(nx, ny, i, dep+1, lim);
    if(~res) return res;
    swap(&mas[y][x], &mas[ny][nx]);
  }
  
  return -1;
}
  
void get_empty(int *x, int *y) {
  int i, j;
  for(i = 0; i < 3; i++) {
    for(j = 0; j < 3; j++) {
      if(!mas[i][j]) {
    *x = j;
    *y = i;
    return;
      }
    }
  }
}
  
int solve() {
  int x, y, lim, ans;
  get_empty(&x, &y);
  for(lim = 0; lim < 50; lim++) {
    copy(cpy, mas);
    if((ans = dfs(x, y, -1, 0, lim)) != -1) return ans;
    copy(mas, cpy);
  }
  return -1;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(){
	int a, b, sum_a, sum_b, n, i;
	while(scanf("%d", &n) != 0){
		if(n == 0) break;
		sum_a = 0;
		sum_b = 0;
		for(i = 0; i < n; i++){
			scanf("%d %d", &a, &b);
			if(a == b){
				sum_a += a;
				sum_b += b;
			}
			else if(a > b) sum_a += a + b;
			else sum_b += a + b;
		}
		printf("%d %d\n", sum_a, sum_b);
	}
	return 0;
}

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

int main(){
  int n;cin >> n;
  int a[n];
  map<int,int> m;
  for(int i=0;i<n-1;++i){
    cin >> a[i];
  }
  for(int i=0;i<n-1;++i){
    m[a[i]-1] += 1;
  }
  for(int i=0;i<n;++i){
    cout << m[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 13712
N,M=list(map(int,input().split()))
ans_list=[0]*N
AC_list=[0]*N
 
for m in range(M):
    p,s = input().split()
    p=int(p)
    
    #対象の問題：pがAC済か判定
    if AC_list[p-1]==1:
        continue
    else:
        if s=='AC':
            AC_list[p-1]=1
        else:
            ans_list[p-1]=ans_list[p-1]+1
    
ans_list_=[]
for n in range(N):
    ans_list_.append(AC_list[n]*ans_list[n])
    
print(sum(AC_list),sum(ans_list_))

Measured memory_bytes: 51672
# D - Floor Function

a, b, n = map(int, input().split())

# max(floor(a * x / b) - a * floor(x / b) for 0 <= x <= n)
# x = k * b のとき, 第1項 == 第2項
# k * b <= x < (k+1) * b のとき, 第1項は単調増加, 第2項は一定

x = min(n, b - 1)
print(a * x // b)


Measured memory_bytes: 9152
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
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)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k;
    cin >> n >> k;
    VI a(n);
    REP(i,n) a[i] = in();
    int ans = 1e9;
    REP(i,n-k+1){
        int l = a[i], r = a[i+k-1];
        int tmp;
        if (r <= 0) tmp = -l;
        else if (l >= 0) tmp = r;
        else tmp = min(2*(-l)+r, -l+2*r);
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    String S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.S= sc.next(); 
    }
    
    //解答処理
    private StringBuilder solve() {
    	StringBuilder answer = new StringBuilder();
        
        for (int i=0; i<S.length(); i++) {
        	char tmp = (char)(S.charAt(i)+ N);
        	//ASCIIコードが90(Z)を超えた場合
        	if (tmp > 90) {
        		tmp = (char)(S.charAt(i) - 26 + N);
        	}
        	answer.append(tmp);
        }
        
        return answer;
    }
    
    //出力
    public void show(StringBuilder answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 36348
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> s(M);
    vector<char> c(M);
    const ll p = N + 1;
    ll ans[p];
    for (int i = 1; i <= N;i++)
    {
        ans[i] = -1;
    }

    if(N != 1){
        for (ll i = 1; i <= M;i++)
        {
            ll s, c;
            cin >> s >> c;
            if(ans[s] != -1){
                if(ans[s] != c){
                    cout << -1 << endl;
                    return 0;
                }
            }
            else{
                if(s == 1 and c == 0){
                    cout << -1 << endl;
                    return 0;
                }
                ans[s] = c;
            }
        }
        for (ll i = 1; i <= N;i++)
        {
            if(ans[i] == -1){
                if(i != 1){
                    cout << 0;
                }
                else{
                    cout << 1;
                }
            }
            else{
                cout << ans[i];
            }
        }
        cout << endl;
    }
    else{
        for (ll i = 1; i <= M;i++)
        {
            ll s, c;
            cin >> s >> c;
            if(ans[s] != -1){
                if(ans[s] != c){
                    cout << -1 << endl;
                    return 0;
                }
            }
            else{
                ans[s] = c;
            }
        }
        if(ans[1] == -1){
            cout << 0 << endl;
        }
        else{
            cout << ans[1] << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Random rand = new Random();
    Scanner stdIn = new Scanner(System.in);

    String[] ans = new String[10];
    int x = 0;
    while (true) {
      String str = stdIn.next();
      if (str.equals("-"))
      break;
      int m = stdIn.nextInt();
      for (int i = 0; i < m; i++) {
        int h = stdIn.nextInt();
        int size = str.length();
        String tmp1 = str.substring(h, size);
        String tmp2 = str.substring(0, h);
        str = tmp1 + tmp2;
      }
      ans[x++] = str;
    }

    for (int i = 0; i < x; i++) {
      System.out.println(ans[i]);
    }
  }
}


Measured memory_bytes: 26428
N = int(input())
S = input()

F = [1] * (N//2 + 2)
for i in range(1, len(F)):
    F[i] = F[i] * 26

def check(l):
    D = set()
    for i in range(N - 2 * l + 1):
        D.add(S[i:i+l])
        if S[i+l:i+2*l] in D:
            return True

OK = 0
NG = N // 2 + 1

while abs(OK - NG) > 1:
    mid = (OK + NG) // 2
    if check(mid):
        OK = mid
    else:
        NG = mid

print(OK)

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

inline li gcd(li a, li b){
    if (a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b, a%b);
}

int main() {
    li a;
    cin >> a;
    cout << 360 / gcd(a, 360) << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <iomanip>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}
int main() {
	ll n,k;cin>>n>>k;
	ll arr[n],freq[64]={};
	loop(n,i,0)cin>>arr[i];
	loop(n,i,0){
		loop(64,j,0){
			if(arr[i]&power(2,j))
				freq[j]++;
		}
	}
	ll res=0;
	for(int i=40;i>=0;i--){
		ll p=power(2,i);
		if(freq[i]*2<n&&p<=k){
			k-=p;
			res+=(n-freq[i])*p;
		}
		else
			res+=freq[i]*p;
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>

int main()
{
    std::string str, ans;
    int num;
    std::cin >> str;
    num = str.length();
    for (int i = 0; i < num; i++) {
        ans = str[i] + ans;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3012
x=require('fs').readFileSync('/dev/stdin','utf8').trim().split(/\s/);
y=[1,2,3,4,5,6,7,8,9,10];

for(i=0;i<x.length-1;i+=3){
    count=0;
    for(j=0;j<10;j++){
        if(y[j]<=20-(x[i]*1+x[i+1]*1)&&y[j]!=x[i+2]&&y[j]!=x[i+1]&&y[j]!=x[i]){
        count++;
        }
    }
    if(count>=4){
        console.log("YES");
    }else{
        console.log("NO");
    }
}

Measured memory_bytes: 15420
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/
 
 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */
 
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{

    fast;
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    int ea;
    vi aa,bb,cc;
    loop(i,a){
    	// cout<<"yo"<<endl;
    	cin >> ea;
    	aa.pb(ea);
    }
    
     loop(i,b){
    	
    	cin >> ea;
    	bb.pb(ea);
    }
     sort(aa.begin(),aa.end(),greater<int>());
     sort(bb.begin(),bb.end(),greater<int>());
     loop(i,c){
    	
    	cin >> ea;
    	cc.pb(ea);
    }
    
    loop(i,x)
    cc.pb(aa[i]);
    loop(i,y)
    cc.pb(bb[i]);
    // cout<<"Yo!"<<endl;
   
   sort(cc.begin(),cc.end(),greater<int>());
   int s=0;
   loop(i,x+y)
   s+=cc[i];
   
  
   cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 8048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[] N = { 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 = sc.nextInt();

		System.out.println(N[K - 1]);
		sc.close();
	}

}


Measured memory_bytes: 21844
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int t[6];
  t[0] = abs(a-b) + abs(b-c);
  t[1] = abs(a-c) + abs(c-b);
  t[2] = abs(b-a) + abs(a-c);
  t[3] = abs(b-c) + abs(c-a);
  t[4] = abs(c-a) + abs(a-b);
  t[5] = abs(c-b) + abs(b-a);
  sort(t, t+6);
  cout << t[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll l, r, d;
    cin >> l >> r >> d;
    ll a = (l - 1) / d;
    ll b = r / d;
    cout << (b - a) << endl;
}

Measured memory_bytes: 3184
#include <iostream>
 
using namespace std;
 
int main()
{
   unsigned long int K, A, B, currBis = 1, remain;
  
   cin >> K >> A >> B;
   
   if( (B <= A + 2) || (K < A + 1) ){
       cout <<K+1<<endl;
       return 0;
    }
    
   K -= (A + 1);
   currBis = B + (K/2)*(B-A) + K%2;
   
   cout <<currBis<<endl;
   
   return 0;
}

Measured memory_bytes: 256
def gcd(x,y):
    amari = max(x,y)%min(x,y)
    if amari == 0:
        return min(x,y)
    return gcd(min(x,y), amari)
def calc_scm(x,y,gcd):
    return x*y//gcd

A,B,C,D = list(map(int, input().split()))
scm = calc_scm(C,D,gcd(C,D))
low = (A-1)//C + (A-1)//D - (A-1)//scm
high = B//C + B//D - B//scm
print(B - A + 1 - (high - low))


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

int main() {

	long long A, B, K;

	cin >> A >> B >> K;

	if (K <= A) {
		cout << A - K << " " << B << endl;
	}
	else if (K >= A + B) {
		cout << 0 << " " << 0 << endl;
	}
	else {
		cout << 0 << " " << B - (K - A) << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;

const int mod=1e9+7;

int n,a,b,c;
vector<int> l(100),usage(100),ans;
void dfs(int use,int A,int B,int C,int index){
    if(index==n-1){
        if(A*B*C==0){
            return;
        }
        int tmp=0,tmpA=0,tmpB=0,tmpC=0;
        for(int i=0;i<n;i++){
            if(usage[i]==0){
                continue;
            }else if(usage[i]==1){
                if(A==1){
                    tmp+=abs(l[i]-a);
                }else if(A>1){
                    tmp+=10;
                    tmpA+=l[i];
                }
            }else if(usage[i]==2){
                if(B==1){
                    tmp+=abs(l[i]-b);
                }else if(B>1){
                    tmp+=10;
                    tmpB+=l[i];
                }
            }else if(usage[i]==3){
                if(C==1){
                    tmp+=abs(l[i]-c);
                }else if(C>1){
                    tmp+=10;
                    tmpC+=l[i];
                }
            }
        }
        if(tmpA){
            tmp+=abs(a-tmpA)-10;
        }
        if(tmpB){
            tmp+=abs(b-tmpB)-10;
        }
        if(tmpC){
            tmp+=abs(c-tmpC)-10;
        }
        ans.push_back(tmp);
        return ;
    }
    usage[index+1]=0;
    dfs(0,A,B,C,index+1);
    usage[index+1]=1;
    dfs(1,A+1,B,C,index+1);
    usage[index+1]=2;
    dfs(2,A,B+1,C,index+1);
    usage[index+1]=3;
    dfs(3,A,B,C+1,index+1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b >> c;
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    dfs(0,0,0,0,-1);
    sort(ans.begin(),ans.end());
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 636