akhauriyash/Code-Regression huggingface dataset:
import math

def factorize(n):
    ret={}
    i = 2
    while n >= i**2:
        cnt = 0
        while n % i == 0:
            n //= i
            cnt += 1
        if cnt != 0:
            ret[i] = cnt
        i += 1
    if n != 1:
        ret[n] = 1
    return ret

def combination(n,r):
    ret = 1
    r = min(r, n-r)
    for i in range(n-r+1, n+1):
        ret *= i
    for i in range(1, r+1):
        ret //= i
    return ret


# mの各素因数を振り分ける
# 各素因数p(^a)について，nつに振り分ける
# n-1+a C n-1 
n,m=map(int, input().split())
f = factorize(m)
ans = 1
for k,v in f.items():
    ans *= combination(n-1+v, v)
    ans %= (int(1e9+7))
print(ans)



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

const int maxn = 200005;

int a[maxn], b[maxn], aa[maxn], bb[maxn];
int n;

int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%d", &b[i]);
    }
    int answer=0;
    for(int i=0;i<=28;i++){
        for(int j=1;j<=n;j++){
            aa[j]=a[j]%(1<<(i+1));
            bb[j]=b[j]%(1<<(i+1));
        }
        sort(bb+1,bb+n+1);
        int t=(1<<(i));
        int sum=0;
        for(int j=1;j<=n;j++){
            int p1=lower_bound(bb+1,bb+n+1,t-aa[j])-bb;
            int p2=lower_bound(bb+1,bb+n+1,2*t-aa[j])-bb;
            int s1=lower_bound(bb+1,bb+n+1,3*t-aa[j])-bb;
            int s2=lower_bound(bb+1,bb+n+1,4*t-aa[j])-bb;
            sum+=(p2-p1)+(s2-s1);
        }
        if(sum&1)
        answer+=(1<<i);
    }
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

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 U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X;
	cin >> N >> X;
	int ans = 0;
	int cur = 0;
	if (X >= 0)ans++;
	REP(i, N) {
		int l;
		cin >> l;
		cur += l;
		if (cur <= X)ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using ll = long long;

int main() {
  int N; cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  auto isGood = [&] (ll K) -> bool {
    ll tot = 0;
    for (int i = 0; i < N; i++) {
      tot += (1 + A[i] + K) / (N+1);
    }
    return tot <= K;
  };
  ll ans = 50.1e16;
  for (int m = 0; m <= N; m++) {
    ll mi = -1, ma = 1.1e16;
    while (ma - mi > 1) {
      ll md = (mi + ma) / 2;
      if (isGood(md * (N+1) + m)) ma = md;
      else mi = md;
    }
    ans = min(ans, ma * (N+1) + m);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  ll n;
  cin >> n;
  vector<ll> A(5);
  loop(i,0,5) cin >> A[i];
  sort(A.begin(), A.end());
  ll m = (n/A[0]) + (n%A[0]!=0);
  cout << m+4 << endl;
}


Measured memory_bytes: 256
n = int(input())

S = []
H = []
C = []
D = []
Slist = []
Hlist = []
Clist = []
Dlist = []

for i in range(n):
    mark, number = map(str, input().split())
    
    if mark=='S':
        S.append(int(number))
    if mark=='H':
        H.append(int(number))
    if mark=='C':
        C.append(int(number))
    if mark=='D':
        D.append(int(number))

if S==[]:
    Slist.append(1,2,3,4,5,6,7,8,9,10,11,12,13)
if H==[]:
    Hlist.append(1,2,3,4,5,6,7,8,9,10,11,12,13)
if C==[]:
    Clist.append(1,2,3,4,5,6,7,8,9,10,11,12,13)
if D==[]:
    Dlist.append(1,2,3,4,5,6,7,8,9,10,11,12,13)

else:
    
    Slen = len(S)
    Hlen = len(H)
    Clen = len(C)
    Dlen = len(D)

    for i in range(Slen):
        for j in range(Slen-1,0,-1):
            if S[j-1]>S[j]:
                S[j-1],S[j] = S[j],S[j-1]

    for i in range(Hlen):
        for j in range(Hlen-1,0,-1):
            if H[j-1]>H[j]:
                H[j-1],H[j] = H[j],H[j-1]

    for i in range(Clen):
        for j in range(Clen-1,0,-1):
            if C[j-1]>C[j]:
                C[j-1],C[j] = C[j],C[j-1]

    for i in range(Dlen):
        for j in range(Dlen-1,0,-1):
            if D[j-1]>D[j]:
                D[j-1],D[j] = D[j],D[j-1]
    
    if S[Slen-1]<13:
        S.append(0)
    if H[Hlen-1]<13:
        H.append(0)
    if C[Clen-1]<13:
        C.append(0)
    if D[Dlen-1]<13:
        D.append(0)

    for i in range(13):
        if S[i]==i+1:
            pass
        else:
            S.insert(i,0)
            Slist.append(i+1)

    for i in range(13):
        if H[i]==i+1:
            pass
        else:
            H.insert(i,0)
            Hlist.append(i+1)

    for i in range(13):
        if C[i]==i+1:
            pass
        else:
            C.insert(i,0)
            Clist.append(i+1)

    for i in range(13):
        if D[i]==i+1:
            pass
        else:
            D.insert(i,0)
            Dlist.append(i+1)

if Slist==[]:
    print('',end='')
if Hlist==[]:
    print('',end='')
if Clist==[]:
    print('',end='')
if Dlist==[]:
    print('',end='')

else:
    Sll = len(Slist)
    Hll = len(Hlist)
    Cll = len(Clist)
    Dll = len(Dlist)

    for i in range(Sll):
        print('S',Slist[i])
    for i in range(Hll):
        print('H',Hlist[i])
    for i in range(Cll):
        print('C',Clist[i])
    for i in range(Dll):
        print('D',Dlist[i])


Measured memory_bytes: 5748
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	constexpr int MAX = 3100;
	
	int N, S;
	int ans = 0;
	vector<int> A, dp(MAX);
	
	cin>>N>>S;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++)
		cin>>A[i];
	
	for(int i = 0; i < N; i++){
		for(int k = MAX - A[i] - 1; k >= 0; k--)
			dp[k+A[i]] = (dp[k+A[i]]+dp[k])%MOD;
		dp[A[i]] = (dp[A[i]]+(i+1))%MOD;
		ans = (ans + dp[S])%MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
        string s;
        cin >> s;
        for (int i = 0; i < s.size() - 1; i ++) {
                if (s[i] == 'A' && s[i + 1] == 'C') return !printf("Yes\n");
        }
        printf("No\n");
        return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<long long> Arr(N);
  for (int i = 0; i < N; i++)
    cin >> Arr[i];
  sort(Arr.begin(), Arr.end());
  vector<long long> Lis;
  for (int i = N - 1; i >= 0; i--) {
    if (i >= 1 && Arr[i] == Arr[i - 1]) {
      Lis.push_back(Arr[i]);
      i--;
    }
  }
  if (Lis.size() < 2) {
    cout << 0 << endl;
    return 0;
  }

  cout << Lis[0] * Lis[1] << endl;
}


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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long int;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
	map<int,int> kosuu;
	int k,n;
	int buf;
	cin>>n>>k;
	REP(i,n){
		cin>>buf;
		kosuu[buf]++;
	}
	vector<P> kkk;
	for(auto x:kosuu){
		kkk.pb(x);
	}

	sort(all(kkk),[](auto x,auto y) -> int {
		return (x.second<y.second);
	});

	int ans=0;
	int idx=0;
	REP(i,sz(kosuu)-k){
		ans+=kkk[idx++].second;
	}
	cout<<ans<<"\n";
	return 0;
	/*
	int ans=0;
	if(sz(kosuu)<=k){
		cout<<"0\n";
	}else{
		if(sz(kosuu)<k*2){
			ans=n;
			k=sz(kosuu)-k;
			while(sz(kosuu)>k){
				auto x=max_element(kosuu.begin(), kosuu.end(),[](auto a, auto b) {
										return a.second < b.second;
									});
				ans-=(*x).second;
				kosuu.erase(x);
			}
		}else{
			while(sz(kosuu)>k){
				auto x=min_element(kosuu.begin(), kosuu.end(),[](auto a, auto b) {
										return a.second < b.second;
									});
				ans+=(*x).second;
				kosuu.erase(x);
			}
		}
		cout<<ans<<"\n";
	}*/
	return 0;
}


