akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int binary_search(int* p, int n, int key,int num)
{
    int low, high, middle;

    low = 0;
    high = n - 1;

    while (low <= high)
    {
        middle = (low + high) / 2;
        if (gcd(num,p[middle])==1)
            return middle;
        else 
            high = middle - 1;
    }
}

int main()
{
    int K;
    lli sum = 0;
    
    scanf("%d", &K);

    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            for (int k = 1; k <= K; k++)
            {
                sum += gcd(i, gcd(j, k));
            }
        }
    }

    printf("%lld", sum);
}



Measured memory_bytes: 3800
#include <stdio.h>

int main(){
  int a,b,bk,p=1,k=1;
  scanf("%d %d",&a,&b);
  bk=b;
  while(bk>0){
    bk/=10;
    k*=10;
  }
  a=a*k+b;
  while(p*p<a) p++;
  if(p*p==a) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>s;
n=s.size();
for(i=0;i<n/2;i++)
{
  if(s[i]!=s[n-i-1])
  {
    count1++;
  }
}
cout<<count1;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int m[10];
    for(int i=0;i<10;i++)cin>>m[i];
    sort(m,m+10);
    reverse(m,m+10);
    for(int i=0;i<3;i++)cout<<m[i]<<endl;
}
//swap(a,b);
//max(a,b);
//min(a,b);
//sort(a,a+5);

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int sz = 2e5+5;
ll mod=1e9+7;

// ll ncr(ll n,ll k)
// {
//     ll res=0;
//     for(int i=0;i<k;i++)
//     {
//     }
// }

ll f(ll x,ll y,ll z)
{
    return x*x+y*y+z*z+x*y+y*z+z*x;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    t=1;
    // cin>>t;
    //sieve();
    // ll pw[1000006];
    // pw[0]=1;
    // for(int i=1;i<1000006;i++)
    // {
    //     pw[i] = (pw[i-1]%mod*2ll)%mod;
    // }
    // cout<<pw[2]<<endl;
    for(int cs=1;cs<=t;cs++)
    {
        
        ll n;
        cin>>n;
        ll ans[n+1]={0};
        for(int x=1;x<=100000;x++)
        {
            if(f(x,x,x)>n)
                break;
            for(int y=x;y<=100000;y++)
            {
                if(f(x,y,y)>n)
                    break;
                for(int z=y;z<=100000;z++)
                {
                    ll val=f(x,y,z);
                    if(val>n)
                        break;
                    if(x==y and y==z)
                    {
                        ans[val] += 1;
                    }
                    else if((x==y and x!=z) or (x==z and x!=y) or(y==z and x!=y))
                        ans[val] += 3;
                    else
                        ans[val] += 6;
                }
            }
        }

        for(int i=1;i<=n;i++)
        {
            cout<<ans[i]<<endl;
        }
        
        
 
    }
    return 0;
} 

Measured memory_bytes: 3688
#include <iostream>

using namespace std;

int main(){
   int N;
    cin >> N;

    int X[N];
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }

    int ans = 1000000000;
    for (int p = 1; p <= 100; p++)
    {
        int sum = 0;
        for (int i = 0; i < N; i++)
        {
            sum += (X[i] - p) * (X[i] - p);
        }
        if (sum < ans)
            ans = sum;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp
const ll mod=1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vll d(10010,0);
    repi(x,1,101){
        repi(y,1,101){
            repi(z,1,101){
                if(x*x+y*y+z*z+x*y+y*z+z*x<=10000){
                    d[x*x+y*y+z*z+x*y+y*z+z*x]++;
                }
            }
        }
    }
    repi(i,1,n+1){
        cout<<d[i]<<endl;
    }
}


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

