akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string A, B;
    cin >> A >> B;
    int N = A.size(), M = B.size();
    if (N < M) {
        cout << "LESS" << endl;
        return 0;
    } else if (N > M) {
        cout << "GREATER" << endl;
        return 0;
    }
    REP(i, N) {
        if (A[i] < B[i]) {
            cout << "LESS" << endl;
            return 0;
        } else if (A[i] > B[i]) {
            cout << "GREATER" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma comment(linker,"/STACK:1024000000,1024000000")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define reT() int T; cin >> T; rep(t, 0, T)
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " "
#define pw(x) (1ll<<(x))
#define modadd(a,b) {a+=b;a%=MOD;}
#define modmul(a,b) {a*=b;a%=MOD;}
#define LL long long
#define IN freopen("in", "r", stdin)
#define OUT freopen("out", "w", stdout)
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
const int inf = 0x3f3f3f3f;
const int N = 110;

int n, m;
char a[N][N];
int dp[N][N];
int main() {
	//IN;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	while (cin >> n >> m) {
		rep(i, 1, n + 1) rep(j, 1, m + 1) {
			cin >> a[i][j];

			if (i == 1 && j == 1) {
				dp[i][j] = (a[i][j] == '#');
				continue;
			}

			dp[i][j] = inf;
			if (i - 1 >= 1) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (a[i][j] == '#' && a[i - 1][j] == '.'));
			if (j - 1 >= 1) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (a[i][j] == '#' && a[i][j - 1] == '.'));
		}
		cout << dp[n][m] << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include  <stdio.h>

int main(){
    int k;
    int x;
        scanf ("%d %d",&k,&x);
        int total = 500*k;
        
    if (total>=x){
        printf ("Yes\n");
        }
    else {
        printf ("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1612
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int n, d,count=0;
	double tmp=0;
	cin >> n >> d;
	vector< vector<int> > x(n, vector<int>(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 0; i < n-1; i++) {
		for (int k = i+1; k < n; k++) {
			tmp = 0;
			for (int j = 0; j < d; j++) {
				tmp += (x[i][j] - x[k][j])*(x[i][j] - x[k][j]);
			}
			tmp = sqrt(tmp);
			if (fmod(tmp,1) == 0) { count++; }
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.math;
import std.exception;
import std.bigint;


T[] readlnSome(T)(){
    return array(readln().split().map!(a => to!T(a))());
}


T readlnOne(T)(){
    return to!T(readln().split()[0]);
}


void main()
{
    foreach(i; 0 .. readlnOne!uint())
        writeln(solve(readlnSome!uint()[0 .. 3]) ? "YES" : "NO");
}


bool solve(uint[] nums)
{
    nums.sort!"a > b"();
    return nums[0] ^^ 2 == nums[1] ^^ 2 + nums[2] ^^ 2;
}

Measured memory_bytes: 1096
xdata = []
ydata = []

while(True):
    x, y = map(int, input().split())

    if x == 0 and y == 0:
        break

    else:
        xdata.append(x)
        ydata.append(y)

for i in range(len(xdata)):
    for k in range(xdata[i]):
        for l in range(ydata[i]):
            print("{}".format("#"), end="")
        print()
    print()



Measured memory_bytes: 7004
#include<iostream>
using namespace std;
int main() {
	int a, b, sum; cin >> a >> b;

	if (b < 10) sum = a * 10 + b;
	else if (b == 100) sum = a * 1000 + b;
	else sum = a * 100 + b;

	for (int i = 1; i < 317; i++) {
		if (i * i == sum) {
			cout << "Yes" << endl;
			return 0;
		}
		else if (i * i > sum) break;
	}
	cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{

    string s;
    cin >> s;

    int a = count(all(s), 'A');
    cout << (a == 0 or a == 3 ? "No" : "Yes") << '\n';
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    SCIN(str);
    SCIN(hint);
    bool ans = false;
    int ins = -1;
    REP(a,str.size()-hint.size()+1){
        string hoge = str.substr(a,hint.size());
        bool result = true;
        REP(b,hint.size()){
            if(hoge.at(b) != '?'&&hoge.at(b) != hint.at(b)){
                result = false;
            }
        }
        if(result){
            ins = a;
        }
    }
    if(ins == -1){
        cout<<"UNRESTORABLE"<<endl;
    }else{
        for(int a = 0;a < str.size();a++){
            if(ins <= a && a < ins+hint.size()){
                cout<<hint.at(a-ins);
            }else{
                if(str.at(a) == '?'){
                    cout<<'a';
                }else{
                    cout<<str.at(a);
                }
            }
        }
        cout<<endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;

int n;
int a[200005],pre[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  pre[i]=(pre[i-1]+a[i])%mod;
	
	int ans=0;
	for (int i=1;i<=n;i++)  ans=(ans+a[i]*pre[i-1]%mod)%mod;
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  
  vector<string> s(n);
  
  for(int i=0; i<n; i++) cin >> s[i];
  sort(s.begin(),s.end());
  
  int maximum=0;
  int count=0;
  
  for(int i=1; i<n; i++){
    if(s[i] == s[i-1]){
      count++;
      maximum=max(maximum,count);
      continue;
    }
    else count=0;
  }
  
  count=0;
  
  if(maximum == 0){
    for(int i=0; i<n; i++) cout << s[i] << endl;
  }
  
  else{
    for(int i=1; i<n; i++){
      if(s[i] == s[i-1]){
        count++;
        if(count == maximum) cout<<s[i]<<endl;
        continue;
      }
      else count=0;
    }
  } 
}

Measured memory_bytes: 14592
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int[]ar=new int[n],dp=new int[n];
		for(int i=0;i<n;i++)ar[i]=Integer.parseInt(st.nextToken());
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0]=0;
		for(int i=1;i<n;i++){
			dp[i]=Math.min(dp[i], dp[i-1]+Math.abs(ar[i]-ar[i-1]));
			if(i>1)dp[i]=Math.min(dp[i],  dp[i-2]+Math.abs(ar[i]-ar[i-2]));
		}
		System.out.println(dp[n-1]);
	}

}


Measured memory_bytes: 31444
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

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

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

    printf("%d",(int)pow(N,3));
    
    return 0;
}

Measured memory_bytes: 384
def ebal(s, op)
    t = ''
    for i in 0..s.length-2
        t += s[i] + (op[i] == '0' ? '' : '+')
    end
    t += s[-1]
    eval(t)
end

def cc045
    s = gets.chomp
    l = s.length

    if l == 1
        puts s
        exit
    end

    r = 0
    for i in 0..2**(l-1)-1
        r += ebal(s, sprintf("%0#{l-1}d" ,i.to_s(2)))
    end

    puts r
end

cc045

Measured memory_bytes: 1916
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << max(a*b, c*d) << endl;

}

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

#define eb emplace_back
#define ld long double
#define ll long long

using namespace std;

const int nm = 300002;

vector<int> row[nm];
int cntcol[nm];
int m, n, k;

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> m >> n >> k;
	for (int i = 1; i <= k; ++i) {
		int u, v;
		cin >> u >> v;
		row[u].eb(v);
		cntcol[v]++;
	}
	int cntmax = -1, nmax = 0;
	for (int i = 1; i <= n; ++i) {
		if (cntcol[i] > cntmax) {
			cntmax = cntcol[i];
			nmax = 1;
		} else if (cntcol[i] == cntmax) {
			nmax++;
		}
	}
	int res = 0;
	for (int i = 1; i <= m; ++i) {
		int cnt = 0;
		for (int j: row[i]) {
			if (cntcol[j] == cntmax) {
				cnt++;
			}
		}
		if (cnt < nmax) {
			res = max(res, (int) row[i].size() + cntmax);
		} else {
			res = max(res, (int) row[i].size() + cntmax - 1);
		}
	}
	cout << res << "\n";
}


Measured memory_bytes: 21184
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

ll pitta[60], smaller[60];

const int shift = 50;

int main(){
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	for( auto &t : a ) cin >> t;
	for( int d = 0; d < shift; ++d ){
		ll mask = (1ll<<(shift-1-d));
		ll cnt = 0;
		for( auto &t : a ){
			if( t & mask ) ++cnt;
		}
		pitta[d+1] = pitta[d] + ( ( k & mask ) ? (n-cnt) : (cnt) ) * mask;
		if(	smaller[d] > 0 ) smaller[d+1] = smaller[d] + max(cnt, n-cnt)*mask;
		if( k & mask ) smaller[d+1] = max( smaller[d+1], pitta[d] + cnt*mask );
	}
	cout << max(pitta[shift], smaller[shift]) << endl;
}

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

using namespace std;

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

typedef long long ll;

int main(){
    int n,r; cin >> n >> r;
    if(n>10) cout << r << endl;
    else cout << r + 100*(10-n) << endl;
    return 0; 
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

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

  int n;
  cin >> n;

  vector<int> a(n);
  fillInt(a, n);

  vector<int> ind(n);
  rep(i, n) {
    ind[a[i]-1] = i;
  }

  int len = 1;
  rep(i, n) {
    int j = i;
    while(j < n-1 && ind[j] < ind[j+1]) j++;
    len = max(len, j-i+1);
    i = j;
  }

  cout << n - len << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<string> s;
  vector<int> cnt;

  string in;
  for(int i = 0; i < n; i++){
    bool flag = true;

    cin >> in;
    
    for(int j = 0; j < s.size(); j++){
      if(s[j] == in){
	cnt[j]++;
	flag = false;
	break;
      }
    }

    if(flag){
      s.push_back(in);
      cnt.push_back(1);
    }
  }

  int m;
  cin >> m;
  
  for(int i = 0; i < m; i++){
    cin >> in;

    for(int j = 0; j < s.size(); j++){
      if(s[j] == in){
	cnt[j]--;
	break;
      }
    }
  }

  sort(cnt.begin(), cnt.end());

  int ans = cnt[cnt.size()-1];
  if(ans < 0) ans = 0;
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include <cstdio>


/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int A, B;
int max;



int main () {

	// 文字列数の読込み
	scanf("%d %d", &A, &B);

	max = A + B;
	if(A - B > max) max = A - B;
	if(A * B > max) max = A * B;

	printf("%d\n", max);	

	return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        r: i32,
    }
    println!("{}", r * r);
}


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

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

	string s;
	cin >> s;

	int g_num = count(s.begin(), s.end(), 'g');
	int p_num = count(s.begin(), s.end(), 'p');

	// cout << g_num << " " << p_num << "\n";

	cout << (g_num + p_num) / 2 - p_num;

	return 0;
}

Measured memory_bytes: 512
N = int(input())
A, B = map(int,input().split( ))
P = list(map(int,input().split( )))

a = len([p for p in P if p <= A])
b = len([p for p in P if A+1 <= p <= B])
c = len([p for p in P if B+1 <= p])
print(min(a,b,c))


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define REP(i, n) for(int i = 0; (i) < (n); ++(i))
#define FOR(i, n) for(int i = 1; (i) <= (n); ++(i))
#define dump(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9 + 7;
// const lint LINF = 1e18;
const double eps = 0.000000001;  //もとの値の10^(-16)まで

using namespace std;

// typedef pair<int, int> P;
// priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
// cout << fixed << setprecision(10) << ans << endl;

signed main() {
  int n;
  cin >> n;
  int ans;
  REP(i, 1000001) {
    if(i == 0) continue;
    if(i * i > n) break;
    if(n % i == 0) ans = i;
  }
  cout << ans + (n / ans) - 2 << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
ev=0
od=0
for i in a:
  if i%2==0:
    ev+=1
  else:
    od+=1
ans=False
if od%2==0:
  ans=True
else:
  if ev==0:
    ans=True
    
print('YES' if ans else 'NO')
  
  

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
ll f(int n, int c) {
	ll ret = 1;
	REP(i, c) {
		ret *= (n - i);
		ret /= (i + 1);
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, p;
	cin >> n >> p;
	vi cnt(2, 0);
	REP(i, n) {
		int a;
		cin >> a;
		cnt[a % 2]++;
	}
	ll ans = 0;
	int i = p;
	while (i <= cnt[1]) {
		ans += f(cnt[1], i);
		i += 2;
	}
	REP(i, cnt[0])ans *= 2;
	cout << ans << endl;

}


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

int main(){

  map<char,int> mp;

  string S; cin >> S;
  for(int i = 0;i < 4;i++){
    mp[S[i]]++;
  }

  bool flag = true;

  for(auto itr = mp.begin();itr!=mp.end();itr++){
    if(itr->second != 2)flag = false;
  }

  if(!flag)cout << "No" << endl;
  else cout << "Yes" << endl;

}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class MainClass
{
  public static void Main(string[] args)
  {    
            var inputs = Enumerable.Range(0, 4)
              .Select(x => int.Parse(Console.ReadLine()))
              .ToArray();
    
            var hoge = inputs.Take(2).ToList();
            var fuga = inputs.Skip(2).Take(2).ToList();

            var hogeRes = hoge[0] < hoge[1] ? hoge[0] : hoge[1];
            var fugaRes = fuga[0] < fuga[1] ? fuga[0] : fuga[1];

            var res = hogeRes + fugaRes;
            Console.WriteLine(res);
  }
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] A = nextInts();

		ArrayList<int[]> list = new ArrayList<>();

		for(int i=0;i<N;i++){
			int[] tmp = new int[2];
			tmp[0]=A[i];
			tmp[1]=i;
			list.add(tmp);
		}

		list.sort((v1,v2) -> {return v1[0] - v2[0];});
		for(int[] tmp : list){
			System.out.println(tmp[1]+1);
		}
	}

	public static boolean isExpN(long a,int base){
		int x=1;
		while((int)Math.pow(x, 2) <= a){
			if((int)Math.pow(x, 2) == a){
				return true;
			}
			x*=base;
		}
		return false;
	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 55224
#include <stdio.h>

int main ()
{
	int n;
	scanf("%d", &n);
	
	long long int A1[n];
	long long int A2=1;
	long long int max=1000000000000000000;
	
	for(int i=0; i<n; i++)
	{
		scanf("%lld", &A1[i]);
	}
	
	for(int j=0; j<n; j++)
	{
		if(A1[j]==0)
		{
			printf("0\n");
			return 0;
		}	
	}	
	
	for(int k=0; k<n; k++)
	{
		if(A1[k] <= max/A2)
		{
			A2 *= A1[k];	
		}
		
		else 
		{
			printf("-1\n");
			return 0;
		}
	}	
	
	printf("%lld\n", A2);
	
	return 0;
}

Measured memory_bytes: 2456
import Data.List (sortBy, sort)

diff :: Num a => [a] -> [a]
diff [_] = []
diff (x:y:xs) = y-x : diff (y:xs)

main :: IO ()
main = do
  n:m:_ <- map read . words <$> getLine
  ds <- sortBy (flip compare) . diff . sort . map read . words <$> getLine
  if n >= m then
      print 0
  else
      print $ sum $ drop (n-1) ds


Measured memory_bytes: 32636
#include <bits/stdc++.h>
using namespace std;
int main() {  
  long int N, A, B;
  cin >> N >> A >>  B;
  long int x = N/(A+B);
  long int ans = 0;
  if(N%(A+B) < A) ans = x*A + (N%(A+B));
  else ans = (x+1)*A;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();

        List cList = new ArrayList<char[]>();
        int result = 0;

        for(int i =0; i < h; i++) {
            String c = sc.next();
            cList.add(c.toCharArray());
        }

        for (int i = 0; i < (1<<h); i++) {
            for (int j = 0; j < (1<<w); j++) {
                int count = 0;
                for(int i2 = 0; i2 < h; i2++) {
                    for (int j2 = 0; j2 < w; j2++) {
                        if((i>>i2 & 1) == 1) {
                            continue;
                        }
                        if((j>>j2 & 1) == 1) {
                            continue;
                        }
                        char[] ca = (char[])cList.get(i2);
                        if(String.valueOf(ca[j2]).equals("#")) {
                            count++;
                        }
                    }
                }
                if(count == k) {
                    result++;
                }
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 38104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#define ll long long 
#define fr(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define inf (1<<31)
#define xx first
#define yy second

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int A,b,h;
	cin>>A>>b>>h;
	cout<<h/2*(A+b);
	
	return 0;
}

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

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

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; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<double> p(N);
    rep(i, N) cin >> p[i];

    vector<vector<double>> dp(N+1, vector<double>(N+1));
    dp[0][0] = 1;
    rep(i, N) {
        rep(j, N) {
            dp[i+1][j] += dp[i][j] * (1 - p[i]);
            dp[i+1][j+1] += dp[i][j] * p[i];
        }
    }

    double ans = 0;
    rep(i, N+1) {
        if (N - i < i) ans += dp[N][i];
    }
    printf("%.10f\n", ans);
}

Measured memory_bytes: 70656
#!/usr/bin/env python3
N, A, B = map(int, input().split())

if A==0 and B==0:
    print(0)
    exit()

s = A + B

a = N // s

ans = A*a
nokori = N-s*a

if nokori <= A:ans += nokori
else: ans += A

print(ans)


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

using namespace std;

#define ll long long int

int main()
{
    ll x;
    cin>>x;
    ll d=100,c=0;
    while(1)
    {
        d*=1.01;
        c++;
        if(d>=x)
            break;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n, x, y;
	cin >> n;
	int minx_plus_y = INT_MAX, maxx_plus_y = INT_MIN, minx_minus_y = INT_MAX, maxx_minus_y = INT_MIN;
	while (n--) {
		cin >> x >> y;
		maxx_plus_y = max(maxx_plus_y, x + y);
		minx_plus_y = min(minx_plus_y, x + y);
		maxx_minus_y = max(maxx_minus_y, x - y);
		minx_minus_y = min(minx_minus_y, x - y);
	}
	cout << max(maxx_plus_y - minx_plus_y, maxx_minus_y - minx_minus_y);
	return 0;
}

Measured memory_bytes: 3540
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
def lcm(a, b):
    return a*b//gcd(a, b)
n=int(input())
t=[int(input()) for i in range(n)]
for i in range(n-1):
    t[i+1] = lcm(t[i],t[i+1])
print(t[n-1])

Measured memory_bytes: 3064
n,m = map(int, input().split())

nl = [list(input()) for _ in range(n)]

ml = [list(input()) for _ in range(m)]



for i in range (0,1+n-m):
    for j in range (0,1+n-m):
        if nl[i][j] ==ml[0][0]:
            flag = 1
            for k in range(0,m):
                for l in range(0,m):
                    if nl[i+k][j+l] !=ml[k][l]:
                        flag = 0
            if flag ==1:
                print("Yes")
                exit() 
print("No")

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n;
const int N = 2e5 + 5;
int a[N];
int m1, m2;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] > m1) {
            m2 = m1;
            m1 = a[i];
        } else if (a[i] > m2) {
            m2 = a[i];
        }
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] != m1) {
            cout << m1 << endl;
        } else {
            cout << m2 << endl;
        }
    }
    return 0;
}


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

int A, P;

int main() {
    cin >> A >> P;

    cout << (3 * A + P) / 2 << endl;
}

Measured memory_bytes: 256
from collections import Counter
def solve():
    N=int(input())
    A=list(map(int,input().split()))

    cnt=Counter(A)

    if cnt[0]==N:
        print("Yes")
        return
    t=0
    for a in A:
        t^=a

    if N%3==0:
        if cnt[0]==int(N//3) and len(cnt)==2:
            print("Yes")
        elif len(cnt)==3 and t==0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


    
if __name__ == "__main__":
     solve()


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

int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> sunuke(n+1,-1);
  for(int i = 1;i <= k;i++){
    int d;
    cin >> d;
    for(int j = 1;j <= d;j++){
      int a;
      cin >> a;
      sunuke[a] = 1;
    }
  }
  int ninnzuu = 0;
  for(int i = 1;i <= n;i++){
    if(sunuke[i] == -1) ninnzuu++;
  }
  cout << ninnzuu << endl;
}


Measured memory_bytes: 3624
//AOJ 0571 JJOOII
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int level = 0, roop = 1, save, save2;
string s;
void count(int i, char c){
	while (true){
		if(s[i + roop] == c)
		roop++;
		if (s[i + roop] != c){
			break;
		}
	}
}
int main(){
	cin >> s;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'O'){
			roop = 0;		
			count(i, 'O');
			save = roop;
			count(i, 'I');
			if (save <= roop - save){
				save2 = 0;
				for (int j = 1; j <= save; j++){
					if (s[i - j] != 'J')
						break;
					save2++;
				}
				if (save2 == save)
					level = max(level, save);
			}
			i += roop;
		}
	}
	cout << level << endl;
}

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

