akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(),(v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define INF (1ll<<60)
#define _T_ <<"\t"<<
#define p2(a,b)		cout<<a _T_ b<<endl
#define p3(a,b,c)		cout<<a_T_b_T_c<<endl

li a[200100], b[200100], dp[200100];
li aa[200100], bb[200100];
li lines = 0;
li best = 0;

li n;
li c;
li h[200100];

inline bool owata() {
	double x12 = (double)(bb[lines - 2] - bb[lines - 3]) / (double)(aa[lines - 3] - aa[lines - 2]);
	double x23 = (double)(bb[lines - 2] - bb[lines - 1]) / (double)(aa[lines - 1] - aa[lines - 2]);
	return x12 >= x23;
}

inline void addLine(li an, li bn) {
	aa[lines] = an;
	bb[lines] = bn;
	lines++;

	while (lines >= 3 && owata()) {
		aa[lines - 2] = aa[lines - 1];
		bb[lines - 2] = bb[lines - 1];
		lines--;
	}

	if (best >= lines)best = lines - 1;
}

inline void addLine(li x) {
	addLine(-2 * h[x], dp[x] + h[x]*h[x] + c);
}

li calc(li x) {
	if (best >= lines)best = lines - 1;
	while (best < lines - 1 &&
	        aa[best]*h[x] + bb[best] >= aa[best + 1]*h[x] + bb[best + 1]) {
		best++;
	}
	return aa[best] * h[x] + bb[best] + h[x] * h[x];
}

int main() {
	cin >> n >> c;
	rin{cin >> h[i];}
	rin{dp[i] = INF;}

	dp[0] = 0;
	addLine(0);

	repp(i, 1, n) {
		dp[i] = calc(i);
		addLine(i);
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 8448
const Main = (input) => {
const dataArray = input.split('\n');
const forecast = dataArray[0];
const weather = dataArray[1];
var hit = 0;
  for(var i = 0; i < 3; i++){
  	if(forecast[i] == weather[i]){
      hit += 1;
    }
  }
  console.log(hit);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    string s;
    int ans = 1000;

    cin >> s;
    for (int i = 0; i < s.size() - 2; i++)
    {
        char ss[3 + 1] = {};
        s.copy(ss, 3, i);
        int a = stoi(ss);
        int sub = abs(a - 753);
        if (sub < ans)
        {
            ans = sub;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  ll n,a,b; cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#define MAX 10000

using namespace std;

int main(){
  int n; cin >> n;
  int a[n+1],b[n+1];
  for(int i=1;i<=n;i++) cin >> a[i];
  //c[i] shows how many times i appears.
  int c[MAX+1];
  for(int i=0;i<=MAX;i++) c[i]=0;
  for(int i=1;i<=n;i++) c[a[i]]++;
  for(int i=1;i<=MAX;i++) c[i]=c[i]+c[i-1];
  for(int i=n;i>=1;i--){
    b[c[a[i]]]=a[i];
    c[a[i]]--;
  }
  for(int i=1;i<=n;i++){
    if(i==n) cout << b[i] << endl;
    else cout << b[i] << " ";
  }
}

Measured memory_bytes: 18756
import math
            
A, B, H, M = map(int, input().split())

"""
h = (H / 12 + (M / 60 / 12)) * 2 * math.pi
m = M / 60 * 2 * math.pi

ax = A * math.cos(h)
ay = A * math.sin(h)

bx = B * math.cos(m)
by = B * math.sin(m)

#print(h, m, ax, ay, bx, by)

ans = ((ax-bx)**2 + (ay-by)**2 )**(1/2)

print(ans)
"""

ang = ((H / 12 + (M / 60 / 12)) - (M / 60)) * 360

#print(ang)

C = ang * math.pi / 180 if ang < 180 else (360 - ang) * math.pi / 180

#print(C / math.pi)

c2 = A**2 + B**2 - 2 * A * B * math.cos(C)

print((c2)**(1/2))

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

int k,q,d[5010];
void solve(){
   int n,x,m; scanf("%d%d%d",&n,&x,&m);
   ll last=x,res=n-1;
   rep(i,0,k){
      ll cnt=(n-i-1+k-1)/k;
      last+=cnt*(d[i]%m);
      if(d[i]%m==0)res-=cnt;
   }
   res-=(last/m-x/m);
   printf("%lld\n",res);
}

int main(){
   scanf("%d%d",&k,&q);
   rep(i,0,k)scanf("%d",&d[i]);
   rep(i,0,q)solve();
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int r, c;
  int sum = 0;
  scanf("%d %d\n", &r, &c);
  int a[r+1][c+1];

  for(int i=0; i<=r; i++){
    for(int j=0; j<=c; j++){
        a[i][j] = 0;
      }
    }

  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
        scanf("%d\n", &a[i][j]);
      }
    }

  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      a[i][c] += a[i][j];
      a[r][j] += a[i][j];
    }
  }

  for(int i=0; i<r; i++){
    sum += a[i][c];
  }

  a[r][c] = sum;

  for(int i=0; i<=r; i++){
    for(int j=0; j<=c; j++){
      if(j == c) printf("%d\n", a[i][j]);
      else printf("%d ", a[i][j]);
    }
  }
  return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
#include <time.h>
#include <bitset>
#include <stack>

using namespace std;

const int MAXN = 107;

char a[MAXN][MAXN];

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

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> a[i][j];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == '#') {
                bool ch = false;
                
                ch |= (i && a[i - 1][j] == '#');
                ch |= (i < n - 1 && a[i + 1][j] == '#');
                ch |= (j && a[i][j - 1] == '#');
                ch |= (j < m - 1 && a[i][j + 1] == '#');
                
                if (!ch) {
                    cout << "No\n";
                    return 0;
                }
            }
        }
    }

    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    db L;
    cin >> L;
    db a = L/3;
    db V = a*a*a;
    cout << prec(8) << V;
    return 0;
}

