akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <map>
#include <string>
#include <sstream>
#include <queue>
#include <iomanip>
#include <set>


using namespace std;

#define ll long long int


int brute_force(vector<int>&A){
    int n = A.size();
    vector<int> pos(n);
    for(int i=0; i<n; i++) pos[i] = i;
    int sum, maxi = 0;
    do{
        sum = 0;
        for(int i=0; i<n; i++){
            sum += A[i] * abs(i - pos[i]);
        }
        maxi = max(sum, maxi);
    }while(next_permutation(pos.begin(), pos.end()));
    return maxi;
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(NULL));
    
    int n; cin>>n;
    vector<ll> A(n);
    vector<pair<ll, int> > Asort(n);
    for(int i=0; i<n; i++){
        cin>>A[i];
        //A[i] = rand()%10;
        Asort[i] = make_pair(-A[i], i);
    }
    //for(int i=0; i<n; i++) cout<<A[i]<<" ";
    //cout<<endl;
    
    
    sort(Asort.begin(), Asort.end());
    
    vector<vector<ll> > DP(n+1, vector<ll>(n+1, 0));
    
    //Formule en ajoutant Asort[i], L + (n-1-R) = i
    DP[1][0] = -Asort[0].first*abs(Asort[0].second);
    DP[0][1] = -Asort[0].first*abs(Asort[0].second - n+1);
    /*for(int i=0; i<n+1; i++){
        for(int j=0; j<n+1; j++){
            cout<<DP[i][j]<<" ";
        }cout<<endl;
    }cout<<endl<<endl;*/
    for(int i = 1; i<n; i++){
        for(int L = 0, R = i+1; L<n+1 && R>=0; L++, R--){
            if(L>0 && R>0) DP[L][R] = max(DP[L-1][R] - Asort[i].first*abs(L-1-Asort[i].second), DP[L][R-1] - Asort[i].first*abs(n-R-Asort[i].second));    //On le place en L+1
            else if(L==0) DP[L][R] = DP[L][R-1] - Asort[i].first*abs(n-R-Asort[i].second);
            else if(R==0) DP[L][R] = DP[L-1][R] - Asort[i].first*abs(L-1-Asort[i].second);
        }
        /*for(int i=0; i<n+1; i++){
            for(int j=0; j<n+1; j++){
                cout<<DP[i][j]<<" ";
            }cout<<endl;
        }cout<<endl<<endl;*/
    }
    
    ll res=0;
    for(int i=0; i<n+1; i++){
        res = max(res, DP[i][n-i]);
    }
    cout<<res<<endl;
    //cout<<"vs "<<brute_force(A)<<endl;

    
    /*
    int k = 0, l = n-1;
    for(int i = 0, j = 0; i < Asort.size(); i += j){
        while(i+j<Asort.size() && Asort[i].first == Asort[i+j].first) j++;
        placer(Asort, i, j, k, l);
    }*/
    
    
    
    
    return 0;
    
    
    
}


Measured memory_bytes: 34616
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int k = sc.nextInt();

        int digits = n.length();
        int[] digit = new int[digits];

        for(int i = 0 ; i < digits ; i++){
            digit[i] = Integer.valueOf(n.substring(i, i+1));
        }

        //桁DP
        //(nを下回っているなら0, 未確定なら1), 0以外がちょうどk個, この桁数目まで
        long[][][] dp = new long[2][k+1][digits];
        dp[0][0][0] = 1;
        dp[0][1][0] = digit[0] - 1;
        dp[1][0][0] = 0;
        dp[1][1][0] = 1;


        for(int i = 1 ; i < digits ; i++){
            for(int j = 0 ; j <= k ; j++){
                dp[0][j][i] += dp[0][j][i-1];
                if(j > 0){
                    dp[0][j][i] += dp[0][j-1][i-1]*9;
                }
                if(digit[i] == 0){
                    dp[1][j][i] += dp[1][j][i-1];
                }else{
                    dp[0][j][i] += dp[1][j][i-1];
                    if(j > 0) {
                        dp[0][j][i] += dp[1][j-1][i-1]*(digit[i]-1);
                        dp[1][j][i] += dp[1][j-1][i-1];
                    }
                }
            }
        }

        System.out.println(dp[0][k][digits-1] + dp[1][k][digits-1]);
    }
}

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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n) {
    vector<int> ans;
    for (int i = 0; i < 10; i++) {
      if (n >> i & 1) ans.emplace_back(1 << i);
    }
    for (int i = 0; i < (int)ans.size(); i++) {
      cout << ans[i] << " \n"[i + 1 == (int)ans.size()];
    }
  }

  return 0;
}


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

using namespace std;


int main() {
  
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    
    if((b-a)<=x)
      {
          if((b-a)<=0)
              printf("delicious");
              
          else
              printf("safe");
      }
      
    else
      printf("dangerous");
  
    	return 0;
} 

Measured memory_bytes: 256
n,m = map(int,input().split())
d = {}
for _ in range(m):
    p,s = input().split()
    try:
        d[int(p)].append(s)
    except:
        d[int(p)] = [s]