using namespace std;

u_int64_t pFactors[101];

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

    for (int i = 1; i <= N; i++)
    {
        pFactors[i] = 0;
        int m = i;
        for (int j = 2; j <= (int)floor(sqrt(m)); j++)
        {
            bool isPrime = true;
            for (int p = 2; p <= (int)floor(sqrt(j)); p++)
            {
                if (j % p == 0)
                {
                    isPrime = false;
                }
            }
            if (!isPrime)
            {
                continue;
            }

            while (m % j == 0)
            {
                pFactors[j]++;
                m /= j;
            }
        }
        if (m != 1)
        {
            pFactors[m]++;
        }
    }

    int gt74 = 0;
    int gt24 = 0;
    int gt14 = 0;
    int gt4 = 0;
    int gt2 = 0;
    for (int i = 2; i <= N; i++)
    {
        if (pFactors[i] >= 74)
        {
            gt74++;
        }
        if (pFactors[i] >= 24)
        {
            gt24++;
        }
        if (pFactors[i] >= 14)
        {
            gt14++;
        }
        if (pFactors[i] >= 4)
        {
            gt4++;
        }
        if (pFactors[i] >= 2)
        {
            gt2++;
        }
    }

    int p74 = gt74;
    int p24q2 = gt24 * (gt2 - 1);
    int p14q4 = gt14 * (gt4 - 1);
    int p4q4r2 = gt4 * (gt4 - 1) * (gt2 - 2) / 2;

    int result = p74 + p24q2 + p14q4 + p4q4r2;
    cout << result << endl;
}

