akhauriyash/Code-Regression huggingface dataset:
n = int(input())
array = [int(x) for x in input().split()]
sort_array = sorted(array)

tmp = n//2

tmp_array = sort_array[tmp-1:tmp+1]

for i in array:
    if i <= tmp_array[0]:
        print(tmp_array[1])
    else:
        print(tmp_array[0])


Measured memory_bytes: 25620
n = input()
count = 0
if(n[1] == 'R'):
  if(n[0] == 'R' and n[2] == 'R'):
    count = 3
  elif(n[0] == 'R' or n[2] == 'R'):
    count = 2
  else:
    count = 1
elif(n[0] == 'R' or n[2] == 'R'):
  count = 1
print(count)

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

using namespace std;

const int N=1050;

long long a[N],x,y;
int b[N],t;
int n,p;

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]);
	x=y=0;p=1;
	for (int i=1;i<=n;i+=2) 
		if (a[i]>0) x+=a[i];
	for (int i=2;i<=n;i+=2)
		if (a[i]>0) y+=a[i];
	for (int i=2;i<=n;++i)
		if (a[i]>a[p]) p=i;
	if (a[p]<=0){
		printf("%lld\n",a[p]);
		printf("%d\n",n-1);
		for (int i=n;i>=p+1;--i) printf("%d\n",i);
		for (int i=1;i<p;++i) puts("1"); 
		return 0;
	}
	p=0;t=0;
	if (x>=y){
		printf("%lld\n",x);
		for (int i=2;i<n;++i)
			if ((i&1) && a[i]<0){
				b[++t]=i-p;p+=2;
			}
		if (a[1]<0){
			b[++t]=1;b[++t]=1;p+=2;
		}
		if ((n&1) && a[n]<0) b[++t]=n-p,p++;
		for (int i=1;i<n-p;i+=2) b[++t]=2;
	}
	else{
		printf("%lld\n",y);
		for (int i=1;i<n;++i)
			if ((i&1)==0 && a[i]<0){
				b[++t]=i-p;p+=2;
			}
		if ((n&1)==0 && a[n]<0) b[++t]=n-p,p++;
		b[++t]=1;p++;
		for (int i=1;i<n-p;i+=2) b[++t]=2;
	}
	printf("%d\n",t);
	for (int i=1;i<=t;++i) printf("%d\n",b[i]); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
    cin>>N>>K;
    vec ans(3,-1);
    rep(i,N+1){
        rep(j,N+1-i){
            if(i*10000 + j*5000 + (N - i - j)*1000 == K){
                ans[0] = i;
                ans[1] = j;
                ans[2] = N - i - j;
            }
        }
    }
    cout<<ans[0]<<' '<<ans[1]<<' '<<ans[2]<<endl;
}

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

int sen(int M){
  int m=M;
  while(true){
    if(m<10){
      return m;
    }
    else m/=10;
  }
}
int main(){
  int N; cin >> N;
  vector<vector<int>> A(9, vector<int>(9));
  for(int i=1;i<N+1;i++){
    int a=i%10;
    int b=sen(i);
    if(a!=0){
    A[a-1][b-1]++;
    }
  }
  int ans=0;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      ans+=A[i-1][j-1]*A[j-1][i-1];
    }
  }
  cout << ans << endl;
}
      

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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int x = a*60+b;
  int y = c*60+d;
  cout << y-x-e << endl;
  return 0;
}


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

int n;
int a[200002];

int allxor = 0;

int main(){

	// Input
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		allxor ^= a[i];
	}

	// Slv
	for(int i=0;i<n;i++){
		if(i)cout<<" ";
		cout<<(a[i]^allxor);
	}
	cout<<endl;

	return(0);
}




Measured memory_bytes: 4412
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

#define MAX_N 200003
int par[MAX_N];
int dep[MAX_N];
int data[MAX_N];

