akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  	int N,K,X;
  	cin >> N >> K >> X;
    cout << (N+K)*X/2 << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//各桁の和
int EDSum(ll number){
    int ans=0;
    while(1){
        ans += number % 10;
        number /= 10;
        if(number == 0) break;
    }
    return ans;
}

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main(void){

  int n;
  while(cin >> n){
    if(n%2)cout << (int)(2*pow(3,n/2)-1) << endl;
    else cout << (int)((2*pow(3,(n-1)/2)-1)/2*3+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define INF 1000'000'000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("in", "r", stdin);
	string s, t;
	cin >> s >> t;
	t.pop_back();
	cout << (s == t ? "Yes" : "No") << endl;
	return 0;
}





Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstring>
#define rg register
using namespace std;
const int N=1005,Inf=0x3f3f3f3f;
int n,num,x[N],dp[N][5005],ans[N],flg;
vector<int> vec[N];
void dfs(int u){
	for(rg int i=0;i<vec[u].size();++i) dfs(vec[u][i]);
	memset(dp[0],Inf,sizeof(dp[0])); flg=0; dp[0][0]=0;
	for(rg int i=0;i<vec[u].size();++i){
		int v=vec[u][i]; flg=!flg;
		memset(dp[flg],Inf,sizeof(dp[0]));
		for(rg int j=0;j<=x[u];++j){
			if(j>=x[v]) dp[flg][j]=min(dp[flg][j],dp[!flg][j-x[v]]+ans[v]);
			if(j>=ans[v]) dp[flg][j]=min(dp[flg][j],dp[!flg][j-ans[v]]+x[v]);
		}
	}
	for(rg int i=0;i<=x[u];++i) ans[u]=min(ans[u],dp[flg][i]);
}
int main(){
	memset(ans,Inf,sizeof(ans)); scanf("%d",&n);
	for(rg int i=2;i<=n;++i) scanf("%d",&num),vec[num].push_back(i);
	for(rg int i=1;i<=n;++i) scanf("%d",x+i);
	dfs(1); 
	if(ans[1]<Inf) puts("POSSIBLE");		
	else puts("IMPOSSIBLE");
	return 0;
}

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

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

    int n,p; cin >> n >> p;
    string s; cin >> s;
    long long ans = 0;
    int temp = 0;
    int a[p]{};
    int p_10 = 1;
    long long five = 0;
    long long even = 0;

    while(s.size()){
        temp = (p_10 * (s.back() - '0') + temp) % p;
        p_10 = (p_10 * 10) % p;
        ans += a[temp] + (temp==0);
        a[temp]++;
        even += (((s.back() - '0')&1) == 0) * (s.size());
        five += ((s.back() == '5'||s.back() == '0')* (s.size()));
        s.pop_back();
    }    
    if(p == 2){
        ans = even;
    }else if( p == 5 ){
        ans = five;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
main = do
  l <- getLine
  let xy12 = map read $ words l
  putStrLn $ unwords $ map show $ abc108b xy12

abc108b :: [Int] -> [Int]
abc108b [x1,y1,x2,y2] = [x3,y3,x4,y4]
  where
    (dx,dy) = (x2-x1,y2-y1)   -- d = v2-v1
    (rdx,rdy) = (-dy,dx)      -- r = d rot 90
    (x3,y3) = (x2+rdx,y2+rdy) -- v3 = v2+r
    (x4,y4) = (x3-dx,y3-dy)   -- v4 = v3-d


Measured memory_bytes: 508
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MX=30000;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n,sum=0;cin>>n;
    if(n==3)return cout<<"2 5 63" , 0;
    vector<ll> a;
    for(ll i=1;i<=MX;i++){
        if(i%2==0 || i%3==0){
            a.push_back(i);
            sum+=i;
            if( (ll)a.size() == n)break;
        }
    }

    ll req = (6 - sum%6)%6;
    for(ll i=n-1;i>=0;i--){
        if( a[i]+req<=MX && ( (a[i]+req)%2==0 || (a[i]+req)%3==0) ){
            a[i]+=req;
            break;
        }
    }

    for(ll i=0;i<n;i++)cout<<a[i]<<" ";

}




Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

# 繰り返し二乗法
def pow_r_mod(x:int, n:int, mod=10**9+7)->int:
    # 計算量 : log N
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x %= mod
        n //= 2
    return (K * x) % mod

def table(n:int, p=10**9+7):
    global fact, factinv, inv
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n+1):
        #fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        #factinv.append((factinv[-1] * inv[-1]) % p)

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)
table(N)