Measured memory_bytes: 256
N = int(input())

t_pre = 0
x_pre = 0
y_pre = 0

cond = True
for i in range(N):
    t, x, y = map(int, input().split(' '))
    
    d = abs(x - x_pre) + abs(y - y_pre)
    
    if d > t:
        cond = False
        break         
        
    if (d % 2 == 0 and (t - t_pre) % 2 == 0) or (d % 2 == 1 and (t - t_pre) % 2 == 1):
        t_pre = t
        x_pre = x
        y_pre = y         
    
    else:
        cond = False
        break 


if cond:
    print('Yes')
else:
    print('No')

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

int n, a[1010][1010], dp[1010][1010], ind[1010][1010], ans = 0;
bool pos = true;

void dfs(int i, int j) {
    if(not pos) return;
    int k = a[i][j], l = ind[k][i];
    if(dp[i][k] > 0) return;
    if(dp[i][k] == -1) {
        pos = false;
        return;
    }
    dp[i][k] = -1, dp[k][i] = -1;
    if(j && dp[i][a[i][j-1]] <= 0) dfs(i, j-1);
    if(l && dp[k][a[k][l-1]] <= 0) dfs(k, l-1);
    dp[i][k] = 1;
    if(j) dp[i][k] = max(dp[i][k], dp[i][a[i][j-1]] + 1);
    if(l) dp[i][k] = max(dp[i][k], dp[k][a[k][l-1]] + 1);
    dp[k][i] = dp[i][k];
}

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n-1; j++) scanf("%d", &a[i][j]), a[i][j]--;
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n-1; j++) ind[i][a[i][j]] = j;
    }
    for(int i = 0; i < n; i++) {
        for(int j = n-2; j >= 0; j--) dfs(i, j);
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n-1; j++) ans = max(ans, dp[i][j]);
    }
    if(not pos) printf("-1");
    else printf("%d", ans);
}