T = 0
pe = 0
for key in d:
    if "AC" in d[key]:
        T += 1
        pe += d[key].index("AC")

print(T,pe)


Measured memory_bytes: 64344
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let a: usize = read();
    let s: String = read();

    if a >= 3200 {
      println!("{}", s);
    } else {
      println!("red")
    }
}


Measured memory_bytes: 4352
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    bool c = false;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'C'){
            c = true;
        }

        if(c){
            if(s[i] == 'F'){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
c = input()

rd = deque([i for i, x in enumerate(c) if x == "R"])
wd = deque([i for i, x in enumerate(c) if x == "W"])
if(len(rd) == 0 or len(wd) == 0):
  print(0)
  exit()
count = 0
for i in range(len(c)):
  if(not(wd[0] < rd[-1])):
    break
  rd.pop()
  wd.popleft()
  count += 1
  if(len(rd) == 0 or len(wd) == 0):
    break
print(count)

Measured memory_bytes: 18896
import itertools
import collections
import bisect

# Union find
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]  # 負の値の場合根を表す。絶対値はツリーの高さ 正の値は次の要素を返す、根まで続く
        self.size = [1 for _  in range(size)]

    #集合の代表を求める
    def find(self,x):
        while self.table[x] >= 0:
            #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    #併合
    def union(self,x,y):
        s1 = self.find(x)#根のindex,table[s1]がグラフの高さ
        s2 = self.find(y)
        if s1 != s2:#根が異なる場合
            if self.table[s1] != self.table[s2]:#グラフの高さが異なる場合
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                    self.size[s1] += self.size[s2]
                else:
                    self.table[s1] = s2
                    self.size[s2] += self.size[s1]
            else:
                #グラフの長さが同じ場合,どちらを根にしても変わらない
                #その際,グラフが1長くなることを考慮する
                self.table[s1] += -1
                self.table[s2] = s1
                self.size[s1] += self.size[s2]
        return

    def group_size(self, x):
        return self.size[self.find(x)]


def main():
    N, M = map(int, input().split())
    st = []
    en = []
    for _ in range(M):
        i, j = map(int, input().split())
        st.append(i-1)
        en.append(j-1)

    # print(st)
    # print(en)
    ans = 0
    for i in range(M):
        uf = UnionFind(N)
        for j in range(len(st)):
            if i == j:
                continue
            uf.union(st[j], en[j])
        group = uf.find(0)
        if not all([uf.find(i) == group for i in range(N)]):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int main(){
int64_t N;
  cin>>N;
  map<int64_t,int64_t>M;
  M[-1]=3;
  for(int64_t i=0;i<N;i++)
    M[i]=0;
  int64_t ans=1;
  for(int64_t i=0;i<N;i++){
  int64_t a;
    cin>>a;
    M.at(a)++;
    if(M.at(a-1)<M.at(a)){
    ans=0; break;
    }else{
    ans=((1+M.at(a-1)-M.at(a))*ans)%mod;
    }
       }cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 6528
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int s[]=new int[n+2];
  s[0]=0;
  s[n+1]=0;
  int ss=0;
  for(int i=0;i<n;i++){
    s[i+1]=sc.nextInt();
    
  }
  for(int i=0;i<n+1;i++)ss+=Math.abs(s[i]-s[i+1]);
  for(int i=1;i<n+1;i++){
  System.out.println(ss+Math.abs(s[i-1]-s[i+1])-(Math.abs(s[i-1]-s[i])+Math.abs(s[i+1]-s[i])));
  }
  

}
}

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