Measured memory_bytes: 11768
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli dp[200100];
lli vis[200100];
string s;

lli calc(lli pos,char dir){
	if(dir != s.at(pos)){
		/*ここが行き止まりだとおしえてやる*/
		return pos;
	}
	if(vis[pos])return dp[pos];
	vis[pos]=1;
	if(dir=='R')dp[pos] = calc(pos+1,dir);
	else dp[pos]=calc(pos-1,dir);

	return dp[pos];
}

signed main(){

	cin>>s;

	/*再帰*/
	/*最終収束地点がどこになるかをメモる*/

	lli cnt[200100];
	REP(i,0,200100){
		cnt[i]=0;
		dp[i]=0;
		vis[i]=0;
	}

	lli size=s.size();
	REP(i,0,size){
		calc(i,s.at(i));
	}

	/*行き泊る場所はわかった*/
	/*そこまでにかかるカウンタからどこに収束するか計算する*/

	REP(i,0,size){
		lli act = abs(i-dp[i]);
		lli pos=dp[i];
		/*偶数回ならそのままdpの場所*/
		/*違うなら1個手戻る*/
		if(act%2==1){
			if(s.at(pos)=='R'){
				pos++;
			}
			else{
				pos--;
			}
		}
		if(DEBUG)cout<<" base="<<i<<" next="<<pos<<endl;
		cnt[pos]++;
	}

	if(DEBUG){
	REP(i,0,size){
		cout<<dp[i]<<endl;
	}
	}

	REP(i,0,size){
		cout<<cnt[i]<<" ";
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 8448
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int N = 1e5 + 1e2, INF = 1e15;
int n, W, mx, w[N], v[N], dp[110][N], ps[N];

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> W;
	for(int i = 1 ; i <= n ; i++){
        cin >> w[i] >> v[i];
	}
	for(int i = 1 ; i <= n ; i++){
        ps[i] = ps[i - 1] + v[i];
	}
	for(int i = 0 ; i <= n ; i++){
        for(int j = 0 ; j <= 1e5 ; j++){
            dp[i][j] = INF;
        }
	}
	for (int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= ps[i] ; j++){
            if(v[i] > j){
                dp[i][j] = dp[i - 1][j];
            }
            dp[i][j] = min(dp[i - 1][j] , dp[i - 1][j - v[i]] + w[i]);
        }
	}
	for (int i = 0; i <= n ; i++){
        for (int j = 0 ; j <= 1e5 ; j++){
            if (dp[i][j] <= W){
                mx = max (mx , j);
            }
        }
	}
	cout << mx + 1;
}
	/*cin >> n >> W;
	for (int i = 1 ; i <= n ; i++)
		cin >> w[i] >> v[i];
	for (int i = 1 ; i <= n ; i++)
		ps[i] = ps[i - 1] + v[i];
	for (int i = 0 ; i <= n ; i++){
		for (int j = 0 ; j <= 1e5 ; j++){
			dp[i][j] = INF;
		}
	}
	for (int i = 1 ; i <= v[0] ; i++){
		dp[0][i] = w[0];
	}
	for (int i = 1 ; i <= n ; i++){
		for (int j = 1 ; j <= ps[i] ; j++){
			if (v[i] > j){
				dp[i][j] = dp[i - 1][j];
			}
			dp[i][j] = min (dp[i - 1][j] , dp[i - 1][j - v[i]] + w[i]);
		}
	}
	for (int i = 0 ; i <= n ; i++){
		for (int j = 0 ; j <= 1e5 ; j++){
			if (dp[i][j] <= W){
				mx = max (mx , j);
			}
		}
	}
	cout << mx + 1;
}*/