Measured memory_bytes: 12288
#include <iostream>
#include <vector>
#include <string>

void bubblesort(std::vector<std::string> &v)
{
   int n = v.size();
    for(int i = 0 ; i < n ; i ++){
        for(int j = n-1 ; j >i ; j --){
            if((int)(v.at(j-1).at(1)) > (int)(v.at(j).at(1))){
                std::string temp = v.at(j);
                v.at(j) = v.at(j-1);
                v.at(j-1) = temp;
            }
        }
    }
}

void insertionsort(std::vector<std::string> &v)
{
    int n = v.size();
    for(int i = 0 ; i < n ; i++){
        int minidx = i;
        for(int j = i ; j < n; j++){
            if((int)v.at(j).at(1) < (int)v.at(minidx).at(1)){
                minidx = j;
            }
        }
        std::string temp = v.at(i);
        v.at(i) = v.at(minidx);
        v.at(minidx) = temp;
    }
}

int main(int argc, char const *argv[])
{
    int n = 0;
    std::cin >> n;
    std::vector<std::string> v;
    for(int i = 0; i < n ; i++){
        std::string temp;
        std::cin >> temp;
        v.push_back(temp);
    }
    std::vector<std::string> bubble = v;
    std::vector<std::string> insertion = v;
    bubblesort(bubble);
    insertionsort(insertion);

    //Bubble sort is always a stable sort.
    for(int i = 0; i < n-1 ; i++){
        std::cout << bubble.at(i) << " ";
    }
    std::cout << bubble.at(n-1) << std::endl;
    std::cout << "Stable" << std::endl;

    for(int i = 0; i < n-1 ; i++){
        std::cout << insertion.at(i) << " ";
    }
    std::cout << insertion.at(n-1) << std::endl;

    //Use the uniqueness of stable
    for(int i = 0; i < n ; i++){
        if(bubble.at(i).compare(insertion.at(i)) != 0){
            std::cout << "Not stable" << std::endl;
            return 0;
        }
    }
    std::cout << "Stable" << std::endl;

    return 0;
}