int main(){
    int n;
    cin >> n;
    int nsqrt = sqrt(n);

    long long ans = 0;
    for(int i=1; i<n; i++){
        long long tmp = (n-1)/i;
        ans += tmp;
    }

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

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
const double EPS=1e-10;
double add(double l, double r){
    if(abs(l+r)<EPS*(abs(l)+abs(r))) return 0;
    return l+r;
}
struct Pt{
    double x, y;
    Pt(double xx=0, double yy=0){x=xx; y=yy;}
    Pt& operator=(const Pt &rhs){x=rhs.x; y=rhs.y; return *this;}
    Pt& operator+=(const Pt &rhs){x = add(x,rhs.x); y = add(y,rhs.y); return *this;}
    Pt& operator-=(const Pt &rhs){x = add(x,-rhs.x); y = add(y,-rhs.y); return *this;}
    Pt& operator*=(const double &rhs){x *= rhs; y *= rhs; return *this;}
    Pt& operator/=(const double &rhs){x /= rhs; y /= rhs; return *this;}
};
Pt operator+(const Pt &a){return a;}
Pt operator-(const Pt &a){return Pt(-a.x,-a.y);}
Pt operator+(const Pt &lhs, const Pt &rhs){Pt ans=lhs; ans += rhs; return ans;}
Pt operator-(const Pt &lhs, const Pt &rhs){Pt ans=lhs; ans -= rhs; return ans;}
Pt operator*(const Pt &lhs, const double &rhs){Pt ans=lhs; ans *= rhs; return ans;}
Pt operator*(const double &lhs, const Pt &rhs){Pt ans=rhs; ans *= lhs; return ans;}
Pt operator/(const Pt &lhs, const double &rhs){Pt ans=lhs; ans /= rhs; return ans;}
bool operator==(const Pt &lhs, const Pt &rhs){return add(lhs.x,-rhs.x)==0 && add(lhs.y,-rhs.y)==0;}
bool operator!=(const Pt &lhs, const Pt &rhs){return !(lhs==rhs);}
bool operator<(const Pt &lhs, const Pt &rhs){return add(lhs.x,-rhs.x)!=0 ? add(lhs.x,-rhs.x)<0 : add(lhs.y,-rhs.y)<0;}
bool operator>(const Pt &lhs, const Pt &rhs){return rhs<lhs;}
bool operator<=(const Pt &lhs, const Pt &rhs){return !(lhs>rhs);}
bool operator>=(const Pt &lhs, const Pt &rhs){return !(lhs<rhs);}
istream& operator>>(istream &is, Pt &rhs){double x, y; is >> x >> y; rhs=Pt(x,y); return is;}
ostream& operator<<(ostream &os, const Pt &rhs){ os << rhs.x << " " << rhs.y; return os;}
double norm(const Pt &a){return add(a.x*a.x,a.y*a.y);}
double abs(const Pt &a){return sqrt(norm(a));}

int main(){
	int n; cin >> n;
    vector<Pt> p(n);
    for(int i=0; i<n; ++i) cin >> p[i];

    double ans=0;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            ans += abs(p[i]-p[j]);
        }
    }
    ans /= n;
    cout << fixed << setprecision(10);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long int

void findAns()
{
    int n;
    cin >> n;

    string s;
    cin >> s;

    if (n & 1) cout << "No";
    else
    {

        string v = s.substr(0, n / 2);
        string t = s.substr(n / 2, n / 2);
        if (v == t) cout << "Yes";
        else
            cout << "No";
    }


}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("o1.txt", "w", stdout);
//     //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s" << "\n";
// #endif

    FAST;
    ll  t = 1;
    //  cin >> t;

    while (t--)
        findAns();
}


Measured memory_bytes: 3664
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
////@formatter:on
//endregion


int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    make(int, m, n);
    makev(a, n);
    if (accumulate(ALL(a), 0ll) >= m){
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 1024
def runlegth(S):
    res = []
    cnt = 1
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            cnt += 1
        else:
            res.append(cnt)
            cnt = 1
    res.append(cnt)
    return res

def main():
    S = input()
    L = runlegth(S)
    n = 0
    ans = [0] * len(S)
    flag = True
    cnt = 0
    for i in range(len(S)):
        if flag:
            if S[i] == 'L':
                tmp = L[n] + L[n+1]
                if cnt % 2 == 0:
                    ans[i-1] = tmp // 2 
                    ans[i] = tmp // 2 if tmp % 2 == 0 else tmp // 2 + 1
                else:
                    ans[i-1] = tmp // 2 if tmp % 2 == 0 else tmp // 2 + 1
                    ans[i] = tmp // 2
                n += 2
                flag = False
            else:
                cnt += 1
        else:
            if S[i] == 'R':
                flag = True
                cnt = 1

    print(*ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 49724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp93 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int M = st[1];

            if (N >= 2 && M >= 2) {
                Console.WriteLine((long)(N - 2) * (M - 2));
            } else if (N == 1 && M == 1) {
                Console.WriteLine(1);
            } else {
                Console.WriteLine(Math.Max(N, M) - 2);
            }



        }
    }
}


Measured memory_bytes: 11348
function Main(input) {

    input = input.split("\n");
    
    N = Number(input[0]);
    let An = input[1].split(" ").map(Number);
    
    if (gcd(An) !== 1) {
        console.log("not coprime");
        return;
    }
        
    let freq = Array(1000001).fill(0);
    for(let A of An) {
        if (A === 1) continue;
        freq[A]++;
        if (freq[A] > 1) {
            console.log("setwise coprime");
            return;
        }
    }
    
    for (let i = 2; i <= 1000001; i++) {
        let tmp = 0;
        for (let j = i; j <= 1000001; j += i) {
            tmp += freq[j];
            if (tmp >= 2) {
                console.log("setwise coprime");
                return;
            }
        }
    }
    
    console.log("pairwise coprime");
    
}

function gcd(arg) {
    
    let f = (a, b) => b ? f(b, a % b) : a
    let ans = arg[0];
    for (let i = 1; i < arg.length; i++) {
        ans = f(ans, arg[i]); 
    }
    return ans;
    
}

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