Measured memory_bytes: 81408
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	int odd = 0, four = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] % 4 == 0) four++;
		else if (a[i] % 2 == 1) odd++;
	}

	if (four >= odd || four + 1 == odd && four + odd == N) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(((A*B)>(C*D)) || ((A*B)==(C*D))) cout<<A*B<<endl;
    else cout<<C*D<<endl;

    return 0;
}


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

using namespace std;

int main() {

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

	vector<int> kirai(k);
	for (int i = 0; i < k; i++) {
		cin >> kirai[i];
	}

	for (int i=n; i < n*200; i++) {
		int test = i;
		bool brkflg = false;
		while (1) {
			for (int j = 0; j < k; j++) {
				if (test % 10 == kirai[j]) {
					brkflg = true;
					break;
				}
			}
			if (brkflg) { break; }
			test /= 10;
			if (test == 0) {
				cout << i << endl;
				return 0;
			}

		}
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1000000007;

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

    int M;
    cin >> M;
    while (M--)
    {
        string s;
        cin >> s;
        int ans = 0;
        set<string> st;
        rep(i, s.size())
        {
            string x = "", y = "";
            rep(j, i + 1) x += s[j];
            Rep(j, i + 1, s.size()) y += s[j];
            rep(I, 2) rep(J, 2) rep(K, 2)
            {
                string X = x, Y = y;
                if (J)
                    reverse(all(X));
                if (K)
                    reverse(all(Y));
                string Z = (I == 1 ? X + Y : Y + X);
                if (st.find(Z) == st.end())
                {
                    ans++;
                    st.insert(Z);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3304
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N,M;
	cin>>N>>M;
	int ans=0;
  	int d=M/N;
	rep1(i,1e5){
		if(M%i==0){
			if(i<=d)ans=max(ans,i);
			if(N<=i)ans=max(ans,M/i);
		}
	}
	cout<<ans;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/
/*prime_test=================================================*/
bool prime_test(int num) {
    if (num < 2) return false;           // 0 と 1 除く
    else if (num == 2) return true;      //2はtrue
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    int sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0) return false;  // 素数ではない
    }
    // 素数である
    return true;
}
/*============================================================*/

/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int q; cin >> q;
    vi ruiseki(1e5+1);
    rep(i,1e5) ruiseki[i+1] = ruiseki[i]+((prime_test(i+1)&&prime_test((i+2)/2))? 1 : 0);

    int l, r;
    rep(i,q) {
        cin >> l >> r;
        cout << ruiseki[r] - ruiseki[l-1] << '\n';
    }
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    int r, d,x[11];
    cin >> r >> d >> x[0];
    if (r >= 2 && r <= 5 && d >= 1 && d <= 100 && x[0] > d && x[0] <= 200)
    {
        for (int i = 0; i < 11; i++)
        {
            if ((i + 1) != 11)
            {
                x[i + 1] = (r * x[i]) - d;
                cout << x[i + 1] << '\n';
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <math.h>
using namespace std;
int a, b, c;


int main() {
	int a[3],step=0;
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	while (!(a[0] == a[1]&&a[1] == a[2])) {
		sort(a, a + 3);
		if (a[0] + 2 <= a[2]) {
			a[0] += 2;
		}
		else {
			a[2] -= 1;
		}
		step++;
	}
	printf("%d\n", step);
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))

    data = []
    visited = set()
    data.append(1)
    visited.add(1)
    ai = 1
    while True:
        ai = A[ai - 1]
        if ai in visited:
            break
        data.append(ai)
        visited.add(ai)
    d_index = data.index(ai)
    if K > d_index:
        rep_data = data[d_index:]
        rep_len = len(rep_data)
        K -= d_index
        print(rep_data[K - K // rep_len * rep_len])
    else:
        print(data[K])

if __name__ == '__main__':
    main()


Measured memory_bytes: 131576
#include <bits/stdc++.h>
#define N 1000050
using namespace std;

char a[N],b[N];
int flag,ans,n;
queue<int> q;

int main() {
    scanf("%d%s%s",&n,a+1,b+1);
    for (int _=1;_<=n;_++) if (a[_] != b[_]) flag = 1;
    if (!flag) return puts("0"), 0;

    int p = n;
    for (int _=n;_>=1;_--) {
        if (b[_-1] == b[_]) continue;
        p = min(p, _);
        while (p && a[p] != b[_]) p--;
        if (!p) return puts("-1"), 0;

        #define sz (int)q.size()
        while (!q.empty())
            if (q.front()-sz >= _) q.pop(); else break;
        q.push(p);
        _!=p ? ans = max(ans,sz) :0;
    }
    printf("%d\n",ans+1);
    return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;

    int count = 1;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) != t.at(i)) count = 0;
    }

    if (count == 1) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> s[i][j];
    if ( h == 1 && w == 1 ) {
        cout << "Yes" << endl;
        return 0;
    }
    int dy[4] = {1, -1, 0, 0};
    int dx[4] = {0, 0, 1, -1};
    rep(i, h) rep(j, w) {
        bool ok = false;
        if ( s[i][j] == '#' ) {
            rep(k, 4) {
                int check_y = i + dy[k];
                int check_x = j + dx[k];
                if ( check_y >= h || check_y < 0 || check_x >= w || check_x < 0 ) continue;
                if ( s[check_y][check_x] == '#' ) ok = true;
            }
            if ( !ok ) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
  	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        int max = 0, result = 0;
        for(int i = 0; i < N; i++){
            max = Math.max(max, a[i]);
            result += a[i];
        }
        
        System.out.println(result - max/2);
    }
}

Measured memory_bytes: 21844
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, c, k = MII()
    if k%2==1:
        print(b-a)
    else:
        print(a-b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = new String(in.readLine());
		String[] ss = s.split(" ");
		int a = Integer.parseInt(ss[0]);
		int b = Integer.parseInt(ss[1]);
		int c = Integer.parseInt(ss[2]);
		int z = 0;
		for(int i = a;i < b+1 ; i++){
			if(c%i == 0){
				z++;
			}
		}
		System.out.println(z);
	}

}

Measured memory_bytes: 17004
n = int(input())
a = {}
for i in range(1, n+1):
    a[i] = int(input())
j = 1
c = 0
while (c < n):
    j = a[j]
    c += 1
    if j == 2:
        print(c)
        break
    if ((j != 2) & (c >= n)):
        print(-1)
        break

Measured memory_bytes: 17892
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, m, l[100000], r[100000], a = 1;
    cin >> n >> m;
    for (int i = 0;i < m; i++) {
        cin >> l[i] >> r[i];
        if (l[i] > a) a = l[i];
        if (n > r[i]) n = r[i];
    }
    if (n >= a) {
        cout << n - a + 1 << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if (a <= b)
			System.out.println(a);
		else if (a > b)
			System.out.println(a - 1);
		scanner.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  char A[50][50], B[50][50];
  for(int i=0; i<N; ++i) scanf("%s", &A[i][0]);
  for(int i=0; i<M; ++i) scanf("%s", &B[i][0]);
  for(int Ay=0; Ay<=N-M; ++Ay)
    for(int Ax=0; Ax<=N-M; ++Ax)
      if([&](int x, int y){
        for(int i = 0; i < M; i++)
          for(int j = 0; j < M; j++)
            if(A[x+i][y+j] != B[i][j])
              return 0;
        return 1;
      }(Ax, Ay))
      {
        cout << "Yes" << endl;
        return 0;
      }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>
int main(){
long long n,m,i,j,k,l,x,y,z,a,b,c,q;
double w;
x=0;y=0;z=0;
scanf("%lld",&q);
for(j=0;j<q;j++){
x=0;
scanf("%lld%lld",&a,&b);if(a>b){c=a;a=b;b=c;}
if(a==b||a+1==b){printf("%lld\n",2*a-2);}else{
y=a*b;
w=sqrt(y-1);
n=w/1;
if(n*n>y-1){n--;}
if(n*(n+1)<y){x++;}
printf("%lld\n",x+2*n-2);
}}
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  string S,T;
  cin>>S>>T;
  cout<<T+S<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string sa,sb;
int a[10001],b[10001],c[10001];
int main()
{
	cin>>sa>>sb;
	int lena=sa.size();
	sb.erase(sb.begin()+sb.find('.'));
	int lenb=sb.size(),lenc;
	for(int i=1;i<=sa.size();i++)a[sa.size()-i+1]=sa[i-1]-'0';
	for(int i=1;i<=sb.size();i++)b[sb.size()-i+1]=sb[i-1]-'0';
	int x=0;
	for(int i=1;i<=lena;i++)
	{
		int x=0;
		for(int j=1;j<=lenb;j++)
		{
			c[i+j-1]=a[i]*b[j]+x+c[i+j-1];
			x=c[i+j-1]/10;
			c[i+j-1]%=10;
		}
		c[i+lenb]=x;
	}
	lenc=lena+lenb;
	while(!c[lenc]&&lenc>1)
		lenc--;
	for(int i=lenc;i>=3;i--)cout<<c[i];
	if(lenc<=3)cout<<0;
}


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

int main()
{
    int n;
    cin>>n;
    while(n--){
        pair<double,double>a[4];
        for(int i=0;i<4;i++){
            cin>>a[i].first>>a[i].second;
        }
        if(abs((a[1].first-a[0].first)*(a[3].second-a[2].second)-(a[3].first-a[2].first)*(a[1].second-a[0].second))<1e-10)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cstring>
using namespace std;
char The[][26] = { "the","uif","vjg","wkh","xli","ymj","znk","aol","bpm","cqn","dro","esp","ftq","gur","hvs","iwt","jxu","kyv","lzw","max","nby","ocz","pda","qeb","rfc","sgd" };
char This[][26] = { "this","uijt","vjku","wklv","xlmw","ymnx","znoy","aopz","bpqa","cqrb","drsc","estd","ftue","guvf","hvwg","iwxh","jxyi","kyzj","lzak","mabl","nbcm","ocdn","pdeo","qefp","rfgq","sghr" };
char That[][26] = { "that","uibu","vjcv","wkdw","xlex","ymfy","zngz","aoha","bpib","cqjc","drkd","esle","ftmf","gung","hvoh","iwpi","jxqj","kyrk","lzsl","matm","nbun","ocvo","pdwp","qexq","rfyr","sgzs" };
char buf[128], tmp[128];
int main()
{
	while (fgets(buf, 128, stdin)) {
		strcpy(tmp, buf);
		int k = 0;
		bool found = false;
		char* p = strtok(buf, " ");
		while (p) {
			if (!found) for (int i = 0; i < 26; ++i)  {
				if (!strcmp(p, The[i]) || !strcmp(p, This[i]) || !strcmp(p, That[i])) {
					found = true;
					k = i;
					break;
				}
			}
			p = strtok(NULL, " ");
		}
		for (int i = 0; tmp[i]; ++i) {
			if ('a' <= tmp[i] && tmp[i] <= 'z')
				putchar((tmp[i] - 'a' - k + 26) % 26 + 'a');
			else
				putchar(tmp[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int n;
  cin>>n;
  int ans = n%1000;
  if(ans) ans = 1000-ans;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, k;
    cin>>n>>k;
    ll ans = k;
    rep(i, n - 1) ans *= k - 1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define maxN 400
int Res[maxN][maxN],m,n,k,cnt;
char A[maxN][maxN];
bool ok[maxN];
void check(int u,int v)
{
    int d=1,D=1;
    Res[u][v]=cnt;
    for (int i=v-1;i>=1;i--)
        if (A[u][i]=='#' || Res[u][i]!=0) break;
        else
        {
            Res[u][i]=cnt;
            D++;
        }
    for (int i=v+1;i<=n;i++)
        if (A[u][i]=='#' || Res[u][i]!=0) break;
        else
        {
            Res[u][i]=cnt;
            d++;
        }
    for (int i=u+1;i<=m;i++)
        if (ok[i]) break;
        else
        {
            for (int j=v;j<=d+v-1;j++)
                Res[i][j]=cnt;
            for (int j=v;j>=v-D+1;j--)
                Res[i][j]=cnt;
        }
    for (int i=u-1;i>=1;i--)
        if (ok[i]) break;
        else
        {
            for (int j=v;j<=d+v-1;j++)
                Res[i][j]=cnt;
            for (int j=v;j>=v-D+1;j--)
                Res[i][j]=cnt;
        }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    
    cin>>m>>n>>k;
    for (int i=1;i<=m;i++)
        for (int j=1;j<=n;j++)
        {
            cin>>A[i][j];
            if (A[i][j]=='#') ok[i]=1;
        }
    for (int i=1;i<=m;i++)
        for (int j=1;j<=n;j++)
            if (A[i][j]=='#')
            {
                cnt++;
                check(i,j);
            }
    for (int i=1;i<=m;i++)
    {
        for (int j=1;j<=n;j++) cout<<Res[i][j]<<' ';
        cout<<endl;
    }
}


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

int main(){
   int S, h, m, s;
   cin >> S;
  
   h=S/3600;
   m=S%3600/60;
   s=S%3600%60;
   
   cout << h << ":" << m << ":" << s << endl;
   
   return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <utility>
using namespace std;

map<string,int> atoms;
stringstream ss;
char name[8];

int parse(){
	map<string,int>::iterator it;

	int ans = 0;

	while(true){
		int w = 0;

		if( ss.peek() == '(' ){
			ss.ignore();
			w = parse();
			ss.ignore();
		}
		else if( isupper( ss.peek() ) ){
			ss >> name[0];

			if( islower( ss.peek() ) ){
				ss >> name[1];
			}
			else{
				name[1] = '\0';
			}

			it = atoms.find(name);
			if( it == atoms.end() ) throw 1;

			w = it->second;
		}
		else{
			break;
		}

		if( isdigit( ss.peek() ) ){
			int x;
			ss >> x;
			w *= x;
		}
		
		ans += w;
	}
	
	return ans;
}


int main(){
	string str;
	int w;
	
	while( cin >> str >> w ){
		atoms.insert( make_pair(str, w) );
	}
	cin.clear();

	while( cin >> str, str[0] != '0' ){
		ss.str(str);
		ss.clear();

		try{
			cout << parse() << '\n';
		}
		catch(int){
			cout << "UNKNOWN\n";
		}
	}
}

Measured memory_bytes: 1304
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=702;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=-INF;
static int t=120000;
class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int evaluate(){
    int sum=0;
    vector<int> l(ntype+1,0);
    for(int day=1;day<=D;++day){
        int type=ans[day];
        sum+=contest[type].s[day];
        l[type]=day;
        for(int t=1;t<=ntype;++t){
            sum-=contest[t].c*(day-l[t]);
        }
    }
    return sum;   
}

void Output(){
    for(int d=1;d<=D;++d) cout<<ans[d]<<endl;
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int temp=ans[p];
    ans[p]=rand()%ntype+1;
    int temp_score=evaluate();
    if(max_score<temp_score) max_score=temp_score;
    else ans[p]=temp;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int temp_score=evaluate();
    if(max_score<temp_score) max_score=temp_score;
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void solve(int times){
    max_score=evaluate();
    for(int i=0;i<times;++i){
        swap();
        change();
    }
}

int main(){
    srand(seed);
    Input();
    Greedy();
    solve(t);
    Output();
}

Measured memory_bytes: 3648
X, N = map(int, input().split())
p = list(input().split())
p = [int(p[i]) for i in range(N)]
ans = float('inf')
dif = float('inf')

for i in range(0, 102):
    if i not in p and abs(i - X) < dif:
        ans = i
        dif = abs(i-X)

print(ans)

Measured memory_bytes: 9196
/*
 *
 * Author: r3gz3n
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T=int> using order_statistics = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

const int MAX = 1e5 + 55;
vector<int> adj[MAX];
int in[MAX], dis[MAX];
bool vis[MAX];

void dfs(int from) {
    if (adj[from].size() == 0) dis[from] = 0;
    for(int to: adj[from]) {
        if (vis[to] == false) {
            vis[to] = true;
            dfs(to);
        }
        dis[from] = max(dis[from], dis[to] + 1);
    }
}


int main(int argc, char* argv[]) {
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    ios::sync_with_stdio(false);
    int n, m, x, y;
    cin >> n >> m;
    for (int i = 0;i < m;++i) {
        cin >> x >> y;
        adj[x].push_back(y);
        in[y]++;
    }
    for (int i = 1;i <= n;++i) {
        if (in[i] == 0) {
            dfs(i);
        }
    }
    int ans = 0;
    for (int i = 1;i <= n;++i) ans = max(ans, dis[i]);
    cout << ans << endl;
    return 0;
}


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

long long kMod = 1e9+7;

int main()
{
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  vector<long long> tmp(n);
  vector<long long> all(n);
  for (long long x = 0; x < n; x++) {
    for (long long y = 0; y < n; y++) {
      if (v.at(x) > v.at(y)) {
        all.at(y)++;
        if (x < y) {
          tmp.at(y)++;
        }
      }
    }
  }

  auto sum = accumulate(tmp.begin(), tmp.end(), 0);

  long long target = k * (k-1) / 2;
  long long res = (sum % kMod) * (k % kMod) % kMod;
  long long x = accumulate(all.begin(), all.end(), 0) % kMod;
  for (long long i = 0; (1LL << i) <= target; i++) {
    if (((1LL << i) & target) != 0) {
      res += x;
      res %= kMod;
    }
    x = 2 * x % kMod;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
    #define LF '\n'
    #define ALL(x) x.begin(), x.end()
    #define iostreamBooster() do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
    using namespace std;
    typedef int64_t i64;
    typedef pair<int,int> pii;
    template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
    template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
    constexpr int INF = 0x3f3f3f3f;
    constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;
    signed main()
    {
    string s;
    cin >> s;
    int len = s.length();
    int ans = INF;
    for (int i = 0; i < len; ++i) {
    string t = s.substr(i, 3);
    //cout << t << endl;
    if ((int)t.length() != 3) continue;
    chmin(ans, abs(stoi(t) - 753));
    }
    cout << ans << endl;
    return 0;
    }


Measured memory_bytes: 256
#include <cstdio>

char s[5];
int main () {
    scanf("%s", &s);
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
    if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
    else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
    else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
    else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
    else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
    else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
    else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
    else if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
}


Measured memory_bytes: 128
sx,sy,tx,ty = map(int,input().split())

dx = tx-sx
dy = ty-sy
ans = ''
ans = ans + 'U'*dy
ans = ans + 'R'*dx
ans = ans + 'D'*dy
ans = ans + 'L'*dx
ans = ans + 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
ans = ans + 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4];
	int n;
	scanf("%d",&n);
	for(int i=3;i>=0;i--)
	{
		a[3-i]=n%10;
		n/=10;
	}
	for(int i=0;i<3;i++)
	{
		if(a[i]==a[i+1])
		{
			printf("Bad");
			return 0;
		}
	}
	printf("Good");
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int cnt = 0;
    for(int i=0; i<n; ++i){
        if(s[i] == '.')
            ++ cnt;
    }

    int ans = cnt;
    for(int i=0; i<n; ++i){
        if(s[i] == '.')
            -- cnt;
        else
            ++ cnt;
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		long n = sc.nextLong();
		long p = sc.nextLong();
		if (n == 1) {
			System.out.println(p);
			return;
		}
		long x = 2;
		int cnt;
		long ans = 1;
		while (Math.ceil(Math.sqrt(p)) >= x) {
			cnt = 0;
			while (p % x == 0) {
				cnt++;
				p = p / x;
			}
			if (n <= cnt) {
				ans *= Math.pow(x, (cnt / n));
			}
			x++;

		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23988
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
int ans[maxn],d[maxn*2],fa[maxn*2],h[maxn*2],now[maxn*2],go[maxn*6],nxt[maxn*6],sta[maxn*6];
bool bz[maxn*6],czy;
int i,j,k,l,r,s,t,n,m,tot,top,rot1,rot2;
/*int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9'){
		
	}
}*/
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void dfs(int x,int y){
	int t=h[x];
	while (t){
		if (go[t]!=y){
			dfs(go[t],x);
			d[x]^=1;
		}
		t=nxt[t];
	}
	d[x]^=1;
}
void travel(int x){
	int t=now[x];
	while (t=now[x]){
		now[x]=nxt[t];
		if (!bz[(t+1)/2]){
			bz[(t+1)/2]=1;
			//now[x]=nxt[t];
			travel(go[t]);
		}
	}
	sta[++top]=x;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&fa[i]);
		if (fa[i]==-1){
			fa[i]=0;
			rot1=i;
		}
		else{
			add(fa[i],i);
			add(i,fa[i]);
		}
	}
	fo(i,n+1,2*n){
		scanf("%d",&fa[i]);
		if (fa[i]==-1){
			fa[i]=0;
			rot2=i;
		}
		else{
			add(fa[i]+n,i);
			add(i,fa[i]+n);
		}
	}
	dfs(rot1,0);
	dfs(rot2,0);
	czy=1;
	fo(i,1,n)
		if (d[i]^d[i+n]){
			czy=0;
			break;
		}
	if (!czy){
		printf("IMPOSSIBLE\n");
		return 0;
	}
	printf("POSSIBLE\n");
	s=0;
	add(s,rot1);
	add(rot1,s);
	add(s,rot2);
	add(rot2,s);
	fo(i,1,n)
		if (d[i]){
			add(i,i+n);
			add(i+n,i);
		}
	fo(i,s,2*n) now[i]=h[i];
	travel(s);
	fo(i,1,n)
		if (d[i]) ans[i]=-1;
	fo(i,1,top-1)
		if (sta[i]>0&&sta[i]<=n&&sta[i+1]==sta[i]+n) ans[sta[i]]=1;
	fo(i,1,n) printf("%d ",ans[i]);
}

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

int main(){
  bool flaga = false, flagb = false;
  for(int i = 0; i < 3; i++){
    char a;
    cin >> a;
    if(a == 'A') flaga = true;
    if(a == 'B') flagb = true;
  }
  if(flaga && flagb){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}

    

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

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

    vector<string> s(n);
    for (auto i = 0; i < n; i++) cin >> s[i];

    sort(s.begin(), s.end());
    for (auto i = 0; i < s.size(); i++) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
	
	double x1,x2,y1,y2,d;
	
	cin >> x1 >> y1 >> x2 >> y2 ;
	d=sqrt(pow(x1 -x2, 2)+pow(y1-y2, 2));
	
	printf("%.8f\n", d);
	return 0;	
}

Measured memory_bytes: 1240
# Problem: https://atcoder.jp/contests/abc088/tasks/abc088_b
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(cardCount, cardNumberList):
    result = 0
    cardNumberList.sort(reverse=True)
    #   print("整列済み {}".format(cardNumberList))
    # Aliceのターン
    AlicesCard = 0
    for j in range(0, cardCount, +2):
        #        print("Alice got {}".format(cardNumberList[j]))
        AlicesCard = AlicesCard + cardNumberList[j]
    BobsCard = 0
    for j in range(1, cardCount, +2):
        #           print("Bob got {}".format(cardNumberList[j]))
        BobsCard = BobsCard + cardNumberList[j]
    result = abs(AlicesCard-BobsCard)
    return result


if __name__ == "__main__":
    N = II()
    AI = LI()
    print("{}".format(solver(N, AI)))


Measured memory_bytes: 3064