Measured memory_bytes: 256
function main()
  n, m, k = parse.(Int, split(readline()))
  a = parse.(Int, split(readline()))
  b = parse.(Int, split(readline()))

  t = sum(b)
  j = m
  ans = 0
  for i in 0:n
    while j > 0 && t > k
      j -= 1
      t -= b[j+1]
    end
    t > k && break
    ans = max(ans, i+j)
    i == n && break
    t += a[i+1]
  end
  ans
end

println(main())

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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> sum(n+1,0);
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    ll minv=2020202020;
    for(int i=1;i<n;i++) minv=min(minv,abs(2*sum[i]-sum[n]));
    cout<<minv<<"\n";
    return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;            cin>>n>>k;
    int h[n],dp[n];
    for(auto i=0;i<n;++i){
        cin>>h[i];
    }
    if(n==2){
        cout<<abs(h[1]-h[0]);
        return 0;
    }
  	
    for(auto i=0;i<k and i<n;++i){
        dp[i]=abs(h[i]-h[0]);        
    }
    for(auto i=k;i<n;i++){
        dp[i]=INT_MAX;
        for(auto j=i-1;j>=i-k;j--){
            dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1];
    return 0;

}

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

int main() {
   int N,H,W;
   cin >> N >> H >> W;
   int r =0;
   for(int i=0;i<N;i++){
       int a=0  ;
       int b=0;
       cin >> a >> b;
	   if(a >=H&& b >=W)r++;
   }
   cout << r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char * argv[])
{
    int x1=0;
    int x2=0;
    int x3=0;
    int n=0;
    
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        scanf("%d",&x1);
        scanf("%d",&x2);
        scanf("%d",&x3);
        if(x1*x1+x2*x2==x3*x3||x2*x2+x3*x3==x1*x1||x3*x3+x1*x1==x2*x2){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int N;
    cin >> N;
    string S[N];
    int a,b,c,d;
    a=0;
    b=0;
    c=0;d=0;

    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    for(int i=0;i<N;i++){
        if(S[i] == "AC")a++;
        else if(S[i] == "WA") b++;
        else if(S[i] == "TLE") c++;
        else if(S[i] == "RE") d++;
    }

    cout << "AC x " << a <<endl;
    cout << "WA x " << b <<endl;
    cout << "TLE x " << c <<endl;
    cout << "RE x " << d <<endl;


    return 0;
}

Measured memory_bytes: 6720
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int A[30],n,m;
char ch[1100];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%s",ch+1);
		for (int j=1;j<=m;j++) A[ch[j]-'a'+1]++;
	}
	for (int i=1;i<=(n+1)/2;i++)
		for (int j=1;j<=(m+1)/2;j++){
			int num=4;
			if (i==n-i+1) num/=2;
			if (j==m-j+1) num/=2;
			int flag=0; //cout<<"fa "<<num<<endl;
			sort(A+1,A+27);// cout<<A[26]<<endl;
			if (A[26]<num){
				printf("No\n"); return 0;
			}
			for (int i=1;i<=26;i++) if (A[i]>=num){
				A[i]-=num; break;
			}
		}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2*1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;
 
using namespace std;
 