Measured memory_bytes: 3164
#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int value;
  int cost;
} box;
int cmp( const void *p, const void *q ) {
    return ((box*)p)->cost - ((box*)q)->cost;
}

int main(void) {
  int a,b;
  long long wallet=0;
  scanf("%d %d",&a,&b);
  box store[a];
  for(int i=0;i<a;i++){
    scanf("%d %d",&(store[i].cost),&(store[i].value));
}
  qsort(store,a,sizeof(box),cmp);
 
  int num=0,want=0;
  while(b-want>0){
      if(store[num].value>0){
	wallet+=store[num].cost;
	store[num].value--;
	want++;}
      else num++;
  
      
}
  printf("%lld",wallet);
  return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;cin >> n;
    vector<int> c(n-1),s(n-1),f(n-1);
    REP(i,n-1){
        cin >> c[i] >> s[i] >> f[i]; 
    }
    REP(i,n){
        ll ans = 0;
        FOR(j,i,n-1){
            if(ans<s[j])ans=s[j];
            if((ans-s[j])%f[j]!=0){
                ans += f[j]-(ans-s[j])%f[j];
            }
            ans += c[j];
        }
        COUT(ans);
    }
    return 0;
}

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

const int MOD = 1e9 + 7;

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

    int dp[s + 1] = {0};

    dp[3] = 1;

    for (int i = 4; i <= s; ++i)
    {
        dp[i] = (dp[i - 1] + dp[i - 3]) % MOD;
    }
    cout << dp[s] << '\n';
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int sum=0;
  string S;
  cin>>S;
  for(int i=0;i<4;i++){
    if(S[i]=='+'){
      sum++;
    }
    else sum--;
    
    
  }cout<<sum<<endl;
}
  

