akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef long long ll;
 
ll mod = 1000000007;
 
int exps[1003];
 
void solve(int n) {
  int div = 2;
  while ( div*div <= n ) {
    if ( n % div == 0 ) {
      exps[div]++;
      n /= div;
    } else {
      div++;
    }
  }
  if (n != 1) {
    exps[n]++;
  }
}
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int n;
  cin >> n;
 
  rep(i, n) {
    solve(i+1);
  }
 
  ll ans = 1;
 
  rep(i, n+1) {
    ans *= (exps[i] + 1);
    ans %= mod;
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 256
def main():
    while True:
        line=raw_input()
        if line=="#":   break;
        solve(line)
        
def solve(line):
    length=len(line)
    INF=1<<29
    dp=[[[[INF for l in range(3)] for k in range(3)] for j in range(2)] for i in range(2)]
    dp[1][1][0][2]=0
    dp[1][0][0][2]=0
    for i in range(length):
        n=i%2
        n2=(i+1)%2
        pos=(int(line[i])+2)%3
        for l in range(3):
            for r in range(3):
                if l<=pos:
                    dp[n][1][l][pos]=min(dp[n][1][l][pos], min(dp[n2][0][l][r], dp[n2][1][l][r]+1) )
                if pos<=r:
                    dp[n][0][pos][r]=min(dp[n][0][pos][r], min(dp[n2][1][l][r], dp[n2][0][l][r]+1) )
        for l in range(3):
            for r in range(3):
                for j in range(2):
                    dp[n2][j][l][r]=INF
    ans=INF
    tmp=(length-1)%2
    for j in range(2):
        for l in range(3):
            for r in range(3):
                ans=min(ans, dp[tmp][j][l][r])
    print ans

if __name__=="__main__":    main()

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

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

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

	sort(a, a + N);

	cout << a[N - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 200000;

struct Instruction {
    char op;
    int i, j, k;
    Instruction(char op, int i, int j, int k) : op(op), i(i), j(j), k(k) { }
};

ostream &operator<<(ostream &out, const Instruction &p) {
    return out << p.op << " " << p.i << " " << p.j << " " << p.k;
}

vector< Instruction >vins;

//int a[N];
void jog(int i, int j, int k) {
    vins.emplace_back('+', i, j, k);
//    a[k] = a[i]+a[j];
}
void tulona(int i, int j, int k) {
    vins.emplace_back('<', i, j, k);
//    a[k] = a[i]<a[j];
}

const int ABINARY = 100;
const int TWO_POWER = 200;
const int TWO_POWER_1 = 300;
const int TOBINARY = 400;
const int MAXLOG = 30;
//const int MAXLOG = 5;
const int ZERO = N-1;

void convert(int from, int seed) {
    jog(ZERO, seed, TWO_POWER);
    for (int i = 1; i <= MAXLOG; i++) {
        jog(TWO_POWER+i-1, TWO_POWER+i-1, TWO_POWER+i);
        jog(TWO_POWER_1+i-1, TWO_POWER+i-1, TWO_POWER_1+i);
    }

    jog(ZERO, ZERO, TOBINARY+MAXLOG+1);
    jog(ZERO, ZERO, TOBINARY+MAXLOG+2);
    for (int i = MAXLOG; i >= 0; i--) {
        jog(TOBINARY+MAXLOG+1, TWO_POWER_1+i, TOBINARY+i);
        tulona(TOBINARY+i, from, TOBINARY+i);
        jog(ZERO, TOBINARY+i, TOBINARY+MAXLOG+2);
        for (int j = 0; j < i; j++) {
            jog(TOBINARY+MAXLOG+2, TOBINARY+MAXLOG+2, TOBINARY+MAXLOG+2);
        }
        jog(TOBINARY+MAXLOG+1, TOBINARY+MAXLOG+2, TOBINARY+MAXLOG+1);
    }
//    cout << "convert: " << a[from] << " " << a[seed] << " => " << a[TOBINARY+MAXLOG+1] << endl;
//    for (int i = MAXLOG-1; i >= 0; i--) cout << a[TOBINARY+i];
//    cout << endl;
}

void process() {
    ///ABINARY+MAXLOG contains current achieved value
    tulona(ZERO, 0, 3);
    convert(0, 3);
    for (int i = MAXLOG-1; i >= 0; i--) {
        jog(2, TOBINARY+i, ABINARY+i); ///copy from TOBINARY to ABINARY
    }

//    cout << "ABINARY:" << endl;
//    for (int i = MAXLOG-1; i >= 0; i--) cout << a[ABINARY+i];
//    cout << endl;

    for (int i = 0; i < MAXLOG; i++) {
//        cout << i << " -> " << a[ABINARY+i] << endl;
        convert(1, ABINARY+i);

        jog(ZERO, ZERO, TOBINARY+MAXLOG);
        for (int j = 0; j < MAXLOG; j++) {
            for (int k = 0; k < j; k++) {
                jog(TOBINARY+j, TOBINARY+j, TOBINARY+j);
            }
//            cout << j << " -> " << a[TOBINARY+j] << endl;
            jog(TOBINARY+j, TOBINARY+MAXLOG, TOBINARY+MAXLOG);
        }
//        cout << "=> " << a[TOBINARY+MAXLOG] << endl;
        for (int k = 0; k < i; k++) {
            jog(TOBINARY+MAXLOG, TOBINARY+MAXLOG, TOBINARY+MAXLOG);
        }
        jog(2, TOBINARY+MAXLOG, 2);
    }
}

int main() {
//    a[0] = 100;
//    a[1] = 69;

    process();
    cout << vins.size() << endl;
    for (Instruction p : vins) cout << p << endl;

//    cout << a[2] << endl;

    return 0;
}


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

int main () {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = 0;
  
  if (X >= Y) {
    if (A > 2*C) ans += 2*X*C;
    else if (A+B > 2*C) ans += 2*Y*C+(X-Y)*A;
    else ans += X*A+Y*B;
  }
  else {
    if (B > 2*C) ans += 2*Y*C;
    else if (A+B > 2*C) ans += 2*X*C+(Y-X)*B;
    else ans += X*A+Y*B;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d %d",$a,$b,$c);
$d=($a%2)*($b%2)*($c%2);

if($d==0){
  print "0\n";
}else{
  $e=array($a,$b,$c);
  sort($e);
  $d=$e[0]*$e[1];
  print "$d\n";
}
?>

Measured memory_bytes: 3064
#include <stdio.h>

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

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


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

int main() {
  int A , B;
  cin >> A >> B;
  int C = 0;
  for ( int i = A; i <= B; i++ ){
    if ( i / 10000 == i % 10 ){
      if ( i % 10000 / 1000 == i % 100 /10 ){
        C++;
      }
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 3588
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, std::vector<long long> A){
  ll s = 0;
  rep(i,N) s+=A[i];
  ll ans = LINF;
  ll now = 0;
  rep(i,N){
    now += A[i];
    ll rest = s-now;
    ll temp = abs(rest-now);
    chmin(ans,temp);
  }
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 1792
n = input()
a = list(map(int,input().split()))
a.insert(0,0.5)
alen = len(a)
a.append(0.5)
a.append(0.5)

ans = 0
 
med = [0 for x in range(alen +2)]
 
for i in range(alen):
    if a[i] == i:
        med[i+1] = 1

for i in range(len(med)):
    if med[i] == 1:
        if med[i+1] == 1:
            med[i+1] = 0
            ans += 1
        else:
            ans += 1
        
print(ans)

Measured memory_bytes: 14004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, i=0;
  cin >> N >> K;
  for(int pos;N>0;N--){
    cin >> pos;
    i+=(pos>abs(pos-K))?abs(pos-K)<<1:pos<<1;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
class RMQ:
    def __init__(self, length, ini_num = float("inf")):
        self.length = 1
        self.ini_num = ini_num
        while self.length < length:
            self.length <<= 1
        self.segtree = [ini_num] * (2 * self.length - 1)

    def update(self, index, n):
        leaf_index = index + self.length - 1
        self.segtree[leaf_index] = n
        while leaf_index > 0:
            leaf_index = (leaf_index - 1) // 2
            self.segtree[leaf_index] = min(self.segtree[leaf_index * 2 + 1], self.segtree[leaf_index * 2 + 2])

    def find(self, a, b, index, l, r):
        if a <= l <= r <= b:
            return self.segtree[index]
        elif b < l or r < a:
            return self.ini_num
        else:
            return min(self.find(a, b, index * 2 + 1, l, (l + r) // 2), self.find(a, b, index * 2 + 2, (l + r) // 2 + 1, r))

v_num, query = map(int, input().split(" "))
rmq = RMQ(v_num, 2147483647)
for _ in range(query):
    com, i, n = map(int, input().split(" "))
    if com == 0:
        rmq.update(i, n)
    else:
        print(rmq.find(i, n, 0, 0, rmq.length - 1))

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

int main(){
  int64_t k,x;
  cin >> x;
  k = 100;
  for(int i = 1;i < 11000000000000000000;i++){
    k += k * 0.01;
    //cout << i << endl;
    //cout << k << endl;
    if(x <= k){
      cout << i << endl;
      break;
    }
  }
  return 0;
}
      

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define loop(a, b, inc) for (int i = a; i <= b; i += inc)
typedef pair<int, int> pii;
typedef pair<int, string> ps;
typedef unsigned long long int llu;
typedef long long int ll;
typedef unsigned u;
const int MOD = 1e7+9, MAXN = 1e6 + 100;

int dp[MAXN][5], tab[MAXN][5];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	loop(1, n, 1) {
		for (int j = 1; j <= 3; ++j)
			cin >> tab[i][j];
	}
	for (int j = 1; j <= n; ++j) {
		dp[n][j] = tab[n][j];
	}
	for (int i = n-1; i >= 0; --i) {
		for (int j = 1; j <= 3; ++j) {
			for (int k = 1; k <= 3; ++k) {
				if (k != j)
					dp[i][j] = max(dp[i][j], dp[i+1][k]+tab[i][j]);
			}
		}
		//cout << dp[i][1] <<" "<< dp[i][2] << " " << dp[i][3] << endl;
	}
	cout << max(max(dp[0][1], dp[0][2]), dp[0][3]) << endl; 
	
	return 0;
}


Measured memory_bytes: 6272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0023
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            for (int i = 0 ; i < n ; i++)
            {
                double[] items = ReadDoubleAr();
                double r1 = items[2];
                double r2 = items[5];
                double d = Math.Sqrt(Math.Pow(items[3] - items[0], 2) + Math.Pow(items[4] - items[1], 2));

                int res = 0;
                if (r1 > r2 && d < r1 - r2) res = 2;
                else if (r1 < r2 && d < r2 - r1) res = -2;
                else if (d <= r1 + r2) res = 1;
                Console.WriteLine(res);
            }

        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

int main(void) {
  int i, x[3], y[3];
  for(i = 0; i < 3; ++i) scanf("%d%d", &x[i], &y[i]);
  double ans, a, b, c, k;
  a = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]));
  b = sqrt((x[2] - x[1]) * (x[2] - x[1]) + (y[2] - y[1]) * (y[2] - y[1]));
  c = sqrt((x[0] - x[2]) * (x[0] - x[2]) + (y[0] - y[2]) * (y[0] - y[2]));
  k = sqrt(2 * a * a * b * b + 2 * b * b * c * c + 2 * c * c * a * a - a * a * a * a - b * b * b * b - c * c * c * c);
  ans = k / 2 / (a + b + c + k / a);
  ans = ans > k / 2 / (a + b + c + k / b) ? ans : k / 2 / (a + b + c + k / b);
  ans = ans > k / 2 / (a + b + c + k / c) ? ans : k / 2 / (a + b + c + k / c);
  printf("%.12lf", ans);
  return 0;
}

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


int main() {
    int N;
    map<int, int> A;
    cin >> N;
    for (int i = 1; i < (N+1); i++) {
        A[i] = 0;
    }
    
    for (int i = 2; i < (N+1); i++) {
        int joshi;
        cin >> joshi;
        A[joshi] += 1;
    }

    for (int i = 1; i < (N+1); i++) {
        cout << A[i] << endl;
    }

}

Measured memory_bytes: 12976
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    auto f = [](int n){
        if(n <= 10) return 1150;
        else if(n <= 20) return n*125-100;
        else if(n <= 30) return n*140-400;
        else return n*160-1000;
    };
    int n;
    while(cin >> n, ~n) cout << 4280-f(n) << "\n";
    return 0;
}


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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n,m;
    cin>>n>>m;
    int edge[n][n];
    memset(edge,0,sizeof(edge));
    rep(i,m){
        int a,b;
        cin>>a>>b;
        edge[a-1][b-1]=1;
        edge[b-1][a-1]=1;
    }
    vector<int> a(n);
    rep(i,n)a[i]=i;
    int ans=0;
    int combi=1;
    rep(i,1,n)combi*=i;
    rep(i,combi){
        bool flag=1;
        rep(j,n-1){
            if(!edge[a[j]][a[j+1]]){
                flag=0;
                break;
            }
        }
        if(flag)++ans;
        next_permutation(a.begin(),a.end());
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N;
int A[2][200100], B[2][200100];
int nxt;

int f(int b){
    int x = 1 << b;
    int j = 0, k = 0, j2 = 0, k2 = 0;
    int res = 0;
    
    for(int i=N-1;i>=0;--i){
        int a = A[nxt][i];
        while(j < N && B[nxt][j] < x - a){++j;}
        while(k < N && B[nxt][k] < 2 * x - a){++k;}
        while(j2 < N && B[nxt][j2] < 3 * x - a){++j2;}
        while(k2 < N && B[nxt][k2] < 4 * x - a){++k2;}

        res ^= j ^ k ^ j2 ^ k2;
    }

    return res & 1;
}

void merge(int (&X)[2][200100], int b){
    int x = 1 << b;
    auto it = lower_bound(X[nxt], X[nxt]+N, x);

    int l = 0, r = it - X[nxt], l2 = r, r2 = N;
    for(int i=0;i<N;++i){
        if(l == r){
            X[!nxt][i] = X[nxt][l2] % x;
            ++l2;
        }else if(l2 == r2){
            X[!nxt][i] = X[nxt][l];
            ++l;
        }else if(X[nxt][l] < X[nxt][l2] % x){
            X[!nxt][i] = X[nxt][l];
            ++l;
        }else{
            X[!nxt][i] = X[nxt][l2] % x;
            ++l2;
        }
    }

    // std::cout << "Case " << b << std::endl;
    // for(int i=0;i<N;++i){
    //     std::cout << X[!nxt][i] << " \n"[i+1==N];
    // }
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[0][i];
    }

    for(int i=0;i<N;++i){
        std::cin >> B[0][i];
    }

    sort(A[0], A[0]+N);
    sort(B[0], B[0]+N);

    int res = f(28) << 28;

    for(int b=27;b>=0;--b){
        res |= f(b) << b;

        if(b > 0){
            merge(A, b);
            merge(B, b);
            nxt = !nxt;
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 3328
a, b = list(map(int, input().split()))
l = [4,6,9,11]
ll = [1, 3, 5, 7, 8, 10, 12]
if a in l and b in l:
    print("Yes")
elif a == b == 2:
    print("Yes")
elif a in ll and b in ll:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
<?php
fscanf(STDIN, "%s", $a);

if($a == 'A') {
  echo 'T';
} else if ($a == 'T') {
    echo 'A';
} else if ($a == 'C') {
    echo 'G';
} else if ($a == 'G') {
    echo 'C';
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   ll a, b, v, w, t;
   cin>>a>>v>>b>>w>>t;
   ll d=abs(a-b);
   if(a==b || (v>w && (v-w)*t>=d)){
      cout << "YES" << endl;
   }
   else{
      cout << "NO" << endl;
   }
   return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

int main() {
    string s;
    cin >> s;
    int n = static_cast<int>(s.size());
    auto nextch = make_v(n+1, 26, n);
    vector<int> dp(n+2, INF<int>);
    vector<pair<char, int>> dp2(n+1, make_pair('a', n));
    dp[n] = 1;
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) nextch[i][j] = nextch[i+1][j];
        nextch[i][s[i]-'a'] = i;
        for (int j = 0; j < 26; ++j) {
            if(nextch[i][j] == n){
                if(dp[i] > 1) dp[i] = 1, dp2[i] = make_pair('a'+j, n);
            }else if (dp[i] > dp[nextch[i][j]+1]+1) {
                dp[i] = dp[nextch[i][j]+1]+1;
                dp2[i] = make_pair('a'+j, nextch[i][j]+1);
            }
        }
    }
    string ans;
    for (int i = 0; i < n;) {
        auto p = dp2[i];
        ans += p.first;
        i = p.second;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 29316
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    vector<int> a(26,0);
    int i,n=s.size(),ans=0;
    for(i=0;i<n;i++){
        a.at(s.at(i)-'a')++;
    }
    for(i=0;i<26;i++){
        if(a.at(i)>1) ans = 1;
    }
    if(ans) cout << "no" << endl;
    else cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
ns = list(map(int, input().split()))
bs = list(map(int, input().split()))
count = 0
for i in range(n):
    monster = min(ns[i], bs[i])
    count += monster
    bs[i] -= monster
    monster2 = min(ns[i+1], bs[i])
    count += monster2
    ns[i+1] -= monster2
print(count)

Measured memory_bytes: 18304
#include <iostream>
#include <ctime>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
const long long int INF=1000000000;
long long int dx[4]={0,0,-1,-1};
long long int dy[4]={0,-1,0,-1};

int main(){
	long long int w,h;
	cin >> w >> h;
	long long int n;
	cin >> n;
	vector<long long int> vx(n);
	vector<long long int> vy(n);
	vector<long long int> hoge(n);
	vector<long long int> piyo(n);
	for(long long int i=0; i<n; ++i){
		cin >> vx[i] >> vy[i];
		hoge[i]=vx[i];
		piyo[i]=vy[i];
	}
	long long int ans=0;
	long long int ans_x,ans_y;
	sort(vx.begin(),vx.end());
	sort(vy.begin(),vy.end());
	if(n%2!=0){
		ans_x=vx[n/2];
		ans_y=vy[n/2];
		long long int maxd;
		maxd=0;
		for(long long int i=0; i<n; ++i){
			ans+=2*abs(vx[n/2]-hoge[i])+2*abs(vy[n/2]-piyo[i]);
			maxd=max(maxd,abs(vx[n/2]-hoge[i])+abs(vy[n/2]-piyo[i]));		
		}
		ans-=maxd;
	} else {
		long long int tmp[4];
		long long int maxd[4];
		for(long long int i=0; i<4; ++i){
			tmp[i]=0;
			maxd[i]=0;
		}
		for(long long int i=0; i<4; ++i){
			for(long long int j=0; j<n; ++j){
				tmp[i]+=2*abs(vx[n/2+dx[i]]-hoge[j])+2*abs(vy[n/2+dy[i]]-piyo[j]);
				/*
				if(i==3&&maxd[i]<abs(vx[n/2+dx[i]]-hoge[j])+abs(vy[n/2+dy[i]]-piyo[j])){
					cout << vx[j] << " " << vy[j] << " " << abs(vx[n/2+dx[i]]-vx[j])+abs(vy[n/2+dy[i]]-vy[j]) << endl;
				}*/
				maxd[i]=max(maxd[i],abs(vx[n/2+dx[i]]-hoge[j])+abs(vy[n/2+dy[i]]-piyo[j]));
			}
		}
		ans=INF*100000000;
		for(long long int i=0; i<4; ++i){
			//cout << vx[n/2+dx[i]] << " " << vy[n/2+dy[i]]<< " " << tmp[i]-maxd[i] << " " << tmp[i] << " " << maxd[i] << endl;
			if(ans>=tmp[i]-maxd[i]&&n/2+dx[i]>=0&&n/2+dy[i]>=0){
				ans=tmp[i]-maxd[i];
				ans_x=vx[n/2+dx[i]];
				ans_y=vy[n/2+dy[i]];
			}
		}
	}
	cout << ans << endl;
	cout << ans_x << " " << ans_y << endl;
	return 0;
}

//01234567

Measured memory_bytes: 4176
let (n, k) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)
let s = read_line () 
  |> Str.full_split (Str.regexp "0+") 
  |> List.map (function Str.Text s | Str.Delim s -> (s.[0], String.length s))

let rec take_sum que = function
  | 0 -> 0
  | n -> (snd @@ Queue.take que) + take_sum que (n - 1)

let rec loop ans sum k que = function
  | [] -> ans
  | (ch, cnt) as pair :: rest ->
      Queue.add pair que;
      let next_sum, next_k = 
        if ch = '1' then (sum + cnt, k)
        else if k = 0 then 
          let t = if fst (Queue.peek que) = '0' then 1 else 2 in
          (sum + cnt - take_sum que t, 0)
        else (sum + cnt, k - 1) in
    loop (max ans next_sum) next_sum next_k que rest

let () = Printf.printf "%d\n" @@ loop 0 0 k (Queue.create ()) s

Measured memory_bytes: 22120
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const int mod = 1e9 + 7;

struct mat {
    int x[3][3];
    mat operator*(const mat &p) const {
        mat ret;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                ret.x[i][j] = 0;
                for (int k = 0; k < 3; ++k) {
                    ret.x[i][j] += (llong)x[i][k] * p.x[k][j] % mod;
                    ret.x[i][j] %= mod;
                }
            }
        }
        return ret;
    }
    void print() const {
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                printf("%d ", x[i][j]);
            }
            printf("\n");
        }
    }
} it = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };

mat pow(mat x, int p) {
    if (p == 0) return it;
    if (p == 1) return x;
    mat ret = pow(x, p >> 1);
    ret = ret * ret;
    if (p & 1) ret = ret * x;
    return ret;
}

int n, m;
int xs[100001];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        scanf("%d", xs + i);
    }
    mat x = { 1, 0, 1, 2, 1, 2, 1, 1, 2 };
    mat y = { 1, 0, 0, 2, 1, 0, 1, 1, 1 };
    mat ret = it;
    int pr = -1;
    for (int i = 1; i <= m; ++i) {
        ret = y * pow(x, xs[i] - pr - 1) * ret;
        pr = xs[i];
    }
    ret = pow(x, n - pr - 1) * ret;
    printf("%d\n", ret.x[2][0]);
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n,m;cin>>n>>m;
  string a[n];
  rep(i,n)cin>>a[i];
  string b[m];
  rep(i,m)cin>>b[i];

  int result;
  rep(i,n-m+1){
    rep(j,n-m+1){
      result=1;
      rep(ii,m)rep(jj,m)if(a[i+ii][j+jj]!=b[ii][jj])result=0;
      if(result){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

map<char,int> nanm;
int nani;
int narec(string s){
	if(s[nani]=='P'||s[nani]=='Q'||s[nani]=='R'){
		nani++;
		return nanm[s[nani-1]];
	}
	if(isdigit(s[nani])){
		nani++;
		return (s[nani-1]-'0'-1);
	}
	if(s[nani]=='-'){
		nani++;
		return -narec(s);
	}
	if(s[nani]=='('){
		nani++;
		int left=narec(s);
		char op=s[nani];
		nani++;
		int right=narec(s);
		nani++;
		if(op=='*')	return min(left,right);
		if(op=='+')	return max(left,right);
	}
	return -2;
}


int main(){
	string s;
	int P,Q,R;
	while(cin>>s&&s!="."){
		int ans=0;
		for(P=-1;P<=1;P++){
			for(Q=-1;Q<=1;Q++){
				for(R=-1;R<=1;R++){
					nani=0;
					nanm['P']=P;nanm['Q']=Q;nanm['R']=R;
					if(narec(s)==1){
						ans++;
					}
				}
			}
		}
		p(ans);
	}
	return 0;
}

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

int main(){
 int H, W;
    while(1){
     cin >> H >> W;
     if( H == 0 && W  == 0 ) break;

        for( int i = 0; i < H; i++ ){
            for( int j = 0; j < W; j++ ){
                if( (i + j ) % 2 == 0 ){
                 cout << "#";
                } else {
                  cout << ".";
                }
            }
           cout << "\n";
        }
        cout << endl;
     }
    
 return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#define N 4

void DataSet(int, int[]);

int main(){
  int i, j, n, m, hit, blow, a[N], b[N];

  while(1){
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0) break;

    DataSet(n, a);
    DataSet(m, b);

    hit = 0; 
    blow = 0;

    for(i=0; i<N; i++){
      for(j=0; j<N; j++){
        if(i == j && a[i] == b[j])
          hit++;
        else if(a[i] == b[j])
          blow++;
      }
    }

    printf("%d %d\n", hit, blow);
  }

  return 0;
}

void DataSet(int x, int data[]){
  int i, y;
  int digit=1000;

  for(i=0; i<N; i++){
    y = x / digit;
    data[i] = y;
    x = x - digit*y;
    digit /= 10;
  }
}

Measured memory_bytes: 0
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long A = sc.nextLong();
        long B = sc.nextLong();
        
        long ans=LCM(A,B);
        System.out.println(ans);	
        
        
    }
    
    static long GCD(long a,long b) {
  	  long tmp;
  	  long r;
  	  if(a<b) {
  		  tmp = a;
  		  a = b;
  		  b = tmp;				  
  	  }
  	  
  	  r = a % b;
  	  while(r!=0) {
  		  a=b;
  		  b=r;
  		  r=a%b;
  	  }
  	  
  	  return b;
    }
    
    static long LCM(long a,long b) {
  	  return a*b/GCD(a,b);
    }
}

Measured memory_bytes: 25044
from collections import Counter
def main():
    N=int(input())
    l=[]
    for i in range(N):
        l.append(int(input()))
    c=Counter(l)
    ans=0
    for i in c:
        if c[i]%2==1:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 16636
A, B = map(int, input().split())
# F(A,B) = F(0,A-1) ^ F(0,B)
# 任意の偶数について、n ^ (n+1) = 1
# ex. F(0,6) = 0^1^2^3^4^5^6 = (0^1)^(2^3)^(4^5)^6 = 1^1^1^6
# 1^1^1^...について、1が偶数個なら0, 奇数個なら1


def xor_func(n):
    if n % 2 == 0:
        tmp = n // 2
        if tmp % 2 == 0:
            x = 0 ^ n
        else:
            x = 1 ^ n
    else:
        tmp = (n + 1) // 2
        if tmp % 2 == 0:
            x = 0
        else:
            x = 1
    return x

f1 = xor_func(A - 1)
f2 = xor_func(B)
ans = f1 ^ f2
print(ans)


Measured memory_bytes: 9180
// Floor Function
// 5/5理解したよ
#include<bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;

ll a, b, n;

ll f(ll x){
  return (a*(x%b)-(a*x)%b)/b;
}

int main(){

  //string s;
  cin >> a >> b >> n;

  //vector<ll> a(n);
  //queue<ll> q;
  //map<string,ll> d{};

  ll ans = f(min(b-1, n));


  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    string S;
    cin >> S;
    int res = 0;
    int cnt = 0;
    REP(i, 3) {
        if (S[i] == 'S') {
            cnt = 0;
        } else {
            ++cnt;
            res = max(res, cnt);
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3648
parseint(x) = parse(Int, x)
readints() = map(parseint, readline() |> split)

function main()
    l, r = readints()
    if r - l >= 2018
        println(0)
    else
        ans = 2019
        for i = l:r-1, j = i+1:r
            ans = min(ans, (i * j) % 2019)
        end
        println(ans)
    end
end

main()

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

const long long mod = 1e9 + 7;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)

#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long A, long long B, long long C) {
  cout<<max((ll)0,C-(A-B))<<endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  func(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int a[500][500];

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


	const int v = 100000;

	int H,W,h,w;
	cin>>H>>W>>h>>w;

	if (H%h==0&&W%w==0){
		cout << "No"<<endl;
		return 0;
	}

	if (h == 1){

	}


	int n = (H / h)*(W/w);


	for (int y=0;y+h<=H;y+=h){
		for (int x=0;x+w<=W;x+=w){
			a[y][x] = v;
			a[y+h-1][x+w-1]=-(v+1);
		}
	}
	if (W%w)for (int y = 0; y + h <= H; y += h)
		a[y][W-1] = v;
	if (H%h)for (int x = 0; x + w <= W; x += w)
		a[H-1][x] = v;
	if (W%w && H%h)
		a[H-1][W-1]=v;

	long long s=0;
	rep(y, H)rep(x, W)s += a[y][x];
	if (s > 0){
		cout << "Yes"<<endl;
		rep(y,H){
			cout << a[y][0];
			rep(x, W-1)cout << ' ' << a[y][x+1];
			cout<<endl;
		}
	}
	else{
		cout << "No"<<endl;
	}


	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 2047483647;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {
  
    string S;
    cin >> S;
    
    ll K = lin();
    
    int cur = 0;
    while(1){
        
        if (cur == K-1){
            
            cout << S[cur] << endl;
            return 0;
            
        }
        
        
        if (S[cur] != '1'){
            cout << S[cur] << endl;
            return 0;
        }
        cur++;
    }
    

    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int p[11];
ll c[11];
ll all[11];
int main()
{
	int D;
	ll G;
	cin >> D >> G;
	for (int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
		all[i] = 100 * (i + 1) * p[i] + c[i];
	}
	ll ans = INF;
	for (int bit = 0; bit < (1 << D); bit++) {
		int point = 0;
		ll sum = 0;
		ll cnt = 0;
		int tmp = bit;
		for (int i = 0; i < D; i++) {
			if (tmp % 2 == 1) {
				sum += all[i];
				cnt += p[i];
			}
			else point = i;
			tmp /= 2;
		}
		int c = 0;
		while (sum < G) {
			if (c == p[point]) break;
			cnt++;
			sum += 100 * (point + 1);
			c++;
		}
		if (sum >= G) ans = min(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import copy
S = input()
Slen = len(S)

Sc=[0]*Slen
for i in range(Slen):
    if S[i:i+2] == 'RL':
        for j in range(i,-1,-1):
            if S[j]=='R':
                Sc[(i-j)%2 + i] += 1
            else:
                break
        for j in range(i+1,Slen):
            if S[j] == 'L':
                Sc[(j-i)%2 +i] += 1
            else:
                break    

print(" ".join(map(str,Sc)))



Measured memory_bytes: 51184
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

x, a, b = na()
print('A' if abs(x - a) < abs(x - b) else 'B')






Measured memory_bytes: 3572
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long a = parseLong(sc.next());
		long b = parseLong(sc.next());
		long n = parseLong(sc.next());
		sc.close();
		long x=Math.min(b-1,n);
		out.println((long)floor((double)a*x/b)-a*(long)floor((double)x/b));
	}
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;

int main() {

    int d, n;
    cin >> d >> n;

    cout << fixed << setprecision(0) << (n == 100 ? 101 * pow(100, d) : n * pow(100, d)) << endl;

    return 0;
}

Measured memory_bytes: 256
// B - ∵∴∵
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t, r = "";
  vs v;
  cin >> s;
  cin >> t;
  rep(i, 0, t.size())
  {
    r = r + s[i] + t[i];
  }
  if (s.size() != t.size())
  {
    r += s[s.size() - 1];
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int N,M,i,t,ans,min,max;
  ans=0;
  scanf("%d %d",&N,&M);
  int L[M+1],R[M+1];
  L[0]=0,R[0]=0;
  for(i=1;i<=M;i++){
    scanf("%d %d",&L[i],&R[i]);
  }
  min=L[1],max=R[1];
  for(i=2;i<=M;i++){
    if(min<L[i]){
      min=L[i];
    }
    if(max>R[i]){
      max=R[i];
    }
  }
  if(max>=min){
  printf("%d",max-min+1);
  }
  else{
    printf("0");
  }
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	vector<string> day = {
		"SAT",
		"FRI",
		"THU",
		"WED",
		"TUE",
		"MON",
		"SUN",
	};

	for(int i=0; i<7; i++){
		if(S==day[i]) {
			cout << i+1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}


int H,W;
int s[50][50];

int ans=INF;


int main()
{
	cin>>H>>W;

  int bnum=0;

	REP(i,0,H){
    string tmp;
    cin>>tmp;
		REP(j,0,W){
      s[i][j]=tmp[j];
      if(s[i][j]=='#'){
        bnum++;
      }
		}
	}
  int visited[50][50];
  REP(i,0,50){
    REP(j,0,50){
      visited[i][j] = INF;
    }
  }
  queue<pair<int,int> > q;
  visited[0][0]=0;
  q.push(make_pair(0,0));

  while(!q.empty()){
    int x,y;
    auto p=q.front();
    q.pop();
    x=p.first;
    y=p.second;
    for (int dx = -1; dx <= 1; ++dx) {
      for (int dy = -1; dy <= 1; ++dy) {
        if (dx * dx + dy * dy == 1) {
          int nx = x + dx;
          int ny = y + dy;
          if (0 <= nx && nx < H && 0 <= ny && ny < W &&
              s[nx][ny] == '.' && visited[nx][ny] == INF) {
            visited[nx][ny] = visited[x][y] + 1;
            q.push(make_pair(nx,ny));
          }
        }
      }

    }
  }


  if(visited[H-1][W-1]==INF){
    cout<<-1<<endl;
  }
  else{
    int a=H*W-bnum-visited[H-1][W-1]-1;
    cout<<a<<endl;
  }

  return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N,M;
    cin>>N>>M;
    cout<<N*(N-1)/2+M*(M-1)/2<<endl;
}

Measured memory_bytes: 3560
from collections import Counter
n, p = map(int, input().split())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


list = factorization(p)
#print(list)
ans = 1
for l in list:
    c = l[1] // n
    ans *= l[0] ** c
print(ans)

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

for _ in range(n):
    x, y, b, p = map(int, input().split())
    if b < 5 and p < 2:
        ans = min((x*b+y*p), ((x*5+y*2)*0.8))
    elif b >= 5 and p < 2:
        ans = min((x*b+y*p), ((x*b+y*2)*0.8))
    elif b < 5 and p >= 2:
        ans = min((x*b+y*p), ((x*5+y*p)*0.8))
    else:
        ans = (x*b+y*p)*0.8

    print(int(ans))



Measured memory_bytes: 5620
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	ll* countTable = new ll[N+1];
	for(int i = 0; i <= N; i++)countTable[i] = 0;

	int* schedule = new int[M];
	for(int i = 0; i < M; i++)scanf("%d",&schedule[i]);

	ll* A = new ll[N];
	ll* B = new ll[N];
	ll* C = new ll[N];

	for(int i = 1; i <= N-1; i++){
		scanf("%lld %lld %lld",&A[i],&B[i],&C[i]);
	}

	int from,to;

	for(int i = 0; i <= M-2; i++){
		from = schedule[i];
		to = schedule[i+1];
		if(from > to){
			swap(from,to);
		}
		countTable[from]++;
		countTable[to]--;
	}

	for(int i = 2; i <= N-1; i++){
		countTable[i] += countTable[i-1];
	}

	ll ans = 0;

	for(int i = 1; i <= N-1; i++){
		if(countTable[i]*(A[i]-B[i])-C[i] > 0){
			ans += B[i]*countTable[i]+C[i];
		}else{
			ans += A[i]*countTable[i];
		}
	}

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 6268
using System;
class main
{
    static void Main(string[] args)
    {
        while (true)
        {
            string s = Console.ReadLine();
            if (s != null)
            {
                    string[] t = s.Split(' ');
                    int a = int.Parse(t[0]);
                    int b = int.Parse(t[1]);
                    int c = a + b;

                    Console.WriteLine(c.ToString().Length);
            }
            if (s == null)
            {
                break;
            }
        }
        //Console.ReadKey();
    }
}

Measured memory_bytes: 5624