akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(vec) vec.begin(), vec.end()
#define chmax(x, y) x = max(x, y);

using namespace std;
typedef pair<int, int> P;

int dp[3005][3005];

int main() {
	int N, T;
	cin >> N >> T;
	vector<P> p(N);

	REP(i, N) cin >> p[i].first >> p[i].second;
	sort(ALL(p));

	int ans = 0;

	REP(i, N) {
		REP(j, T) {
			chmax(dp[i + 1][j], dp[i][j]);
			int x = j + p[i].first;
			if (x < T) chmax(dp[i + 1][x], dp[i][j] + p[i].second);
		}
		chmax(ans, dp[i][T - 1] + p[i].second);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35456
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int n, m;
	map<string, ll> mp;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		if (mp.find(s) != mp.end())mp[s]++;
		else mp.insert(make_pair(s,1));
	}
	cin >> m;
	REP(i, m) {
		string s;
		cin >> s;
		if (mp.find(s) != mp.end())mp[s]--;
	}
	ll ans = 0;
	for (pair<string, ll> p : mp) {
		if (ans < p.second)ans = p.second;
	}
	cout << ans << endl;
}



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

def f(i, j):
    a = abs(j - i)
    b = abs(Y - j) + 1 + abs(X - i)
    c = abs(j - X) + 1 + abs(Y - i)

    d = min(a, b, c)
    return d

D = [0] * N
for j in range(2, N + 1):
    for i in range(1, j):
        d = f(i, j)
        D[d - 1] += 1

for i in range(N - 1):
    print(D[i])


Measured memory_bytes: 3444
n = gets.strip.to_i
s = gets.strip
max = 0
x = 0
(0...n).each do |i|
  ope = s[i]
  if ope == "I" then
    x += 1
    elsif ope == "D"
    x -= 1
  end
  
  if max < x then
    max = x
  end
end

puts max

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		ll* ppl = new ll[n];
		for(int i=0;i<n;i++){
			scanf("%lld",ppl+i);
		}

		sort(ppl,ppl+n);
		ll wait=0;
		ll sum=0;
		for(int i=0;i<n-1;i++){
			wait += ppl[i];
			sum+=wait;
		}

		delete[] ppl;

		cout << sum << endl;
	}
}

Measured memory_bytes: 0
import numpy as np
x1,y1,x2,y2=[int(a) for a in input().split()]
p1 = np.array([x1,y1])
p2 = np.array([x2,y2])
v1 = p2-p1
v2 = np.array([-v1[1],v1[0]])
p3 = p2+v2
p4 = p3+(-v1)
print(" ".join([str(v) for v in list(p3)+list(p4)]))

Measured memory_bytes: 12440
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;


int main(){
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        lli sum=0;
        for(ll i=1;i<=n;i++){
            if(i%5!=0 && i%3!=0){
                //cout<<i<<" ";
                sum+=i;
            }
        }
        cout<<sum;
    }
    return 0;
}
    

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

    int a,b,c;
    cin>>a>>b>>c;

    if(a==b&&b!=c||b==c&&a!=b||c==a&&b!=a){
        Yes(true);
    }else{
        Yes(false);
    }


}

Measured memory_bytes: 256
def swap(x):
    s = len(x)//2
    out = []
    if s>=1:
        for i in range(s):
            out.append([x[i][0],x[-1-i][1]])
            out.append([x[-1-i][0],x[i][1]])
        if len(x)%2==1:
            out.append([x[s][0],x[s][1]])
    else:
        out.append(x[0])
    return out

N, K = map(int, input().split())

if K == 1:
    for i in range(N):
        print(K+i,K+2*N-i-1,K+2*N+i)
elif K <= (N+1)/2:
    ans=[]
    for i in range(N):
        ans.append([K+i,K+2*N-i-1])
    if N%2 == 0:
        s=N//2
        ans_1 = ans[:s+1]
        ans_2 = ans[s+1:-1]
        ans_3 = ans[-1]
        ans_1_new = swap(ans_1)
        ans_2_new = swap(ans_2)
        ans_new = ans_1_new + ans_2_new + [ans_3]
    else:
        s=(N-1)//2
        ans_1 = ans[:s+1]
        ans_2 = ans[s+1:]
        ans_1_new = swap(ans_1)
        ans_2_new = swap(ans_2)
        ans_new = ans_1_new + ans_2_new
    ans = []
    for elem in ans_new:
        ans.append([elem[0],elem[1],elem[0]+elem[1]])
    ans = sorted(ans, key=lambda x: x[2])
    for i in range(N):
        ans[i][2] = K + 2*N + i
        print(ans[i][0],ans[i][1],ans[i][2])