mca = 1
for i in range(1, a+1):
    mca *= (m-i+1) * inv[i]
    mca %= P

mcb = mca
for i in range(a+1, b+1):
    mcb *= (m-i+1) * inv[i]
    mcb %= P

#print((pow_r_mod(2, m)-1-mca-mcb) % P)
print((pow(2, m, P)-1-mca-mcb) % P)

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

int main() {

	string a,b,c;

	cin >> a >> b >> c;

	if (a[a.length()-1]==b[0]&&b[b.length()-1]==c[0]) {
		cout << "YES" << endl;
	}

	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var k = parseInt(input[0].split(" ")[1]);
  x = new Array(n).fill(0);
  tmp = input[1].split(" ");
  var plus=0;
  var minus=0;
  for(i=0;i<n;i++){
    x[i]=parseInt(tmp[i]);
    if(x[i]>0){
      plus++;
    }else if(x[i]<0){
      minus++;
    }
  }
  var ans=Math.pow(10,9)+7;
  if(x.indexOf(0)!=-1){
    n-=1;
    k-=1;
    x.splice(x.indexOf(0),1);
  }
  if(x.length==0){
    ans=0;
  }else if(n!=2){
    for(i=0;i<n-k+1;i++){
      if(x[i]<0&&x[i+k-1]>0){
        ans=Math.min(ans,Math.abs(x[i])*2+x[i+k-1],Math.abs(x[i])+x[i+k-1]*2);
      }else if(i==minus-k){
        ans=Math.min(ans,Math.abs(x[i]));
      }else if(i==minus){
        ans=Math.min(ans,x[i+k-1]);
      }
    }
  }else{
    ans=Math.min(Math.abs(x[0]),x[1]);
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a+b)%24<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main(int argc, char *argv[]){
    int N, Q;
    std::cin >> N >> Q;

    std::vector<long int> X(N),S(N),T(N);
    for(int i=0; i<N; ++i){
        std::cin >> S[i] >> T[i] >> X[i];
    }

    std::vector<long int> D(Q);
    for(int i=0; i<Q; ++i){
        std::cin >> D[i];
    }

    std::vector<int> XIdx(N);
    std::iota(XIdx.begin(),XIdx.end(),0);
    std::sort(XIdx.begin(),XIdx.end(),
        [&X](const auto &lhs, const auto &rhs){
            return X[lhs] < X[rhs];
        });


    std::vector<int> DIdx(Q);
    std::iota(DIdx.begin(),DIdx.end(),0);
    std::vector<long int> pos(Q,-1);
    long int left, right;
    int idx;
    for(int i=0; i<N; ++i){
        idx = XIdx[i];
        left = S[idx] - X[idx];
        right = T[idx] - X[idx];
        auto leftIter = std::partition_point(DIdx.begin(),DIdx.end(),
            [&D,&left](const auto &d){
                return D[d] < left;
            });
        auto rightIter = std::partition_point(DIdx.begin(),DIdx.end(),
            [&D,&right](const auto &d){
                return D[d] < right;
            });
        for(auto iter=leftIter; iter<rightIter; ++iter){
            pos[*iter] = X[idx];
        }
        DIdx.erase(leftIter,rightIter);
    }

    std::for_each(pos.begin(),pos.end(),
        [](auto &x){
            std::cout << x << std::endl;
        });
    return 0;
}


Measured memory_bytes: 11264
#include<stdio.h>
#include<string.h>
int main(){
  int n,c=0,l,i,j,m;
  char s[101],k[101];
  scanf("%d %s",&n,s);
  while(n--){
    scanf("%s",k);
    l=strlen(k);
    for(i=0;i<l;i++){
      if(s[0]-k[i])continue;
      for(j=1;i+j<l;j++){
	if(s[1]-k[i+j])continue;
	for(m=0;i+j*m<l;m++){
	  if(s[m]==0)break;
	  if(s[m]-k[i+j*m])break;
	}
	if(s[m]==0){
	  c++;//printf("%d\n",n);
	  i=j=l;
	}
      }	
    }
  }
  printf("%d\n",c);
  return 0;
}
  

Measured memory_bytes: 600
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
ls = [0]
rs = [0]
for l,r in src:
    ls.append(l)
    rs.append(r)
ans = 0
for l,r in zip(reversed(sorted(ls)),sorted(rs)):
    if l <= r: break
    ans += 2*(l-r)
print(ans)

Measured memory_bytes: 20036
import java.io.*;
import java.util.*;

public class Main {
  static int MOD = 1000000007;
  static double EPS = 1e-9;

  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(in.readLine());

    int fiveCount = 0;
    int sevenCount = 0;
    for (int i = 0; i < 3; i++) {
      int x = Integer.parseInt(st.nextToken());
      if (x == 5)
        fiveCount++;
      if (x == 7)
        sevenCount++;
    }
    if (fiveCount == 2 && sevenCount == 1)
      System.out.println("YES");
    else
      System.out.println("NO");

    in.close();
  }
}