int main() {
    int n;
    ll sum = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            for(int z = 1; z <= n; z++)
                sum += __gcd(i, __gcd(z, j));
    cout << sum << endl;
}


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

int n,m;
char a[505][505];

void work()
{
	scanf("%d %d\n",&n,&m);
	for (int i=1; i<=n; i++)  scanf("%s\n",a[i]+1);
	printf("%s\n",a[1]+1);
	for (int i=2; i<n; i++)
		{
			putchar('#');
			for (int j=2; j<m; j++)
				putchar((a[i][j]=='#')||(i%2==0)?'#':'.');
			puts(".");
		}
	printf("%s\n\n",a[n]+1);
	printf("%s\n",a[1]+1);
	for (int i=2; i<n; i++)
		{
			putchar('.');
			for (int j=2; j<m; j++)
				putchar((a[i][j]=='#')||(i%2==1)?'#':'.');
			puts("#");
		}
	printf("%s\n",a[n]+1);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main(){
  int N,W;cin >> N >> W;
  vector<vector<ll>> dp(N + 1,vector<ll>(100010,INF));
  vector<ll> w(N), v(N);
  rep(i, N) cin >> w[i] >> v[i];
  dp[0][0] = 0;
  rep(i, N) {
    rep(j, 100001) {
      chmin(dp[i + 1][j], dp[i][j]);
      if(j + v[i] <= 100001) chmin(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
    }
  }
  ll ans = 0;
  rep(i, 100001) {
    //    if( i <= 100) cout<< dp[N][i] << endl;
    if(dp[N][i] <= W) chmax(ans, (ll)i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 83204
N = int(input())
A = list(map(int, input().split()))
X = sum(A)
xi = A[0]
ans = abs(X - 2 * A[N-1])
for i in range(1, N-1):
  xi += A[i]
  ans = min(abs(X - 2 * xi), ans)
print(ans)

Measured memory_bytes: 24808
#include <iostream>
#include <cstdlib>
#include <vector>

int main()
{
    int n(0);
    std::cin >> n;

    std::vector<int> p(n, 0), p_ref(n);
    std::vector<int> pos(2, -1);
    auto pos_it = std::begin(pos);
    for(int i=0; i < n; ++i){
        auto& v = p[i];
        std::cin >> v;
        p_ref[i] = i+1;
        
        if(v != i+1){
            *pos_it = i;
            ++pos_it;
            
            // > 2
            if(pos_it == std::end(pos)){
                break;
            }
        }
    }
    
    bool b_sort = false;
    if(p.size() == p_ref.size()){
        if(p != p_ref){
            std::swap(p[pos[0]], p[pos[1]]);
        }
        if(p == p_ref){
            b_sort = true;
        }
    }
    
    if(b_sort){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
    
    return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  ll M;
  cin >> M;

  dijkstra d(N);
  
  rep(i, M){
    ll a, b;
    cin >> a >> b;
    a--;b--;
    d.add_edge(a, b, 1);
  }
  d.run(0);
  if(d.d[N-1]>2){
    cout << "IMPOSSIBLE";
  }else{
    cout << "POSSIBLE";
  }
  
  return 0;
}


Measured memory_bytes: 17156
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;

int main(){
    
    int h, w, m;
    cin >> h >> w >> m;
    
    vector<int> h1(h, 0), w1(w, 0);
    set<P> s;
    
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        h1[a]++;
        w1[b]++;
        s.emplace(a, b);
    }
    
    int h_max = *max_element(h1.begin(), h1.end());
    int w_max = *max_element(w1.begin(), w1.end());
    
    vector<int> h2, w2;

    rep(i, h) if(h1[i] == h_max) h2.push_back(i);
    rep(i, w) if(w1[i] == w_max) w2.push_back(i);
    
    int ans = h_max + w_max;
    
    for(int i:h2) for(int j:w2){
        if(s.count(P(i, j))) continue;
        cout << ans << "\n";
        return 0;
    }
    
    ans--;
    cout << ans << "\n";
    return 0;

    return 0;
}



Measured memory_bytes: 23348
n = int(input())
s = list(map(int, input()))
cnt = 0
for i1 in range(10):
    for i2 in range(10):
        for i3 in range(10):
            for i in range(n):
                if s[i]==i1: 
                    for j in range(i+1, n):
                        if s[j]==i2:
                            for k in range(j+1, n):
                                if s[k]==i3:
                                    cnt += 1
                                    #print(i1, i2, i3)
                                    break
                            break
                    break

print(cnt)



Measured memory_bytes: 43740
#include <cstdio>

using namespace std;
const int Max_N(1050);
typedef long long int LL;

constexpr LL Abs(LL x)
{
	return x >= 0LL ? x : -x;
}

int N;
LL X[Max_N], Y[Max_N];
bool flag;

int main()
{
	scanf("%d", &N);
	for (int i = 1;i <= N;++i)
	{
		scanf("%lld%lld", X + i, Y + i);
		if ((Abs(X[1] + Y[1]) & 1) ^ (Abs(X[i] + Y[i]) & 1))
		{
			printf("-1");
			return 0;
		}
	}
	if (((Abs(X[1] + Y[1])) & 1) == 0)
	{
		flag = true;
		for (int i = 1;i <= N;++i)
			--X[i];
	}
	for (int i = 1;i <= N;++i)
	{
		LL x = X[i] + Y[i], y = X[i] - Y[i];
		X[i] = x, Y[i] = y;
	}
	if (flag)
	{
		printf("%d\n", 1 + 31);
		printf("%d ", 1);	
	}
	else
		printf("%d\n", 31);
	for (LL i = 0LL;i <= 30LL;++i)
		printf("%lld ", 1LL << i);
	printf("\n");
	for (int i = 1, gx, gy;i <= N;++i)
	{
		if (flag)
			putchar('R');
		gx = gy = 0;
		if (X[i] < 0LL)
			gx = 1, X[i] = -X[i];
		if (Y[i] < 0LL)
			gy = 1, Y[i] = -Y[i];
		for (LL j = 0LL;j <= 30LL;++j)
			X[i] += (1LL << j), Y[i] += (1LL << j);
		X[i] >>= 1LL, Y[i] >>= 1LL;
		LL Sumx = 0LL, Sumy = 0LL;
		for (LL j = 0LL, c1, c2, x, y;j <= 30LL;++j, X[i] >>= 1LL, Y[i] >>= 1LL)
		{
			c1 = (X[i] & 1LL), c2 = (Y[i] & 1LL);
			c1 = (c1 * 2LL) - 1LL, c2 = (c2 * 2LL) - 1LL;
			if (gx)
				c1 = -c1;
			if (gy)
				c2 = -c2;
			Sumx += (1LL << j) * c1, Sumy += (1LL << j) * c2;
			x = (c1 + c2) / 2LL, y = (c1 - c2) / 2LL;
			if (x == -1LL)
				putchar('L');
			if (x == +1LL)
				putchar('R');
			if (y == -1LL)
				putchar('D');
			if (y == +1LL)
				putchar('U');
		}
		puts("");
	}
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

const int maxn = 10000000;
int par[maxn];
int ranks[maxn];
int ans;

void init(int n)
{
    REP(i, n)
    {
        par[i] = i;
        ranks[i] = 0;
    }
}

int find(int x)
{
    return par[x] == x ? x : par[x] = find(par[x]);
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    // if x and y have same parent, they already belong same unite
    if (x == y)
        return;

    ans--;
    if (ranks[x] < ranks[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if (ranks[x] == ranks[y])
            ranks[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

int main(void)
{
    int n, q;
    cin >> n >> q;
    init(n);
    ans = n;
    REP(i, q)
    {
        int p, a, b;
        cin >> a >> b >> p;
        unite(a, b);
    }

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

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

using namespace std;
int n;
char a[200005];
int main(){
	scanf("%s", a + 1);
	n = strlen(a + 1);
	int ans = n;
	int flag = 0;
	for(int i = 2; i <= n; i ++){
		if(flag){
			flag -= 1; continue;
		}
		if(a[i] == a[i - 1]) {
			ans -= 1; flag = 2;
		}
	}
	printf("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 384
n=int(input())
a=[int(i) for i in input().split()]
cnt=[0 for i in range(64)]
mask=1
for i in range(64):
    for j in a:
        if j|mask==j: #立っている
            cnt[i]+=1
    mask*=2
x=1
res=0
for i in range(64):
    res+=cnt[i]*(n-cnt[i])*x
    res%=1000000007
    x*=2
print(res)


Measured memory_bytes: 125496
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        value: String,
    };
    let mut value = value;
    loop {
        let previous = value.clone();
        value = remove_suffix(&value, "dreamer").to_string();
        value = remove_suffix(&value, "dream").to_string();
        value = remove_suffix(&value, "eraser").to_string();
        value = remove_suffix(&value, "erase").to_string();
        if value == "" {
            println!("YES");
            return;
        }
        if value == previous {
            println!("NO");
            return;
        }
    }
}

fn remove_suffix<'a>(s: &'a str, p: &str) -> &'a str {
    if s.ends_with(p) {
        &s[..s.len() - p.len()]
    } else {
        s
    }
}


Measured memory_bytes: 2556
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

void b_resale(void) {
	int n;
	int* v;
	int* c;
	cin >> n;
	v = (int*)calloc(n, sizeof(int));
	c = (int*)calloc(n, sizeof(int));
	for (int i = 0; i < n; i++)cin >> v[i];
	for (int i = 0; i < n; i++)cin >> c[i];
	int* d;
	d = (int*)calloc(n, sizeof(int));
	int max = 0;
	bool all_minus = true;
	for (int i = 0; i < n; i++) {
		d[i] = v[i] - c[i];
		if (d[i] > 0) all_minus = false;
	}
	sort(d, d + n);
	if (all_minus)max = 0;
	else {
		for (int i = 0; i < n; i++) {
			if (d[i] >= 0)max += d[i];
		}
	}

	cout << max << endl;
}

int main()
{
    b_resale();

    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int r,d,x;cin>>r>>d>>x;
    vector<int> ans(10);
    ans[0]=r*x-d;
    

    rep1(i,10){
        ans[i]=r*ans[i-1]-d;
    }
    rep0(i,10){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cout<<#x<<" "<<endl;
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
//-------------------------------------------------------------------------------





int main(){
	// S
	// #ifndef ONLINE_JUDGE
	// freopen("E:\\input-output\\input.txt","r",stdin);
	// freopen("E:\\input-output\\output.txt","w",stdout);
	// #endif
	string s,t;
	cin>>s>>t;
	int m=s.length();int n=t.length();
	int lcs[m+1][n+1]={0};
	for(int i=0;i<=m;++i){ //fill first row
		lcs[i][0]=0;
	}
	for(int j=0;j<=n;++j){
		lcs[0][j]=0;
	}
	for(int i=1;i<=m;++i){
		for(int j=1;j<=n;++j){
			if(s[i-1]==t[j-1]){//last char matches
				lcs[i][j]=1+lcs[i-1][j-1];

			}
			else{
				lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
			}
		}
	}
	// for(int i=0;i<=m;++i){
	// 	for(int j=0;j<=n;++j){
	// 		cout<<lcs[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	// cout<<lcs[m][n]<<endl;
	int len=lcs[m][n];
	// cout<<len<<endl;
	int i=m,j=n;
	char lcs_str[len+1];
	lcs_str[len]='\0';
	len--;
	while(i>=0 && j>=0){
		if(s[i-1]==t[j-1]){
			// cout<<len<<endl;
			lcs_str[len]=s[i-1];
			// cout<<s[i]<<endl;
			i--;j--;len--;

		}
		else if(lcs[i-1][j]>lcs[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	cout<<lcs_str
		<<endl;


}
 

Measured memory_bytes: 35456
fn main() {
    let (n, k) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        let v: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
        (v[0], v[1])
    };
    println!("{}", (n - 2) / (k - 1) + 1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
  ll n,ans=0,cnt=0;
  cin>>n;
  vector<int>a(n+2);
  rep(i,n){
    int A;
    cin>>A;
    a.at(i+1)=A;
  }
  a.at(n+1)=pow(10,9)+1;
  sort(a.begin(),a.end());
  a.at(0)=a.at(1);
  rep(i,n+1){
    if (a.at(i+1)!=a.at(i)) {
      if (cnt>=a.at(i)) {
        ans+=cnt-a.at(i);
        cnt=1;
      }
      else{
        ans+=cnt;
        cnt=1;
      }
    }
    else{
      cnt+=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n = readln.chomp.to!int;
	int[] ps = readln.chomp.split.map!(to!int).map!(x => x - 1).array;
	
	int[] as, bs;
	as.length = n, bs.length = n;
	
	for(int i = 0; i < n; i ++){
		as[i] = bs[n - 1 - i] = 30000 * (i + 1);
		}
	
	for(int i = 0; i < n; i ++){
		as[ps[i]] += i, bs[ps[i]] += i;
		}
	
	as.map!(to!string).join(" ").writeln;
	bs.map!(to!string).join(" ").writeln;
	}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
#define x first
#define y second
#define size(a) (ll)(a).size()

typedef long long ll;
typedef long double ld;

using namespace std;
int n;
string s;


int main()
{
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");


    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin >> n;

    vector<ld> Num(n);
    for (int i = 0; i < n; i++)
    {
        cin >> Num[i];
    }

    sort(Num.begin(), Num.end());
    ld res = Num[0];

    for (int i = 1; i < n; i++)
    {
        res = (res + Num[i]) / 2;
    }

    cout.precision(10);
    cout << fixed << res << "\n";




}


Measured memory_bytes: 256
N,T=list(map(int,input().split()))
A=list(map(int,input().split()))
maxval=[0 for i in range(N)]
maxdif=[0 for i in range(N)]
for i in range(N):
    if i==0:
        maxval[N-1-i]=A[N-1]
        maxdif[N-1-i]=0
    else:
        maxval[N-1-i]=max(maxval[N-i],A[N-i-1])
        maxdif[N-1-i]=maxval[N-1-i]-A[N-1-i]

print(maxdif.count(max(maxdif)))

Measured memory_bytes: 14436
n=int(input())
p=[[0]*n for i in range(26)]
for i in range(n):
    s=input()
    h=ord("a")
    for j in range(len(s)):
        p[ord(s[j])-h][i]+=1
c=""
for i in range(26):
    c+=min(p[i])*chr(h+i)
print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<atcoder/all>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

void solve() {
  ll k;
  cin>>k;
  rep(i,k)
    cout << "ACL";
  cout<<endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>
 
using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
 
const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
struct people { ll v, k, year; };
struct Combination{
  int mod;
  vector< int64_t > mfact, rfact;
 
  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod){
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }
 
  int64_t fact(int k) const{
    return (mfact[k]);
  }
 
  int64_t pow(int64_t x, int64_t n) const{
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }
 
  int64_t inv(int64_t x)const {
    return (pow(x, mod - 2));
  }
 
  int64_t P(int n, int r) const{
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }
 
  int64_t C(int p, int q) const{
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }
 
  int64_t H(int n, int r) const{
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};
 
int main() {
	ll n, a[100100], cou[101100], itl, itr;
        Combination comb(100100,MOD);
	cin >> n;
	for (int i = 1;i <= n + 1;i++) {
		cin >> a[i];
		if (cou[a[i]] == 0)cou[a[i]]++;
		else itr = i;
	}
	for (int i = 1;i <= n+1;i++) {
		if (a[i] == a[itr]) {
			itl = i;
			break;
		}
	}
	for (int i = 1;i <= n + 1;i++) {
		cout << (MOD + comb.C(n + 1, i) - comb.C(itl + n - itr, i - 1)) % MOD << endl;
	}
}

Measured memory_bytes: 4352
using System;
using System.Linq;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
           int[] AB = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = AB[0];
            int B = AB[1];
            Console.WriteLine(A * B);
        }
    }
}

Measured memory_bytes: 28236
#include<stdio.h>
#include<string.h>
#define LEN 100000

typedef struct q{
char name[100];
int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
Q[tail]=x;
tail=(tail+1) % LEN;
}

P dequeue(){
P x=Q[head];
head=(head+1) % LEN;
return x;
}

int min(int a,int b){
return a < b ? a : b;
}

int main(){
int lap=0,c;
int i,q;
P a;
scanf("%d%d",&n,&q);

for(i=1;i <= n; i++){
scanf("%s",Q[i].name);
scanf("%d",&Q[i].t);
}
head=1;
tail=n+1;

while(head != tail){
a=dequeue();
c=min(q,a.t);
a.t-=c;
lap+=c;
if(a.t > 0) enqueue(a);
else{
printf("%s %d\n",a.name,lap);
}
}
return 0;
}

Measured memory_bytes: 10756
K,N = [int(i) for i in input().rstrip().split()]
A = [int(i) for i in input().rstrip().split()]
A.sort()
maxD = [A[0] + (K - A[-1]), 0]
for i, a in enumerate(A):
    if i == 0:
        continue
    D = A[i] - A[i-1]
    if D > maxD[0]:
        maxD = [D,i]
print(K - maxD[0])

Measured memory_bytes: 26444
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
# a <= b <= c

for b in range(1,N-1):
  for c in range(b+1,N):
    # search min(c) with a + b > c <=> a > c - b
    idx = bisect.bisect_left(L,L[c]-L[b]+1)
    #print(L[b],L[c],idx)
    ans += max(b-idx,0) if idx >= 0 else 0 
    #print(idx, ans)
#print(L)
print(ans)

Measured memory_bytes: 45832
#include<stdio.h>
int main()
{

    char a[11],b[11],c[11];
    int x , y, z;

    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);

    x=strlen(a)-1;
    y=strlen(b)-1;
    z=strlen(c)-1;

        if((a[x]==b[0])&&(b[y]==c[0]))
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }

    return 0;
}



Measured memory_bytes: 1584
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,c,t,count = 2000;
  cin >> N >> T;
  for(int i = 0; i < N; i++){
    cin >> c >> t;
    if(t <= T){
      count = min(count,c);
    }
  }
  if(count == 2000){
    cout << "TLE" << endl;
  }
  else{
    cout << count << endl;
  }
}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;
char A[555][555];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
    {
        bool ok=false;
        rep(i,N)rep(j,N)if(A[i][j]=='#')ok=true;
        if(!ok){
            cout<<-1<<endl;
            return 0;
        }
    }

    int ans=LLONG_MAX;


    int b=0;

    rep(i,N){
        bool ok=true;
        rep(j,N)if(A[j][i]=='.')ok=false;
        if(ok)b++;
    }

    rep(i,N){
        int cost=0;
        rep(j,N)if(A[i][j]=='.')cost++;
        bool flag=false;
        rep(j,N)if(A[j][i]=='#')flag=true;
        if(!flag)cost++;
        chmin(ans,N-b+cost);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

char ret(int v){
    if(v==1) return 'a';
    else if(v==2) return 'b';
    else if(v==3) return 'c';
    else if(v==4) return 'd';
    else if(v==5) return 'e';
    else if(v==6) return 'f';
    else if(v==7) return 'g';
    else if(v==8) return 'h';
    else if(v==9) return 'i';
    else if(v==10) return 'j';
    else if(v==11) return 'k';
    else if(v==12) return 'l';
    else if(v==13) return 'm';
    else if(v==14) return 'n';
    else if(v==15) return 'o';
    else if(v==16) return 'p';
    else if(v==17) return 'q';
    else if(v==18) return 'r';
    else if(v==19) return 's';
    else if(v==20) return 't';
    else if(v==21) return 'u';
    else if(v==22) return 'v';
    else if(v==23) return 'w';
    else if(v==24) return 'x';
    else if(v==25) return 'y';
    else if(v==0) return 'z';
}

int main()
{
   ll N, cnt1, cnt2, cnt=0;
   int num[100000];
   string s;
   cin >> N;
   cnt1 = N/26; //26で割れる回数
   cnt2 = N%26; //あまり
   while(1){
       cnt1 = N/26;
       cnt2 = N%26;
       if(cnt1==0){
           num[cnt]=(int)cnt2;
           cnt++;
           break;
       }
       else if(cnt1==1&&cnt2==0){
           num[cnt]=(int)cnt2;
           cnt++;
           break;
       }
       else{
           num[cnt]=(int)cnt2;
           cnt++;
           if(cnt2==0){
               N=cnt1-1;
           }
           else{
               N=cnt1;
           }
       }
   }
   for(int i=cnt-1; i>=0; i--){
       char c_tmp= ret(num[i]);
       //cout << num[i] << " " << c_tmp << endl;
       s.push_back(c_tmp);
   }
   cout << s << endl;
}

Measured memory_bytes: 3572
N = int(input())
A = list()

for i in range(0, N):
  A_i = int(input())
  A.append(A_i)

A_sorted = sorted(A, reverse=True)

for val in A:
  result = A_sorted[0]
  if val == A_sorted[0]:
    result = A_sorted[1]
  print(result)

Measured memory_bytes: 14112
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;

int a, b, c, x, y;

int cost(int ax, int bx, int abx) { return ax * a + bx * b + abx * c; }

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

    int ans = INF;
    cin >> a >> b >> c >> x >> y;
    ans = cost(x, y, 0);
    if (x < y) {
        ans = min(ans, cost(0, y - x, 2 * x));
        ans = min(ans, cost(0, 0, 2 * y));
    } else {
        ans = min(ans, cost(x - y, 0, 2 * y));
        ans = min(ans, cost(0, 0, 2 * x));
    }
    print(ans);
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
private class C {
    fun solve() {
        var n = nextLong()
        var result = ""
        while (n > 0) {
            var mod = (n % 26).toInt()
            if (mod == 0) {
                mod = 25
            } else {
                mod--
            }
            n = (n - mod - 1) / 26
            val c = 'a' + mod
            result = c + result
        }
        println(result)
    }

    var tokenBuffer = listOf<String>()
    var bufferPosition = 0

    private fun checkBuffer() {
        if (bufferPosition == tokenBuffer.size) {
            tokenBuffer = nextLine().split(" ")
            bufferPosition = 0
        }
    }

    fun nextLine() = readLine()!!
    fun nextInt(): Int {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toInt()
    }

    fun nextLong(): Long {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toLong()
    }

    fun nextDouble(): Double {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toDouble()
    }

    fun nextToken(): String {
        checkBuffer()
        return tokenBuffer[bufferPosition++]
    }
}

fun main() {
    val reader = C().solve()

}


Measured memory_bytes: 36548
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        self.total += w
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j):  # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1)

    def search(self, k):
        if k > self.total:
            return -1
        if k == 0:
            return 0
        step = 1 << (self.size.bit_length() - 1)
        now_index = 0
        ret = 0
        while step:
            if now_index + step < self.size and ret + self.bit[now_index + step - 1] < k:
                ret += self.bit[now_index + step - 1]
                now_index += step
            step >>= 1
        # now_indexを伸ばしいって、sumがk以上に達する直前まで伸ばし続けるならreturnのところでnow_index - 1。
        # その場合、bit.sum(now_index - 1) <= k < bit.sum(now_index)
        # 達してすぐのindexであれば-1しない
        return now_index


q = I()
query = []
A = []
for _ in range(q):
    l = LI()
    if l[0] == 1:
        A += [l[1]]
    query += [l]

ind_to_co = sorted(set(A))
co_to_ind = {}
for i, x in enumerate(ind_to_co):
    co_to_ind[x] = i

bit1 = BIT(len(A))
bit2 = BIT(len(A))
n = 0
B = 0
for l in query:
    if l[0] == 1:
        B += l[2]
        bit1.add(co_to_ind[l[1]], 1)
        bit2.add(co_to_ind[l[1]], l[1])
        n += 1
    else:
        min_ind = bit1.search(n // 2 + bool(n % 2))
        d = n // 2 + bool(n % 2)
        min_val = bit2.interval_sum(min_ind + 1, bit2.size) - bit1.interval_sum(min_ind + 1, bit1.size) * ind_to_co[
            min_ind] \
                  + bit1.sum(min_ind - 1) * ind_to_co[min_ind] - bit2.sum(min_ind - 1) + B
        print(ind_to_co[min_ind], min_val)

Measured memory_bytes: 111188
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
char red[N][N], blue[N][N], purple[N][N];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++ i) {
		scanf("%s", purple[i]);
		for (int j = 0; j < m; ++ j) {
			red[i][j] = blue[i][j] = purple[i][j];
		}
	}
	for (int i = 1; i < m - 1; ++ i) red[0][i] = '#';
	for (int j = 1; j < m - 1; ++ j) {
		for (int i = 1; i < n - 1; ++ i) {
			if (red[i][j] == '.') continue;
			if (red[i][j - 1] == '#') continue;
			for (int k = i - 1; red[k][j] != '#'; -- k) {
				red[k][j] = '#';
				if (red[k][j - 1] == '#') break;
			}
		}
	}
	for (int i = 0; i < n; ++ i) {
		for (int j = 0; j < m; ++ j) {
			if (red[i][j] == '.' && blue[i][j] == '.') blue[i][j] = '#';
		}
	}
	for (int i = 0; i < n; ++ i) puts(red[i]);
	puts("");
	for (int i = 0; i < n; ++ i) puts(blue[i]);
	/*for (int i = 0; i < n; ++ i) {
		for (int j = 0; j < m; ++ j) {
			bool isred = red[i][j] == '#';
			bool isblue = blue[i][j] == '#';
			bool ispurple = purple[i][j] == '#';
			printf("check %d %d\n", i, j);
			assert((isred && isblue) == ispurple);
		}
	}*/
}



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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
string s;

void input() {
  IN(s);
}

void solve() {
  pair<char, int> p1 = make_pair(s[0], 1);
  pair<char, int> p2 = make_pair('0', 0);
  bool ok = true;
  FOR(i, 1, 4){
    if(p1.first == s[i]) {
      p1.second++;
    } else if(p2.first == s[i]) {
      p2.second++;
    } else if(p2.first == '0') {
      p2.first = s[i];
      p2.second = 1;
    } else {
      ok = false;
    }
  }
  string r = (ok && p1.second==2 && p2.second==2) ? "Yes" : "No";
  PRINT(r);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.append(0)

pos = 0 #0ポジなし、1ポジあり
kane = 1000 #所持金
kabu = 0
hi = 0      #現在日

while hi < n:
    if pos == 0:
        if a[hi] < a[hi+1]:
            kabu = kane // a[hi]
            kane = kane % a[hi]
            pos = 1
            hi += 1
        else:
            hi += 1
    else:
        if a[hi] > a[hi+1]:
            kane += a[hi]*kabu
            kabu = 0
            pos = 0
            hi += 1
        else:
            hi += 1

print(kane)



Measured memory_bytes: 9136