int main() {
    ll n, k;
    cin >> n >> k;

    vector<ll> av(n, 0);

    for (int i=0; i<k; i++) {
        ll d;
        cin >> d;

        for (int j=0; j<d; j++) {
            ll a;
            cin >> a;
            av.at(a-1)++;
        }
    }
    ll ans = 0;

    for (int i=0; i<n; i++) {
        if (av.at(i) == 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
//    .------------------------------------------------------------.
//    |   _  __   ___    ___    ___   _  _    ___     _     _  _   |
//    |  | |/ /  / _ \  |   \  |_ _| | \| |  / __|   /_\   | \| |  |
//    |  | ' <  | (_) | | |) |  | |  | .` | | (_ |  / _ \  | .` |  |
//    |  |_|\_\  \___/  |___/  |___| |_|\_|  \___| /_/ \_\ |_|\_|  |
//    |             ___    ___     _     _  _    ___               |
//    |            / _ \  | _ \   /_\   | \| |  / __|              |
//    |           | (_) | |   /  / _ \  | .` | | (_ |              |
//    |            \___/  |_|_\ /_/ \_\ |_|\_|  \___|              |
//    |                 ___   ___    ___    ___                    |
//    |                | _ ) | __|  / __|  / _ \                   |
//    |                | _ \ | _|  | (_ | | (_) |                  |
//    |                |___/ |___|  \___|  \___/                   |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2019-10-08 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("tune=native")

#define vec vector
#define prq priority_queue
#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

//    .-----------------------------------------.
//    |        ___   _   _    ___   ___         | 
//    |       | _ ) | | | |  / __| / __|        | 
//    |       | _ \ | |_| | | (_ | \__ \        | 
//    |       |___/  \___/   \___| |___/        | 
//    |  ___   ___    ___    ___    _  _   ___  | 
//    | | _ ) | __|  / __|  / _ \  | \| | | __| |
//    | | _ \ | _|  | (_ | | (_) | | .` | | _|  | 
//    | |___/ |___|  \___|  \___/  |_|\_| |___| |
//    |                                         | 
//    '-----------------------------------------'

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    vec<int> x(n);
    for(auto &i:x)
        scanf("%d",&i);
    const ll inf=1e18;
    vec<ll> dp(n,inf);
    dp[0]=0;
    for(int i=1;i<n;++i)
        for(int j=1;j<=min(k,i);++j)
            dp[i]=min(dp[i],dp[i-j]+abs(x[i]-x[i-j]));
    printf("%lld\n",dp[n-1]);
}



Measured memory_bytes: 1408
#include<stdio.h>
long power(int n,int p){
  int i = 0;
  long result = 1;
  for(i=0;i<p;i++){
    result *= n;
  }
  return result;
}
int main(){
  int n = 0;
  int i = 0;
  int a[100] = {};
  long cnt = 1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    if(a[i] % 2 == 0){
      cnt *= 2;
    }
  }
  printf("%d",power(3,n)-cnt);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>


using namespace std;


int main() {

	string a, b, c, x;

	cin >> a >> b >> c;

	x = a[0];
	a.erase(a.begin());

	for (int i = 0; i < 100000000000; i++) {
		if (x == "a") {
			if (a.empty()) {
				cout << "A" << endl;
				return 0;
			}
			x = a[0];
			a.erase(a.begin());
		}

		if (x == "b") {
			if (b.empty()) {
				cout << "B" << endl;
				return 0;

			}
			x = b[0];
			b.erase(b.begin());
		}

		if (x == "c") {
			if (c.empty()) {
				cout << "C" << endl;
				return 0;

			}
			x = c[0];
			c.erase(c.begin());
		}
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    ll res=0;
    if(n<600) res = 8;
    else if(n<800) res = 7;
    else if(n<1000) res = 6;
    else if(n<1200) res = 5;
    else if(n<1400) res = 4;
    else if(n<1600) res = 3;
    else if(n<1800) res = 2;
    else if(n<2000) res = 1;
    cout << res << endl;
}


Measured memory_bytes: 3632
#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() {
	int n,m;
    cin >> n >> m;
	vector<int> s(m);
	vector<int> c(m);
	rep(i,m){
		cin >> s[i] >> c[i];
	}
	int ans = -1;
    if(n == 1){
        for(int i = 0;i < 10;i++){
            int ju = 1;
		    for(int j = 0;j < m;j++){
			  if(int(fmod((i/pow(10,n-s[j])),10)) != c[j] ){
                  ju = 0;
			  }
		    }
            if(ju){
                ans = i;
                break;
            }
        }
      
        cout << ans << endl;
        return 0;
    }
  
  
	for(int i = pow(10,n-1);i < pow(10,n)-1;i++){
        int ju = 1;
		for(int j = 0;j < m;j++){
            //cout << int(fmod((i/pow(10,n-s[j])),10)) << endl;
			if(int(fmod((i/pow(10,n-s[j])),10)) != c[j] ){
                ju = 0;
			}
		}
        if(ju){
            ans = i;
            break;
        }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  set<string> se;
  rep(i,0,n){
    string s;
    cin>>s;
    se.insert(s);
  }
  cout << se.sz << endl;
  return 0;
}

Measured memory_bytes: 19188
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

int main() {
  int n,h[110000];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> h[i];

  bool flag = 0;
  for(int i = 0; i < n-1; i++) {
    if(flag & h[i] == h[i+1] + 1) {
      cout << "No" << endl;
      return 0;
    }

    if(h[i] > h[i+1]) {
      if(h[i] == h[i+1] + 1) flag = 1;
      else {
        cout << "No" << endl;
        return 0;
      }
    }
    else if(h[i] < h[i+1]) flag = 0;
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 3948
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

int n,z,w;

signed main(){
	cin>>n>>z>>w;
	int a,b;
	if(n==1){
		cin>>a;
		cout<<abs(a-w)<<en;
	}else{
		int c;
		for(int i=0; i<n-2; i++) cin>>c;
		cin>>a>>b;
		cout<<max(abs(a-b), abs(b-w))<<en;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
const int maxn = 2e5 +5;
const int inf = 1e9 + 1;
const ll llinf = 1e18 + 5;
int n;
ii a[maxn];
char dir[] = {'R' , 'D' , 'U' , 'L'};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i].first >> a[i].second;
        a[i] = mp(a[i].first + a[i].second , a[i].first - a[i].second);
        if((a[i].first + a[1].first) % 2 != 0)return cout << -1 , 0;
    }
    vector<ll> d;
    for(int i = 32 ; i >= 0 ; --i){
        d.pb(1ll << i);
    }
    if(a[1].first % 2 == 0)d.pb(1);
    cout << d.size() << endl;
    for(auto c : d)cout << c << " ";
    cout << endl;
    for(int i = 1 ; i <= n ; ++i){
        ll x = 0 , y = 0;
        for(auto c : d){
            auto Fix = [&](ll & x ,ll lim , ll d){
                if(x > lim)return x -= d , 1;
                return x += d , 0;
            };
            cout << dir[Fix(x,a[i].first,c) + Fix(y,a[i].second,c) * 2];
        }
        cout << endl;
    }
}



Measured memory_bytes: 384
import math
def cmb(n, r):
        if r > n: 
                return 0
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
 
import collections
N = int(input())
s= [input() for i in range(N)]
ans=0
#各文字列文字列をソート
s=list(map(sorted,s))
 
s.sort()        #リストをソート
s=list(map(''.join,s))  #リストになっていたものを文字列に変換
clist = collections.Counter(s) #リスト内の各要素の数を数え上げ
kaisu=list(clist.values())
 
for i in kaisu:
        ans += cmb(i,2)
 
print(ans)

Measured memory_bytes: 121432
/*
      Ashraful Islam Paran
      27-August-2020
      09:51:48
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i <= 0; i--)
#define w(t) int t; cin >> t; while (t--)



typedef unsigned long long ull;
typedef vector<long long> vi;
#define ull unsigned long long
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second


int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a,b;
    cin>>a>>b;
    if(a==b)
    {
        yes;
    }
    else
    {
        no;
    }
    
    
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s;cin>>s;
  ll limit=s.size();
  rep(i,s.size()){
    if(s[i]!=s[i+1]){
      limit=min(limit,max(ll(i+1),ll(s.size()-i-1)));
    }
  }
  cout<<limit<<endl;
}

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    n %= 10;
    if (n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon";
    else if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout << "hon";
    else
        cout <<"bon";

}

Measured memory_bytes: 3628
using System;

namespace abc166_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            int[] a = new int[n];

            for (int i = 0; i < k; i++)
            {
                var d = int.Parse(Console.ReadLine());
                var da = Console.ReadLine().Split(' ');

                foreach(var j in da)
                {
                    int aj = int.Parse(j);
                    a[aj - 1] += 1;
                }
            }
            int ans = 0;
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                {
                    ans += 1;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;

#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
const ll mod = 1e9 + 7;


int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int d, n;
	cin >> d >> n;
	if(n == 100) {
		if(d == 0) cout << 101 << endl;
		if(d == 1) cout << 10100 << endl;
		if(d == 2) cout << 1010000 << endl;
		return 0;
	}
	int r = 1;
	for(int i = 0; i < d; i++) r *= 100;
	r *= n;
	cout << r << endl;
	return 0;
}

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

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

Measured memory_bytes: 3596
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto t = readln.split.to!(int[]);
    auto a = readln.split.to!(int[]);

    auto m = new int[](n);
    auto h = new int[](n);
    h[0] = t[0];

    foreach (i ; 1 .. n) {
        if (t[i] > t[i - 1]) {
            h[i] = t[i];
        }
        else {
            m[i] = t[i];
        }
    }

    long ans = 1;

    if (h[n - 1] > 0) {
        if (a[n - 1] != h[n - 1]) {
            ans = 0;
        }
    }
    else {
        if (a[n - 1] > m[n - 1]) {
            ans = 0;
        }
    }

    foreach_reverse (i ; 0 .. n - 1) {
        if (h[i] > 0) {
            if (a[i] < h[i]) {
                ans = 0;
                break;
            }
        }
        else if (a[i] > a[i + 1]) {
            if ((h[i] > 0 && a[i] != h[i]) || (m[i] > 0 && m[i] < a[i])) {
                ans = 0;
                break;
            }
        }
        else {
            m[i] = min(m[i], a[i]);
            ans *= m[i];
            ans %= mod;
        }
    }

    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 8392
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
using namespace std;

template <int32_t MOD>
struct mint {
    int64_t value;
    mint() = default;
    mint(int64_t value_) : value(value_) {}
    inline mint<MOD> operator + (mint<MOD> other) const { int64_t c = this->value + other.value; return mint<MOD>(c >= MOD ? c - MOD : c); }
    inline mint<MOD> operator - (mint<MOD> other) const { int64_t c = this->value - other.value; return mint<MOD>(c <    0 ? c + MOD : c); }
    inline mint<MOD> operator * (mint<MOD> other) const { int64_t c = this->value * int64_t(other.value) % MOD; return mint<MOD>(c < 0 ? c + MOD : c); }
    inline mint<MOD> & operator += (mint<MOD> other) { this->value += other.value; if (this->value >= MOD) this->value -= MOD; return *this; }
    inline mint<MOD> & operator -= (mint<MOD> other) { this->value -= other.value; if (this->value <    0) this->value += MOD; return *this; }
    inline mint<MOD> & operator *= (mint<MOD> other) { this->value = this->value * int64_t(other.value) % MOD; if (this->value < 0) this->value += MOD; return *this; }
};

constexpr int MOD = 1e9 + 7;
mint<MOD> solve(int n, vector<vector<int> > const & g) {
    vector<mint<MOD> > cnt(n + 3);
    cnt[0] = 1;
    for (int i = 2; i < cnt.size(); i += 2) {
        cnt[i] = cnt[i - 2] * (i - 1);
    }
    function<vector<array<mint<MOD>, 2> > (int, int)> go = [&](int i, int parent) {
        vector<array<mint<MOD>, 2> > dp, dp1;
        dp.assign(2, {});
        dp[1][false] = 1;
        for (int j : g[i]) if (j != parent) {
            auto dp2 = go(j, i);
            dp.swap(dp1);
            dp.assign(dp1.size() + dp2.size() - 1, {});
            REP (t, dp1.size()) {
                REP (u, dp2.size()) {
                    REP (p, 2) {
                        REP (q, 2) {
                            dp[t][p ^ q ^ 1] += dp1[t][p] * dp2[u][q] * cnt[u];  // don't use the edge (i, j)
                            dp[t + u][p ^ q] += dp1[t][p] * dp2[u][q];  // use the edge (i, j)
                        }
                    }
                }
            }
        }
        return dp;
    };
    auto dp = go(0, -1);
    assert (dp.size() == n + 1);
    mint<MOD> acc = 0;
    REP (i, n + 1) {
        acc += dp[i][false] * cnt[i];
        acc -= dp[i][true ] * cnt[i];
    }
    return acc;
}

int main() {
    int n; cin >> n;
    vector<vector<int> > g(n);
    REP (i, n - 1) {
        int x, y; cin >> x >> y;
        -- x; -- y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout << solve(n, g).value << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b,h,m;
  cin>>a>>b>>h>>m;

  ll min=60;
  ll hour=60*12;
  ld arad=(h*60+m)*1.0/hour*2*M_PI;
  ld brad=m*1.0/min*2*M_PI;

  ld ax=a*sin(arad);
  ld ay=a*cos(arad);
  ld bx=b*sin(brad);
  ld by=b*cos(brad);

  ld res=sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));

  cout<<Decimal;
  cout<<res<<endl;
}



Measured memory_bytes: 4168
import sys
from collections import defaultdict
readline = sys.stdin.readline

N = int(readline())
AB = [list(map(int, readline().split())) for i in range(N)]

C = [(a,b) for a,b in AB if (a==0 and b==0)]
AB = [(a,b) for a,b in AB if not (a==0 and b==0)]
P = 1000000007
def mod_prod(a,b):
    return a * b % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n // 2
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret

def gcd(_a,_b):
    a,b = abs(_a), abs(_b)
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    while a % b != 0:
        a, b = b, a % b
    
    return b

def norm(a,b):
    g = gcd(a,b)
    a,b = a//g, b//g
    if a < 0:
        a,b = -a, -b
    if a == 0 and b < 0:
        b = -b
    return a,b

dic = defaultdict(int)
for a,b in AB:
    a,b = norm(a,b)
    dic[(a,b)] += 1

ans = len(C)
keys = list(dic.keys())

x = 1
for a,b in keys:
    n = dic[(a,b)]
    if n != 0:
        p,q = norm(b, -a)
        m = dic[(p,q)]
        x = x * (mod_pow(2, n) + mod_pow(2, m) - 1)
        x %= P
        dic[(p,q)] = 0
        dic[(a,b)] = 0
x -= 1
ans += x
ans %= P
print(ans)

Measured memory_bytes: 212180
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, T;
    cin >> N >> T;
    ll ans = 0;
    ll t, t_b = 0;
    rep(0, i, N)
    {
        cin >> t;
        if (t - t_b < T)
        {
            ans += t - t_b;
        }
        else
        {
            ans += T;
        }
        t_b = t;
    }
    cout << ans + T << endl;
}

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

int main(){
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  ll ans = 0;
  rep(i,n) {
    ans += (ll)(lower_bound(a,a+n,b[i]) - a) * (ll)(c + n - upper_bound(c,c+n,b[i]));
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int left = 0, right = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      left++;
    } else {
      left--;
      if (left < 0) {
        left = 0;
        right++;
      }
    }
  }
  for (int i = 0; i < right; i++) {
    cout << '(';
  }
  cout << s;
  for (int i = 0; i < left; i++) {
    cout << ')';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1 << 28;
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; ++i) {
        cin >> A[i];
    }
    vector<pii> whites;
    deque<pii> blacks;
    deque<pii> blacks2;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (A[i][j] == '.')
                whites.emplace_back(i, j);
            else
                blacks.emplace_back(i, j);
        }
    }
    vector<string> A2 = A;
    int ret = 0;
    int num = blacks.size();
    while (num != H * W) {
        ret++;
        for (auto it = blacks.begin(); it != blacks.end(); it = next(it)) {
            int origy = it->first;
            int origx = it->second;
            for (int i = 0; i < 4; ++i) {
                int y = origy + dy[i];
                int x = origx + dx[i];
                if (x >= 0 && x < W && y >= 0 && y < H) {
                    if (A[y][x] == '.') {
                        A[y][x] = '#';
                        blacks2.emplace_back(y, x);
                        num++;
                    }
                }
            }
        }
        blacks = blacks2;
        blacks2.clear();
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 16616
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    ll sum = 0;
    for (int i = 0; i < s.length(); i++) {
        sum += s[i]-'0';
    }
    if (sum%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 3788
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var a = sc.nextInt()
  var b = sc.nextInt()
  if (a == 1) a = 14
  if (b == 1) b = 14

  if (a == b) {
    println("Draw")
  } else if (a > b) {
    println("Alice")
  } else {
    println("Bob")
  }
}

Measured memory_bytes: 25404
#include <iostream>
using namespace std;
int main()
{
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  
  if(W<x+r||H<y+r)
    cout << "No\n";
  else if(x-r<0||y-r<0)
    cout << "No\n";
  else
    cout << "Yes\n";
  
  return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

int h,w,n,a[101][101];
vector<int> v;

int main(void){
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;

}


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

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

typedef long long ll;

using namespace std;
int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    
    int countAddFront = 0;
    int countAddBack = 0;
    REP(i, N)
    {
      char c = S[i];
      if (c == '(')
      {
        countAddBack++;
      }
      else if (c == ')')
      {
        if (countAddBack > 0)
        {
          countAddBack--;
        }
        else
        {
          countAddFront++;
        }
      }
    }
    
    string ans = "";

    REP(i, countAddFront)
    {
      ans += "(";
    }
    ans += S;
    REP(i, countAddBack)
    {
      ans += ")";
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
# abc119_a
year, month, day = map(int, input().split("/"))
if month <= 4:
 print("Heisei")
else:
 print("TBD")

"""
from datetime import datetime
S=input()
to_dt=datetime.strptime(S,'%Y/%m/%d')
# 2019/04/30
from_dt=datetime(2019,4,30)
# 2019/04/30以前であれば、"Heisei"
# 以降は"TBD"
if to_dt <= from_dt:
 print("Heisei")
else:
 print("TBD")
"""


Measured memory_bytes: 2940
N=gets.chomp!.to_i
N.times do
  data = gets.chomp!.split(' ')
  data.collect! do |s|
    i=s.to_i
    i*=i
  end
  a=data[0];b=data[1];c=data[2]
  res=a+b==c||b+c==a||c+a==b
  puts res ? "YES" : "NO"
end


Measured memory_bytes: 6864
X,Y=map(int,input().split())

answer=0
if X==3:
  answer+=100000
elif X==2:
  answer+=200000
elif X==1:
  answer+=300000
  
if Y==3:
  answer+=100000
elif Y==2:
  answer+=200000
elif Y==1:
  answer+=300000
  
if X==1 and Y==1:
  answer+=400000
  
print(answer)

Measured memory_bytes: 9112
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,M;
  cin>>N>>M;
  vector<lint> A(N),S(N);
  REP(i,N)cin>>A[i];
  sort(ALL(A),greater<lint>());
  // for(auto e:A)cerr<<e<<" ";
  // cerr<<endl;
  S[0]=A[0];
  FOR(i,1,N)S[i]=S[i-1]+A[i];
  lint ok=2e5+2;
  lint ng=0;
  lint ans=0;
  while(ok-ng!=1){
    lint c=(ok+ng)/2;
    lint score=0;
    lint num=0;
    // cerr<<c<<endl;
    REP(i,N){
      lint l=-1,r=N;
      while(r-l!=1){
        lint cc=(l+r)/2;
        if(A[cc]>=c-A[i])l=cc;
        else r=cc;
      }
      // cerr<<l<<endl;
      if(l>=0){
        score+=S[l]+(l+1)*A[i];
        num+=l+1;
      }
    }
    // cerr<<endl;
    if(num<=M){
      ans=score+(c-1)*(M-num);
      ok=c;
      // cerr<<c<<" "<<num<<endl;
    }else{
      ng=c;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

bool binarySearch(int *A, int n, int key) {
    int low = 0, high = n;
    while (low < high) {
        int mid = (low + high) / 2;
        if (A[mid] == key) {
            return true;
        }
        else if (A[mid] > key) {
            high = mid;
        }
        else
            low = mid + 1;
    }
    return false;
}

int main() {
    int n, A[1000000], m;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &A[i]);
    }
    
    int sum = 0;
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
        int key;
        scanf("%d", &key);
        if (binarySearch(A, n, key))
            sum++;
    }
    printf("%d\n", sum);
    return 0;
    
}


Measured memory_bytes: 3016
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    t = int(ipt())
    for _ in range(t):
        n = int(ipt())
        camp = [[] for i in range(n+1)]
        camm = [[] for i in range(n+1)]
        ans = 0
        pn = 0
        for i in range(n):
            k,l,r = map(int,ipt().split())
            ans += min(r,l)
            if l >= r:
                camp[k].append(l-r)
                pn += 1
            else:
                camm[k].append(r-l)

        hq = []
        for i in range(1,n+1):
            for j in camp[i]:
                hpq.heappush(hq,j)
            t = len(hq)-i
            for j in range(t):
                hpq.heappop(hq)
        for i in hq:
            ans += i
            
        hq = []
        for i in range(n):
            for j in camm[n-i]:
                hpq.heappush(hq,j)
            t = len(hq)-i
            for j in range(t):
                hpq.heappop(hq)
        for i in hq:
            ans += i

        print(ans)



    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 105612
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(n % i == 0){
            ans += n / i - 1;
        } else {
            ans += n / i;
        }

    }
    cout << ans << endl;
}



Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, a[100000], b[100000], c[100000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++)
		cin >> c[i];
	sort(a, a + n); sort(b, b + n); sort(c, c + n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int k = lower_bound(a, a + n, b[i])- a;
		if (k == n) k--;
		while (k >= 0 && a[k] >= b[i]) k--;
		int o = upper_bound(c, c + n, b[i]) - c;
		sum += ((k + 1)*(n - o));
	}
	cout << sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 2560
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            set.add(s[i]);
        }
        System.out.println(set.size());

    }

}


Measured memory_bytes: 80224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 40
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int n,m1,m2,a,b,c,ans=INF,cnt=1;
int f[410][410];
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int main(){
	
	memset(f,0x3f,sizeof(f));
	f[0][0]=0;
	n=read(),m1=read(),m2=read();
	FUP(i,1,n)
	{
		a=read(),b=read(),c=read();
		FDW(j,400,a)
		{
			FDW(k,400,b)
			{
				f[j][k]=min(f[j][k],f[j-a][k-b]+c);
				int gcdd=gcd(j,k);
				if(j/gcdd==m1&&k/gcdd==m2)
				{
					ans=min(ans,f[j][k]);
					//printf("%d,%d\n",j,k);
				}
			}
		}
		//printf("%d\n",f[2][2]);
	}
	printf("%d\n",ans==INF?-1:ans);
    return 0;
}

Measured memory_bytes: 896
import java.util.*;
import java.math.BigDecimal;

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

	int n = sc.nextInt();
	while(n!=0){

	    BigDecimal a = new BigDecimal(sc.next());
	    BigDecimal b = new BigDecimal(sc.next());
	    BigDecimal sum = a.add(b);

	    if(a.toString().length()>80 || b.toString().length()>80 || sum.toString().length()>80){
		System.out.println("overflow");
	    }else{
		System.out.println(sum);
	    }
	    n--;
	}
    }
}

Measured memory_bytes: 11000