Measured memory_bytes: 256
function main()
	x = parse(readline())
	max = 1
	i = 2
	while i <= sqrt(x)
		j = 1
		while i^j <= x
			j += 1
		end
		if max < i^(j-1)
			max = i^(j-1)
		end
		i += 1
	end
	print(max)
end

main()

Measured memory_bytes: 109332
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Dec  5 00:37:04 2018
//
package main

import "fmt"

var n, x int

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	fmt.Scan(&n, &x)
	arr := make([]int, n)

	for i := range arr {
		fmt.Scan(&arr[i])
		arr[i] = abs(arr[i] - x)
	}
	ans := arr[0]

	for i := range arr {
		ans = gcd(ans, arr[i])
	}
	fmt.Println(ans)
}


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

int main() {
    int n, value = 0;
    cin >> n;
        int before_A;
        
    int a[n], b[n], c[n-1];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    for(int i=0; i<n-1; i++){
        cin >> c[i];
    }


    before_A = -22;

    for(int i=0; i<n; i++){
        value += b[a[i]-1];


        if(a[i] == (before_A + 1)) value += c[a[i-1]-1];
        
        before_A = a[i];
    }
    

    cout << value;

}

Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  let
    bn = length $ filter (== '#') s
    (c, _, _) = foldl' go (bn, 0, 0) s
    go (ans, cbn, i) '#' = (min ans (cbn + ((n - i) - (bn - cbn))),     cbn + 1, i + 1)
    go (ans, cbn, i) '.' = (min ans (cbn + ((n - i) - (bn - cbn)) + 1), cbn + 0, i + 1)
  print c


