akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int n;
 cin>>n;
 vector<long long int> a;
 for(int i=0;i<n;i++)
 {
 	long long int x;
 	cin>>x;
 	a.push_back(x);
 }
 int ans=0;
 sort(a.begin(),a.end());
 for(int i=0;i<n-2;i++)
 {
 	for(int j=i+1;j<n-1;j++)
 	{
 	if(a[i]!=a[j])
 		{
 			for(int k=j+1;k<n;k++)
 				{
 					if(a[j]!=a[k] && a[i]!=a[k])
 					{
 						if(a[i]+a[j]>a[k])
 							ans++;
 					}
 				}
 		}
 	}
 }
 cout<<ans;
 return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int unsigned long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N= 10000001;
int b[N];

void solve() {
        int n; cin >> n;

        int sm= 1;

        for (int i = 2; i <= n; i++) {
                for (int j = i; j <= n; j+= i) b[j]+= 1;
                sm+= i* (b[i]+ 1);
	}

        cout << sm<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 81640
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main()
{
	int k;
	cin >> k;
	vector<int>num(k);
	for (int i = 0;i < k;i++) {
		num[i] = i + 1;
	}
	long long kotae = 0;
	for (int i = 1;i <= k;i++) {
	  for (int j = 1;j <= k;j++) {
	    for (int m = 1;m <= k;m++) {
          int x=gcd(i,j);
          kotae+=gcd(x,m);
        }
      }
	}
	cout << kotae << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline bool ok(ll ra,ll rb,ll k,ll tag)
{ll rm=ra+rb,nda=rm/(k+1),ndb=rm-nda;
if (tag==0&&nda==ra&&rm%(k+1)==k) return 0;
return (nda<=ra);
}
inline char getf(ll pos,ll k)
{return (pos%(k+1)==0?'B':'A');}
inline char getb(ll pos,ll k)
{return (pos%(k+1)==0?'A':'B');}
int main (){
	ll q,a,b,c,d;
	scanf ("%lld",&q);
	while (q--)
	{scanf ("%lld%lld%lld%lld",&a,&b,&c,&d);
	ll k=(max(a,b)-1)/(min(a,b)+1)+1;
	ll l=0,r=a+b;
	while (l<=r)
	{ll mid=(l+r)>>1ll;
	ll rod=mid/(k+1),rm=mid-rod*(k+1);
	ll ra=a-(rod*k+rm),rb=b-rod;
	if (ok(ra,rb,k,rm)) {l=mid+1;}
	else {r=mid-1;}
	}
	for (ll i=c;i<=min(r,d);i++) putchar(getf(i,k));
	for (ll i=max(c,r+1);i<=d;i++) putchar(getb(a+b-i+1,k));
	puts("");
	}
	return 0;
}
	

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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007



int main() {
    int A , B; cin >> A >> B;
    int num = 1;
    int ans = 0;
    while(num < B){
        num += (A-1);
        ans++;
    }
    cout << ans << endl;

}





Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,d;
    cin>>n>>d;
    int sum=0;
    while(n>0)
    {
        n=n-(2*d+1);
        sum++;
    }
    cout<<sum;
    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli base[7][7];
lli d[7][7];

int main(){

    lli h,w,k;
    cin>>h>>w>>k;

    REP(i,0,h){
        REP(j,0,w){
            char tmp;
            cin>>tmp;
            if(tmp=='.')base[i][j]=0;
            else base[i][j]=1;
        }
    }

    lli ans = 0;
    for(lli iBit=0;iBit<(1LL<<h);iBit++){
        for(lli jBit=0;jBit<(1LL<<w);jBit++){
            lli cnt=0;
            REP(i,0,h){
                REP(j,0,w){
                    if((iBit&(1LL<<i)) || (jBit&(1LL<<j))){
                        d[i][j]=2;
                    }
                    else{
                        d[i][j] = base[i][j];
                    }
                    if(d[i][j]==1)cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }

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


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

AB.sort()
cost = 0
cnt = 0
i = 0
while(cnt<M):
  a, b = AB[i]
  if M-cnt<=b:
    cost += a * (M-cnt)
    cnt = M
    break
  cost += a * b
  cnt += b
  i += 1
ans = cost
print(ans)

Measured memory_bytes: 27460
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n;
    cin>>n;
    vector<pair<string,int>> v;
    map<int,int> m;
    rep(i,n){
        string s;
        int p;
        cin>>s>>p; p*=-1;
        v.push_back({s,p});
        m[p] = i+1;

    }
    sort(v.begin(),v.end());
    rep(i,n){
        cout<<m[v[i].second]<<endl;
    }







    
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define MAX INT_MAX
#define MOD 1000000007
using namespace std;
int main()
{	

	ll n;
	cin>>n;
	if(n>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll n;
  cin >> n;

  string ans = "";
  while (n > 26) {
    n--;
    ans += ('a' + n % 26);
    n /= 26;
  }
  n--;
  ans += ('a' + n);
 

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

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


Measured memory_bytes: 3588
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int main() {
    int N; cin >> N;
    vector<int> draws;
    draws.push_back(1);
    for (int i=6; i<=N; i*=6) draws.push_back(i);
    for (int i=9; i<=N; i*=9) draws.push_back(i);

    int dp[N+1];
    fill(dp, dp+N+1, INF);
    dp[0] = 0;

    rep(i,N+1){
      rep(j,draws.size()){
        if (i >= draws[j]){
          dp[i] = min(dp[i], dp[i-draws[j]]+1);
        }
      }
    }

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


Measured memory_bytes: 640
from heapq import heapify, heappush, heappop

def solve():
    N, K = map(int, input().split())
    Ps = list(map(int, input().split()))

    ans = N - K + 1

    numAsc = 0
    num = 0
    P0 = -1
    for P in (Ps+[-1]):
        if P0 < P:
            num += 1
        else:
            if num >= K:
                numAsc += num-K+1
            num = 1
        P0 = P
    if numAsc > 0:
        ans -= numAsc - 1

    if K > 2:
        mins = [N] * N
        P = min(Ps[:K+1])
        mins[0] = P
        PQ = [(P, i) for i, P in enumerate(Ps[:K+1])]
        heapify(PQ)
        for i in range(K+1, N):
            heappush(PQ, (Ps[i], i))
            while True:
                P, pos = heappop(PQ)
                if i-K <= pos:
                    mins[i-K] = P
                    heappush(PQ, (P, pos))
                    break

        maxs = [-1] * N
        P = max(Ps[:K+1])
        maxs[0] = P
        PQ = [(-P, i) for i, P in enumerate(Ps[:K+1])]
        heapify(PQ)
        for i in range(K+1, N):
            heappush(PQ, (-Ps[i], i))
            while True:
                P, pos = heappop(PQ)
                if i-K <= pos:
                    maxs[i-K] = -P
                    heappush(PQ, (P, pos))
                    break

        isSorteds = [False] * N
        num = 0
        P0 = -1
        for i, P in enumerate(Ps+[-1]):
            if P0 < P:
                num += 1
                if num >= K-1:
                    isSorteds[i-K+1] = True  ###
            else:
                if num >= K:
                    numAsc += num-K+1
                num = 1
            P0 = P

        for i in range(N-K):
            L, R = Ps[i], Ps[i+K]
            minK, maxK = mins[i], maxs[i]
            if L == minK and R == maxK and not isSorteds[i]:
                ans -= 1

    print(ans)


solve()

Measured memory_bytes: 121824
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d",&N);
  std::vector<int> A(N);
  int sum=0;
  for (size_t i = 0; i < N; i++) {
    std::cin >> A[i];
    sum+=A[i];
  }
  double ave=(double)sum/N;
  int aveSei=round(ave);
  int cost=0;
  for (size_t i = 0; i < N; i++) {
    cost+=pow(aveSei-A[i],2);
  }
  printf("%d\n",cost);
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 1400

int dp[MAX][MAX],G[MAX][MAX];

int getLargestSquare(int H,int W)
{
  int maxWidth=0;
  for(int i=0;i<H;i++)
    {
      for(int j=0;j<W;j++)
	{
	  dp[i][j]=(G[i][j]+1)%2;
	  maxWidth |= dp[i][j];
	}
    }

  for(int i=1;i<H;i++)
    {
      for(int j=1;j<W;j++)
	{
	  if(G[i][j]){
	    dp[i][j]= 0;
	  } else {
	    dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
	    maxWidth=max(maxWidth,dp[i][j]);
	  }
	}
    }
  return maxWidth * maxWidth;
}

int main(void)
{
  int H,W;
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++)
    {
      for(int j=0;j<W;j++)
	{
	  scanf("%d",&G[i][j]);
	}
    }
  printf("%d\n",getLargestSquare(H,W));
  return 0;
}

Measured memory_bytes: 18068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, K;
    cin >> N >> K;
    map<ll, ll> cnt;
    ll a, b;
    rep(i, N)
    {
        cin >> a >> b;
        cnt[a] += b;
    }
    for (auto i : cnt)
    {
        K -= i.second;
        if (K <= 0)
        {
            cout << i.first;
            return 0;
        }
    }
    return 0;
}

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

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

    const int nmmax=50;
    char A[nmmax][nmmax],B[nmmax][nmmax];

    for(int y=0;y<N;++y)
        for(int x=0;x<N;++x)
            cin >> A[y][x];

    for(int y=0;y<M;++y)
        for(int x=0;x<M;++x)
            cin >> B[y][x];

    bool exist=false;

    for(int ly=0;ly<N;++ly){
        for(int lx=0;lx<N;++lx){
            if(ly+M-1>=N or lx+M-1>=N) continue;

            bool match=true;
            for(int y=0;y<M;++y)
                for(int x=0;x<M;++x)
                    if(A[ly+y][lx+x]!=B[y][x])
                        match=false;

            if(match)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}


Measured memory_bytes: 3548
/* ALDS1_7_B: Binary Tree */
/* 20181124 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#define N 25
#define NIL -1

typedef struct {
	int parent;
	int left;
	int right;
	int sibling;
	int childNum;
	int depth;
	int height;
} Tree;

void depthCal(Tree *node, int id, int depth);
int heightCal(Tree *node, int id);
void printTree(Tree *node, int n);

int main(void) {
	Tree *node = (Tree *)malloc(sizeof(Tree) * N);
	int i, n, id, left, right, root;

	scanf("%d", &n);

	for(i = 0; i < n; i++) {
		node[i].parent = NIL;
		node[i].sibling = NIL;
		node[i].childNum = 0;
	}

	for(i = 0; i < n; i++) {
		scanf("%d %d %d", &id, &left, &right);
		node[id].left = left;
		node[id].right = right;
		if(left != NIL) {
			node[left].parent = id;
			node[left].sibling = right;
			node[id].childNum++;
		}
		if(right != NIL) {
			node[right].parent = id;
			node[right].sibling = left;
			node[id].childNum++;
		}
	}

	for(i = 0; i < n; i++) {
		if(node[i].parent == NIL) {
			root = i;
			break;
		} 
	}

	depthCal(node, root, 0);
	heightCal(node, root);
	printTree(node, n);

	return 0;
}

void depthCal(Tree *node, int id, int depth) {
	if(id == NIL) return;
	node[id].depth = depth;
	depthCal(node, node[id].left, depth + 1);
	depthCal(node, node[id].right, depth + 1);
}

int heightCal(Tree *node, int id) {
	int h1 = 0, h2 = 0;

	if(node[id].left != NIL)
		h1 = heightCal(node, node[id].left) + 1;
	if(node[id].right != NIL)
		h2 = heightCal(node, node[id].right) + 1;

	node[id].height = h1 > h2 ? h1 : h2;

	return node[id].height;
}

void printTree(Tree *node, int n) {
	int id = 0, i = 0, child;
	
	while(id < n) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", 
			id, node[id].parent, node[id].sibling, node[id].childNum, node[id].depth, node[id].height);

		if(node[id].parent == NIL) {
			printf("root\n");
		} else if(node[id].childNum == 0) { /* node[id].left == NIL*/
			printf("leaf\n");
		} else {
			printf("internal node\n");
		}

		id++;
	}

}


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

const int MAX_NUM = 55555; // 55555 以下の素数の数は5637

int main() {
    vector<int> prime, prime5p1;
    bool p[MAX_NUM + 1];
    rep(i, MAX_NUM) p[i] = true;
    p[0] = false;
    p[1] = false;
    rep(i, MAX_NUM) {
        if (p[i] == true) {
            prime.push_back(i);
            for (int j=i+i; j<MAX_NUM; j+=i) p[j] = false;
        }
    }
    for (auto k : prime) if (k%5 == 1) prime5p1.push_back(k);

    int N;
    cin >> N;
    for (auto k : prime5p1) {
        if (N == 0) break;
        cout << k << " ";
        N--;
    }

    cout << endl;

    return 0;
}

 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,t,k[32],a[32][32],ans;
bool fl,flag;
int main(){
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		scanf("%d",&k[i]);
		for (j=1;j<=k[i];j++) scanf("%d",&a[i][j]);
	}
	for (t=1;t<=m;t++){
		fl=1;
		for (i=1;i<=n && fl;i++){
			flag=0;
			for (j=1;j<=k[i] && !flag;j++)
				if (a[i][j]==t) flag=1;
			if (!flag) fl=0;
		}
		ans+=fl;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
int main()
{
	int n;
	std::cin >> n;
	std::string str;
	std::cin >> str;
	int max = -1;
	for (int i = 1; i < n; i++)
	{
		int cnt = 0;
		std::string suba, subb;
		suba = str.substr(0, i);
		subb = str.substr(i);
		for (char j = 'a'; j <= 'z'; j++)
		{
			if (suba.find(j) != std::string::npos && subb.find(j) != std::string::npos)
			{
				cnt++;
			}
		}
		if (max < cnt)
		{
			max = cnt;
		}
	}
	std::cout << max << std::endl;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct BinaryIndexedTree{
	int n;
	vector<int>dat;
	BinaryIndexedTree(int n=0):n(n){
		dat.resize(n+1);
	}
	void add(int k,int x){
		for(k++;k<=n;k+=k&-k)dat[k]+=x;
	}
	int sum(int k){
		int ret=0;
		for(k++;k;k-=k&-k)ret+=dat[k];
		return ret;
	}
};

string S;
int K;

queue<int>que[26];


signed main(){
    cin>>S>>K;
    rep(i,S.size())que[S[i]-'a'].push(i);

    BinaryIndexedTree bit(222222);
    rep(i,S.size())bit.add(i,1);

    string ans(S.size(),'a');
    rep(i,S.size()){
        rep(j,26){
            if(que[j].size()==0)continue;
            int p=que[j].front();
            int cost=bit.sum(p)-1;
            if(cost<=K){
                K-=cost;
                ans[i]=j+'a';
                bit.add(p,-1);
                que[j].pop();
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6632
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

    ll x;
    cin>>x;

    cout<<(x*(x-1))/2<<endl;


}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    int x, c = 0;
    cin >> x;
    while(x/500 != 0)
    {
        x -= 500;
        c += 1000;
    }
    while(x/5 != 0)
    {
        x -= 5;
        c += 5;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  string s;
  cin>>n>>s;
  vector<ll>v1(10,-1);
  vector<ll>v2(10,-1);
  for(ll i=0;i<10;i++){
    for(ll j=0;j<n;j++){
      if(s[j]=='0'+i){
        v1[i]=j;
        break;
      }
    }
  }
  for(ll i=0;i<10;i++){
    for(ll j=n-1;j>=0;j--){
      if(s[j]=='0'+i){
        v2[i]=j;
        break;
      }
    }
  }
  for(ll i=0;i<10;i++){
    for(ll j=0;j<10;j++){
      if(v1[i]==-1||v2[j]==-1)continue;
      ll t=0;
      for(ll k=v1[i]+1;k<v2[j];k++){
        t|=(1<<(s[k]-'0'));
      }
      ll a=0;
      for(ll k=0;k<10;k++){
        if(t&(1<<k))a++;
      }
      ans+=a;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n;  cin >> n;
    vector<ll> l(n);
    rep(i,0,n) cin >> l[i];
    ll ans = 0;
    sort(ALL(l));

	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			int idx=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
			ans+=idx-j-1;
		}
	}

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


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

int main(){
	string a,b;
	cin>>a;
	b=a;
	reverse(a.begin(),a.end());
	for(int i=0;i<b.size();i++){
		if(b[i]=='b')
			b[i]='d';
		else if(b[i]=='d')
			b[i]='b';
		else if(b[i]=='q')
			b[i]='p';
		else if(b[i]=='p')
			b[i]='q';
	}
	if(a==b)cout<<"Yes";
	else cout<<"No";
//	main();
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ;
  int MAX = 0;
  string ans = "Yes";
  
  rep(i,n){
    int x ;
    cin >> x ;
    if(MAX - 2 >= x )
      ans = "No";
    MAX = max(x,MAX);
  }
    
  cout << ans ;


}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0,nn=(intl)(n);i<nn;++i)
#define Rep1(i,n) for(intl i=1,nn=(intl)(n)+1;i<nn;++i)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(intl ii=0,nn=(intl)(a.size());ii<nn;ii++){cin>>(a).at(ii);}
#define Input2(a,b) for(intl ii=0,nn=(intl)(a.size());ii<nn;ii++){cin>>(a).at(ii);cin>>(b).at(ii);}
#define mp make_pair
#define mt make_tuple
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
using si = set<intl>;
using vsi = vec<si>;
using mii = map<intl,intl>;
using vmii = vec<mii>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;



int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  intl N;
  cin >>N;
  cout <<N+N*N+N*N*N;
}

Measured memory_bytes: 3604
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    int  n, m ; 
    cin >> n >> m ; 
    vi  a(m),b(m) ; 
    vector <vi>  key(m+1, vi(15, 0)) ; 
    for (int i=0;i<m;i++){
    	cin >> a[i] >> b[i] ; 
    	for (int j=0;j<b[i];j++) {
    		cin >> key[i][j] ; 
    		key[i][j]-- ; 
    	}
    }
    vi  dp( 1<<n, 1e9 ) ; 
    dp[0] = 0 ; 
    for (int i=0;i<m;i++){ 
    	int now = 0 ; 
    	for (int j=0;j<b[i];j++){ 
    		now |= (1 << key[i][j] ) ; 
    	} 
    	if (i == 0) dp[now] = a[i] ; 
    	for (int  bit = 0; bit < (1<<n) && i>0 ; bit++ ) { 
    		dp[bit | now] = min(dp[bit | now], dp[bit]+a[i]) ; 
    	} 
    } 
    if (dp[ (1<<n) - 1 ] == 1e9) dp[(1<<n)-1] = -1 ; 
    co (dp[(1<<n)-1]) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3720
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();
		int n = scan.nextInt();
		List<Integer> p = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int a = scan.nextInt();
			p.add(a);
		}

		for (int i = 0; i < 100; i++) {
			if (!p.contains(x - i)) {
				System.out.println(x - i);
				break;
			} else if (!p.contains(x + i)) {
				System.out.println(x + i);
				break;
			}
		}
	}
}

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

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n[] = new int[3];
        n[0] = sc.nextInt();
        n[1] = sc.nextInt();
        n[2] = sc.nextInt();
        Arrays.sort(n);
        
        System.out.println(n[2] * 10 + n[1] + n[0]);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll par[55], ran[55];
ll n, m;
ll root(ll x) {
	return par[x] == x ? x : par[x] = root(par[x]);
}
bool same(ll x, ll y) {
	return root(x) == root(y);
}
void unite(ll x, ll y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (ran[x] == ran[y])ran[x]++;
	}
}
void yan() {
	for (int o = 1; o <= n; o++) {
		par[o] = o;
		ran[o] = 0;
	}
}
int main() {
	cin >> n >> m;
	P p[55];
	ll ans = 0;
	for (int i = 0; i < m; i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0; i < m; i++) {
		yan();
		ll p1 = p[i].first, p2 = p[i].second;
		for (int j = 0; j < m; j++) {
			if (i == j)continue;
			unite(p[j].first, p[j].second);
		}
		ll num;
		for (int k = 1; k <= 3; k++) {
			if (k == p1 || k == p2)continue;
			num = k;
			break;
		}
		if (root(p1) != root(p2) || root(p1) != root(num) || root(p2) != root(num))ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# AOJ 0582: Triangle Types
# Python3 2018.6.30 bal4u

sa = sb = sc = 0;
while True:
	a, b, c, = map(int, input().split())
	if a + b <= c or b + c <= a or c + a <= b: break
	if c < a: c, a = a, c
	if c < b: c, b = b, c
	t = (a*a + b*b) - c*c
	if   t == 0: sa += 1
	elif t  > 0: sb += 1
	else:        sc += 1
print(sa+sb+sc, sa, sb, sc)


Measured memory_bytes: 5604
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>

typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll W = 1000000007;
// tuple にすれば回るんじゃないかな。


using namespace std;
void omajinai() {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}



static function<ll(ll,ll)> sumfunc = [](ll l1,ll l2)->ll{return l1 + l2;};
class UF{
public:
    vector<ll> v;
    vector<ll> v2;
    function<ll(ll,ll)> func;
    UF(long t,function<ll(ll,ll)> func){
        v = vector<ll>(t);
        v2 = vector<ll>(t);
        for(int i = 0; i<v.size();i++) v[i] = i;
        this->func = func;
    }
    long getunion(long t){
        if(v[t] == t) return t;
        v[t] = getunion(v[t]);
        return v[t];
    }
    void unite(pair<long,long> p){
        long a = getunion(p.first), b = getunion(p.second);
        if(a>b) swap(a,b);
        v[b] = a;
        v2[a] = func(v2[b],v2[a]);
    }
    long sizeofunion(){
        long sum = 0;
        for(int i = 0 ; i<v.size();i++) if(v[i] == i ) sum++;
        return sum;
    }
};

class Main{
public:
    
    int N;
    vector<long> K;
    
    
    Main(){
        cin>>N;
        K = vector<long>(2);
        REP(i,N){
            long l; cin>>l;
            K[l%2]++;
        }
    }
    
    void run(){
        long l = K[1] - K[1]%2;
        K[0] += l/2;
        K[1] = K[1]%2;
        while(K[0] >1){
            l = K[0] - K[0]%2;
            K[0] -= l/2;
        }
        bool OK = K[0] + K[1] == 1;
        cout<<(OK? "YES":"NO")<<endl;
    }
};

int main(){
    omajinai();
    Main().run();
}

Measured memory_bytes: 384
N, X, M = map(int, input().split())

Visited = [0]*(M+1)
latestvisit = [0]*(M+1)
count = 0
latest = 0
proper = 0
        
for i in range (0, N):
	if Visited[X] > 0:
		latest = X
		latestvisit[X] = i
		proper = 1
		break
	latestvisit[X] = i
	Visited[X]+= 1
	X = (X**2)%M

for j in range (0, M+1):
	count+=(j*Visited[j])

if proper == 0:
	print(count)
	exit()
    
P = sum(Visited)
A = latestvisit[X]
B = latestvisit[(X**2)%M]
slouch = 0

for i in range (0, M):
	if latestvisit[i] >=B and latestvisit[i] <= A:
		slouch+=i

count+=((N-P)//(A-B+1))*slouch


for i in range (0, (N-P)%(A-B+1)):
	count+=X
	X = (X**2)%M

print(count)

Measured memory_bytes: 69172
import sys
input = sys.stdin.readline
a = list(map(int, input().split()))
mx = max(a)
sm = sum(a)
if ((mx * 3 - sm) % 2):
  print(((mx + 1) * 3 - sm) // 2)
else:
  print((mx * 3 - sm) // 2)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
vector<long long> transform(long long a){
  vector<long long> v;
  while(a) v.push_back(a % 10), a /= 10;
  reverse(v.begin(), v.end());
  return v;
}
long long recover(vector<long long> a){
  long long val = 0;
  for(long long i : a) val = val * 10 + i;
  return val;
}
long long sod(long long a){
  long long ans = 0;
  while(a) ans += a % 10, a /= 10;
  return ans;
}
long long nxt(long long cur){
  vector<long long> now = transform(cur);
  int len = now.size();
  vector<long long> ops; ops.push_back(cur);
  for(int i = 0; i < len; i++){
    for(int j = now[i] + 1; j <= 9; j++){
      vector<long long> mv = now;
      for(int k = i + 1; k < len; k++) mv[k] = 9;
      mv[i] = j;
      ops.push_back(recover(mv));
    }
  }
  sort(ops.begin(), ops.end(), [&](long long a, long long b){
    long long va = a * sod(b), vb = b * sod(a);
    if(va == vb) return a < b;
    return va < vb;
  });
  return ops[0];
}
int main(){
  int k; cin >> k;
  long long now = 1;
  for(int i = 0; i < k; i++){
    cout << now << endl;
    now = nxt(now + 1);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int A,B,C,D,m;
    cin >> m ;
    A=m/1000;
    B=(m/100)%10;
    C=(m/10)%10;
    D=m%10;
    if(A+B+C+D==7)
    {
        cout << A <<'+' << B << '+' << C << '+' << D << '=' <<7<<endl;
    }
    else if (A-B+C+D==7)
    {
        cout << A <<'-' << B << '+' << C << '+' << D << '=' <<7<<endl;
    }
    else if (A+B-C+D==7)
    {
        cout << A <<'+' << B << '-' << C << '+' << D << '=' <<7<<endl;
    }
    else if(A+B+C-D==7)
    {
        cout << A <<'+' << B << '+' << C << '-' << D << '=' <<7<<endl;
    }
    else if(A-B-C+D==7)
    {
        cout << A <<'-' << B << '-' << C << '+' << D << '=' <<7<<endl;
    }
    else if(A-B+C-D==7)
    {
        cout << A <<'-' << B << '+' << C << '-' << D << '=' <<7<<endl;
    }
    else if(A+B-C-D==7)
    {
        cout << A <<'+' << B << '-' << C << '-' << D << '=' <<7<<endl;
    }
    else if(A-B-C-D==7)
    {
        cout << A <<'-' << B << '-' << C << '-' << D << '=' <<7 <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  [k,s] <- map read . words <$> getLine :: IO [Int]
  let xy = [xpy | x <- [0..k], y <- [0..k], let xpy = x + y]
  let zs = [z | p <- xy, let z = s - p, z >=0 && z <= k]
  print $ length zs



Measured memory_bytes: 764
#include<iostream>
#include<cmath>
#include<map>

using namespace std;

int main(){


	char c[3][5];

	for(int i = 0;i < 3;i++){
		scanf("%s",c[i]);
	}

	printf("%c%c%c",c[0][0],c[1][1],c[2][2]);


    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    string S;
    cin >> S;

    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }

    return 0;
}

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

int main(){
  int K, A, B, S;
  S = 0;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++){
    if (i % K == 0){
      S++;
      cout << "OK" << endl;
      break;
    }
  }
  if(S == 0) cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 998244353ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

#define MAX_N 1000000
long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}
long long mod_inverse(long long a, long long m) {
	long long x, y;
	if(extgcd(a, m, x, y) == 1) return (m + x % m) % m;
	else return -1;
}
vector<long long> fact(MAX_N+1, INF);
long long mod_fact(long long n, long long& e) {
	if(fact[0] == INF) {
		fact[0]=1;
		if(MAX_N != 0) fact[1]=1;
		for(ll i = 2; i <= MAX_N; ++i) {
			fact[i] = (fact[i-1] * i) % MOD;
		}
	}
	e = 0;
	if(n == 0) return 1;
	long long res = mod_fact(n / MOD, e);
	e += n / MOD;
	if((n / MOD) % 2 != 0) return (res * (MOD - fact[n % MOD])) % MOD;
	return (res * fact[n % MOD]) % MOD;
}
// return nCk
long long mod_comb(long long n, long long k) {
	if(n < 0 || k < 0 || n < k) return 0;
	long long e1, e2, e3;
	long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3);
	if(e1 > e2 + e3) return 0;
	return (a1 * mod_inverse((a2 * a3) % MOD, MOD)) % MOD;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,b,k;
	cin>>n>>a>>b>>k;
	if(k==0) {
		cout<<1<<endl;
		return 0;
	}
	vector<ll> acm(n+1);
	REP(i,n+1) {
		if(i==0) acm[i]=mod_comb(n,i);
		else acm[i]=(acm[i-1]+mod_comb(n,i))%MOD;
	}
	ll ans=0;
	REP(i,n+1) {
		if((k-i*a)%b!=0) continue;
		ll ca=i, cb=(k-i*a)/b;
		ans+=(mod_comb(n,ca)*mod_comb(n,cb))%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 10368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = (iA + iB) % 24;

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long n, k, l;
    readlnTo(n, k, l);

    long[] p, q, r, s;
    foreach(i; iota(k)) {
        long pi, qi;
        readlnTo(pi, qi);
        p ~= pi-1;
        q ~= qi-1;
    }

    foreach(i; iota(l)) {
        long ri, si;
        readlnTo(ri, si);
        r ~= ri-1;
        s ~= si-1;
    }

    auto pqUFT = new UnionFindTree(n);
    foreach(i; iota(k)) {
        pqUFT.unite(p[i], q[i]);
    }

    auto rsUFT = new UnionFindTree(n);
    foreach(i; iota(l)) {
        rsUFT.unite(r[i], s[i]);
    }

    ulong[][] t;
    foreach(i; iota(n)) {
        t ~= [pqUFT.find(i), rsUFT.find(i)];
    }
    t.sort();
    auto u = t.assumeSorted();
    iota(n).map!(i => u.trisect([pqUFT.find(i), rsUFT.find(i)])[1].length).map!(to!string).join(" ").writeln();
}



Measured memory_bytes: 28540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.nextLine());
		int a = Integer.parseInt(sc.nextLine());
		int b = Integer.parseInt(sc.nextLine());

		System.out.println((x - a) % b);

		sc.close();
	}
}

Measured memory_bytes: 21972
// ALLAH \\
whoishussain.org
#include<bits/stdc++.h>
using namespace std;
main(){
long long n, t = 0, sum = 0, a[100100];
cin >>n;
for(int i = 0;i < n;i ++ ) cin >> a[i];
sort(a,a+n);
for(int i = 0;i < n;i ++){
if( sum * 2 < a[i] ) t = i;
sum += a[i];
}
cout << n - t << endl;
}

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

void a(){
    string s,t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s){
        cout << a-1 << " "<<b;
    }else{
        cout << a << " "<<b-1;
    }
}

void b(){
    string s;
    cin >> s;
    for(auto i:s){
        cout << 'x';
    }
}
int main(){
    b();
    return 0;
}

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

typedef long long ll;

int N, Q;
ll A[200010], B[200010];
ll ans;
int cnt;
multiset<ll> ms;

int main()
{
    cin >> N >> Q;
    for(int i = 0; i < N * 2; i++)cin >> A[i];
    for(int i = 0; i < N * 2; i++)cin >> B[i];

    for(int i = 1; i < N * 2 - 1; i++)
    {
        if(A[i] > B[i])
        {
            ans += A[i];
            cnt++;
        }
        else
        {
            ans += B[i];
        }
        ms.insert(abs(A[i] - B[i]));
    }

    for(int i = 0; i < Q; i++)
    {
        int id;
        ll a, b;
        cin >> id >> a >> b;
        if(id == 1 || id == 2 * N)
        {
            A[id - 1] = a;
            B[id - 1] = b;
        }
        else
        {
            cnt -= (A[id - 1] > B[id - 1]);
            cnt += (a > b);
            ans += -max(A[id - 1], B[id - 1]) + max(a, b);
            ms.erase(ms.lower_bound(abs(A[id - 1] - B[id - 1])));
            ms.insert(abs(a - b));
            A[id - 1] = a;
            B[id - 1] = b;
        }
        if(cnt % 2 == 0)cout << ans + A[0] + A[N * 2 - 1] << endl;
        else cout << ans - (*ms.begin()) + A[0] + A[2 * N - 1] << endl;
    }
}


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

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

const int nax = 1e5+20;
const  ll mod =  1e9+7;


//Modular Addition
inline void add_self(ll& a, ll b){
    a+=b;
    if(a>=mod)
        a-=mod;
}

//Modular Subtraction
inline void sub_self(ll& a , ll b){
    a -= b;
    if(a < 0)
        a+= mod;
}





int main(){
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n,k;
    cin>>n>>k;

    vector<ll>dp(k+1);

    dp[0] = 1;

    for(int child = 0; child < n; child++) {
        int upto;
        cin >> upto;
        vector<ll>fake(k+1);
        for (int used = k; used >= 0; --used) {
            int L = used+1;
            int R = used + min(upto, k - used);
            ll tmp = dp[used];
            if (L <= R) {
                add_self(fake[L], tmp);
                if (R + 1 <= k) {
                    sub_self(fake[R + 1], tmp);
                }
            }

        }
        ll prefix_sum = 0;

        for(int i = 0; i <= k; ++i){
            add_self(prefix_sum,fake[i]);
            add_self(dp[i],prefix_sum);
        }
    }

    cout<<dp[k];







}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;
    set<ll> st;
    bool flag = 1;
    rep(i,N){
        ll a;cin >> a;
        ll S  = st.size();
        st.insert(a);
        if(S == st.size()){
            flag = 0;
        }
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

using namespace std;
using ll = long long;

template <typename T>
struct edge
{
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge &operator=(const int &x)
	{
		to = x;
		return *this;
	}

	operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T>>;
template <typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T>
using Matrix = vector<vector<T>>;

template <typename T>
vector<T> dijkstra(WeightedGraph<T> &g, int s)
{
	const auto INF = numeric_limits<T>::max();
	vector<T> dist(g.size(), INF);

	using Pi = pair<T, int>;
	priority_queue<Pi, vector<Pi>, greater<Pi>> que;
	dist[s] = 0;
	que.emplace(dist[s], s);
	while (!que.empty())
	{
		T cost;
		int idx;
		tie(cost, idx) = que.top();
		que.pop();
		if (dist[idx] < cost)
			continue;
		for (auto &e : g[idx])
		{
			auto next_cost = cost + e.cost;
			if (dist[e.to] <= next_cost)
				continue;
			dist[e.to] = next_cost;
			que.emplace(dist[e.to], e.to);
		}
	}
	return dist;
}

int main()
{
	int n, m;
	cin >> n >> m;
	WeightedGraph<ll> g(n);
	for (int i = 0; i < n - 1; ++i)
	{
		g[i + 1].push_back({i + 1, i, 0});
	}
	for (int i = 0; i < m; ++i)
	{
		int l, r;
		ll c;
		cin >> l >> r >> c;
		g[l - 1].push_back({l - 1, r - 1, c});
	}
	auto ans = dijkstra(g, 0).at(n - 1);
	if (ans > 1e18)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}
}

Measured memory_bytes: 10104
# 写経#2284578
S = input()
alp = "abcdefghijklmnopqrstuvwxyz"
def h(string, least = 'Z'):
  for c in alp:
    if c not in string:
      if c <= least:
        continue
      return string + c
  if string == "":
    return "-1"
  return h(string[:-1], string[-1])
print(h(S))

Measured memory_bytes: 61772