akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <map>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	vi a;
	a.resize(n);
	map <int,int> occ;

	ll ans = 0;
	for(int i = 0; i < n; i++) {
		cin>>a[i];
		occ[a[i]]++;
	}
	for (auto p: occ){
		int key = p.first;
		int val = p.second;
		if (val < key) ans +=val;
		else ans += (val - key);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF=1e18,MOD=1e9+7;
int main(){
  vector<int>a(5);
  for(int i=0;i<5;i++)cin>>a[i];
  int k;
  cin>>k;
  bool flag=true;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(i==j)continue;
      if(abs(a[j]-a[i])>k)flag=false;
    }
  }
  if(flag)cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n) {
		int put1, put2;
		cin >> put1 >> put2;
		ans += put2 - put1 + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	ll n, ans=0,a,b;
	string s;
	cin >> a >> b;
	if (abs(a - b) < 2) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
typedef long long ll;
typedef long double ld;
ld dp[302][302][302], n;
ld solve(int co1, int co2, int co3)
{
	if(co1 == 0 && co2 == 0 && co3 == 0)return 0;
	if(co1 < 0 || co2 < 0 || co3 < 0)return 0;
	if(dp[co1][co2][co3] != -1)return dp[co1][co2][co3];
	ld den = co1 + co2 + co3;
	ld val1 = co1 * solve(co1-1, co2, co3);
	ld val2 = co2 * solve(co1+1, co2-1, co3);
	ld val3 = co3 * solve(co1, co2+1, co3-1);
	return dp[co1][co2][co3] = (n + val1 + val2 + val3)/den;
}
int main()
{
	int co1 = 0, co2 = 0, co3 = 0, a;
	scanf("%Lf", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a);
		if(a == 1)co1++;
		else if(a == 2)co2++;
		else co3++;
	}
	for (int i = 0; i <= 300; ++i)
		for (int j = 0; j <= 300; ++j)
			for (int k = 0; k <= 300; ++k)
				dp[i][j][k] = -1;
	printf("%.10Lf\n",solve(co1, co2, co3));
}

Measured memory_bytes: 430336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N;
    ll K;cin>>N>>K;
    vector<int> A(N),B[200001];
    for(int i=0;i<N;i++){
        cin>>A[i];
        B[A[i]].push_back(i);
    }
    int cnt=1,now=0;
    while(1){
        auto it=upper_bound(all(B[A[now]]),now);
        if(it==B[A[now]].end()){
            if(B[A[now]].size()==1){
                now=(now+1)%N;
                cnt++;
            }else{
                now=(B[A[now]][0]+1)%N;
                cnt++;
            }
        }else{
            now=((*it)+1)%N;
        }
        if(now==0) break;
    }
    
    K=(K-1)%cnt+1;
    //cout<<cnt<<endl;
    
    cnt=1;now=0;
    
    //cout<<K<<endl;
    
    if(K>=2){
    while(1){
        auto it=upper_bound(all(B[A[now]]),now);
        if(it==B[A[now]].end()){
            if(B[A[now]].size()==1){
                now=(now+1)%N;
                cnt++;
            }else{
                now=(B[A[now]][0]+1)%N;
                cnt++;
            }
        }else{
            if((*it)==N-1) cnt++;
            now=((*it)+1)%N;
        }
        if(cnt==K) break;
    }
    }
    
    vector<int> appear(200001,-1);
    vector<int> ans;
    
    for(int i=now;i<N;){
        int a=A[i];
        auto it=upper_bound(all(B[a]),i);
        if(it==B[a].end()){
            ans.push_back(a);
            i++;
        }else{
            i=(*it)+1;
        }
    }
    
    for(int i=0;i<ans.size();i++){
        if(i) cout<<" ";
        cout<<ans[i];
    }
    
    cout<<endl;
}


Measured memory_bytes: 14968
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
//------------------------------------------------------------
		int n = sc.nextInt();
		int l =sc.nextInt();
		String[] strings =new String[n];
		for (int i=0;i<n;i++) {
			strings[i]=sc.next();
		}
		Arrays.sort(strings);
		for (int i=0;i<n;i++) {
			System.out.print(strings[i]);
		}
//------------------------------------------------------------
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    string s,t;
    cin>>s>>t;int ans=0;
    for(int i=0;i<s.size();i++)
    if(s[i]!=t[i])ans++;
    cout<<ans<<endl;
}


return 0;
}





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

using namespace std;

long long a,b,n,tmp;