else:
    print(-1)

Measured memory_bytes: 47464
S=input()
while len(S)>=5:
    if len(S)>=7 and S[-7:]=="dreamer":
        S=S[:-7]
        continue
    if len(S)>=6 and S[-6:]=="eraser":
        S=S[:-6]
        continue
    elif S[-5:]=="dream" or S[-5:]=="erase":
        S=S[:-5]
        continue
    else:
        break
if len(S)==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9124
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

h = int(arr_data[0][0])
w = int(arr_data[0][1])

arr_temp01=[]
for i in range(1,1+h):
    
    if arr_data[i][0]!= w * ".":
        
        arr_temp01.append(arr_data[i][0]) 
    else:
        h-=1

arr_temp02=[]
for v in list(zip(*arr_temp01)):
    
    if "".join(v) != h*".":
    
        arr_temp02.append("".join(v))
    else:
        w-=1
        
for v in list(zip(*arr_temp02)):
    
    print("".join(v))

Measured memory_bytes: 3188
H, W = map(int, input().split())
S = [input() for i in range(H)]
distW = [[0 for j in range(W)] for i in range(H)]
distH = [[0 for j in range(W)] for i in range(H)]

for i in range(H):
    j = 0
    while j < W:
        if S[i][j]==".":
            dj = 1
            for nj in range(1, W+1):
                if j+nj == W or S[i][j+nj] == "#":
                    for nnj in range(nj):
                        dj = nj
                        distW[i][j+nnj] = nj
                    break
            j += dj
        elif S[i][j]=="#":
            distW[i][j] = 0
            j+=1

for j in range(W):
    i = 0
    while i < H:
        if S[i][j]==".":
            di = 1
            for ni in range(1, H+1):
                if i+ni == H or S[i+ni][j] == "#":
                    di = ni
                    for nni in range(ni):
                        distH[i+nni][j] = ni
                    break
            i += di
        elif S[i][j]=="#":
            distH[i][j] = 0
            i+=1

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, distW[i][j]+distH[i][j]-1)

print(ans)

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

#define endl '\n'