Measured memory_bytes: 122300
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main() {

  string S, ans;

  cin >> S;

  if( S == "Sunny" ){
    ans = "Cloudy";
  }
  if( S == "Cloudy" ){
    ans = "Rainy";
  }
  if( S == "Rainy" ){
    ans = "Sunny";
  }

  cout << ans << endl;
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

#define ll long long
const int maxn=1e6+5;
const int mod=1e9+7;

int f[maxn],g[maxn],r[maxn];

void init()
{
    f[0]=g[0]=f[1]=g[1]=r[1]=1;
    for(int i=2;i<maxn;i++)
    {
        f[i]=(ll)f[i-1]*i%mod;
        r[i]=(ll)(mod-mod/i)*r[mod%i]%mod;
        g[i]=(ll)g[i-1]*r[i]%mod;
    }
}

inline int nCm(int n,int m)
{
    if(m<0 || m>n) return 0;
    return (ll)f[n]*g[m]%mod*g[n-m]%mod;
}

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

    init();
    int n;cin>>n;
    int a=n/3,b=n%3;

    ll ans=0;
    while(a)
    {
        ans=(ans+nCm(b+a-1,a-1))%mod;
        a--;b+=3;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 15396
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		String[] str = s.split("");
		int total = 700;
		
		for (byte i = 0; i < s.length(); i++) {
			if (str [i].equals("o")) {
				total += 100;
			}
		}
		
		System.out.println(total);
	}
}

Measured memory_bytes: 21712
#include <stdio.h>
int main(void)
{
	int a;
	int b;
	scanf("%d %d",&a,&b);
	if(a>=13)
		printf("%d\n",b);
	else if(a>=6 && a<=12)
		printf("%d\n",b/2);
	else
		printf("%d\n",0);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c;cin>>a>>b>>c;
  ll k; cin>>k;
  if(k%2==0)cout<<a-b<<endl;
  else cout<<b-a<<endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import numpy

rl = sys.stdin.readline

n, k= map(int, rl().split())
li = [[0, 0] for _ in range(n)]
for _ in range(k):
    a, b = rl().split()
    b = b.rstrip()
    a = int(a) - 1
    if li[a][1] == 0:
        if b == 'WA':
            li[a][0] += 1
        else:
            li[a][1] = 1
ac = 0
wa = 0
for lis in li:
    i, v = lis
    if v == 1:
        ac += 1
        wa += i
print(ac, wa)






Measured memory_bytes: 22128
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

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

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (998244353)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=200010;

int n,m,dp[maxn];
pair<int,int> s[15];

int main()
{
	SF("%d%d",&n,&m);
	for(int i=1;i<=m;i++) SF("%d%d",&s[i].fs,&s[i].sc);
	
	dp[1]=1;
	for(int i=2;i<=n;i++)
	{
		dp[i]=dp[i-1];

		for(int j=1;j<=m;j++)
		{
			int l=max(i-s[j].sc-1,0),r=max(i-s[j].fs,0);
			dp[i]=((dp[i]+dp[r])%MOD-dp[l]+MOD)%MOD;
		}
	}

	PF("%d",(dp[n]-dp[n-1]+MOD)%MOD);

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    if (N >= 1 && N <= 9) cout << N << endl;
    else if (N >=10 && N <= 99) cout << 9 << endl;
    else if (N >=100 && N <= 999) cout << 9 + (N - 99) << endl;
    else if (N >=1000 && N <= 9999) cout << 909 << endl;
    else if (N >=10000 && N <= 99999) cout << 909 + (N - 9999) << endl;
    else if (N ==100000) cout << 90909 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}
void merge(int arr[],int a[],int l, int m, int r)
{
	int i, j, k;
	int n1 = m - l + 1;
	int n2 = r - m;

	/* create temp arrays */
	int L[n1],R[n2],LL[n1],RR[n2];

	/* Copy data to temp arrays L[] and R[] */
	for (i = 0; i < n1; i++)
	{
		L[i] = arr[l + i];
		LL[i]=a[l+i];
	}
	for (j = 0; j < n2; j++)
	{
		R[j] = arr[m + 1+ j];
		RR[j]=a[m+1+j];
	}
	/* Merge the temp arrays back into arr[l..r]*/
	i = 0; // Initial index of first subarray
	j = 0; // Initial index of second subarray
	k = l; // Initial index of merged subarray
	while (i < n1 && j < n2)
	{
		if (L[i] <= R[j])
		{
			arr[k] = L[i];
			a[k]=LL[i];
			i++;
		}
		else
		{
			arr[k] = R[j];
			a[k]=RR[j];
			j++;
		}
		k++;
	}

	/* Copy the remaining elements of L[], if there
	are any */
	while (i < n1)
	{
		arr[k] = L[i];
		a[k]=LL[i];
		i++;
		k++;
	}

	/* Copy the remaining elements of R[], if there
	are any */
	while (j < n2)
	{
		arr[k] = R[j];
		a[k]=RR[j];
		j++;
		k++;
	}
}

/* l is for left index and r is right index of the
sub-array of arr to be sorted */
void mergeSort(int arr[],int a[],int l, int r)
{
	if (l < r)
	{
		// Same as (l+r)/2, but avoids overflow for
		// large l and h
		int m = l+(r-l)/2;

		// Sort first and second halves
		mergeSort(arr,a,l, m);
		mergeSort(arr,a, m+1, r);

		merge(arr,a,l, m, r);
	}
}
int prime(int n)
{
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        char c;
        cin>>c;
        if(c>=97)
            cout<<"a";
        else
            cout<<"A";


}


Measured memory_bytes: 3580
import string

n = int(raw_input())
while n != 0:
	l  = [raw_input().split() for i in xrange(n)]
	f = [i for i,j in l]
	t = [j for i,j in l]
	d = string.maketrans(''.join(f), ''.join(t))
	s = [raw_input().strip() for i in xrange(int(raw_input()))]
	print ''.join(s).translate(d)
	n = int(raw_input())

Measured memory_bytes: 10336
a, b, c, k = map(int, input().split())
if k <= a:
    k_pa, k_pb, k_pc = k , 0, 0 
elif k > a and k-a <= b:
    k_pa, k_pb, k_pc = a, b, 0
elif k > a and k-a > b:
    k_pa, k_pb, k_pc = a, b, k-a-b
point = k_pa - (k-k_pa-k_pb)
print(point)

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
  	cin >> d[i];
  }
	sort(d.begin(), d.end());
  if(d[n/2 - 1] == d[n/2]) {
  	cout << 0 << endl;
  }
  else {
  	cout << d[n/2] - d[n/2 - 1] << endl;
  }
    
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))