Measured memory_bytes: 37244
import math
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

n = int(input())
if n == 1:
    print(0)
else:
    a = factorization(n)
    cnt = 0
    for i in a:
        #print(i,math.floor((math.sqrt(1+8*i[1])-1)/2))
        cnt += math.floor((math.sqrt(1+8*i[1])-1)/2)
    print(cnt)

Measured memory_bytes: 9484
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

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

int i,j;

int main(void){
    
    int a,b;
    cin >>a >> b;
    if(a+b>=10)cout<<"error";
    else cout<<a+b;
    
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
S = input()

first = int(S[:2])
second = int(S[2:])

canFirstMM = first >= 1 and first <= 12
canSecondMM = second >= 1 and second <= 12

if canFirstMM and not canSecondMM:
  result = "MMYY"
elif not canFirstMM and canSecondMM:
  result = "YYMM"
elif canFirstMM and canSecondMM:
  result = "AMBIGUOUS"
else:
  result = "NA"
  
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define OUT(x) cout << x << endl
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int max_value(std::map<string, int> m) {
  int max = 0;
  for (std::map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
    if (max < it->second) max = it->second;
  }
  return max;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n;
    map<string,int> map;
    REP(i,n){
        string s;
        cin >> s;
        if(map.count(s)) map[s]+=1;
        else map.insert(make_pair(s,1));
    }
    cin >> m;
    REP(i,m){
        string s;
        cin >> s;
        if(map.count(s)) map[s]-=1;
        else map.insert(make_pair(s,-1));
    }
    int max_yen = max_value(map);
    if(max_yen>0) cout << max_yen << endl;
    else cout << 0 << endl;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int n;cin>>n;
  map<int, int> mp;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    mp[a]=i;
  }
  for(auto &kv : mp){
    cout<<kv.second+1<<' ';
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 8260
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
//using Graph = vector<vector<int>>;
//#define pi 3.1415926535

const int MOD = 1000000007;

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

  vector<ll> a(n);
  vector<ll> s(n);

  cin >> a[0];
  s[0] = a[0];
  for(int i = 1; i < n; i++){
    cin >> a[i];
    s[i] = s[i - 1] + a[i]; 
    s[i] = s[i] % MOD;
  }

  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(s[n - 1] >= s[i]){
      ans += a[i] * (s[n - 1] - s[i]);
    }
    else{
      ans += a[i] * (MOD + s[n - 1] - s[i]);
    }
    ans = ans % MOD;
  }

  cout << ans << endl;

  return 0; 
}

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