void init(int nu) {
  for(int iu=0;iu<nu;iu++){
    par[iu] = iu;
    dep[iu] = 0;
    data[iu] = 1;
  }
}
int find(int xu){
  if(par[xu] == xu) return xu;
  return par[xu] = find(par[xu]);
}
void unite(int xu, int yu){
  data[xu] = 0;
  data[yu] = 0;
  xu=find(xu);
  yu=find(yu);
  if(xu == yu) return;
  if(dep[xu] < dep[yu]){
    par[xu] = yu;
  }else{
    par[yu] = xu;
    if(dep[xu] == dep[yu]) dep[xu]++;
  }
}
bool same(int xu, int yu){
  return find(xu) == find(yu);
}

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  init(2*N+1);
  int ui, vi, wi;
  range(i, N-1) {
    std::cin >> ui >> vi >> wi;
    if(wi%2==1){
      unite(ui, vi+N);
      unite(ui+N, vi);
    }else{
      unite(ui, vi);
      unite(ui+N, vi+N);
    }
  }
  for(int i=1;i<=N;i++){
    std::cout << (same(1, i)?0:1) << '\n';
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;
const ll INF = 1e12;

ll N, M, X;

ll C[20];
ll A[20][20];

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

    REP(i,N){
        ll c;
        cin >> c;
        C[i] = c;
        REP(j,M){
            cin >> A[i][j];
        }
    }

    ll ans = INF;
    for(int bit = 0; bit < (1LL << N); bit++){
        vector<ll> T(M, 0);
        ll tmp = 0;
        REP(i,N){
            if((bit >> i) & 1){
                ll c = C[i];
                tmp += c;
                REP(j,M){
                    ll a = A[i][j];
                    T[j] += a;
                }
            }
        }

        bool valid = true;
        REP(j,M){
            if(T[j] < X){
                valid = false;
                break;
            }
        }

        if(valid)
            chmin(ans, tmp);
    }

    if(ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}


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

#define mp          make_pair
#define pb          push_back
#define ff          first
#define ss          second
#define ii          pair<int,int>
#define mod         int(1e9+7)
#define inf         1e18

typedef long long int lli;
typedef long double ld;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

double dp[3005][3005];
double A[3005];

void solve()
{
    int n;
    cin>>n;
    cout<<fixed;
    cout<<setprecision(10);
    for(int i=0;i<n;i++)
        cin>>A[i];

    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
                dp[i][j]=dp[i-1][j]*(1-A[i-1]);
            else
                dp[i][j]=dp[i-1][j-1]*A[i-1] + dp[i-1][j]*(1-A[i-1]);
        }
    }
    double ans=0;
    for(int i=0;i<=n;i++)
    {
        if(i>n-i)
            ans+=dp[n][i];
    }
    cout<<ans<<endl;
}

int main()
{
    fio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
//    cin>>t;
    for(int i=0;i<t;i++)
    {
        solve();
    }
    return 0;
} 

Measured memory_bytes: 49944
N = int(input())
A = list(map(int,input().split()))
A2 = list(map(int,input().split()))
total = A[0] + sum(A2)
total2 = [total]
p = 0
if N > 1:
    for i in range(N-1) :
        total = total + A[i+1] - A2[i]
        total2.append(total)
    print(max(total2))
else:
    print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
const int mod=1e9+7;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
    return f*x;
}
int ksm(int a,int b){
	if(b<0) return 1;
	int ans=1;
	while(b){
		if(b&1) ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}
int f[2010][2010];//
int sum[10001];
main(){
	int n=read(),k=read();
	f[0][n+1]=1;
	for(int i=1;i<=k;i++){
		sum[n+1]=f[i-1][n+1];
		for(int j=n;j>=1;j--) sum[j]=(sum[j+1]+f[i-1][j])%mod;
		for(int z=1;z<=n-i+1;z++)
			f[i][z]=sum[z];
	}
	cout<<1ll*(f[k][1]-f[k-1][1]+mod)%mod*ksm(2,n-k-1)%mod;
}

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

using ll = long long;
using pii = pair<int, int>;

template<class T>
using max_heap = priority_queue<T>;
template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, long long D, long long A, std::vector<long long> X, std::vector<long long> H){
    vector<pii> XH;
    rep(i, N) XH.emplace_back(X[i], H[i]);
    sort(all(XH));

    queue<pii> que;
    ll ans = 0;
    ll cur = 0;
    rep(i, N) {
        while(!que.empty()) {
            auto a = que.front();
            if (XH[i].first <= a.first) break;
            que.pop();
            cur -= a.second;
        }

        if (XH[i].second - cur <= 0) continue;
        ll n = (XH[i].second - cur) / A;
        if ((XH[i].second - cur) % A > 0) n++;
        ans += n;
        cur += n * A;
        que.emplace(XH[i].first + 2LL * D,n * A);
    }

    cout << ans << endl;
}

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

    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    long long A;
    scanf("%lld",&A);
    std::vector<long long> X(N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&H[i]);
    }
    solve(N, D, A, std::move(X), std::move(H));
    return 0;
}