a = sum(A)
b = a//2

s = 0

for i in range(N):
  s+=A[i]
  if b<=s:
    s_h = s - A[i]
    break

t = a - s
t_h = a - s_h
if s_h>=t_h:
  ans_h = s_h-t_h
  
else:
  ans_h = t_h-s_h
if s>=t:
  ans = s-t
  ans = min(ans,ans_h)
  print(ans)
  
else:
  ans = t-s
  ans = min(ans,ans_h)
  print(ans)

Measured memory_bytes: 26220
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}



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

	if(N >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	


	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int n, m;
struct matrix
{
	int a[5][5];
	int h,l;
}ans,a,b,A;
matrix operator *(matrix a,matrix b)
{
	matrix c;
	c.h = a.h;
	c.l = b.l;
	for(int i = 0; i <= c.h; i ++)
		for(int j = 0; j <= c.l; j ++)
		{
			c.a[i][j] = 0;
			for(int k = 0; k <= a.l; k ++)
				c.a[i][j] = (c.a[i][j] + 1ll * a.a[i][k] * b.a[k][j] % MOD) % MOD;
		}
	
	return c;
}
int main()
{
	scanf("%d%d", &n, &m);
	a.h = b.h = a.l = b.l = 3;
	a.a[0][0] = 2; a.a[0][1] = 1; a.a[0][2] = 1; a.a[0][3] = 1;
	a.a[1][0] = 1; a.a[1][1] = 1; a.a[1][2] = 0; a.a[1][3] = 1;
	a.a[2][0] = 1; a.a[2][1] = 0; a.a[2][2] = 1; a.a[2][3] = 1;
	a.a[3][0] = 1; a.a[3][1] = 0; a.a[3][2] = 0; a.a[3][3] = 1;
	A = a;
	b.a[0][0] = 1; b.a[0][1] = 1; b.a[0][2] = 1; b.a[0][3] = 1;
	b.a[1][0] = 0; b.a[1][1] = 1; b.a[1][2] = 0; b.a[1][3] = 1;
	b.a[2][0] = 0; b.a[2][1] = 0; b.a[2][2] = 1; b.a[2][3] = 1;
	b.a[3][0] = 0; b.a[3][1] = 0; b.a[3][2] = 0; b.a[3][3] = 1;
	ans.h = 0;
	ans.l = 3;
	ans.a[0][0] = 1;
	int last = 0;
	while(m --)
	{
		int x;
		scanf("%d",&x);
		int t = x - last - 1;
		last = x;
		a = A;
		while(t)
		{
			if(t & 1) ans = ans * a;
			a = a * a;
			t >>= 1;
		}
		ans = ans * b;
	}
	int t = n - last;
	a = A;
	while(t)
	{
		if(t & 1) ans = ans * a;
		a = a * a;
		t >>= 1;
	}
	printf("%d\n",ans.a[0][3]);
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		sc.close();

		int[] dA = {3,5,7};
		int x = 0;
		int y = 0;

		int count = 0;
		Queue<String> queue = new ArrayDeque<String>();
		queue.add("3");
		queue.add("5");
		queue.add("7");

		while(y < N){
			x = Integer.parseInt(queue.poll());
			for(int i = 0 ; i < 3 ; i++){
				y = x * 10 + dA[i];
				queue.add(String.valueOf(y));
				//System.out.println(y);

				if(y >100 && y <= N){
					//System.out.println(y);
					String yy = String.valueOf(y);
					if(yy.contains("3")&&yy.contains("5")&&yy.contains("7")){
						//System.out.println(yy);
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 28244
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
const int N=1e5+2;
int n,m,q,rev[N],ans[N];

struct data{
	int t,a,id;
	bool operator < (const data &b) const {
		return t<b.t;
	}
}dt[N];

inline void apx(int &x,const int y){
	if(x<y) x=y;
}
inline void apn(int &x,const int y){
	if(x>y) x=y;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
#ifndef ONLINE_JUDGE
	//	freopen("c.in","r",stdin);
#endif
	n=nxi(),m=nxi();
	for(int i=1;i<=m;++i){
		rev[i]=nxi();
	}
	q=nxi();
	std::sort(rev+1,rev+m+1);
	for(int i=1;i<=q;++i){
		dt[i].id=i;
		dt[i].t=nxi(),dt[i].a=nxi();
	}
	std::sort(dt+1,dt+q+1);
	int dpos=0,upos=n,pd=0,cnq=1,r=-1;
	for(int i=1;i<=m;++i,r=-r){
		//		printf("dpos%d upos%d pd%d\n",dpos,upos,pd);
		while(cnq<=q&&dt[cnq].t<=rev[i]){
			int move=r*(dt[cnq].t-rev[i-1]),dis=dt[cnq].a-dpos;
			apn(dis,upos-dpos);
			apx(dis,0);
			int ans0=pd+dis+move;
			apn(ans0,n);
			apx(ans0,0);
			ans[dt[cnq].id]=ans0;
			++cnq;
		}
		int p=r*(rev[i]-rev[i-1]);
		pd+=p;
		if(r>0&&pd+(upos-dpos)>n){
			upos-=std::min(upos-dpos,pd+(upos-dpos)-n);
			pd=n-(upos-dpos);
		}
		else if(r<0&&pd<0){
			dpos+=std::min(upos-dpos,-pd);
			pd=0;
		}
//		printf("upos%d dpos%d pd%d\n",upos,dpos,pd);
	}
	while(cnq<=q){
		int move=r*(dt[cnq].t-rev[m]),dis=dt[cnq].a-dpos;
		apn(dis,upos-dpos);
		apx(dis,0);
		int ans0=pd+dis+move;
		apn(ans0,n);
		apx(ans0,0);
		ans[dt[cnq].id]=ans0;
		++cnq;
	}
	for(int i=1;i<=q;++i){
		printf("%d\n",ans[i]);
	}
	return 0;
}

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

using namespace std;

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int r = 0; r <= 3000; ++r)
    for (int g = 0; g <= 3000; ++g)
      if (R * r + G * g <= N && (N - R * r - G * g) % B == 0) ans++;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
int main(){
    ll l,r;
    cin>>l>>r;

    if(r-l>2018 || l%2019 >= r%2019){
        cout<<"0";
        return 0;
    }else{
    ll res=INT_MAX;
    for(ll i=l;i<=r;i++){
        ll tmp;
        for(ll j=i+1;j<=r;j++){
                tmp = i*j%2019;
                res = min(res,tmp);
            }
        }
        cout<<res;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int i;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
        a[0]--;
    for(i=0;i<n;i++)
    {
        if(i&&a[i]-1>=a[i-1])
            a[i]--;
    }
    for(i=1;i<n;i++)
        if(a[i]<a[i-1])
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 640
import math
N = int(input())
xy = []
for i in range(N):
  x, y = map(int, input().split())
  xy += [(x, y, math.atan2(y,x))]
xy.sort(key=lambda val:val[2])
x_accum = [0]
y_accum = [0]
for i in range(N):
  x_accum += [x_accum[-1] + xy[i][0]]
  y_accum += [y_accum[-1] + xy[i][1]]
  
ans = 0
for i in range(N+1):
  for j in range(i,N+1):
    ans = max(ans,  math.hypot(x_accum[j]-x_accum[i] ,y_accum[j]-y_accum[i]))
    ans = max(ans,  math.hypot(x_accum[-1] -x_accum[j]+x_accum[i] ,y_accum[-1]-y_accum[j]+y_accum[i]))
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=998244353;
const long long inf=1ll<<61;
struct BIT {
	int node[500006]; int N = 500002;
	void init() {
		fill(node, node + N + 1, 0);
	}
	void add(int i, int x) {
		while (i <= N) {
			node[i] += x; i += i & -i;
		}
	}
	int sum(int x) {
		int s = 0;
		while (x > 0) {
			s += node[x]; x -= x & -x;
		}
		return s;
	}
};
int c[500006];
int l[500006],r[500006];
struct query{
	int l,id;
};

BIT b;
int app[500006];
int ans[500006];
vector<query>Q[500006];

signed main(){
	int n,q;cin>>n>>q;
	rep(i,n){
		cin>>c[i];
		c[i]--;
	}
	rep(i,q){
		cin>>l[i]>>r[i];
		l[i]--;r[i]--;
		Q[r[i]].push_back({l[i],i});
	}
	
	fill(app,app+n+1,-1);
	rep(i,n){
		if(app[c[i]]==-1){
			app[c[i]]=i;
			b.add(i+1,1);
		}
		else{
			b.add(app[c[i]]+1,-1);
			app[c[i]]=i;
			b.add(i+1,1);
		}
		for(auto e:Q[i]){
			ans[e.id]=b.sum(i+1)-b.sum(e.l);
		}
	}
	rep(i,q)cout<<ans[i]<<endl;
}

Measured memory_bytes: 52036
N = int(input())
L = list('abcdefghijklmnopqrstuvwxyz')
if N <= 26:
    print(L[N - 1])
    exit()

L = list('zabcdefghijklmnopqrstuvwxy')
ans_l = []


while (True):
    syou = N // 26
    amari = N % 26
    ans_l.append(L[amari])

    if amari == 0:
        N = syou - 1
    else:
        N = syou
    
    if N <= 26: break
    
if N == 26: N = 0
ans_l.append(L[N])

ans_l = ans_l[::-1]
print(*ans_l, sep="")
    


Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
const ll mod = 1000000007;
int main(){
	ll N, K;
	cin >> N >> K;
	ll tmp1, tmp2;
	vl consnum(N);
	for(ll c = 0; c < N; c++){ //cを固定
		//b+c = C*K -> b = C*K - c -> Cはなに？ -> なんこあるか -> C*K > cとなるCからN >= C*K -cとなるCまで
		//a+c = D*K -> a = D*K - c -> Dはなに？ -> 同じ
		//Cを2乗すればよい。
		//やるぞ〜〜
		if(2*(c+1) % K == 0){
			consnum[c] = floor(((double)N+(double)c+1.0) / (double)K) - ceil((2.0+(double)c) / (double)K) + 1;
		}
	}
	ll ans = 0;
	REP(i, N){
		ans += pow(consnum[i],2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int id[50];
    memset(id, 0, sizeof(id));
    for(int i=1, sum=0; ; ++i){
        sum += i;
        if(sum >= 50) break;
        id[sum] = i;
    }
    For(i, 1, 50) chmax(id[i], id[i-1]);

    lint n;
    scanf("%lld", &n);
    lint ans = 0;
    for(lint i=2; i*i<=n; ++i)if(n%i == 0){
        int cnt = 0;
        while(n%i == 0){
            n /= i;
            ++cnt;
        }
        ans += id[cnt];
    }
    if(n > 1) ans += 1;
    printf("%lld\n", ans);
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	string s; cin >> s;
	ll ans = 0;
	vector<vector<int>>rgb(3, vector<int>(N, 0));
	rep(i, 0, N) {
		if (s[i] == 'R')rgb[0][i]++;
		if (s[i] == 'G')rgb[1][i]++;
		if (s[i] == 'B')rgb[2][i]++;
	}
	rep(i, 1, N) {
		rgb[0][i] += rgb[0][i - 1];
		rgb[1][i] += rgb[1][i - 1];
		rgb[2][i] += rgb[2][i - 1];
	}
	char ch[] = { 'R','G','B' };
	rep(i, 0, N) {
		rep(j, i + 1, N) {
			if (s[i] == s[j])continue;
			int x;
			rep(k, 0, 3)if (s[i] != ch[k] && s[j] != ch[k])x = k;
			ll comb = rgb[x][j - 1] - rgb[x][i] + rgb[x][N - 1] - rgb[x][j];

			if ((i + j)%2 == 0) {
				if (s[(i + j) / 2] == ch[x])comb--;
			}
			int k = 2 * j - i;
			if (k < N && s[k] == ch[x])--comb;
			ans += comb;
		}
	}
	cout << ans / 2 << "\n";

	return 0;
}

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

signed main(){
  int n,k,r,s,p,ans=0;string t;cin>>n>>k>>r>>s>>p>>t;
  for(int i=0;i<k;i++){
    int now=i;
    while(now<n){
      int cnt=1;
      while(now+k<n&&t[now]==t[now+k])now+=k,cnt++;
      if(t[now]=='r')ans+=p*((cnt+1)/2);
      if(t[now]=='s')ans+=r*((cnt+1)/2);
      if(t[now]=='p')ans+=s*((cnt+1)/2);
      now+=k;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,l=0;
    double b;
    cin>>a>>b;
    int A[a];
    double k=0;
    for(int i=0;i<a;i++)cin>>A[i],k+=A[i];
    for(int i=0;i<a;i++){
        if(k/(4*b)<=A[i]){
            l++;
        }
    }
    if(b<=l){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int N, a, b, c, d;

	cin >> N;
	a = N / 1000;
	b = N % 1000 / 100;
	c = N % 1000 % 100 / 10;
	d = N % 1000 % 100 % 10;
	if ((a == b) && (b == c) || (b == c) && (c == d))
    {
      cout << "Yes" << endl;
    }
	else
    {
      cout << "No" << endl;
    }
  return (0);
}

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

int main(){
  int t1, t2, r1, r2;
  cin >> t1 >> t2 >> r1 >> r2;
  if(r1 < 0 or r2 < 0){
    if(t1 < t2) cout << "Alice" << endl;
    else if(t1 > t2) cout << "Bob" << endl;
    else cout << "Draw" << endl;
    return 0;
  }
  if(r1 > r2) cout << "Alice" << endl;
  else if(r1 < r2) cout << "Bob" << endl;
  else cout << "Draw" << endl;
}



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

int main(){
	int n;
	cin >> n;
	
	if(n < 10) cout << n << endl;
	else if(n <= 99) cout << 9 << endl;
	else if(n < 1000) cout << (n-99)+9 << endl;
	else if(n <= 9999) cout << 909 << endl;
	else if(n < 100000) cout << (n-9999)+900+9 << endl;
	else cout << 90909 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][]A = new int[n][m];
		int[]b = new int[m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		for(int i = 0; i < m; i++) {
			b[i] = scan.nextInt();
		}
		scan.close();
		for(int i = 0; i < n; i++) {
			int t = 0;
			for(int j = 0; j < m ; j++) {
				t += A[i][j] * b[j];
			}
			System.out.println(t);
		}
		scan.close();
	}
}


Measured memory_bytes: 40236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String INPUT = br.readLine();
		int i = 0;
		int j = 0;
		String a;

		while( (a = br.readLine()).equals("END_OF_TEXT")!=true ){
			String[] input = a.split(" ");
			for( i=0 ; i<input.length ; i++ ){
				if( (INPUT.toUpperCase()).equals(input[i].toUpperCase()) ){
					j++;
				}
				if( input[i].equals("END_OF_TEXT") ) break;
			}
		}

		System.out.println(Integer.toString(j));
	}
}

Measured memory_bytes: 24256
from itertools import combinations

epsilon = 5 * 10 ** (-7)

N = int(input())
#Get points as complex numbers like x + yi.
points = [complex(*list(map(int, input().split()))) for _ in range(N)]


#try a circle that has a line connecting farthest 2 points as a diameter.
longest_radius = 0
for p, q in combinations(points, 2):
    radius = abs(p - q) / 2
    if longest_radius < radius:
        longest_radius = radius
        center = (p + q) / 2

out_of_circle = False
for s in points:
    if abs(s - center) > longest_radius + epsilon:
        out_of_circle = True
        break

if not out_of_circle:
    print(longest_radius)
    exit()


#If failed, then try any circles that has 3 or more points on the edge.
smallest_radius = 10 ** 9
for p, q, r in combinations(points, 3):
    denominator = (p-q)*r.conjugate() + (q-r)*p.conjugate() + (r-p)*q.conjugate()
    if denominator == 0 + 0j:
        continue
    numerator = (p-q)*(abs(r)**2) + (q-r)*(abs(p)**2) + (r-p)*(abs(q)**2)
    center = numerator/denominator
    radius = abs(p - center)

    for s in points:
        if abs(s - center) > radius + epsilon:
            break
    else:
        smallest_radius = min(smallest_radius, radius)

print(smallest_radius)


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

int main() {
  int n,m; cin >> n >> m;
  string s; cin >> s;
  if(s[m-1] == 'A') s[m-1] = 'a';
  if(s[m-1] == 'B') s[m-1] = 'b';
  if(s[m-1] == 'C') s[m-1] = 'c';
  
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n), q(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        q[p[i]] = i;
    }
    lint ret        = 0;
    multiset<int> s = {-1, -1, n, n};
    for (int i = n; i >= 1; --i) {
        lint curr = q[i];
        auto it   = prev(s.lower_bound(curr), 2);
        lint ll   = *it;
        lint lr   = *next(it);
        lint rl   = *next(it, 2);
        lint rr   = *next(it, 3);
        ret += ((rr - rl) * (curr - lr) + (lr - ll) * (rl - curr)) * i;
        s.insert(curr);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N, M;
    cin >> N >> M;

    ll sum = 0;

    REP(i, M) {
        ll tmp;
        cin >> tmp;
        sum += tmp;
    }

    if(sum > N) {
        cout << -1 << endl;
    } else {
        cout << N - sum << endl;
    }



    return 0;
}

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

int main() {
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<long long> p(A), q(B), r(C);
    for(int i=0; i<A; ++i) cin >> p[i];
    for(int i=0; i<B; ++i) cin >> q[i];
    for(int i=0; i<C; ++i) cin >> r[i];
    sort(begin(p), end(p), greater<long long>());
    sort(begin(q), end(q), greater<long long>());
    sort(begin(r), end(r), greater<long long>());

    long long res = 0;
    priority_queue<long long, vector<long long>, greater<long long>> Q;
    for(int i=0; i<X; ++i) {
        res += p[i];
        Q.push(p[i]);
    }
    for(int i=0; i<Y; ++i) {
        res += q[i];
        Q.push(q[i]);
    }

    long long sum = res;
    for(int i=0; i<min(C, X + Y); ++i) {
        long long tmp = Q.top(); Q.pop();
        res = max(res, sum - tmp + r[i]);
        sum = sum - tmp + r[i];
    }
    cout << res << '\n';
}


Measured memory_bytes: 4724