typedef long long ll;

const int N = 55;
int n, m, a, b;
vector<int> e[N];
int dfu[N], low[N];
int vt, ans;

void dfs(int par, int x) {
    if (dfu[x] != 0) return;
    dfu[x] = vt;
    low[x] = vt;
    ++vt;
    for (int y : e[x]) {
        if (y == par) continue;
        dfs(x, y);
        low[x] = min(low[x], low[y]);
        if (low[y] > dfu[x])
            ++ans;
    }
}

int main() {
    vt = 1;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        e[a - 1].push_back(b - 1);
        e[b - 1].push_back(a - 1);
    }

    dfs(-1, 0);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3656
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        String W = scan.nextLine();
        int count = 0;
        String T;
        while ((T = scan.nextLine()) != null) {
            if (T.equals("END_OF_TEXT")) {
                break;
            }
            String[] str = T.split(" ");
            for (int i = 0; i < str.length; i++) {
                if(str[i].equalsIgnoreCase(W)) {
                    count++;
                }
            }
        }
            System.out.println(count);
    }
}

Measured memory_bytes: 26084
def solve(n, k):
    MOD = 998244353

    if n > k:
        return 0
    if n == 1:
        return pow(2, k - 1, MOD)

    pf, kf = 1, 1
    for m in range(2, k + 1):
        pf = kf
        kf *= m
        kf %= MOD
    inv = pow(kf, MOD - 2, MOD)
    invs = [1] * (k + 1)
    invs[k] = inv
    for m in range(k, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    ans = 0
    if k & 1 == 0:
        r = k >> 1
        s = k - n + 1
        ans = pf * (invs[r] * invs[r - 1] - invs[s] * invs[k - s - 1]) % MOD

    for r in range(k // 2 + 1, k + 1):
        if r * 2 >= n + k:
            ans += kf * invs[r] * invs[k - r]
        else:
            s = r * 2 - n + 1
            ans += kf * (invs[r] * invs[k - r] - invs[s] * invs[k - s])
        ans %= MOD

    return ans


print(solve(*map(int, input().split())))


Measured memory_bytes: 22772
<?php
$s=trim(fgets(STDIN));
$n=strlen($s);
$c=($n-1)/2;
$i=0;
while($i<$c){
  if($s[$i]!=$s[$n-1-$i]){
    echo "No";
    exit;
  }
  ++$i;
}
if($n==3){
  echo "Yes";
  exit;
}
$i=0;
$d=($c-1)/2;
while($i<$d){
  if($s[$i]!=$s[$c-1-$i]){
    echo "No";
    exit;
  }
  if($s[$c+1+$i]!=$s[$n-1-$i]){
    echo "No";
    exit;
  }
  ++$i;
}
echo "Yes";

Measured memory_bytes: 4856
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, k = LI()
    a = LI_()
    d = defaultdict(int)
    i = a[0]
    t = 1
    d[0] = 1
    while not d[i]:
        t += 1
        d[i] = t
        i = a[i]
    if n >= k:
        i = 0
        for _ in range(k):
            i = a[i]
        print(i + 1)
    else:
        k -= d[i] - 1
        k %= (t - (d[i] - 1))
        for _ in range(k):
            i = a[i]
        print(i + 1)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 121132
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    long long H,W;
    cin >> H >>W;
    if(H ==1 || W ==1)
    {
        cout << "1" << endl;   
    }
    else if((H*W)%2 == 0)
    {
        cout << H*W/2 << endl;       
    }
    else
    {
        cout << H*W/2 +1 << endl; 
    }
}


Measured memory_bytes: 256