Measured memory_bytes: 20052
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def longs: Seq[Long] = strings.map(_.toLong)
    def doubles: Seq[Double] = strings.map(_.toDouble)
    def i(n: Int): Int = ints(n)
    def d(n: Int): Double = doubles(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))
  def readToEnd(ls: List[Line] = Nil): List[Line] = readLine match {
    case l if l.string == null => ls
    case l => readToEnd(ls :+ l)
  }

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]): Unit = {
    readToEnd().foreach(l => println((l.i(0) + l.i(1)).toString.length))
  }
}

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

#define N 51000

int main()
{
  int i,j,n,p1,p2;
  char prime[N];
  while(scanf("%d",&n)!=EOF){
    for (i=0;i<N;i++){
      prime[i]=1;
    }
    prime[0]=0;
    for (i=1;i<(int)sqrt(N);i++){
      if (prime[i]==1){
        for (j=i+1;(i+1)*j<=N;j++){
          prime[(i+1)*j-1]=0;
        }
      }
    }
    for (i=n-2;i>=0;i--)
      if (prime[i]==1){
        p1=i+1;
        break;
      }
    for (i=n;i<N;i++)
      if (prime[i]==1){
        p2=i+1;
        break;
      }
    printf("%d %d\n",p1,p2);
  }

  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci S(N);
    REP(i,N) cin >> S[i];
    int M; cin >> M;
    veci T(M);
    REP(i,M) cin >> T[i];
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    int ans = 0;
    for(int t : T) {
        int l = -1;
        int r = N;
        while(r-l > 1) {
            int mid = (r+l)/2;
            if(S[mid] > t) r = mid;
            else l = mid;
        }
        if(t == S[l]) ans++;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3300
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    for(int i = 0; i < n; ++i){
        cin >> x.at(i);
    }

    ll ans = 2 * (abs(x.back()) + abs(x.front()));
    for(int i = 0; i + k <= n; ++i){
        ll xmin = x.at(i);
        ll xmax = x.at(i + k - 1);
        if(xmin >= 0){
            ans = min(ans, xmax);
        }else if(xmax <= 0){
            ans = min(ans, - xmin);
        }else if(abs(xmin) > abs(xmax)){
            ans = min(ans, 2 * xmax - xmin);
        }else{
            ans = min(ans, xmax - 2 * xmin);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int X,A;

	cin >> X >> A;	

	int ans = 0;
	if (X >= A){
		ans = 10;
	}
	printf("%d",ans);

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, m, q;

int main() {
	while (cin >> n >> m >> q&&n + m + q) {
		bool st[1010] = {};
		bool f[1010][40];
		rep(i, m)rep(j, n)f[i][j] = 1;
		rep(i, q) {
			string s, b;
			cin >> s >> b;
			rep(j, m) {
				rep(k, n) {
					if (b[j] - '0' == st[j]) {
						if (s[k] == '1')f[j][k] = 0;
					}
					else {
						if (s[k] == '0')f[j][k] = 0;
					}
				}
				st[j] = b[j] - '0';
			}
		}
		rep(i, m) {
			int num = -1;
			rep(j, n) {
				if (f[i][j]) {
					if (num == -1)num = j;
					else num = -2;
				}
			}
			if (num == -2)cout << "?";
			else if (num <= 9)cout << num;
			else cout << (char)('A' + num - 10);
		}
		cout << endl;
	}
}


Measured memory_bytes: 3128
#include<stdio.h>
#include<algorithm>
using namespace std;
char s[200];
char after[200];
char fore[200];
int main()
{
	int n;
	scanf("%d",&n);
	getchar();
	for(int i=0;i<n;i++){
		scanf("%c",&s[i]);
		after[s[i]-'a']++;
	}
	int ans=0;
	int res=0;
	for(int i=0;i<n;i++){
		after[s[i]-'a']--;
		if(fore[s[i]-'a']==0){
			res++;
			fore[s[i]-'a']++;}
		if(after[s[i]-'a']==0){
			res--;
			}
			ans=max(ans,res);
	}
	printf("%d\n",ans);
	return 0;
}
			
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main(){
  int n; cin >> n;
  int MAX = 60;
  vector<vector<ll>> cnt52(MAX, vector<ll>(MAX));
  rep(i, n){
    long double x; cin >> x;
    ll y = (ll)(x * 1e9 + 0.5);
    //cout << y << endl;

    int a = 0, b = 0;
    while(y % 5 == 0){
      y /= 5;
      a++;
    }
    while(y % 2 == 0){
      y /= 2;
      b++;
    }
    cnt52[a][b]++;
  }

  ll ans = 0;
  rep(i, MAX){
    rep(j, MAX){
      rep(ii, MAX){
        rep(jj, MAX){
          if(make_pair(i, j) > make_pair(ii, jj)) continue;
          if(i + ii < 18 || j + jj < 18) continue;
          if(i == ii && j == jj) ans += cnt52[i][j] * (cnt52[i][j] - 1) / 2;
          else ans += cnt52[i][j] * cnt52[ii][jj];
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3776
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::{HashSet,HashMap};
#[allow(unused_imports)]
use std::cmp::{min,max};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input!(n:usize);
    let n = format!("{:b}", n);
    println!("{}", 1 << n.len() - 1);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
char a[100],b[100];
int ans=0;
int main(){
	scanf("%s",a+1);
	scanf("%s",b+1);
	for(int i=1;i<=3;i++){
		if(a[i]==b[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

const int MOD = 1e+9 + 7;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for( int i = 0; i < N; ++i ) cin >> A[i];

    long long ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(i < j and A[i] > A[j]) ans += (long long) K*(K+1)/2 % MOD; 
            if(i > j and A[i] > A[j]) ans += (long long) K*(K-1)/2 % MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = (ll)1e9 + 7;
int N;
string s[2];
ll dp[52];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < 2; i++) {
    cin >> s[i];
  }  
  fill_n((ll*)dp, 52, -1);

  if (s[0][0] == s[1][0]) dp[0] = 3;
  else dp[0] = dp[1] = 6;

  int sz = s[0].size();
  for (int i = 0; i < sz; i++) {
    if (dp[i] >= 0) continue;
    if (s[0][i - 1] == s[1][i - 1]) {
      if (s[0][i] == s[1][i]) {
        dp[i] = dp[i - 1] * 2 % MOD;
      } else {
        dp[i] = dp[i + 1] = dp[i - 1] * 2 % MOD;
      }
    } else {
      if (s[0][i] == s[1][i]) {
        dp[i] = dp[i - 1];
      } else {
        dp[i] = dp[i + 1] = dp[i - 1] * 3 % MOD;
      }
    }
  }
  cout << dp[sz - 1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <map>
#include <sstream>
using namespace std;
int n, cost[100005], weight[100005];
int main()
{   
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> cost[i];

    weight[1] = 0;
    weight[2] = abs(cost[1] - cost[2]);

    for (int i = 3; i <= n; i++)
    {
        weight[i] = min(abs(cost[i - 1] - cost[i]) + weight[i - 1], abs(cost[i - 2] - cost[i] ) + weight[i - 2]);
       
    }
    cout << weight[n];
    
    return 0;
}

Measured memory_bytes: 1024
/**
 *    author:  tourist
 *    created: 22.11.2019 20:40:28       
**/
#include <bits/stdc++.h>

using namespace std;

class dsu {
 public:
  vector<int> p;
  int n;

  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].emplace_back(y, i);
    g[y].emplace_back(x, i);
  }
  vector<int> from(m), to(m);
  for (int i = 0; i < m; i++) {
    cin >> from[i] >> to[i];
    --from[i]; --to[i];
  }
  vector<vector<int>> uses(m, vector<int>(n - 1, 0));
  vector<vector<int>> at(n - 1);
  vector<int> any_que;
  vector<int> any_pe;
  for (int i = 0; i < m; i++) {
    vector<int> pr(n, -1);
    vector<int> pe(n, -1);
    vector<int> que(1, from[i]);
    pr[from[i]] = -2;
    for (int b = 0; b < (int) que.size(); b++) {
      for (auto& p : g[que[b]]) {
        int u = p.first;
        if (pr[u] == -1) {
          que.push_back(u);
          pr[u] = que[b];
          pe[u] = p.second;
        }
      }
    }
    any_que = que;
    any_pe = pe;
    int v = to[i];
    while (v != from[i]) {
      int me = i + m * (v < pr[v]);
      at[pe[v]].push_back(me);
      v = pr[v];
    }
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    ans += min((int) at[i].size(), 2);
  }
  vector<int> skip(m, 0);
  dsu d(2 * m);
  for (int it = n - 1; it > 0; it--) {
    int e = any_pe[any_que[it]];
    set<int> who;
    for (int i : at[e]) {
      who.insert(d.get(i) % m);
    }
    if (who.size() < at[e].size() || who.size() < 2) {
      continue;
    }
    int x = d.get(*at[e].begin());
    int y = d.get(*next(at[e].begin()));
    d.unite(x, (y + m) % (2 * m));
    d.unite((x + m) % (2 * m), y);
  }
  for (int i = 0; i < m; i++) {
    assert(d.get(i) != d.get(i + m));
  }
  cout << ans << '\n';
  for (int i = 0; i < m; i++) {
    if (i / m != d.get(i) / m) {
      swap(from[i], to[i]);
    }
    cout << from[i] + 1 << " " << to[i] + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 21632
import itertools
import math

n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]

root = {}
for i in range(n-1):
    ix, iy = xy[i][0], xy[i][1]
    for j in range(i+1, n):
        jx, jy = xy[j][0], xy[j][1]
        root[(i, j)] = ((ix-jx)**2+(iy-jy)**2)**(1/2)

long = 0
for i in itertools.permutations([i for i in range(n)]):
    for j in range(1, len(i)):
        long += root[tuple(sorted([i[j-1], i[j]]))]
print(long/math.factorial(n))


Measured memory_bytes: 9464
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

long long N;
string s; 

void solve(){
    for(int i=1; i<=3500; ++i){
        for(int j=1; j<=3500; ++j){
            if(4*i*j>N*j+N*i&&(N*i*j)%(4*j*i-N*i-N*j)==0){
                cout << i << " " << j << " " << (N*i*j)/(4*i*j-N*i-N*j) << endl;
                return ;
            }
        }
    }
}
int main() {
    cin >> N;
    solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll q;cin>>q;
  for(ll i=0;i<q;i++){
    ll x,y;
    cin>>x>>y;
    if(x>y)swap(x,y);
    
    long double k=sqrt(x*y-0.75)-x+0.5;
    ll lk=k;
    
    ll ans=x-1+k+(x*y-1)/(x+k);
    cout<<(ll)(x-1+k+(x*y-1)/(x+k))-(x!=y)<<endl;
  }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

int main(){
	IOS;
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	ll dif = b - a;
	bool ok = false;
	for(int m = 0;m < n;m++){
		ll low = c * (n - m - 1) - d * m;
		ll high = d * (n - m - 1) - c * m;
		if(dif >= low && dif <= high)ok = true;
	}
	dump(ok ? "YES":"NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
 
using namespace std;
typedef long long int lli;
const int MAX=1e5;
 
int main(){
	int N;
	cin>>N;
	lli a[3*MAX];
	rep(i,3*N)cin>>a[i];
	sort(a,a+3*N);
	lli ans=0;
	for(int i=N;i<3*N;i+=2)ans+=a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h,w;
	cin>>h>>w;
	string s[h];
	for(int i = 0; i<h; i++)
		cin>>s[i];
	for(int i = 0; i<h; i++)
	{
		for(int j = 0; j<w; j++)
		{
			int sum = 0;
			if(j+1<w && s[i][j+1]=='#')
				sum++;
			if(i+1<h && s[i+1][j]=='#')
				sum++;
			if(i+1<h && j+1<w && s[i+1][j+1]=='#')sum++;
			if(i>0 && j>0 &&s[i-1][j-1]=='#') sum++;
			if(i>0 && j+1<w && s[i-1][j+1]=='#') sum++;
			if(i+1<h && j>0 && s[i+1][j-1]=='#') sum++; 
			if(j>0 && s[i][j-1]=='#')
				sum++;
			if(i>0 && s[i-1][j]=='#')
				sum++;
			if(s[i][j]=='#') cout<<'#';
			else
				cout<<sum;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << a+b+c - (max(a,max(b,c))) << endl;
    return 0;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

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

    if (S[0] != 'A') {
        std::cout << "WA" << std::endl;
        return 0;
    }
    S[0] = 'a';

    int count = 0;
    for (int i = 2; i < S.size() - 1; ++i) {
        if(S[i] == 'C') {
            count++;
            S[i] = 'c';
        }
    }
    if (count != 1) {
        std::cout << "WA" << std::endl;
        return 0;
    }

    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] < 'a') {
            std::cout << "WA" << std::endl;
            return 0;
        }
    }

    std::cout << "AC" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

const int lens = 2e5 + 1;
const long long mod = 1e9 + 7;

long long a[lens],sum[lens];
int main()
{
    int n;
    std::ios::sync_with_stdio(false);
    std::cin >> n;
    for(int i = 1;i <= n;i++)
    {
        std::cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    
    long long ans = 0;
    for(int i = 1;i <= n;i++)
    {
        ans = (ans + (((sum[n] - sum[i]) % mod) * (a[i] % mod)) % mod) % mod;
    }
    std::cout << ans;
    return 0;
}



Measured memory_bytes: 6740
n = input()
a = [int(i) for i in input().split()]
def chk(a, t):
  ans = 0
  x = 0
  for i in a:
    x += i
    if t == True and x < 1:
      ans+=1-x
      x=1
    elif t == False and x>-1:
      ans+=x+1
      x=-1
    t=not t
  return ans
print(min(chk(a,True),chk(a,False)))

Measured memory_bytes: 14332
import fractions
N,K=map(int,input().split())
A=list(map(int,input().split()))
gc=A[0]
for i in range(1,N):
    gc=fractions.gcd(gc,A[i])
#print(gc)
A.sort()
if (K<=A[N-1])and(((A[N-1]-K)%gc)==0)and((K%gc)==0):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 88172
#include<stdio.h>

int main(void) {

	int height = 0;	scanf("%d", &height);
	int width = 0;	scanf("%d", &width);

	while (1) {

		if ((height == 0) && (width == 0)) {
			break;
		}

		for (int i = 0; i < height; i++) {

			for (int j = 0; j < width; j++) {
				printf("#");
			}

			printf("\n");
		}

		printf("\n");

		scanf("%d %d", &height, &width);
	}

	return 0;
}


Measured memory_bytes: 2048
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	for sc.Scan() {
		s := sc.Text()
		arr := strings.Split(s, " ")
		r, _ := strconv.ParseFloat(arr[0], 64)
		fmt.Printf("%f %f\n", math.Pi*r*r, 2*math.Pi*r)
	}
}



Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m;
  scanf("%lld", &n);
  char w[n][20], b;
  for(i = 0; i < n; ++i) {
    scanf("%s", w[i]);
    if(i) if(w[i][0] != b) {
      printf("No");
      return 0;
    }
    b = w[i][strlen(w[i]) - 1];
  }
  for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(!strcmp(w[i], w[j])) {
    printf("No");
    return 0;
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
ans = 0

for i in range(K, N+2):
  ans += N*(N+1)//2 - (N-i)*(N-i+1)//2 - i*(i-1)//2 +1
  
print(ans%mod)

Measured memory_bytes: 9992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 300010, INF = 300000000;
int n, a[N], sum[2], b[N], dp[N];
bool check(int x) {
  rep (i, 1, n)
    if (i&1) b[i] = a[i];
    else b[i] = -a[i];
  rep (i, 2, n) b[i] += b[i-1];
  memset(dp, 0, sizeof dp);
  dp[0] = 1;
  int cur = 0;
  rep (i, 1, n) if (i % 2 == 1) {
    if (b[i] - cur >= x) {
      dp[i+1] = 1;
      cur = min(cur, b[i+1]);
    }
  }
  if (dp[n+1] == 1) return true;
  else return false;
}
int main() {
  read(n);
  rep (i, 1, n) read(a[i]);
  rep (i, 1, n) sum[i&1] += a[i];
  if (n % 2 == 0) {
    printf("%d %d\n", max(sum[0], sum[1]), min(sum[0], sum[1]));
    return 0;
  } else {
    int ans = sum[1];
    int l = -INF, r = INF, res = INF;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check(mid)) l = mid + 1, res = mid;
      else r = mid - 1;
    }
    ans = max(ans, res + sum[0]);
    printf("%d %d\n", ans, sum[1] + sum[0] - ans);
  }
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n;
int ans,last,now;
int main()
{
	cin>>n;
	while(n--)
	{
		int tmp;
		cin>>tmp;
		ans=max(ans,now);
		if(tmp<=last)
		{
			now++;
		}
		else
		{		
			now=0;
		}
		last=tmp;
	}
	ans=max(ans,now);
	cout<<ans;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (k+1)
s = ["Second", "First"]

for i in range(1, k+1):
    for x in a:
        if x <= i:
            if b[i-x] == 0:
                b[i] = 1
                break

print(s[b[k]])


Measured memory_bytes: 3828
N,K=(int(x) for x in input().split())

prob=0

for i in range(1,N+1):
    j=1
    count=0
    while(True):
        if(i*j>=K):
            prob+=(1/N)*((1/2)**count)
            break
        else:
            j*=2
            count+=1

print(prob)

Measured memory_bytes: 3060
ALPHABET = "abcdefghijklmnopqrstuvwxyz"

def alphabet_decimal(v):
    def convert(v):
        while v > 0:
            yield ALPHABET[(v - 1) % len(ALPHABET)]
            v = (v - 1) // len(ALPHABET)
    return ''.join(convert(v))[::-1]
v =int(input())
print(alphabet_decimal(v))

Measured memory_bytes: 9100
import sys
from time import time
from random import randrange, random
input = lambda: sys.stdin.buffer.readline()

DEBUG_MODE = False

st = time()
def get_time():
    return time() - st

L = 26
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

ans = [randrange(L) for _ in range(D)]

class BinaryIndexedTree:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (self.n+1)
    
    def sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res
    
    def add(self, i, x):
        if i <= 0: raise IndexError
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def lower_bound(self, x):
        if x <= 0: return 0
        cur, s, k = 0, 0, 1 << (self.n.bit_length()-1)
        while k:
            nxt = cur + k 
            if nxt <= self.n and s + self.data[nxt] < x:
                s += self.data[nxt]
                cur = nxt
            k >>= 1
        return cur + 1

def rsum(x):
    return x*(x+1)//2

b = [BinaryIndexedTree(D) for _ in range(L)]

score = 0
for d, cont in enumerate(ans):
    b[cont].add(d+1, 1)
    score += S[d][cont]

for i in range(L):
    m = b[i].sum(D)
    tmp = 0
    s = [0]
    for j in range(1, m+1):
        s.append(b[i].lower_bound(j))
    s.append(D+1)

    for j in range(len(s)-1):
        x = s[j+1] - s[j] - 1
        tmp += rsum(x)
    
    score -= tmp*C[i]

def chg(d, p, q):
    diff = 0
    d += 1

    o = b[p].sum(d)
    d1 = b[p].lower_bound(o-1)
    d2 = b[p].lower_bound(o+1)

    diff += rsum(d-d1) * C[p]
    diff += rsum(d2-d) * C[p]
    diff -= rsum(d2-d1) * C[p]

    o = b[q].sum(d)
    d1 = b[q].lower_bound(o)
    d2 = b[q].lower_bound(o+1)

    diff += rsum(d2-d1) * C[q]
    diff -= rsum(d-d1) * C[q]
    diff -= rsum(d2-d) * C[q]

    d -= 1
    diff -= S[d][p]
    diff += S[d][q] 

    ans[d] = q
    b[p].add(d+1, -1)
    b[q].add(d+1, 1)
    
    return diff

while True:
    if random() >= 0.8:
        d, q = randrange(D), randrange(L)
        p = ans[d]
        diff = chg(d, p, q)
        if diff > 0:
            score += diff
        else:
            chg(d, q, p)
    else:
        d1 = randrange(D-1)
        d2 = randrange(d1+1, min(d1+3, D))
        p, q = ans[d1], ans[d2]
        diff = chg(d1, p, q)
        diff += chg(d2, q, p)
        if diff > 0:
            score += diff
        else:
            chg(d1, q, p)
            chg(d2, p, q)

    if DEBUG_MODE: print(score)
    if get_time() >= 1.7: break

if DEBUG_MODE: print(score)
else:
    for x in ans: print(x+1)


Measured memory_bytes: 90692
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, long> P;

bool cmp(P a, P b)
{
  return a.second < b.second;
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<P> vc(N);
  int t;
  long d;
  for (int i = 0; i < N; i++)
  {
    cin >> t >> d;
    vc[i] = make_pair(t, d);
  }
  sort(vc.rbegin(), vc.rend(), cmp);
  long oishisa_sum = 0;
  long neta_kind = 0;
  vector<int> neta_count(N + 1);
  vector<int> st;
  for (int i = 0; i < K; i++)
  {
    if (neta_count[vc[i].first] == 0)
      neta_kind++;
    else
      st.push_back(i);
    neta_count[vc[i].first]++;
    oishisa_sum += vc[i].second;
  }
  long ans = oishisa_sum + neta_kind * neta_kind;
  for (int i = K; i < N; i++)
  {
    if (neta_count[vc[i].first] == 0 && !st.empty())
    {
      neta_kind++;
      neta_count[vc[i].first]++;
      int rem = st.back();
      st.pop_back();
      neta_count[vc[rem].first]--;
      oishisa_sum -= vc[rem].second;
      oishisa_sum += vc[i].second;
      ans = max(ans, oishisa_sum + neta_kind * neta_kind);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

int main(){
	int n;
	cin >> n;
	int a = 0, w = 0, t = 0, r = 0;
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		
		if(str == "AC")
			a++;
		else if(str == "TLE")
			t++;
		else if(str == "WA")
			w++;
		else
			r++;
	}
	
	cout << "AC x " << a << endl;
	cout << "WA x " << w << endl;
	cout << "TLE x " << t << endl;
	cout << "RE x " << r << endl;
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;

  int n0=n/100,n2=n%10,n1=(n%100-n2)/10;
  if(n0<n1 || (n0==n1 && n0<n2)) cout<<n0+1<<n0+1<<n0+1<<endl;
  else cout<<n0<<n0<<n0<<endl;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int main() {


    while (true) {


        int n, x;
        cin >> n >> x;

        if (n == 0 && x == 0)return 0;

        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) count++;
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3096
import sys
import fractions


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
ans = 0
for _ in range(N):
    if ans == 0:
        ans = int(input())
    else:
        t = int(input())
        ans = (ans * t) // fractions.gcd(ans, t)
print(ans)


Measured memory_bytes: 5048
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int, readline().split())

A = list(map(int, readline().split()))

sum = sum(A)
ct = 0
for a in A:
    if sum * (1/(4*M)) <= a:
        ct += 1

if ct >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

    s = '+' + s;
    t = '-' + t;

    int dp[s.size() + 2][t.size() + 2];
    rep(i,s.size() + 2)
        rep(j,t.size() + 2)
            dp[i][j] = 0;

    for(int i = 0;i < s.size();i++){
        for(int j = 0;j < t.size();j++){
            if(s[i] == t[j]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else if(i == 0 || j == 0){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    /*rep(i, s.size() + 2){
        rep(j, t.size() + 2){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    int i = s.size() - 1,j = t.size() - 1;
    
    string ans;
    while(i != 0 && j != 0){
        if(dp[i-1][j] == dp[i][j]){
            i--;
        }
        else if(dp[i][j-1] == dp[i][j])
        {
            j--;
        }
        else if (dp[i][j] - 1 == dp[i - 1][j - 1])
        {
            ans = s[i] + ans;
            i--;
            j--;
        }
        else if(i == 0 && j == 0){
            break;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 35456