void solvetask(){
    int n; cin >> n;
    if (n >= 30) cout << "Yes\n";
    else cout << "No\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int N,C,K;
    cin>>N>>C>>K;
    int ans=0;
    int cou=0;
    int first=-1;
    int lis[100001];
    for(int i=0;i<N;i++)cin>>lis[i];
    sort(lis,lis+N);
    for(int i=0;i<N;i++){
        int now;
        now=lis[i];
        if(first==-1){
            first=now;
            cou++;
            ans++;
        }
        else{
            if(now<=first+K){
                cou++;
            }
            else{
                first=now;
                cou=1;
                ans++;
            }
        }
        if(cou==C){
            cou=0;
            first=-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  trace(A, n);
  
  for( i = 2;i<=n;i++){
    key = A[i];
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1;
    while (j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    trace(A,n);
  }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
// #include <iostream>
// #include <stack>
// #include <vector>
// #include <string>
using namespace std;

/* 教訓: スペース区切りの標準入力は極力stringstreamを使って処理すべし */

int stack_polish(vector<string>);

int main(int argc, char const *argv[])
{
    string str_tmp;
    stringstream ss;
    vector<string> vs;

    getline(cin, str_tmp);
    ss << str_tmp;

    while (!ss.eof())
    {
        ss >> str_tmp;
        vs.push_back(str_tmp);
    }

    // for (int i = 0; i < (int)vs.size(); i++)
    // {
    //     cout << vs[i] << " ";
    // }
    // cout << endl;

    cout << stack_polish(vs) << endl;

    return 0;
}

int stack_polish(vector<string> vs)
{
    int res = 0;
    int operand_a = 0, operand_b = 0;
    stack<string> st;

    for (int i = 0; i < (int) vs.size(); i++)
    {
        if (vs[i] == "+")
        {
            // cout << "plus" << endl;
            operand_b = stoi(st.top());
            st.pop();
            operand_a = stoi(st.top());
            st.pop();
            st.push(to_string(operand_a + operand_b));
        }
        else if (vs[i] == "-")
        {
            // cout << "minus" << endl;
            operand_b = stoi(st.top());
            st.pop();
            operand_a = stoi(st.top());
            st.pop();
            st.push(to_string(operand_a - operand_b));
        }
        else if (vs[i] == "*")
        {
            // cout << "times" << endl;
            operand_b = stoi(st.top());
            st.pop();
            operand_a = stoi(st.top());
            st.pop();
            st.push(to_string(operand_a * operand_b));
        }
        else
        {
            st.push(vs[i]);   
            // cout << "pushed " << vs[i] << ", current size = " << st.size() << endl;
        }
    }

    res = stoi(st.top());
    return res;
}

// int ctoi(char c)
// {
//     int res = 0;
//     if (0 <= c && c <= 9)
//     {
//         res = 'c' - '0';
//     }
//     else
//     {
//         res = -1;
//     }

//     return res;
// }


Measured memory_bytes: 3284
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string names;

string karuta[100100];
int nn[400];
int main() {
	long long A = 0,B=0,C=0,D=0;
	cin >> A >> B >> C >> D;
	long long counto = 0;
	long long CC = 0, DD = 0,EE=0;
	CC = (B / C) - ((A-1) / C);
	DD = (B / D) - ((A-1) / D) ;
	EE = ((B / ((C/gcd(C , D))*D))) - ((A-1)/((C / gcd(C, D)) * D ));
	//cout << CC << endl;
	//cout << DD << endl;
	//cout << EE << endl;
	cout << B-(A-1)-CC-DD+EE << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
}


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

const int maxn=1e5+10;
int dp[maxn],in[maxn];
vector<int > G[maxn];
int main()
{
    queue<int> q;
    int n,m,a,b,ans = 0;
	scanf("%d%d",&n,&m);
    for(int i = 1;i<=m;++i)
		scanf("%d%d",&a,&b),in[b]++,G[a].push_back(b);
    for(int i = 1;i<=n;++i)
		if(!in[i]) q.push(i);
    while(!q.empty())
    {
        int now = q.front();
        q.pop();
        int sz = G[now].size();
        for(int i = 0;i<sz;++i)
        {
            dp[G[now][i]] = max(dp[G[now][i]],dp[now]+1);
            in[G[now][i]]--;
            if(in[G[now][i]]==0) q.push(G[now][i]);
        }
    }
    for(int i=1;i<=n;++i)
		ans = max(ans,dp[i]);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 9920
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>

#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPA(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#if defined(_MSC_VER)||__cplusplus > 199711L
#define AUTO(r,v) auto r = (v)
#else
#define AUTO(r,v) typeof(v) r = (v)
#endif
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(AUTO(it,(c).begin());it != (c).end();++it)
#define LL long long
#define int LL
#define INF  99999999
#define DEV 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
using namespace std;

double A, L, X;

signed main()
{
	QUICK_CIN;
	//ifstream cin("debug.txt");
	//ofstream cout("result.txt");

	while (cin >> A >> L >> X){
		double S = 0;
		S = L/2*sqrt(2 * L*X + X*X) + A / 4 * sqrt(4 * L*L - A*A);

		printf("%.10lf\n", S);

	}


}

Measured memory_bytes: 1256
#include <stdio.h>
#include <ctype.h>
#include <string.h>


int main() {
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	while (1) {
		C = C - B;
		if (C <= 0) {
			printf("Yes");
			break;
		}
		
		A = A - D;
		if (A <= 0) {
			printf("No");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1736
// header {{{
// #define NDEBUG
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)        (abs((a)-(b)) < EPS)
#define CILING(a, b)    (((a)+(b)-1)/(b))

template<class T>
using PIT = pair<int, T>;
template<class T>
using PTI = pair<T, int>;
using PII = pair<int, int>;
using PDI = pair<double, int>;
using LL  = long long;
using ULL = unsigned long long;
// }}}

int main() {
    int n, m;cin >> n >> m;
    queue<int> q[300];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int a;cin >> a;
            q[i].push(a);
        }
    }
    map<int, bool> dont;
    int ans = 40000;
    while(true){
        map<int, int> m;
        for(int i=0;i<n;i++){
            if(q[i].empty()){
                goto end;
            }
            while(dont[q[i].front()]){
                q[i].pop();
                if(q[i].empty()){
                    goto end;
                }
            }
            m[q[i].front()]++;
        }
        int maxk = 0;
        int maxv = 0;
        for(auto kv : m){
            if(kv.second > maxv){
                maxv = kv.second;
                maxk = kv.first;
            }
        }
        ans = min(ans, maxv);

        dont[maxk] = true;

        map<int, int> m2;
        for(int i=0;i<n;i++){
            if(q[i].empty()){
                goto end;
            }
            while(dont[q[i].front()]){
                q[i].pop();
                if(q[i].empty()){
                    goto end;
                }
            }
            m2[q[i].front()]++;
        }
        maxk = 0;
        maxv = 0;
        for(auto kv : m2){
            if(kv.second > maxv){
                maxv = kv.second;
                maxk = kv.first;
            }
        }
        ans = min(ans, maxv);
    }
end:

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


Measured memory_bytes: 768
#include<stdio.h>

int main()
{
     int n, m, l;
     int i, j, k;
     scanf("%d %d %d",&n,&m,&l);
     int a[n][m], b[m][l];
     long c[n][l];
     for(i=0;i<n;i++){
       for(j=0;j<m;j++){
         scanf("%d",&a[i][j]);
       }
     }
     for(i=0;i<m;i++){
       for(j=0;j<l;j++){
         scanf("%d",&b[i][j]);
       }
     }
 
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){ 
        c[i][j]=0;
        for(k=0;k<m;k++){
            c[i][j]+=a[i][k]*b[k][j];
            }
        printf("%ld",c[i][j]);
        if(j!=l-1){
            printf(" ");
            }else{
            printf("\n");
            }
        }  
      }
    return 0;
}


Measured memory_bytes: 2852
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

typedef complex<double> C;
typedef pair<C,C> pp;
typedef vector<C> VP;
#define eq(a,b) (fabs(a-b)<eps)
#define veq(a,b) (eq(a.real(),b.real())&&eq(a.imag(),b.imag()))
const C O{0,0};

void In(C& p){
	double x,y;
	cin>>x>>y;
	p=C(x,y);
}

void Out(C p){
	cout<<syosu(9)<<p.real()<<' '<<p.imag()<<endl;
}

double Dot(C p,C q){
	return p.real()*q.real()+p.imag()*q.imag();
}

double Det(C p,C q){
	return p.real()*q.imag()-q.real()*p.imag();
}

C Cross(C a,C b,C c,C d){
	C A=b-a,B=d-c;
	return a+A*Det(B,c-a)/Det(B,A);
}

int n;
C a,b,c,d;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		In(a);
		In(b);
		In(c);
		In(d);
		Out(Cross(a,b,c,d));
	}
}


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

using namespace std;

const int N = 100010;

struct Heap{
	Heap *l, *r;
	int val, len, size;
}*root[N], Pool[N * 2], *cur = Pool;

int fa[N];
priority_queue<pair<int, int> >Q;

Heap *newnode(int val_)
{
	cur++;
	cur -> len = 0;
	cur -> size = 1;
	cur -> val = val_;
	cur -> l = cur -> r = NULL;
	return cur;
}

Heap *Merge(Heap *A, Heap *B)
{
	if(!A)return B;
	if(!B)return A;
	if(A -> val > B -> val)swap(A, B);
	A -> r = Merge(A -> r, B);
	A -> size = (A -> l ? A -> l -> size : 0) + (A -> r ? A -> r -> size : 0) + 1;
	if(!(A -> l))swap(A -> l, A -> r);
	if(A -> l && A -> r && A -> l -> len < A -> r -> len)swap(A -> l, A -> r);
	if(A -> r)A -> len = A -> r -> len + 1;
	else A -> len = 0;
	return A;
}

int getf(int u)
{
	if(u == fa[u])return u;
	return fa[u] = getf(fa[u]);
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
	{
		int val;
		scanf("%d", &val);
		root[i] = newnode(val);
		fa[i] = i;
	}
	for(int i = 1; i <= m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x++; y++;
		int u, v;
		u = getf(x), v = getf(y);
		if(u > v)swap(u, v);
		fa[v] = u;
		root[u] = Merge(root[u], root[v]);
	}
	for(int i = 1; i <= n; i++)
		if(getf(i) == i)
		{
			Q.push(make_pair(root[i] -> size, i));
		}
	long long ans = 0;
	while(Q.size() > 1)
	{
		pair<int, int> v1 = Q.top();
		Q.pop();
		pair<int, int> v2 = Q.top();
		Q.pop();
		int u = v1.second, v = v2.second;
		if(!root[u] || !root[v])
		{
			puts("Impossible");
			return 0;
		}
		ans += (root[u] -> val + root[v] -> val);
		if(u > v)swap(u, v);
		fa[v] = u;
		root[u] = Merge(Merge(root[u] -> l, root[u] -> r), Merge(root[v] -> l, root[v] -> r));
		if(root[u])Q.push(make_pair(root[u] -> size, u));
		else Q.push(make_pair(0, u));
	}
	cout << ans << endl;
}

Measured memory_bytes: 6264
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def mod_cmb(n: int, k: int, p: int) -> int:
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if (k > n - k):
        return mod_cmb(n, n - k, p)
    c = d = 1
    for i in range(k):
        c *= (n - i)
        d *= (k - i)
        c %= p
        d %= p
    return c * pow(d, p - 2, p) % p

def main():
    n, k = i_map()
    num_list = i_list()

    first = 0
    second = 0

    for i in range(n):
        for j in range(i+1,n):
            if num_list[i] > num_list[j]:
                first += 1
        for j in range(n):
            if num_list[j] < num_list[i]:
                second += 1
    
    ans = first * k + k * (k-1) * second // 2

    print(ans%MOD)

if __name__ == '__main__':
    main()


Measured memory_bytes: 41708
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		string O = GetString();
		string E = GetString();
		
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < E.Length; i++)
		{
			sb.Append(O[i]);
			sb.Append(E[i]);
		}
		if(O.Length > E.Length)
			sb.Append(O[O.Length - 1]);

		Console.WriteLine(sb);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,Z,W;
int a[2010];

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

  cin >> N >> Z >> W;
  REP(i,N) cin >> a[i];
  int ans = abs(a[N-1]-W);
  if (N > 1) CHMAX(ans,abs(a[N-1]-a[N-2]));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans
string S;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> S;
    if (S[S.size() - 1] == 's')
        S += "es";
    else
        S += "s";
    cout << S << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int x,y;
    cin>>x>>y;
    bool flag=false;
    rep(i,x+1)
    {
        int b=i;
        int t=x-i;
        if(b*2+t*4==y)flag=true;
    }
    if(flag)
    {
        sayyes;
    }
    else
    {
        sayno;
    }
    
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <memory>
#include <memory.h>
using namespace std;

int d[21][21];

int main(){
  char ch;
  int n, m;
  memset(d, -1, sizeof(d));
  int x1, x2, y1, y2;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a, b, c, d2;
    cin >> a >> ch >> b >> ch >> c >> ch >> d2;
    d[a][b] = c;
    d[b][a] = d2;
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(d[j][i] < 0) continue;
      for(int k = 1; k <= n; k++){
	if(d[i][k] >= 0 && (d[j][k] < 0 || d[j][k] > d[j][i] + d[i][k])){
	  d[j][k] = d[j][i] + d[i][k];
	}
      }
    }
  }
  cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;
  cout << y1 - y2 - d[x1][x2] - d[x2][x1] << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    vector<bool> flags(N, false);
    //操作: 順列で隣り合う二つの数を選んでスワップする。
    int fcnt = 0;
    REP(i, N) {
        cin >> p[i];
        if(p[i] == i + 1) {
            fcnt++;
            flags[i] = true;
            // cout << p[i] << i + 1 << endl;
        }
    }
    if(fcnt == 0) {
        cout << 0 << endl;
        return 0;
    }
    long long cnt = 0;
    REP(i, N) {
        if(flags[i] == true) {
            if(i + 1 < N) {
                cnt++;
                std::swap(p[i + 1], p[i]);
                flags[i] = false;
                if(flags[i + 1] == true) {
                    flags[i + 1] = false;
                } else if(p[i + 1] == i + 2) {
                    flags[i + 1] = true;
                }
            }
        }
    }
    for(int i = N - 1; i >= 0; i--) {
        if(flags[i] == true) {
            cnt++;
            if(i - 1 >= 0) {
                std::swap(p[i - 1], p[i]);
                flags[i] = false;
                if(flags[i - 1] == true) {
                    flags[i - 1] = false;
                } else if(p[i - 1] == i) {
                    flags[i - 1] = true;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;

int main()
{
    int n;
    cin >> n;
    vector<int> A;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        A.push_back(temp);
    }
    sort(A.begin(), A.end());
    int max = A[n - 1];
    double near = abs((double)A[0] - max / 2.0);
    int ans = A[0];
    for (int i = 1; i < n - 1; i++)
    {
        double temp = abs((double)A[i] - max / 2.0);
        if (near > temp)
        {
            near = temp;
            ans = A[i];
        }
    }
    cout << max << " " << ans << endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
string s;
int a[2000010];
char str[500010];
void build(int t,int x,int y)
{
	if (x==y) a[t]=(1<<(s[x]-'a'));
	else
	{
		build(t*2+1,x,(x+y)/2);
		build(t*2+2,(x+y)/2+1,y);
		a[t]=a[t*2+1]|a[t*2+2];
	}
}
void cor(int t,int x,int y,int xi,int yi)
{
	if (x==y && x==xi) a[t]=(1<<yi);
	else
	{
		if (xi<=(x+y)/2) cor(t*2+1,x,(x+y)/2,xi,yi);
		else cor(t*2+2,(x+y)/2+1,y,xi,yi);
		a[t]=a[t*2+1]|a[t*2+2];
	}
}
int getit(int t,int x,int y,int xi,int yi)
{
	if (y<xi || x>yi) return 0;
	else if (xi<=x && y<=yi) return a[t];
	else return getit(t*2+1,x,(x+y)/2,xi,yi)|getit(t*2+2,(x+y)/2+1,y,xi,yi);
}
int main()
{
	scanf("%d%s",&n,&str);
	s=str;
	build(0,0,n-1);
	scanf("%d",&m);
	while (m--)
	{
		//cout <<m<<" ##\n"; 
		int typ;
		scanf("%d",&typ);
		if (typ==1)
		{
			int x;
			char c;
			scanf("%d %c",&x,&c);
			x--;
			cor(0,0,n-1,x,c-'a');
		}
		else
		{
			int x,y;
			scanf("%d%d",&x,&y);
			x--,y--;
			printf("%d\n",__builtin_popcount(getit(0,0,n-1,x,y)));
		}
	}
	return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int D,G;
    vector<int> p,c;

    cin>>D>>G;

    p.resize(D);
    c.resize(D);

    for(int i=0; i<D; i++){
        cin>>p[i]>>c[i];
    }
    int ans=1e9;

    for(int bits=0; bits<=(1<<D); bits++){
        int s=0,num=0,rest_max=-1;
        for(int i=0; i<D; i++){
            if(bits>>i & 1){
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }else{
                rest_max=i;
            }
        }
        if(s<G){
            int need;
            int s1=100*(rest_max+1);
            need=(G-s+s1-1)/s1;
            if(need>p[rest_max]){
                continue;
            }
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))

def main():
  n = int(input())
  A = readInts()
  A = sorted(A)
  ans = 0
  if n%2==1:#奇数ならば
    A.remove(0)
  if A[0::2]==A[1::2]:#偶数個数えた時と、奇数個数えた時
    ans = 2**(n//2)%(10**9+7)
  print(ans)
if __name__ == '__main__':
  main()

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main(){
  string a,b,c;
  int z,x,n=0;
  cin>>a>>b;
  z=a.size();
  x=b.size();
  for(int i=0;i<z+x;i++){
    c[n]=a[i];
    n++;
    c[n]=b[i];
    n++;
  }
  for(int i=0;i<z+x;i++){
    cout<<c[i];
  }
  cout<<"\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[409],sum[409][409],s[409];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    s[0]=a[0];
    for(int i=1;i<n;i++)s[i]=s[i-1]+a[i];
    for(int sz=1;sz<n;sz++)
    {
        for(int i=0;i<n-sz;i++)
        {
            sum[i][i+sz]=9999999999999999;
            for(int k=i;k<i+sz;k++)
            {
                sum[i][i+sz]=min(sum[i][k]+sum[k+1][i+sz],sum[i][i+sz]);
            }
            sum[i][i+sz]+=s[i+sz];
            if(i!=0)sum[i][i+sz]-=s[i-1];
        }
    }
    cout<<sum[0][n-1];
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
const int inf = 1e+9+10;
const ll linf = 1e+18;

const int MAXN = 2e+5 + 5;
int a[MAXN] = {0};
const ll mod = 1e+9 + 7;

void solve()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    
    int t = n - 1;
    ll res = 1;
    while(t > 0)
    {
        if(a[t] != 2)
        {
            cout << 0;
            return;
        }
        res *= 2;
        res %= mod;
        t -= 2;
    }
    
    if(n & 1 && a[0] != 1)
    {
        cout << 0;
        return;
    }
    
    cout << res;
}

int main()
{
    //ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define N 8
#define FREE -1
#define NFREE 1

int X[N][N];
int row[N], col[N], dpos[2*N-1], dneg[2*N-1];
int input_row[N];

void init(){
    for(int i=0;i<N;++i) row[i] = col[i] = FREE;
    for(int i=0;i<N*2-1;++i) dpos[i] = dneg[i] = FREE;
}
void printboard(){
    /*for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(X[i]==true){
                if(row[i]!=j) return;
            }
        }
    }*/
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(X[i][j]!=true) printf(".");
            else printf("Q");
        }
        printf("\n");
    }
}
void recur(int i){
    //printf("%d \n",i);
    if(i==N){
        printboard();
        return;
    }
    if(input_row[i]==true && i<N){
        recur(i+1);
    }
    for(int j=0;j<N;++j){
        if(col[j]==NFREE||dpos[i+j]==NFREE||dneg[i-j+N-1]==NFREE) continue;
        // 标记我们放了Q
        //row[i] = j;
        X[i][j] = true;
        col[j]=NFREE;
        dpos[i+j]=NFREE;
        dneg[i-j+N-1]=NFREE;
        recur(i+1);
        X[i][j] = false;
        //row[i]=FREE;
        col[j]=FREE;
        dpos[i+j]=FREE;
        dneg[i-j+N-1]=FREE;
    }
}

int main(){
    init();
    for(int i=0;i<N;++i){
        input_row[i] = false;
        for(int j=0;j<N;++j){
            X[i][j] = false;
        }
    }
    int k, r, c;
    cin>>k;
    for(int i=0;i<k;++i){
        cin>>r>>c;
        X[r][c] = true;
        input_row[r] = true;
        row[r] = NFREE;
        col[c] = NFREE;
        dpos[r+c] = NFREE;
        dneg[r-c+N-1] = NFREE;
    }
    recur(0);
    return 0;
}



Measured memory_bytes: 3076
S = input()
n = len(S)

answer = 0
for i in range(2 ** (n - 1)):
    total_sum = 0
    tmp = S[0]
    for j in range(n - 1):
        if (1 << j) & i:
            total_sum += int(tmp)
            tmp = S[j + 1]
        else:
            tmp += S[j + 1]
    total_sum += int(tmp)
    answer += total_sum

print(answer)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a,b,c,t;
    scanf("%d%d%d",&a,&b,&c);
    if(a<b)
    {
        t=a;
        a=b;
        b=t;
    }
    if(a<c)
    {
        t=a;
        a=c;
        c=t;
    }
    if(b<c)
    {
        t=b;
        b=c;
        c=t;
    }
    printf("%d\n",b+c);
    return 0;
}


Measured memory_bytes: 128
def main(n, w):
    res = max(w)
    for i in range(1, n):
        s_1, s_2 = w[:i], w[i:]

        _min = abs(sum(s_1) - sum(s_2))
        if _min < res:
            res = _min

    print(res)


if __name__ == '__main__':
    n = int(input())
    w = list(map(int, input().split(' ')))

    main(n, w)


Measured memory_bytes: 3060
#include<iostream>
//#include<vector>
//#include<algorithm>
//#include<numeric>
//#include<queue>
#include<cstdio>
#include<string>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int num=0;
  for(int i=0;i<n-1;++i){
    if(s[i]==s[i+1]) num++;
  }
  num = min(num+2*k, n-1);
  
  printf("%d\n", num);
  return 0;
}

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

int main(void){
    long n,x,m,ans=0;
    cin >> n >> x >> m;
    if(x==0){
        cout << 0 << endl;
        return 0;
    } 
    vector<long> k,s(m);
    map<long,long> mp;
    long cur = x,d=0,e=0;
    k.push_back(cur);
    mp[cur] = 1;
    for(int i=2;i<=m;i++){
        cur = (cur*cur)%m;
        k.push_back(cur);
        if(1<=mp[cur]){
            d = mp[cur];
            e = i;
            break;
        }  
        mp[cur] = i;
    }
    //cout << d << e << endl;
    long fsum = 0,cirsum=0,resum=0;
    for(int i=0;i<d-1;i++) fsum += k[i];
    for(int i=d-1;i<e-1;i++) cirsum += k[i];
    for(int i=0;i<=(n-d)%(e-d);i++) resum += k[d-1+i];
    //cout << fsum << ' ' << cirsum <<' '<<resum << endl;
    cout << fsum + (n-d)/(e-d)*cirsum + resum << endl;
}


Measured memory_bytes: 7448
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm.*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
// #define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}
/*		1. Take all the inputs
		4. Whenever you do multiplication and division in the same line, beware.
*/
void solve(){
	// int main  or  int32_t main ...
	double n;
	cin >> n;
	double tpi = 6.28318530717958623200;
	cout << tpi*n << endl;
}
/*	memset() can be used to set all values as 0 or -1 for integer data types.*/

int main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	std::cout << std::setprecision(20); std::cout << std::fixed;
	int t; t = 1;
	// cin >> t;
	while(t--){ solve(); }
	return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


Measured memory_bytes: 3608
N = int(input())
H = list(map(int, input().split()))

prev = H[-1]
for i in range(N - 2, -1, -1):
    #print(i)
    if not H[i] <= prev:
        if not H[i] - 1 <= prev:
            print('No')
            quit()
        else:
            H[i] -= 1
            prev = H[i]
    else:
        prev = H[i]
print('Yes')

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
int ans=0;
vector<vector<int>> search(int x,int y,vector<vector<int>> umi){
    umi[y][x]=-1;
    ans++;
    
    if(umi[y+1][x]!=-1){
        umi=search(x,y+1,umi);
    }
    if(umi[y][x-1]!=-1){
        umi=search(x-1,y,umi);
    }
    if(umi[y][x+1]!=-1){
        umi=search(x+1,y,umi);
    }
    if(umi[y-1][x]!=-1){
        umi=search(x,y-1,umi);
    }
    return umi;
}


int main(void){
    int h,w;
    char c;
    int x;
    int y;
    vector<vector<int>> umi;
    while(cin>>w>>h,h){
        vector<vector<int>> umi;
        vector<int> nul;
        for(int j=0;j<w+2;j++){
            nul.push_back(-1);
        }
        umi.push_back(nul);
        for(int i=0;i<h;i++){
            vector<int> tmp;
            tmp.push_back(-1);
            for(int j=0;j<w;j++){
                if(cin>>c,c=='@'){
                    tmp.push_back(1);
                    x=j+1;
                    y=i+1;
                }
                else if(c=='.'){
                    tmp.push_back(0);
                }
                else{
                    tmp.push_back(-1);
                }
            }
            tmp.push_back(-1);
            umi.push_back(tmp);
            getchar();
        }
        umi.push_back(nul);
        for(int i=0;i<h+2;i++){
            for(int j=0;j<w+2;j++){
                //cout<<umi[i][j]+1;
            }
            //cout<<endl;
        }
        search(x,y,umi);

        
        cout<<ans<<endl;
        ans=0;
    }
    
}

Measured memory_bytes: 4284
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    int N;

    cin >> N;
    
    cout << (N > 999 ? "ABD" : "ABC") << endl;
}


Measured memory_bytes: 256
t = [int(input()) for i in range(5)]

amari = []
totalTime = sum(t)

for num in t:
    if num%10 != 0:
        amari.append(10 - num%10)
amari.sort(reverse=True)

for i in amari[1:]:
    totalTime = totalTime + i

print(totalTime)

Measured memory_bytes: 3060
import java.util.*;
public class Main{public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  String po=n+"";
  String s[]=po.split("",0);
  int ans=0;
  for(int i=0;i<s.length;i++)ans+=Integer.parseInt(s[i]);
  System.out.println((n%ans==0)?"Yes":"No");
}}


Measured memory_bytes: 21332
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int, int> > S2;
	char ch;
	int sum = 0;
	for(int i = 0; cin >> ch; i++){
		if( ch == '\\' ) S1.push(i);
		else if( ch == '/' && S1.size() > 0 ){
			int j = S1.top(); S1.pop();
			sum += i-j;
			int a = i-j;
			while( S2.size() > 0 && S2.top().first > j ){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j,a));
		}
	}
	
	vector<int> ans;
	while( S2.size() > 0 ){ ans.push_back(S2.top().second); S2.pop(); }
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for(int i = 0; i < ans.size(); i++){
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3232