Measured memory_bytes: 5744
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    int N,X,T;
    scanf("%d %d %d",&N,&X,&T);
    int ans=(N/X+(N%X>0))*T;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
	int maxtime = 0, maxlen = 0;
	string str, maxTimeWord, maxLenWord;
	map<string, int> word;
	while (cin >> str)
	{
		if ((signed)str.length() > maxlen)
			maxlen = str.length(), maxLenWord = str;
		if ((word[str]++) >= maxtime)
			maxtime = word[str], maxTimeWord = str;
		if (cin.get() == '\n') break;
	}
	cout << maxTimeWord << " " << maxLenWord << endl;

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>
#include <boost/dynamic_bitset.hpp>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
	vector<string> vs(1);
	scan(vs);
	auto s = vs[0];
	int first = s.find("A");
	int last = s.rfind("Z");

  // cout << string(begin(s) + first, begin(s) + last + 1) << "\n";
	cout << last + 1 - first << "\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
	string s;
	getline(cin, s);

	if (s.size() == 0) {
		getline(cin, s);
	}

	for_each(begin(s), end(s), [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 640
/**
*   @Author : MeGaCrazy
*   @InitTime : Thu Jul 18 03:14:33 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;

//const int N=3e5+7;
//int l[N],r[N];
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
    vector<pair<char,int> > v;
    string s;
    int k;
    cin>>s>>k;
    set<string>st;
    for(int i=0;i<s.size();i++){
      string cur="";
      for(int j=i;j<s.size()&&cur.size()<5;j++){
          cur+=s[j];
          st.insert(cur);
      }
    }
    int cnt=0;  	
    string  ans="";
    for(auto it=st.begin();it!=st.end();it++){
         ans=*it;
         if(cnt+1==k)break;
         cnt++;
    }
    cout<<ans<<endl;







}

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

int main() {
  int N, M;
  int a, b;
  cin >> N >> M;
  
  int roads[N];
  for(int i = 0; i < N; i++) {
    roads[i] = 0;
  }
  
  for(int i = 0; i < M; i++) {
    cin >> a >> b;
    roads[a - 1]++;
    roads[b - 1]++;
  }
  
  for(int i = 0; i < N; i++){
    cout << roads[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
/*using P = pair<int, int>; */
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    str s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3620
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()

if n == 2:
    print(a[1], a[0])
elif abs(a[-1] / 2 - a[bisect_left(a, a[-1] / 2)]) < abs(a[-1] / 2 - a[bisect_left(a, a[-1] / 2) - 1]):
    print(a[-1], a[bisect_left(a, a[-1] / 2)])
else:
    print(a[-1], a[bisect_left(a, a[-1] / 2) - 1])

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

int main(){
    int N;
    cin >> N;
    
    vector<pair <int,int> > vec;
    
    for(int i = 0;i < N;i++){
        int a,b;
        cin >> a >> b;
        vec.push_back( make_pair(b,a));
    }
    
    sort(vec.begin(),vec.end());
    
    bool check = true;
    int sum = 0;
    for(int i = 0;i < N;i++){
        sum += vec[i].second;
        if(sum > vec[i].first){
            check = false;
            break;
        }
    }
    
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=500050,mod=1000000007;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,a[maxn],s[maxn],pre[maxn],ans,f[maxn];
vector<int> vec[1048576];
inline int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
int main(){
	n=read();
	pre[0]=1;
	FOR(i,1,n){
		vec[s[i]=s[i-1]^(a[i]=read())].PB(i);
		pre[i]=pre[i-1]+(s[i]==0);
	}
	FOR(_,1,1048575){
		int sum1=0,sum2=0;
		FOR(i,0,(int)vec[_].size()-1){
			f[i]=(1+1ll*pre[vec[_][i]-1]*sum1%mod-sum2+mod)%mod;
			if(!s[n] || vec[_][i]==n) ans=(ans+f[i])%mod;
			sum1=(sum1+f[i])%mod;
			sum2=(sum2+1ll*f[i]*pre[vec[_][i]])%mod;
		}
	}
	if(!s[n]) ans=(ans+qpow(2,vec[0].size()-1))%mod;
	printf("%d\n",ans);
}
// overrated(?)

Measured memory_bytes: 42228
K = int(input())+1
sum_gcd = 0
def gcd(p,q):
    if p % q == 0:
        return q
    return gcd(q,p%q)
for a in range(1,K):
    sum_gcd += a
    for b in range(a+1,K):
        gcd_ab =gcd(a,b)
        sum_gcd += gcd_ab*6
        for c in range(b+1,K):
            sum_gcd +=gcd(gcd_ab,c)*6
print(sum_gcd)


Measured memory_bytes: 9120
var
	N,i,ans,now:Longint;
	S:String;
	L,R:Array[0..300001]of Longint;
begin
	readln(N);
	readln(S);
	for i:=1 to N do begin
		L[i]:=L[i-1];
		if S[i]='W' then inc(L[i]);
	end;
	for i:=N downto 1 do begin
		R[i]:=R[i+1];
		if S[i]='E' then inc(R[i]);
	end;
	ans:=N;
	for i:=1 to N do begin
		now:=L[i-1]+R[i+1];
		if ans>now then ans:=now;
	end;
	writeln(ans);
end.


Measured memory_bytes: 3072
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val numberList = (1..n).map { readLine()!!.toInt() }
    val sorted = numberList.sortedDescending()
    numberList.forEach {
        if(it == sorted.first()) {
            println(sorted[1])
        } else {
            println(sorted.first())
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  
  string str;
  cin >> str;
  
  for (int i=0; i<str.size(); i++) {
    cout << char ( ((int)str.at(i) + N - 65) % 26 + 65);
  }
}

Measured memory_bytes: 256
from sys import stdin, stdout
import math
import bisect
import datetime
from collections import defaultdict
import random

def bl_solve(a):
    ans = []
    for k in range(2, a + 1):
        tmp = a
        while tmp > 0:
            if tmp % k == 0:
                tmp = tmp // k
            else:
                tmp -= k
            if tmp == 1:
                ans.append(k)
                break
    return ans

def bl_solve2(a):
    if a == 2:
        ans = 1
    else:
        ans = 2
    for k in range(2, int(math.sqrt(a))+1):
        tmp = a
        while tmp >= k:
            if tmp % k == 0:
                tmp = tmp // k
            else:
                tmp %= k
        if tmp == 1:
            ans+=1
        if (a - 1) % k == 0 and k != math.sqrt(n - 1):
            ans+=1
    return ans

def fj(a):
    arr = defaultdict(int)
    i = 2
    while i <= math.sqrt(a):
        while a % i == 0:
            a //= i
            arr[i] += 1
        i += 1
    if a != 1:
        arr[a] += 1
    ans = 1
    for key, value in arr.items():
        ans *= (value + 1)
    return ans-1

def solve(a):
    if a == 2:
        return 1
    ans = fj(a - 1)
    i = 2
    while True:
        tmp = round(a**(1 / i))
        if tmp ** i == a:
            ans += 1
        if tmp < 2:
            break
        i+=1
    return ans + 1
    

n = int(stdin.readline().strip())

ans = bl_solve2(n)
stdout.writelines(str(ans)+'\n')

# for n in range(2, 10000):
#     ans = bl_solve(n)
#     ans2 = bl_solve2(n)
#     if ans2 == len(ans):
#         print('True')
#     else:
#         print('False')
#         print(ans2,len(ans),ans)
#         input()
    # print(n, len(ans), ans)
    

Measured memory_bytes: 48872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int r, g, b;
  cin >> r >> g >> b;

  int tmp = 10 * g + b;
  if(tmp % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
	return 0;
}



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

using vi = vector<int>;
using ll = long long;

const ll inf = 1e9;

inline int dist(int x1, int y1, int z1, int x2, int y2, int z2) {
    return abs(x1 - y1) + abs(y1 - y2) + abs(z1 - z2);
}

int dx[] = { 0,0,0,0,-1,1 ,0};
int dy[] = { 0,0,-1,1,0,0 ,0};
int dz[] = { -1,1,0,0,0,0 ,0};

int ans;
int n;

struct P {
    int x, y, z;
    P(int x, int y, int z) :x(x), y(y), z(z) {}
    P() {}
    P rotX(int dir) const {
        return dir ? P(x, n - z - 1, y) : P(x, z, n - y - 1);
    }
    P rotY(int dir) const {
        return dir ? P(z, y, n - x - 1) : P(n - z - 1, y, x);
    }
    P rotZ(int dir) const {
        return dir ? P(n - y-1, x, z) : P(y, n - x-1, z);
    }
    int dist(P const &p) const {
        return abs(x - p.x) + abs(y - p.y) + abs(z - p.z);
    }
    bool inner() const {
        return
            0 <= x && 0 <= y && 0 <= z &&
            x < n && y < n && z < n;
    }
};

void dfs(const P &a, const P &b, int role) {
    // cout << " " << a.x << " " << a.y << " " << a.z << " " << role << endl;
    ans = min(role + a.dist(b), ans);
    if (role == 9) return;
    if (a.x != b.x) {
        dfs(a.rotX(0), b, role + 1);
        dfs(a.rotX(1), b, role + 1);
    }
    if (a.y != b.y) {
        dfs(a.rotY(0), b, role + 1);
        dfs(a.rotY(1), b, role + 1);
    }
    if (a.z != b.z) {
        dfs(a.rotZ(0), b, role + 1);
        dfs(a.rotZ(1), b, role + 1);
    }
}

int main() {
    while (cin >> n) {
        ans = 1e9;
        P a, b;
        cin >> a.x >> a.y >> a.z;
        cin >> b.x >> b.y >> b.z;
        for (int i = 0; i < 6; ++i) {
            P aa = a;
            aa.x += dx[i];
            aa.y += dy[i];
            aa.z += dz[i];
            if (aa.inner()) {
                dfs(aa, b, 0);
            }
        }
        ++ans;
        dfs(a, b, 0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3116
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0, 0)
cnt = 0
for j in range(n + 1):
    cnt += abs(a[j + 1] - a[j])
# print(cnt)

for i in range(1, n + 1):
    if a[i - 1] <= a[i] <= a[i + 1] or a[i - 1] >= a[i] >= a[i + 1]:
        print(cnt)
    else:
        cos = abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]) - abs(a[i - 1] - a[i + 1])
        print(cnt - cos)


Measured memory_bytes: 14048
#include<stdlib.h>
#include<stdio.h>

int main()
{
  long N,T,tmin=999999,cmin=99999,i;
  scanf("%ld%ld",&N,&T);
  for(i=0;i<N;i++)
  {
  long c,t;
  scanf("%ld%ld",&c,&t);
  if(t<=T){
  if(cmin>c) cmin = c;
  if(tmin>t) tmin = t;
  }
	}
	
	if(tmin<=T) printf("%ld",cmin);
	else printf("TLE");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
#define N 200005
ll a[N],dp[N],n,k;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>a[i];
    for(ll i=1;i<=k;i++){
        for(ll j=1;j<=n;j++){
            if(i>=a[j] && dp[i-a[j]]==0)dp[i]=1;
        }
    }
    if(dp[k])cout<<"First"<<endl;
    else cout<<"Second"<<endl;
return 0;
}


Measured memory_bytes: 1024
using System;
 
namespace AOJ
{
    class DigitNumber
    {
        public static void Main(string[] args)
        {
            for (int i = 0; i < 200; i++)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
 
                var tmp = input.Split(' ');
 
                int test = int.Parse(tmp[0]) + int.Parse(tmp[1]);
                Console.WriteLine(test.ToString().Length);
            }
        }
    }
}

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

int main(){
  int n,a,b,loop,dig;
  int sum=0,tmp=0;
  cin >> n >> a >> b;
  
  for(int i=1; i<=n; i++){
    tmp = 0;
    loop = i;
    while(loop){
      dig = loop % 10;
      tmp += dig;
      loop /= 10;
    }
    
    if((tmp >= a)&&(tmp <= b)){
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

int main(){
  int n;
  double ab,cd;
  double x1,y1,x2,y2,x3,y3,x4,y4;

  scanf("%d", &n);
  while(n--){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);

    if(x2 == x1){
      if(x3 == x4) printf("YES\n");
      else printf("NO\n");
      continue;
    }
    ab = (y2-y1) / (x2-x1);
    cd = (y4-y3) / (x4-x3);

    if(ab == cd) printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int[] a = new int[] {512, 2816, 14336, 71936, 359936, 1799936, 8999936, 44999936, 224999936, 1124999936};
        char[] s = scanner.next().toCharArray();
        System.out.println(java.util.stream.IntStream.range(0, s.length).mapToLong(i -> a[s.length - i - 1] / (1 << (10 - s.length)) * (s[i] - 48L)).sum());
    }
}

Measured memory_bytes: 27732
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }


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

    ll A, B; cin >> A >> B;
    ll sum = A+B;
    if (sum%2==0) {
        cout << sum/2 << '\n';
    } else {
        cout << "IMPOSSIBLE" << '\n';
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int r, c, cell;
    cin >> r >> c;
    int cells[r+1][c+1];
    for (int i=0; i<=r; i++){
        for (int j=0; j<=c; j++){
            cells[i][j] = 0;
        }
    }
    for (int i=0; i<r; i++){
        for (int j=0; j<c; j++){
            cin >> cell;
            cells[i][j] += cell;
            cells[i][c] += cell;
            cells[r][j] += cell;
            cells[r][c] += cell;
        }
    }
    for (int i=0; i<=r; i++){
        for (int j=0; j<=c; j++){
            if (j < c) cout << cells[i][j] << " ";
            if (j == c) cout << cells[i][j] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

int32_t main() 
{
    fastio
    int n;
    cin>>n;
    vector<ll> vec(n);
    for(int i = 0; i<n; ++i)
        cin>>vec[i];
    sort(all(vec), greater<int>());

    if(n==2) {
        cout<<vec[0]<<endl;
        return 0;
    }

    ll ans = vec[0];  
    ll cnt = 0;
    ll ind = 1;
    for(int i = 2; i<n; ++i) {
        if(cnt >= 2) {
            cnt = 0;
            ind++;
        }

        ans += vec[ind];
        cnt++;
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 4792
s = " " + gets.chomp
max = s.size - 1
(2..max).each{|r|
  if s[r-1]==s[r]
    puts "#{r-1} #{r}"
    exit
  end
}
(3..max).each{|r|
  t = s[r-2..r]
  if t[0]==t[1] or t[1]==t[2] or t[2]==t[0]
    puts "#{r-2} #{r}"
    exit
  end
}
puts "-1 -1"

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
//解答写し
long long nagasa[51],niku[51];
long long keisan(long long k,long long x){
  if(x==nagasa[k])return niku[k];
  long long kotae=0;
  x--;
  if(x>0){
    long long l=min(x,nagasa[k-1]);
    kotae+=keisan(k-1,l);
    x-=l;
  }
  if(x>0){
    kotae++;
    x--;
  }
  if(x>0){
    long long l=min(x,nagasa[k-1]);
    kotae+=keisan(k-1,l);
    x-=l;
  }
  return kotae;
}
int main() {
  int n;
  cin>>n;
  long long m;
  cin>>m;
  nagasa[0]=1;
  niku[0]=1;
  for(int i=1;i<=n;i++){
    nagasa[i]=nagasa[i-1]*2+3;
    niku[i]=niku[i-1]*2+1;
  }
  cout<<keisan(n,m)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	int N;
	ll W,w0,w,v,n0,n1,n2,n3,Wsum,Vsum;
	cin >> N >> W;
	vector<pair<ll, ll> > pairs0, pairs1, pairs2, pairs3;
	vector<ll> v0, v1, v2, v3, Vmax;
	cin >> w0 >> v;
	pairs0.push_back(make_pair(w0, v));

	for (int i = 1; i < N; i++) {
		cin >> w >> v;
		if (w == w0) pairs0.push_back(make_pair(w, v));
		if (w == w0 + 1) pairs1.push_back(make_pair(w, v));
		if (w == w0 + 2) pairs2.push_back(make_pair(w, v));
		if (w == w0 + 3) pairs3.push_back(make_pair(w, v));
	}

	if (w0 > W) {
		cout << 0 << endl;
		return 0;
	}

	sort(pairs0.begin(), pairs0.end(), greater<pair<ll, ll> >());
	sort(pairs1.begin(), pairs1.end(), greater<pair<ll, ll> >());
	sort(pairs2.begin(), pairs2.end(), greater<pair<ll, ll> >());
	sort(pairs3.begin(), pairs3.end(), greater<pair<ll, ll> >());
	
	n0 = min(W / w0, (ll)pairs0.size());
	n1 = min(W / (w0 + 1), (ll)pairs1.size());
	n2 = min(W / (w0 + 2), (ll)pairs2.size());
	n3 = min(W / (w0 + 3), (ll)pairs3.size());
	
	for (ll i = 0; i < n0; i++) { v0.push_back(pairs0[i].second); }
	for (ll i = 0; i < n1; i++) { v1.push_back(pairs1[i].second); }
	for (ll i = 0; i < n2; i++) { v2.push_back(pairs2[i].second); }
	for (ll i = 0; i < n3; i++) { v3.push_back(pairs3[i].second); }
	for (ll i = 0; i < n0 + 1; i++) {
		for (ll j = 0; j < n1 + 1; j++) {
			for (ll k = 0; k < n2 + 1; k++) {
				for (ll l = 0; l < n3 + 1; l++) {
					Wsum = i*w0 + j*(w0 + 1) + k*(w0 + 2) + l*(w0 + 3);
					if (Wsum <= W) {
						Vsum = 0;
						if (i != 0) Vsum += accumulate(v0.begin(), v0.begin() + i, 0);
						if (j != 0) Vsum += accumulate(v1.begin(), v1.begin() + j, 0);
						if (k != 0) Vsum += accumulate(v2.begin(), v2.begin() + k, 0);
						if (l != 0) Vsum += accumulate(v3.begin(), v3.begin() + l, 0);
						Vmax.push_back(Vsum);
					}
				}
			}
		}
	}
	sort(Vmax.begin(), Vmax.end(), greater<ll>());
	cout << Vmax[0] << endl;
	return 0;
}

Measured memory_bytes: 2424
N = int(input())
K = int(input())
def nonzero1(N):
    m = len(str(N))
    a = int(str(N)[-m]) 
    return a + 9*(m-1)
def nonzero2(N):
    m = len(str(N))
    a = int(str(N)[-m])
    n = N - a * (10**(m-1))
    s = ((m-1)*(m-2)*9*9)//2 + (m-1)*(a-1)*9
    return s + nonzero1(n)
def nonzero3(N):
    m = len(str(N))
    a = int(str(N)[-m])
    n = N - a * (10**(m-1))
    s = ((m-1)*(m-2)*(m-3)*9*9*9)//6 +((m-1)*(m-2)*9*9*(a-1))//2
    return s + nonzero2(n)
if K == 1:
    print(nonzero1(N))
elif K == 2:
    print(nonzero2(N))
else:
    print(nonzero3(N))

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r * r * pi;
        double length = 2 * r * pi;
        System.out.printf("%f %f\n", area, length);
        sc.close();
    }
}


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

/* 累積和クラス */
template <class Type_ElementsA, class Type_ElementsS>
class Cumulative_Sum{
private:
    const int n;
    std::vector<Type_ElementsA> A;
    std::vector<Type_ElementsS> S;
public:
    Cumulative_Sum(int nn): n(nn){
        A.resize(nn); S.resize(nn+1);
    }
    Cumulative_Sum(std::vector<Type_ElementsA> &AA): n(A.size()){
        A = AA;
    }
    void input_VecInt(void){
        for(int i = 0; i < n; ++i) scanf("%d", &A[i]);
    }
    void input_VecLong(void){
        for(int i = 0; i < n; ++i) scanf("%lld", &A[i]);
    }
    /* Aの内容からSの計算 */
    void previous(void){
        S[0] = 0; for(int i = 0; i < n; ++i) S[i+1] = S[i] + A[i];
    }
    Type_ElementsS sumOf(int k){
        return S[k];
    }
    /* 区間[left, right]の値 */
    Type_ElementsS between(int left, int right){
        return S[right+1] - S[left];
    }
};


int main(void){
    int n; scanf("%d", &n);
    Cumulative_Sum<int, long long int> D(n);
    D.input_VecInt(); D.previous();
    /* k番目の切り込み ; A[k]とA[k+1]の間　(0 ≤ k < n-1) */
    int left = 0, medium = 1, right = 2;
    long long int A[4];
    long long int res = 2e18+1;
    while(medium + 1 < n-1){
        while(left + 2 <= medium){
            long long int TD = abs(D.between(0, left) - D.between(left+1, medium));
            long long int ND = abs(D.between(0, left+1) - D.between(left+2, medium));
            if(TD < ND) break;
            left++;
        }
        while(right + 2 <= n-1){
            long long int TD = abs(D.between(medium+1, right) - D.between(right+1, n-1));
            long long int ND = abs(D.between(medium+1, right+1) - D.between(right+2, n-1));
            if(TD < ND) break;
            right++;
        }
        A[0] = D.between(0, left);
        A[1] = D.between(left+1, medium);
        A[2] = D.between(medium+1, right);
        A[3] = D.between(right+1, n-1);
        std::sort(A, A+4);
        long long diff = A[3] - A[0];
        if(res > diff) res = diff;
        medium++;
    }
    printf("%lld\n", res);
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>

int main(void) {
  int A, B;
  scanf("%d %d", &A, &B);

  int sum = 0;
  if(A > B) {
    sum += A--;
  } else {
    sum += B--;
  }
  if(A > B) {
    sum += A--;
  } else {
    sum += B--;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 5005;
const int mod = (int) 1e9 + 7;

int n, k, a[N], ans, s[N][N], p[N];

inline void solve () {
        scanf ("%d%d", &n, &k);
        for (int i = 1; i <= n; i++) {
                scanf ("%d", &a[i]);
        }
        s[n + 1][0] = 1;
        for (int i = n; i >= 1; i--) {
                for (int j = 0; j <= k; j++) {
                        s[i][j] |= s[i + 1][j];
                        s[i][min (k, j + a[i])] |= s[i + 1][j];
                }
        }
        if (!s[1][k]) {
                printf ("%d\n", n);
                return;
        }
        p[0] = 1;
        for (int i = 1; i <= n; i++) {
                if (a[i] >= k) {
                        p[k] = 1;
                        continue;
                }
//                for (int j = 0; j <= k; j++) {
//                        printf ("%2d", j);
//                }
//                puts ("");
//                for (int j = 0; j <= k; j++) {
//                        printf ("%2d", p[j]);
//                }
//                puts ("");
//                for (int j = 0; j <= k; j++) {
//                        printf ("%2d", s[i + 1][j]);
//                }
//                puts ("");
                int l = 0, r = 0, b = 1;
                ans++;
                for (int j = k - 1; j >= 0; j--) {
                        while (r + j + 1 < k) {
                                b += s[i + 1][++r];
                        }
                        while (l + j < k - a[i]) {
                                b -= s[i + 1][l++];
                        }
                        if (b && p[j]) {
                                ans--;
                                break;
                        }
                }
                for (int j = k; j >= 0; j--) {
                        p[min (j + a[i], k)] |= p[j];
                }
        }
        printf ("%d\n", ans);
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 98048
def examA():
    AB = [I() for _ in range(2)]
    for i in range(1,4):
        if not i in AB:
            ans = i
            break
    print(ans)
    return

def examB():
    N = I()
    S,T = LSI()
    ans = ""
    for i in range(N):
        ans += S[i]+T[i]
    print(ans)
    return

def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examC():
    A, B = LI()
    ans = lcm(A,B)
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    ans = N; cur = 1
    for a in A:
        if cur==a:
            ans -=1
            cur +=1
    if ans==N:
        ans = -1
    print(ans)
    return

def examE():
    N = I()
    ans = 0
    if N%2==0:
        N //=2
        while(N>0):
            ans +=N//5
            N //=5
    print(ans)
    return


def bfs(n,e,fordfs):
    #点の数、スタートの点、有向グラフ
    W = [-1]*n
    #各点の状態量、最短距離とか,見たかどうかとか
    W[e] = 0
    que = deque()
    que.append(e)
    len = [float("inf")]*n
    len[e] = 0
    while que:
        now = que.popleft()
        nowv = W[now]
        nowlen = len[now]
        for ne in fordfs[now]:
            if nowv == W[ne]:
                #ループが嫌な時
                return -1
            elif W[ne] == -1:
                W[ne] = (nowv+1) % 2
                len[ne] = nowlen+1
                que.append(ne)
    return len
def examF():
    N, u, v = LI()
    V = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        V[a-1].append(b-1)
        V[b-1].append(a-1)
    La = bfs(N,u-1,V)
    Lb = bfs(N,v-1,V)
#    print(La)
#    print(Lb)
    ans = 0
    for i in range(N):
        if La[i]>Lb[i]:
            continue
        ans = max(Lb[i],ans)
    print(ans-1)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examF()


Measured memory_bytes: 67232
#include "bits/stdc++.h"
using namespace std;
int n,k;
string s;
int main()
{
    cin>>n>>k;
    cin>>s;
    int cnt=0;
    string res="";
    for(int i=0;i<n;i++){
        if(s[i]>='A'&&s[i]<='Z'){
            cnt++;
            if(cnt==k) res+=s[i]-'A'+'a';
            else res+=s[i];
        }else res+=s[i];
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    let n: usize = sc.next();
    let m: usize = sc.next();
    let l: usize = sc.next();

    let a: Vec<Vec<u64>> = (0..n).map(|_| sc.vec(m)).collect();
    let b: Vec<Vec<u64>> = (0..m).map(|_| sc.vec(l)).collect();

    for i in 0..n {
        for j in 0..l {
            let mut c: u64 = 0;
            for k in 0..m {
                c += a[i][k] * b[k][j];
            }
            print!("{}{}", c, if j == l - 1 { '\n' } else { ' ' });
        }
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }

    fn char(&mut self) -> char {
        self.chars()[0]
    }
}



Measured memory_bytes: 5052
import scala.io.StdIn.{readInt,readLine}

object Main {

  def gcd(x:Long, y:Long):Long = if(y==0) x else gcd(y, x%y)
  def lcm(x:Long, y:Long) = (x/gcd(x,y))*y
        def pow(x:Long, y:Long, z:Long):Long = {
                def multi(m:Long, n:Long) = { ( (m%z) * (n%z) ) % z }

                def scan(m:Long, n:Long, odd:Long, b:Long):Long = {
                        n match {
                                case 0 => 1
                                case 1 => multi(m, odd)
                                case _ =>
                                        scan(multi(m,m), n/2, (if(n%2==1) multi(odd, b) else odd), multi(b,b))
                        }
                }
                scan(x, y, 1, x)
        }

  def main(args:Array[String]) = {
    Iterator.continually(readLine).takeWhile(_.trim!="0 0 0 0 0 0").foreach { s =>
      val n = s.split(" ").map(_.toLong)
      val a1 = n(0);val m1 = n(1);val a2 = n(2);val m2 = n(3);val a3 = n(4);val m3 = n(5)
      val i1 = Stream.from(1).find(pow(a1,_,m1)==1).getOrElse(0)
      val i2 = Stream.from(1).find(pow(a2,_,m2)==1).getOrElse(0)
      val i3 = Stream.from(1).find(pow(a3,_,m3)==1).getOrElse(0)
      println(lcm(i1,lcm(i2,i3)))
    }
  }
}

Measured memory_bytes: 137936
#include <cstdio>
#include <cmath> 
#include <algorithm>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std ;
inline 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') { x = x * 10+ch-48 ; ch = getchar() ; }
	return x * f ;
}

const int N = 1e5+11,mod = 1e9+7;
LL ans1,ans2,sum;
int n;
int a[N];

int main() {
	n=read();
	For(i, 1, n) a[i]=read();
	For(i, 1, n) {
		sum= sum+a[i];
		if(i%2==1) 
			if(sum<=0) {
				ans1=ans1 + abs(1-sum);
				sum=1;
			}
			else {}
		else 
			if(sum>=0) {
				ans1=ans1 + abs(-1-sum);
				sum=-1;
			}
	}
	
	
	sum = 0;
	For(i, 1, n) {
		sum = sum+a[i]; 
		if(i%2==0) 
			if(sum<=0) {
				ans2=ans2 + abs(1-sum);
				sum=1;
			}
			else {}
		else 
			if(sum>=0) {
				ans2=ans2 + abs(-1-sum);
				sum=-1;
			}
	}
	printf("%lld\n",min(ans1,ans2));
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!
import sys
X = int(input())
l = [100, 101, 102, 103, 104, 105]
dp = [0] * 1000000

dp[0] = 1
for i in range(100001):
   
    if dp[i] == 1:
        for j in range(6):
            dp[i + l[j]] = 1

print(dp[X])

Measured memory_bytes: 48492
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
 
typedef pair<int,int> P;
typedef pair<int,P> P1;
 
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define pque(int) priority_queue<int>
#define rpque(int) priority_queue<int,vector<int>,greater<int> >
#define mp1(a,b,c) P1(a,P(b,c))
#define fr first
#define sc second
 
const int INF=1000000000;
 
int main(){
	while(1){
		int n;
		int a[2][110];
 
		scanf("%d",&n); if(n==0)break;
		rep(i,n)scanf("%d",&a[0][i]);
		rep(i,n)scanf("%d",&a[1][i]);
 
		bool used[2][110]; rep(i,110){ used[0][i]=false; used[1][i]=false; }
		int d[2][110]; rep(i,110){ d[0][i]=INF; d[1][i]=INF; }
		rpque(P1) que;
 
		d[0][0]=0; d[1][0]=0;
		que.push(mp1(0,0,0));
		que.push(mp1(0,1,0));
 
		while(!que.empty()){
			P1 p=que.top(); que.pop();
			if(!used[p.sc.fr][p.sc.sc]){
				int p1=p.fr,p2=p.sc.fr,p3=p.sc.sc;
				if(a[p2][p3]==0){
					rep(i,3){
						if(p3+i<n)if(d[1-p2][p3+i]>p1+1){
							d[1-p2][p3+i]=p1+1;
							que.push(mp1(d[1-p2][p3+i],1-p2,p3+i));
						}
					}
				}
				else if(a[p2][p3]==1){
					if(a[p2][p3+1]==1){
						if(p3+1<n)if(a[p2][p3+1]==1&&d[p2][p3+1]>p1){
							d[p2][p3+1]=p1;
							que.push(mp1(d[p2][p3+1],p2,p3+1));
						}
					}
					else {
						rep(i,3){
							if(p3+i<n)if(d[1-p2][p3+i]>p1+1){
								d[1-p2][p3+i]=p1+1;
								que.push(mp1(d[1-p2][p3+i],1-p2,p3+i));
							}
						}
					}
				}
				else {
					if(p3>0){
						if(d[p2][p3-1]>p1){
							d[p2][p3-1]=p1;
							que.push(mp1(d[p2][p3-1],p2,p3-1));
						}
					}
				}
				used[p2][p3]=true;
			}
		}
		if((used[0][n-1]&&a[0][n-1]!=2)||(used[1][n-1]&&a[1][n-1]!=2))printf("%d%c",min(d[0][n-1],d[1][n-1]),10);
		else puts("NA");
	}
}

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

int main() {
  int N;
  cin >> N;
  int i = 0;
  int sum = 0;
 for(int i = 0; i < N; i++ ){
   int l , r;
   cin >> l >> r;
   sum = sum + r - l + 1;
 }
  cout << sum << endl;
}


Measured memory_bytes: 256
n=int(input())
ans=[]
data=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
while(n>0):
    n-=1
    ans.append(n%26)
    n=n//26
for i in range(len(ans)-1,-1,-1):
    print(data[ans[i]],end="")


Measured memory_bytes: 61688