int main() {

    cin>>n>>a>>b;

    tmp = a+b;

    if(tmp>=n){
        if(n<a){
            cout<<n<<endl;
        }else{
            cout<<a<<endl;
        }
        return 0;
    }

    long long ans = (n/tmp)*a;
    long long m = (n%tmp);

    if(m>=a){
        ans += a;
    }else{
        ans += m;
    }

    cout<<ans<<endl;

    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> ab(n,vector<int>(2));
    vector<vector<int>> cd(m,vector<int>(2));
    
    vector<int> ans(n);
    
    rep(i,n) cin >> ab[i][0] >> ab[i][1];
    rep(i,m) cin >> cd[i][0] >> cd[i][1];
    
    
    for(int i = 0; i < n; i++){
        int minv = 1e9;
        int k = 0;
        
        for(int j = 0; j < m; j++){
            int d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]);
            
            if(d<minv){
                minv = d;
                k = j;
            }
        }
        ans[i] = k + 1;
    }
    rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define X first
#define Y second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

const ll mod=998244353;
const ll MAXN=2e5+5;
const ll inf=1e17;

int main()
{
    fastio;
    ll h,a;
    cin>>h>>a;
    if(h%a==0) cout<<(h/a)<<endl;
    else cout<<(h/a)+1<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
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;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

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

    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    int score = 0;
    // 文字に
    unordered_map<char, int> point;
    point['r'] = p;
    point['s'] = r;
    point['p'] = s;
    bitset<100000> win;

    for (int i = 0; i < n; i++)
    {
        if (i >= k && t[i] == t[i - k] && win.test(i - k))
        {
            ;
        }
        else
        {
            score += point[t[i]];
            win.set(i);
        }
    }

    cout << score << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

signed main() {
    int X;
    cin >> X;

    cout << (X/500)*1000 + ((X%500)/5)*5;
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
 
int main(void){
     
    char ch;
    while(1){
        scanf("%c",&ch);
        if(isupper(ch)!=0){
            ch=tolower(ch);
            printf("%c",ch);
        }else if(islower(ch)!=0){
            ch=toupper(ch);
            printf("%c",ch);
        }else{
            printf("%c",ch);
        }
        if(ch=='\n') break;
    }
    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
    }else{
        int ans = 0;
        ll acc = 1;
        while(acc <= n){
            ans++;
            acc *= 2;
        }
        cout << ans << endl;
    }
    return 0;
}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int mod = 1e9+7;
struct mint { //逆元などを使いたければmint2{{{
  int x;
  mint(int x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
ostream& operator<<(ostream& os, const mint& a){
  os << a.x;
  return os;
} //}}}

int solve(){
  int n,m;cin>>n>>m;

  vector<int> s(n); 
  rep(i,n){
    cin>>s[i];
  }
  vector<int> t(m); 
  rep(i,m){
    cin>>t[i];
  }

  vector<vector<mint>> dp(n+1, vector<mint>(m+1));
  rep(i,n+1)rep(j,m+1)if(i==0||j==0) dp[i][j]=1;
  rep(i,1,n+1)rep(j,1,m+1){
    dp[i][j]+=dp[i-1][j];
    dp[i][j]+=dp[i][j-1];
    dp[i][j]-=dp[i-1][j-1];
    if(s[i-1]==t[j-1]) dp[i][j]+=dp[i-1][j-1];
  }
  dump_2d(dp,n+1,m+1);
  cout << dp[n][m] << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 31616
#include<stdio.h>
#include<stdlib.h>
#define NIL -1

typedef struct{
  int deg;
  int depth;
  int parent;
  int *child;
  int c_check;
}node;

node *tree;

int main(){
  int num;
  int i, j, n;

  scanf("%d", &n);
  tree = (node*)malloc(sizeof(node)*n);
  for(i=0; i<n; i++){
    tree[i].depth = 0;
    tree[i].parent = NIL;
    tree[i].child = 0;
    tree[i].c_check = 0;
  }
  
  for(i=0; i<n; i++){
    scanf("%d", &num);
    scanf("%d",&tree[num].deg);
    if(tree[num].deg != 0){
      tree[num].child = (int *)malloc(sizeof(int)*tree[num].deg);
      tree[num].c_check++;
      for(j=0; j<tree[num].deg; j++){
	scanf("%d", &tree[num].child[j]);
	tree[tree[num].child[j]].parent = num;
	tree[tree[num].child[j]].depth = tree[num].depth + 1;
      }
    }
    else if(tree[num].deg==0&&tree[num].parent!=NIL){
      tree[num].depth=tree[tree[num].parent].depth+1;
    }
  }

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, tree[i].parent, tree[i].depth);
    if(tree[i].depth == 0) printf("root, [");
    else if(tree[i].c_check == 0) printf("leaf, [");
    else printf("internal node, [");

    for(j=0; j<tree[i].deg; j++){
      if(j != 0)printf(", ");
      printf("%d", tree[i].child[j]);
    } printf("]\n");
  }
  return 0;
}



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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int k;
    cin >> k;
    ll kani=7;
    map<int , int> mp;
    bool flag=true;
    ll ans=1;
    while(1){
        if(kani%k==0) break;
        kani=(kani*10+7)%k;
        if(mp[kani]!=0){
            flag=false;
            break;
        }
        mp[kani]++;
        ans++;
    }
    if(flag) cout << ans << endl;
    else cout <<"-1" << endl;

    return 0;
}

Measured memory_bytes: 50420
local n=io.read("n")

local t={}
for i=1,math.sqrt(n) do
    if n%i==0 then
        if i>1 then
            table.insert(t,i)
        end
        if i~=n//i then
            table.insert(t,n//i)
        end
    end
end
table.sort(t)

local sum=0
for i=1,#t do
    local m=t[i]-1
    if (m+1)*(n//m)==n then
        sum=sum+m
    end
end
print(sum)

Measured memory_bytes: 2780
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DecayedBridges solver = new DecayedBridges();
        solver.solve(1, in, out);
        out.close();
    }

    static class DecayedBridges {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] aa = new int[m];
            int[] bb = new int[m];

            for (int i = 0; i < m; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                aa[i] = a;
                bb[i] = b;
            }

            UnionFind uf = new UnionFind(n);
            long point = (long) n * (n - 1) / 2;
            long[] score = new long[m + 1];

            for (int i = m; 0 < i; i--) {
                score[i] = point;

                int a = aa[i - 1];
                int b = bb[i - 1];
                boolean isSame = uf.same(a, b);
                if (isSame) {
                    continue;
                }
                point -= (long) uf.size(a) * (long) uf.size(b);
                uf.unite(a, b);
            }

            for (int i = 1; i <= m; i++) {
                out.println(score[i]);
            }
        }

        public class UnionFind {
            private int[] size;
            private int[] parents;

            public UnionFind() {
            }

            public UnionFind(int size) {
                this.size = new int[size];
                this.parents = new int[size];
                for (int i = 0; i < size; i++) {
                    makeSet(i);
                }
            }

            public void makeSet(int x) {
                parents[x] = x;
                size[x] = 1;
            }

            public int findSet(int x) {
                if (x != parents[x]) {
                    parents[x] = findSet(parents[x]);
                }
                return parents[x];
            }

            public boolean unite(int x, int y) {
                if (same(x, y)) {
                    return false;
                }
                link(findSet(x), findSet(y));
                return true;
            }

            public int size(int x) {
                return size[findSet(x)];
            }

            public boolean same(int x, int y) {
                return findSet(x) == findSet(y);
            }

            private void link(int x, int y) {
                if (size[x] > size[y]) {
                    parents[y] = parents[x];
                    size[x] += size[y];
                } else {
                    parents[x] = parents[y];
                    size[y] += size[x];
                }
            }

        }

    }
}



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

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<long long int> pa, pb, pc;
  long long int ans=0;
  for(int i=0; i<a; i++){
    long long int n;
    cin >> n;
    pa.push_back(n);
  }
  for(int i=0; i<b; i++){
    long long int n;
    cin >> n;
    pb.push_back(n);
  }
  for(int i=0; i<c; i++){
    long long int n;
    cin >> n;
    pc.push_back(n);
  }
  sort(pa.begin(),pa.end(),greater<long long int>());
  sort(pb.begin(),pb.end(),greater<long long int>());
  sort(pc.begin(),pc.end(),greater<long long int>());
  priority_queue<long long int> que;
  for(int i=0; i<x; i++){
    que.push(pa[i]);
  }
  for(int i=0; i<y; i++){
    que.push(pb[i]);
  }
  for(int i=0; i<c; i++){
    que.push(pc[i]);
  }
  
  for(int i=0; i<x+y; i++){
    long long int t = que.top();
    que.pop();
    ans += t;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8304
A = []
for i in range(0,3):
    A.extend(list(map(int, input().split())))
N = int(input())
for i in range(0,N):
    b = int(input())
    for j in range(0,9):
        if A[j] == b:
            A[j] = 0

if A[0] == 0 and A[1] == 0 and A[2] == 0:
    print('Yes')
elif A[3] == 0 and A[4] == 0 and A[5] == 0:
    print('Yes')
elif A[6] == 0 and A[7] == 0 and A[8] == 0:
    print('Yes')
elif A[0] == 0 and A[3] == 0 and A[6] == 0:
    print('Yes')
elif A[1] == 0 and A[4] == 0 and A[7] == 0:
    print('Yes')
elif A[2] == 0 and A[5] == 0 and A[8] == 0:
    print('Yes')
elif A[0] == 0 and A[4] == 0 and A[8] == 0:
    print('Yes')
elif A[2] == 0 and A[4] == 0 and A[6] == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

ll putere(ll n, ll x)
{
    ll sol = 1;
	if(x == 0)
		return 1;
    while(x)
    {
        if(x&1)
        {
            sol*=n;
            if(sol > MOD)
            {
                sol%=MOD;
            }
        }
        n = n * n;
        if(n > MOD)
        {
            n%=MOD;
        }
        x>>=1;
    }
    return sol;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	ll n,k;
	cin >> n >> k;
	ll total = 0;
	vector<ll> dp(k+1);

	for(int gd = k; gd >= 1; --gd)
	{
		ll total_mult = k / gd;

		ll temp = putere(total_mult,n);
	
		temp%=MOD;
		temp%=MOD;

		ll extra = 0;
		for(int j = gd*2; j<= k; j+=gd)
		{
			extra = (extra + dp[j]) % MOD;
		}

		dp[gd] = (temp + MOD - extra) % MOD;
	}

	for(int i =1; i<= k; ++i)
	{
		ll ad = (dp[i]%MOD * i % MOD) % MOD;
		total += ad;
		total%=MOD;
	}


	cout << total;
    return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define mino "test"
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define matrix vector<vector<ll>>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define Down(i,a,b) for(int i=a; i>=b; i--)
#define FOR_(i,a,b) for(int i=a; i<b; i++)
#define turbo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oo 1e9

const int N = 2e5 + 5;

using namespace std;

typedef pair<ll,int> pii;


int q, n, m;
int SA[N], SB[N], TA[N], TB[N];
string S, T;

void nhap()
{
    cin >> S >> T >> q;
    n = S.size();
    m = T.size();
    S = ' ' + S;
    T = ' ' + T;
}

void xuli()
{
    FOR(i,1,n)
    {
        SA[i] = SA[i-1];
        SB[i] = SB[i-1];
        if(S[i] == 'A') SA[i]++;
        else SB[i]++;
    }

    FOR(i,1,m)
    {
        TA[i] = TA[i-1];
        TB[i] = TB[i-1];
        if(T[i] == 'A') TA[i]++;
        else TB[i]++;
    }

    FOR(i,1,q)
    {
        int u, v, x, y;
        cin >> u >> v >> x >> y;
        int H1 = (SA[v] - SA[u-1]) - (SB[v] - SB[u-1]);
        int H2 = (TA[y] - TA[x-1]) - (TB[y] - TB[x-1]);
        if((H1 - H2) % 3 == 0) cout << "YES\n";
        else cout << "NO\n";
    }
}

int main()
{
    //freopen(mino".inp","r",stdin);
    //freopen(mino".out","w",stdout);
    turbo
    nhap();
    xuli();
}


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

int main() {
    ios::sync_with_stdio(false);
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    if(a+b == c+d)
        cout << "Balanced" << endl;
    else if (a+b < c+d)
        cout << "Right" << endl;
    else
        cout << "Left" << endl;


    return 0;
}



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

int main(){
  int n;
  cin>>n;
  int a[n],b[n];
  for(int i=0;i<n;++i)cin>>a[i];
  for(int i=0;i<n;++i)cin>>b[i];
  int ans=0;
  for(int i=0;i<n;++i){
    ans+=max(0,a[i]-b[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  ll  long long int
#define  sz  200010

using namespace std;

map<ll,ll>mp;

int main()
{

    ll n,s=0,l,r,d,a;

    cin>>n;

    while(n--)
    {
      cin>>a;
      if(mp[a]==0)
      {
          mp[a]++;
      }
      else
      {
          mp.erase(a);
      }
    }

    cout<<mp.size()<<endl;

    return 0;
}


Measured memory_bytes: 6528
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//
int main() {
	int n,a; cin >> n;

	a = n % 10;
	if (a == 3)cout << "bon" << endl;
	else if (a == 0 || a == 1 || a == 6 || a == 8)cout << "pon" << endl;
	else cout<<"hon"<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
  int i,count=0,ans=0;
  char s[111];
  for(i=0;i<111;i++)
    s[i]='\0';
  cin>>s;
  for(i=0;s[i]!='\0';i++){
    if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T')
      count++;
    else{
      if(count>ans)
          ans=count;
      count=0;
    }
  }
  if(count>ans)
    ans=count;
  cout<<ans<<endl;
}


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

int main()
{
    double N, ans = 0;
    cin >> N;

    double red = N / 1000;
    int red1 = N / 1000;

    if(red != red1){
        ++red1;
    } 


    ans = red1*1000 - N;
    cout << ans << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int A,B,C,D,E;
  cin>>A>>B>>C;
 D=A-C;
 E=B-C;
 D=D*E;
  if(D>0){
  cout<<"No"<<endl;
  }else{
  cout<<"Yes"<<endl;
  }
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MOD 1e9+7

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

ll dp[3001][3001];

int main(){
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();

    vector<char> ans;

    REP(i, n) REP(j, m) {
        if(s[i] == t[j]) {
            dp[i+1][j+1] = dp[i][j] + 1;
        } else {
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }

    int i = n, j = m;

    /* 経路復元 */
    while(i>0 && j>0) {
        if(dp[i][j] == dp[i-1][j]) {
            i--;
        } else if(dp[i][j] == dp[i][j-1]) {
            j--;
        } else {
            ans.push_back(s[i-1]);
            i--, j--;
        }
    }

    REP_REV(i, ans.size()){
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 70784
def check():
    X, K, D = list(map(int, input().split(' ')))
    
    if K*D <= abs(X):
        if X > 0:
            return X - K*D
        else:
            return X + K*D
            
    N = abs(X) // D
    signX = -1 if X < 0 else 1
    X = X * signX
    
    nearest_point = X - N*D
    
    if (K-N) % 2 == 0:
        return nearest_point
    else:
        return nearest_point - D

print(abs(check()))

Measured memory_bytes: 8956
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc185
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc185B();
        }

        public static void solve_abc185B()
        {
            long[] nab = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long n = nab[0];
            long a = nab[1];
            long b = nab[2];
            long x = n / (a + b);
            long xr = n % (a + b);
            Console.WriteLine(a > 0 ? x * a + Math.Min(xr, a) : 0);
        }

        public static void solve_abc185A()
        {
            string s = Console.ReadLine();

            if (s.Contains('A') && s.Contains('B'))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	s := io.Next()
	cnt, max := 0, 0
	for i := range s {
		if s[i] == 'R' {
			cnt++
		} else {
			if cnt > max {
				max = cnt
			}
			cnt = 0
		}
	}
	if cnt > max {
		max = cnt
	}
	io.Println(max)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
struct edge_t {
  int u, v, w;
  edge_t() = default;
  edge_t(int u, int v, int w) : u(u), v(v), w(w) {}
  friend bool operator<(const edge_t &lhs, const edge_t &rhs) {
    return lhs.w < rhs.w;
  }
};
int main() {
  int n;
  cin >> n;
  vector<int>a(3*n);
  for(int &i : a)cin>>i;
  vector<int64_t> pref(n + 1), suff(n + 1);
  {
    multiset<int> s1;
    multiset<int, greater<>> s2;
    for (int i = 0; i < n; ++i) {
      s1.insert(a[i]);
      pref[0] += a[i];
    }
    for (int i = 1; i <= n; ++i) {
      pref[i] += pref[i - 1];
      pref[i] -= *s1.begin();
      s2.insert(*s1.begin());
      s2.insert(a[i + n - 1]);
      s1.erase(s1.begin());
      pref[i] += *s2.begin();
      s1.insert(*s2.begin());
      s2.erase(s2.begin());
    }
  }
  {
    multiset<int, greater<>> s1;
    multiset<int> s2;
    for (int i = 0; i < n; ++i) {
      s1.insert(a[3 * n - 1 - i]);
      suff[0] += a[3 * n - 1 - i];
    }
    for (int i = 1; i <= n; ++i) {
      suff[i] += suff[i - 1];
      suff[i] -= *s1.begin();
      s2.insert(*s1.begin());
      s2.insert(a[2 * n - i]);
      s1.erase(s1.begin());
      suff[i] += *s2.begin();
      s1.insert(*s2.begin());
      s2.erase(s2.begin());
    }
  }
  int64_t ans = numeric_limits<int64_t>::min() / 2;
  for (int i = 0; i <= n; ++i) {
    ans = max(ans, pref[i] - suff[n - i]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 15392
while True:
 a,op,b=raw_input().split()
 if op == "?":break
 if op == "+":print int(a) + int(b)
 if op == "-":print int(a) - int(b)
 if op == "*":print int(a) * int(b)
 if op == "/":print int(a) / int(b)

Measured memory_bytes: 6436
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2==1)cout << "No" << endl;
  else{
    bool ok = 1;
    rep(i,n/2){
      if(s[i]!=s[i+n/2])ok=0;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
   int N,L;
   cin >> N >> L;

   vector<string> s(N);
    string ans;
   for(int i = 0; i < N; i++){
       cin >> s[i];
   }

   sort(s.begin(), s.end());

    for(int i = 0; i < N; i++){
        ans += s[i];
    }

    cout << ans;

    return 0;
}

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

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

	vector<vector<double>> x(n, vector<double>(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}		
	}

	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			double tmp = 0;
			for (int k = 0; k < d; k++) {
				tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);				
			}
			tmp = sqrt(tmp);
			if(floor(tmp)==tmp)	ans++;
		}
	}

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

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

int main() {
  int N, A, B;
  N = 0;
  A = 0;
  B = 0;
  
  cin >> N >> A >> B;
  
  if(N * A > B) {
    
    cout << B << endl;
    
  } else {
    
    cout << N * A << endl;
    
  }
}

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();
    String s = sc.next();
    char[] c = s.toCharArray();
    int l = c.length;

    int r = 0;
    int g = 0;
    int b = 0;

    for(char cc:c){
      if(cc=='R'){r++;}
      if(cc=='G'){g++;}
      if(cc=='B'){b++;}
    }
    long sum = (long)r * g * b;

    for(int i=0; i<l-1;i++){
      for(int j=i+1; j<l;j++){
        if(c[i]!=c[j]&&2*j-i<n){
          if(c[2*j-i]!=c[i]&&c[2*j-i]!=c[j]){
            sum--;
          }
        }
      }
    }

    System.out.println(sum);






  }
}

Measured memory_bytes: 36024
# 179 B
N = int(input())
ans = 0
allD = []
anslist = []
for i in range(N):
    D = list(map(int, input().split()))
    allD.append(D)
    
for i in range(N):
    if allD[i][0] == allD[i][1]:
        ans += 1
        anslist.append(ans)
    else:
        ans = 0
        anslist.append(ans)

print('Yes') if 3 in anslist else print('No')

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

ll k, m, ans, a, b;
ll t[1 << 17], d[1 << 17];
vector<ll> u, v;

int main(){
    cin >> k >> a >> b;
    ans = 1;
    if (a + 1 >= b || a > k - 1){
        cout << k + 1 << endl;
        return 0;
    }
    else{
        ans = a;
        k -= a + 1;
        ans = b;
        ans += (b - a) * (k / 2) + k % 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        ss: [proconio::marker::Chars; h],
    }
    let mut dp = vec![vec![std::usize::MAX; w]; h];
    let mut deque = std::collections::VecDeque::new();
    dp[0][0] = if ss[0][0] == '.' { 0 } else { 1 };
    deque.push_back((0, 0, dp[0][0]));
    while let Some((hi, wi, current_cost)) = deque.pop_front() {
        let nexts = {
            let mut nexts = vec![];
            if hi != h - 1 {
                nexts.push((hi + 1, wi));
            }
            if wi != w - 1 {
                nexts.push((hi, wi + 1));
            }
            nexts
        };
        for (next_hi, next_wi) in nexts {
            let next_cost = current_cost
                + if ss[hi][wi] == '.' && ss[next_hi][next_wi] == '#' {
                    1
                } else {
                    0
                };
            if next_cost < dp[next_hi][next_wi] {
                dp[next_hi][next_wi] = next_cost;
                deque.push_back((next_hi, next_wi, next_cost));
            }
        }
    }
    let ans = dp[h - 1][w - 1];
    println!("{}", ans);
}


Measured memory_bytes: 2584
_ = input()
a = list(map(int, input().split()))

counts = [0] * (10 ** 5 + 1)
for ai in a:
    counts[ai] += 1

s = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    s += (c - b) * counts[b]
    print(s)
    counts[c] += counts[b]
    counts[b] = 0

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int D, N, arr[101];
int main(){
  int Lj4PdHRW, res;
  rd(N);
  for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
    rd(D);
    arr[D]=1;
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(101==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = arr[0];
      for(KL2GvlyY=1;KL2GvlyY<101;KL2GvlyY++){
        Q5VJL1cS += arr[KL2GvlyY];
      }
    }
    res =Q5VJL1cS;
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180107-1

// --- original code ---
// int N, D, arr[101];
// {
//   int res;
//   
//   rd(N);
//   rep(N){
//     rd(D);
//     arr[D]=1;
//   }
//   res = sum(arr(101));
//   wt(res);
// }


Measured memory_bytes: 256
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;
int_fast32_t nn, n, sqrtN;
int_fast64_t ans, d;
char c;
char wr[15];
char *w = wr;
main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> nn;
    const int_least32_t n = nn;
    if(n == 1) {
        putc_unlocked(49, stdout);
    } else {
        const int_fast32_t sqrtN = sqrt(n);
        ans = -(int_fast64_t)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
        for(int i = 1; i <= sqrtN; ++i) {
            const int_fast32_t a = n / i;
            ans += ((int_fast64_t)i * (i + a) * (a + 1 - i));
        }
        cout<<ans;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
        string s;
        int a, z;
        cin >> s;
        for (int i = 0; i < s.length(); i++)
                if (s[i] == 'A') {
                        a = i;
                        break;
                }
        for (int i = s.length() - 1; i > 0; i--)
                if (s[i] == 'Z') {
                        z = i;
                        break;
                }

        cout << z - a + 1 << endl;

        return 0;
}

Measured memory_bytes: 640
count = Array.new(1000000,0)

a = gets
until a.nil?
 b = a.split(",")
 x = b[0].to_i
 y = b[1].to_i
 s = b[2].to_i

 yy = y + 1
 3.times do
  xx = x + 1
  3.times do
   sx = xx.to_s
   if xx < 0
    sx = "100"
   end
   if xx > 9
    sx = "100"
   end
   sy = yy.to_s
   if yy < 0
    sy = "100"
   end
   if yy > 9
    sy = "100"
   end
   index = sy + sx
   indexnum = index.to_i
   count[indexnum] += 1
   xx -= 1
  end
  yy -= 1
 end
 if s == 1
  sx = (x + 1).to_s
  if x + 1 > 9
   sx = "100"
  end
  sy = (y + 1).to_s
  if y + 1 > 9
   sy = "100"
  end
  indexnum = (sy + sx).to_i
  count[indexnum] -= 1
  
  sx = (x - 1).to_s
  if x - 1 < 0
   sx = "100"
  end
  sy = (y + 1).to_s
  if y + 1 > 9
   sy = "100"
  end
  indexnum = (sy + sx).to_i
  count[indexnum] -= 1

  sx = (x + 1).to_s
  if x + 1 > 9
   sx = "100"
  end
  sy = (y - 1).to_s
  if y - 1 < 0
   sy = "100"
  end
  indexnum = (sy + sx).to_i
  count[indexnum] -= 1

  sx = (x - 1).to_s
  if x - 1 < 0
   sx = "100"
  end
  sy = (y - 1).to_s
  if y - 1 < 0
   sy = "100"
  end
  indexnum = (sy + sx).to_i
  count[indexnum] -= 1

 elsif s == 3
  sx = (x + 2).to_s
  if x + 2 > 9
   sx = "100"
  end
  sy = y.to_s
  indexnum = (sy + sx).to_i
  count[indexnum] += 1
    
  sx = (x - 2).to_s
  if x - 2 < 0
   sx = "100"
  end
  sy = y.to_s
  indexnum = (sy + sx).to_i
  count[indexnum] += 1
  
  sx = x.to_s
  sy = (y + 2).to_s
  if y + 2 > 9
   sy = "100"
  end
  indexnum = (sy + sx).to_i
  count[indexnum] += 1

  sx = x.to_s
  sy = (y - 2).to_s
  if y - 2 < 0
   sy = "100"
  end
  indexnum = (sy + sx).to_i
  count[indexnum] += 1
  
 end
  
 a = gets
end

seihoukei = []
i = 0
while i < 100
 seihoukei << count[i]
 i += 1
end

puts seihoukei.count{|c| c == 0}
puts seihoukei.max



Measured memory_bytes: 14696
n, h = map(int, input().split())
AB = [(list(map(int, input().split()))) for _ in range(n)]

A = []
B = []
for a, b in AB:
    A.append(a)
    B.append(b)

max_A = max(A)
C = sorted([b for b in B if b >= max_A], reverse=True)

cnt = 0
for c in C:
    h -= c
    cnt += 1
    if h <= 0:
        print(cnt)
        exit()

atack = h // max_A
cnt += atack
h -= atack * max_A
if h <= 0:
    print(cnt)
else:
    print(cnt+1)

Measured memory_bytes: 30448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    double n;
    cin >> n;
    // finding length
    double length = n / 3;

    n -= length;

    // finding breadth
    double breadth = n / 2;

    // finding height
    double height = n - breadth;

    double ans = length * breadth * height;

    cout.precision(24);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	static Scanner sc = new Scanner(System.in);
	static int a, b;
	
	public static void main(String[] args) {
		
		while(read())
		{	
			solve();
		}
	}
	
	static boolean read(){
		if(!sc.hasNext()) return false;
		
		a = sc.nextInt();
		b = sc.nextInt();
		return true;
	}
	
	static void solve(){
		System.out.println(Integer.toString(a+b).length());
	}
}

Measured memory_bytes: 12000
using System;
class matrix{
    public static void Main(){
        String[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int m = int.Parse(str[1]);
        int l = int.Parse(str[2]);
        int[,] m1 = new int[n,m];
        int[,] m2 = new int[m,l];
        for(int i=0; i<n; i++){
            str = Console.ReadLine().Split(' ');
            for(int j=0; j<m; j++){
                m1[i,j] = int.Parse(str[j]);
            }
        }
        for(int i=0; i<m; i++){
            str = Console.ReadLine().Split(' ');
            for(int j=0; j<l; j++){
                m2[i,j] = int.Parse(str[j]);
            }
        }
        for(int i=0; i<n; i++){
            for(int j=0; j<l; j++){
                long sum = 0;
                for(int k=0; k<m; k++){
                    sum+=m1[i,k]*m2[k,j];
                }
                if(j==(l-1)){
                    Console.WriteLine(sum);
                }
                else{
                    Console.Write(sum+" ");
                }
            }
        }
    }
}


Measured memory_bytes: 17940
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;
 
int n;

signed main() {
    cin >> n;
  cout << n*n*n;
    
	return 0;
}

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

int main()
{
string s;
while(cin>>s){
int ans1=0,ans2=0;
for(int i=0;i<s.size()-2;i++){
string t="";
t+=s[i];
t+=s[i+1];
t+=s[i+2];
if(t=="JOI")
ans1++;
if(t=="IOI")
ans2++;
}
cout<<ans1<<endl<<ans2<<endl;
}
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int p,q,r;
	std::cin >> p >> q >> r;
	std::vector<int> v = {p,q,r};
	sort(v.begin(),v.end());
	std::cout << v[0] + v[1] << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int a,b,h,m;
  double hdeg,mdeg;
  double x1,y1,x2,y2;
  double deg,dist;
  cin >> a >> b >> h >> m;

  hdeg = (360.0d +  90.0d - ((h/12.0d)*360.0d + m/60.0d/12.0d * 360.0d)) ;
  mdeg = (360.0d +  90.0d - (m/60.0d)*360.0d) ;
  //hdeg = 360*(h/12.0);
  if(hdeg > 360){
    hdeg -= 360;
  }
  if(mdeg > 360){
    mdeg -= 360;
  }
  //cout << hdeg << endl;
  //cout << mdeg << endl;
  hdeg = 2*M_PI*hdeg/360.0;
  mdeg = 2*M_PI*mdeg/360.0;

  x1 = a * cos(hdeg);
  y1 = a * sin(hdeg);

  x2 = b * cos(mdeg);
  y2 = b * sin(mdeg);

  dist = sqrt(pow(x1-x2,2) + pow(y1-y2,2));
  //dist = (pow(x1-x2,2) + pow(y1-y2,2));
  //cout << x1 << " " << y1 << endl;
  //cout << x2 << " " << y2 << endl;
  
  printf("%0.12lf\n",dist);
//  if(hdeg > mdeg){
//    deg = hdeg - mdeg;
//  }
//  else{
//    deg = mdeg - hdeg;
//  }
//
//  if(deg > 180){
//    deg = 360 -deg;
//  }
  
  

  return 0;
}


Measured memory_bytes: 4076