akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
using namespace std;
int main(){
  int k[3];
  int a;int b;
  cin>>a>>b;
  k[0]=a+b;k[1]=a-b;k[2]=a*b;
  int max=k[0];
  for(int i=0;i<3;i++){
    if(k[i]>max){
      max=k[i];
    }
  }
  cout<<max<<endl;

}


Measured memory_bytes: 3628
import java.io.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val n = nextInt()
    val map: MutableMap<Int, Int> = mutableMapOf()
    repeat(n){
        val a = nextInt()
        if(map.containsKey(a)){
            map[a] = map[a]!! + 1
        } else {
            map[a] = 1
        }
    }

    var ans = 0
    for (key in map.keys){
        val count = map[key]!!
        if(count % 2 == 1) ans++
    }

    println(ans)

}

fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!
fun swap(a: String, b: String) = Pair<String, String>(b, a)
fun swap(a: Int, b: Int) = Pair<Int, Int>(b, a)
fun swap(a: Long, b: Long) = Pair<Long, Long>(b, a)
fun swap(a: Double, b: Double) = Pair<Double, Double>(b, a)

fun gcd(a: Int, b: Int): Int = if (a % b == 0) b else gcd(b, (a % b))

Measured memory_bytes: 45884
#include <stdio.h>

int main() {
  int x_1, y_1, x_2, y_2;
  scanf("%d %d %d %d", &x_1, &y_1, &x_2, &y_2);
  int x_3 = x_2 + y_1 - y_2;
  int y_3 = y_2 + x_2 - x_1;
  int x_4 = x_1 + y_1 - y_2;
  int y_4 = y_1 + x_2 - x_1;
  printf("%d %d %d %d\n", x_3, y_3, x_4, y_4);
  return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

#define MAX_N 10*10*10*10*10
#define MAX_A 10*10*10*10*10*10*10*10*10

int main()
{
	long long int N;
	long long int a[MAX_N];
	long long int i;
	long long int x=0, y=0, z=0;

	scanf("%lld", &N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
		if(a[i]%4 == 0)
			x++;
		else if(a[i]%2 == 0)
			y++;
		else
			z++;
	}

	if(y%2 == 0){
		if(x+1 >= z)
			printf("Yes\n");
		else
			printf("No\n");
	} else {
		if(x >= z)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int a[2005],b[2005];
int main()
{
	int n,x;
	scanf("%d%d",&n,&x);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	long long ans=(1LL<<60);
	for (int i=0;i<n;i++)
	{
		long long sum=1LL*i*x;
		for (int j=0;j<n;j++)
		{
			b[j]=min(b[j],a[(j-i+n)%n]);
			sum+=b[j];
		}
		ans=min(ans,sum);
	}
	printf("%lld",ans);
}

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

typedef long long ll;
typedef unsigned long long ull;

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

    int cnt = 0;
    for(int i=0;i<N;i++){
        int minj = i;
        for(int j=i;j<N;j++){
            if(A[j]<A[minj]) minj = j;
        }
        if(A[i] != A[minj]) cnt++;
        int tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
    }
    cout << A[0];
    for(int i=1;i<N;i++) cout << ' ' << A[i];
    cout << endl << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3100
# coding=utf-8

if __name__ == "__main__":
    N, K, Q = map(int, input().split())

    score = [K for i in range(N)]

    for i in range(Q):
        tmp = int(input())
        score[tmp-1] += 1

    score = [elm - Q for elm in score]

    for elm in score:
        if elm > 0:
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 9884
#include <iostream>
#include <algorithm>

using namespace std;

int H, W, N;

long long int a[300][300];
long long int a_(int x, int y){
  if(x < 0 || y < 0){
    return 0;
  }
  return a[x][y];
}

long long int S(int sx, int sy, int gx, int gy){
  long long int ret = 0;
  ret += a_(gx, gy);
  ret -= a_(sx - 1, gy);
  ret -= a_(gx, sy - 1);
  ret += a_(sx - 1, sy - 1);
  return ret;
}

long long int func(int sx, int sy, int gx, int gy, int num){
  if(num == 1){
    return S(sx, sy, gx, gy);
  }
  long long int ret = 0;
  for(int n = 1; n < num; n++){
    for(int x = sx; x < gx; x++){
      ret = max(ret, min(func(sx, sy, x, gy, n), func(x + 1, sy, gx, gy, num - n)));
    }
    for(int y = sy; y < gy; y++){
      ret = max(ret, min(func(sx, sy, gx, y, n), func(sx, y + 1, gx, gy, num - n)));
    }
  }
  return ret;
}

int main(){
  cin >> H >> W >> N;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 1; i < H; i++){
    for(int j = 0; j < W; j++){
      a[i][j] += a[i - 1][j];
    }
  }
  for(int i = 0; i < H; i++){
    for(int j = 1; j < W; j++){
      a[i][j] += a[i][j - 1];
    }
  }
  long long int ans = func(0, 0, H - 1, W - 1, N);
  if(N == 4){
    for(int i = 0; i < H - 1; i++){
      for(int j = i + 1; j < H - 1; j++){
        long long int S1 = 0, S2 = 0;
        int id1;
        for(int k = 0; k < W - 1; k++){
          long long int ret = min(S(0, 0, i, k), S(0, k + 1, j, W - 1));
          if(ret >= S1){
            id1 = k;
            S1 = ret;
          }
        }
        for(int k = 0; k <= min(W - 1, id1); k++){
          long long int ret = min(S(i + 1, 0, H - 1, k), S(j + 1, k + 1, H - 1, W - 1));
          if(ret > S2){
            S2 = ret;
          }
        }
        ans = max(ans, min(S1, S2));
      }
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W / 2; j++){
        swap(a[i][j], a[i][W - j - 1]);
      }
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W - 1; j++){
        a[i][j] -= a[i][j + 1];
      }
    }
    for(int i = 0; i < H; i++){
      for(int j = 1; j < W; j++){
        a[i][j] += a[i][j - 1];
      }
    }
    for(int i = 0; i < H - 1; i++){
      for(int j = i + 1; j < H - 1; j++){
        long long int S1 = 0, S2 = 0;
        int id1;
        for(int k = 0; k < W - 1; k++){
          long long int ret = min(S(0, 0, i, k), S(0, k + 1, j, W - 1));
          if(ret >= S1){
            id1 = k;
            S1 = ret;
          }
        }
        for(int k = 0; k <= min(W - 1, id1); k++){
          long long int ret = min(S(i + 1, 0, H - 1, k), S(j + 1, k + 1, H - 1, W - 1));
          if(ret > S2){
            S2 = ret;
          }
        }
        ans = max(ans, min(S1, S2));
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3572
#include <stdio.h>
#include <sysexits.h>
int main(void){
  int x;
  if(scanf("%d",&x)!=1){
exit(1);
}
  if(x==22){
  printf("Christmas Eve Eve Eve");
  }
  else if(x==23){
    printf("Christmas Eve Eve");
  }
  else if(x==24){
   printf("Christmas Eve");
  }
  else if(x==25){
   printf("Christmas");
  }
  return 0;
}


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

using namespace std;

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

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  ll sum=0;
  int N,data[100];
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>data[i];
    sum+=data[i];
  }
  sort(data,data+N);
  int j=0;
  if(sum%10==0){
    while(true){
      if(data[j]%10==sum%10){
        j++;
        if(j==N) break;
      }else break;
    }
    if(j!=N)sum-=data[j];
    else sum=0;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;

int main(int argc, char **argv)
{
    while(true) {
        int n;scanf("%d",&n);
        if(!n)return 0;
        int x=n;
        int prod=1;
        for(int i = 2; x>1; i++) {
            if(i*i>x)i=x;
            int num=1;
            int sum=1;
            while(x%i==0) {
                sum+=num*=i;
                x/=i;
            }
            prod *= sum;
        }
        n*=2;
        puts(prod==n?"perfect number":prod<n?"deficient number":"abundant number");
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while ( !S.empty() ) {
    int u = S.top(); S.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if ( color[v] == NIL ) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for (int i = 0; i < n; i++) color[i] = NIL;
  for (int u = 0; u < n; u++) {
    if (color[u] == NIL) dfs(u, id++);
  }
}

int main() {
  int s, t, m, q;

  cin >> n >> m;

  for ( int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 9024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="SUN")cout << 7 << endl;
  else if(s=="MON")cout << 6 << endl;
  else if(s=="TUE")cout << 5 << endl;
  else if(s=="WED")cout << 4 << endl;
  else if(s=="THU")cout << 3 << endl;
  else if(s=="FRI")cout << 2 << endl;
  else cout << 1 << endl;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll x, k, d;
  cin >> x >> k >> d;
  if (x < 0) {
    x *= -1;
  }

  // 正の位置にm回
  ll k2 = min(x / d, k);
  if (k2 + 1 <= k && abs(x - k2 * d) > abs(x - (k2 + 1) * d)) {
    k2++;
  }

  ll x2 = x - k2 * d;
  if ((k - k2) % 2 == 0) {
    cout << abs(x2) << '\n';
  } else {
    cout << min(abs(x2 + d), abs(x2 - d)) << '\n';
  }

  return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
char A[105] , B[105] , C[105];

int main(){
    int N , i , Ans = 0;
    scanf( "%d%s%s%s" , &N , A , B , C );

    for( i = 0 ; i < N ; ++i ){
        if( A[i] == B[i] && A[i] == C[i] ) continue;
        else{
            if( A[i] == B[i] ) ++Ans;
            else if( A[i] == C[i] ) ++Ans;
            else if( B[i] == C[i] ) ++Ans;
            else Ans += 2;
        }
    }

    printf( "%d\n" , Ans );
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;


int main(){
    int n;
    cin >> n;
    bool ok = false;
    for(int i = 1 ; i <= n ; ++i){
        if(n % i)continue;
        int x = n / i;
        if(i <= 9 && x <= 9)ok = true;
    }
    puts(ok ? "Yes" : "No");
}

Measured memory_bytes: 256
N, K = map(int, input().split(' '))
ans = 0

if K % 2 != 0:
    ans = (N // K) ** 3
else:
    k = K / 2
    x = N // k
    if x % 2 == 0:
        ans = 2 * (x / 2) ** 3
    else:
        ans = ((x // 2) + 1) ** 3 + (x // 2) ** 3

print(int(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)

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

  pair<ll, ll> AB[N];
  rep(i, N) {
    cin >> AB[i].first >> AB[i].second;
  }
  sort(AB, AB+N);

  ll dp[N+2][T+1], dp_r[N+2][T+1];
  rep(i, N+2) rep(j, T+1) dp[i][j] = dp_r[i][j] = 0;

  rep(i, N) {
    ll A = AB[i].first, B = AB[i].second;
    rep(t, T+1) {
      if (t-A >= 0)
        dp[i+1][t] = max(dp[i][t], B + dp[i][t-A]);
      else
        dp[i+1][t] = dp[i][t];
    }
  }
  ll ans = 0;
  rep(i, N) {
    ans = max(ans, dp[i][T-1] + AB[i].second);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 141056
#include<iostream>
#include<queue>
#include<utility>
#include<cmath>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> pii;
typedef pair<double,pii> pdii;

int main(){
	int h,w;
	vector<pdii> vec;
	loop(i,1,200){
		loop(j,i+1,200){
			pii dt=pii(i,j);
			pdii res=pdii((i*i+j*j),dt);
			vec.push_back(res);
		}
	}
	sort(vec.begin(),vec.end());
	while(1){
		cin>>h>>w;
		if(h==0 && w==0)break;
		rep(i,vec.size()){
			if(vec[i].first==(h*h+w*w) &&vec[i].second.first==h && vec[i].second.second==w){
				cout<<vec[i+1].second.first<<" "<<vec[i+1].second.second<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1572
n, w = map(int, input().split())

dp = [[[-1]*4*n for j in range(n+1)] for i in range(n+1)]
dp[0][0][0] = 0
w1 = None
for i in range(n):
    ws, vs = map(int, input().split())
    if i == 0:
        w1 = ws
    ws -= w1
    for j in range(i+2):
        for k in range(4*n):
            if j-1 >= 0 and k-ws >= 0 and dp[i][j-1][k-ws] >= 0:
                dp[i+1][j][k] = max(dp[i][j][k], dp[i][j-1][k-ws]+vs)
            else:
                dp[i+1][j][k] = dp[i][j][k]

ans = 0
for j in range(n+1):
    for k in range(4*n):
        if w1*j + k <= w:
            ans = max(ans, dp[-1][j][k])
print(ans)


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<long> X(N);
  long ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    ans += abs(X[i]);
  }
  int l = 0, r = K-1;
  while (r < N) {
    long tmp1 = abs(X[l]) + abs(X[r] - X[l]);
    long tmp2 = abs(X[r]) + abs(X[l] - X[r]);
    ans = min({ans, tmp1, tmp2});
    l++; r++;
  }
  cout << ans << endl;
}

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

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        int[] a = new int[N];
        int[] b = new int[N];
        int[] c = new int[N];

        for(int i = 0; i < N; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
        }
        int[][] F = new int[N][];
        for (int i = 0; i < N; i++)
            F[i] = new int[3];
        F[0][0] = a[0];
        F[0][1] = b[0];
        F[0][2] = c[0];

        for (int i = 1; i < N; i++)
        {
            F[i][0] = Math.Max(F[i - 1][1], F[i - 1][2]) + a[i];
            F[i][1] = Math.Max(F[i - 1][0], F[i - 1][2]) + b[i];
            F[i][2] = Math.Max(F[i - 1][0], F[i - 1][1]) + c[i];
        }

        Console.WriteLine(Math.Max(F[N - 1][0], Math.Max(F[N - 1][1], F[N - 1][2])));
    }
}


Measured memory_bytes: 23228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct mint {
    const int mod = 998244353;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

vector<vector<ll>> g;

mint dfs(ll v, ll p = -1) {
    mint ans = 1;
    for(auto u : g[v]) {
        if (u == p) continue;
        ans *= dfs(u, v);
    }
    return ans + 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<pair<ll, ll>> xd(n);
    rep(i, n) cin >> xd[i].first >> xd[i].second;
    sort(all(xd));
    g.resize(n);
    set<pair<ll, ll>> s;
    rrep(i, n) {
        ll x = xd[i].first, d = xd[i].second;
        while((sz(s) > 0) && (s.begin()->first < (x + d))) {
            g[i].push_back(s.begin()->second);
            s.erase(s.begin());
        }
        s.insert(make_pair(x, i));
    }
    mint ans = 1;
    for(auto x : s) ans *= dfs(x.second);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 26880
K,T=map(int,input().split())
a=list(map(int,input().split()))
b=[]

for i,an in enumerate(a):
    b.append([an,i])
ex = -1
ans = 0

if T == 1:
	print(K-1)
else:
  for i in range(K):
    list.sort(b, reverse=True)
    if ex == b[0][1] and b[1][0] != 0:
      b[1][0] -= 1
      ex = b[1][1]
      if b[0][1] == 0 and b[1][1] == 0:
        break
    else:
      b[0][0] -= 1
      if ex == b[0][1]:
        ans+=1
      ex = b[0][1]
      if b[0][1] == 0 and b[1][1] == 0:
        break
  print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
class UnionFind {
  private:
    vector<int> parent;
    vector<int> height;
    vector<int> m_size;

  public:
    vector<ll> weight;
    UnionFind(int size_)
        : parent(size_), height(size_, 0), m_size(size_, 1), weight(size_, 0) {
        for(int i = 0; i < size_; ++i)
            parent[i] = i;
    }
    void init(int size_) {
        parent.resize(size_);
        height.resize(size_, 0);
        m_size.resize(size_, 0);
        for(int i = 0; i < size_; ++i)
            parent[i] = i;
    }
    int find(int x) {
        if(parent[x] == x)
            return x;
        return parent[x] = find(parent[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) {
            return;
        }
        int t = size(x) + size(y);
        m_size[x] = m_size[y] = t;
        if(height[x] < height[y]) {
            parent[x] = y;
            weight[y] += weight[x];
        } else {
            // height[x] >= height[y]
            parent[y] = x;
            weight[x] += weight[y];
        }
        if(height[x] == height[y]) {
            ++height[x];
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) {
        if(parent[x] == x)
            return m_size[x];
        return size(parent[x] = find(parent[x]));
    }
};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    UnionFind tree(H * W);
    REP(i, H) {
        cin >> S[i];
        REP(j, W) {
            if(S[i][j] == '#') {
                tree.weight[i * W + j]++;
            }
        }
    }

    //白黒の順番の連結成分を探す
    REP(i, H) {
        REP(j, W - 1) {
            if(S[i][j] != S[i][j + 1]) {
                tree.unite(W * i + j, W * i + j + 1);
            }
        }
    }
    REP(j, W) {
        REP(i, H - 1) {
            if(S[i][j] != S[i + 1][j]) {
                tree.unite(W * i + j, W * (i + 1) + j);
            }
        }
    }
    set<int> p;
    REP(i, H) {
        REP(j, W) { p.insert(tree.find(i * W + j)); }
    }
    ll ans = 0;
    for(auto now : p) {
        int hoge = tree.size(now);
        // cout << tree.weight[now] << " " << (hoge - tree.weight[now]) << endl;
        ans += tree.weight[now] * (hoge - tree.weight[now]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef unsigned long long ll;
typedef pair<ll, ll> P;
const double EPS = 1e-10;

const int maxn = 300010;
ll rol[maxn];
ll mpow[maxn];

int calc(const string S, const vector<int> &Q, int mod){
  int n = S.size(), m = Q.size();
  mpow[0] = 1;
  for(int i = 0; i < n; i++) mpow[i+1] = mpow[i] * mod;
  
  rol[0] = 0;
  for(int i = 0; i < n; i++){
    rol[i+1] = rol[i] + mpow[i] * (S[i] - 'a' + 1);
  }
  int L = 1, R = 1;

  int dl[4] = {1, -1, 0, 0};
  int dr[4] = {0, 0, 1, -1};

  set<ll> s;
    
  for(int i = 0; i < m; i++){
    L += dl[Q[i]];
    R += dr[Q[i]];
    s.insert((rol[R] - rol[L-1]) * mpow[n-R]);
  }
  return s.size();
}

int main(){
  int n, m;
  cin >> n >> m;
  
  string S;
  string tmp;
  vector<int> Q(m);
  
  cin >> S;
  REP(i, m){
    cin >> tmp;
    if(tmp == "L++") Q[i] = 0;
    if(tmp == "L--") Q[i] = 1;
    if(tmp == "R++") Q[i] = 2;
    if(tmp == "R--") Q[i] = 3;
  }

  cout << max(calc(S, Q, 29), calc(S, Q, 31)) << endl;
  return 0;
  
}

Measured memory_bytes: 21392
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=1e9+7;
const int M=1e6+10;
const int N=2e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int n,m,k,T;
int a[N];
ll ans;
int main() 
{
    int i,j;
	n=read(),k=read();
	for(i=k;i<=n+1;i++) {
		ans+=1ll*i*(2*n-i+3)/2-1ll*i*(i+1)/2+1;
		ans%=mod;		
	}

	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long

using namespace std;

void solve()
{
	
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=(n/(a+b))*a;
	n-=(n/(a+b))*(a+b);
	if(n>a)ans+=a,n-=a;
	else ans+=n;
	 // if(n>b)n-=b;
cout<<ans<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	 // cin>>T;
	while(T--)
	{
    		solve();
	}
}

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

constexpr ll mod = 1000000007;

int main() {
    int n;
    scanf("%d",&n);
    map<int,int> mp;
    for(int i = 2; i <= n; i++) {
        int m = i;
        for(int j = 2; j <= n; j++) {
            while(m % j == 0) {
                mp[j]++;
                m /= j;
            }
        }
    }
    ll ans = 1;
    for(auto c : mp) {
        ans *= c.second+1;
        ans %= mod;
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 256
import java.util.*;


public class Main {

	Main(){
		doIt();
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n =sc.nextInt();
			int m = sc.nextInt();

			if(n == 0 && m == 0){
				break;
			}

			ArrayList<Integer> taro = new ArrayList<Integer>();
			ArrayList<Integer> hanako = new ArrayList<Integer>();

			int taroSum = 0;
			int hanakoSum = 0;


			for(int i = 0; i < n; i++){
				int taroNum = sc.nextInt();
				taro.add(taroNum);
				taroSum+= taroNum;
			}
			for(int i = 0; i < m; i++){
				int hanakoNum = sc.nextInt();
				hanako.add(hanakoNum);
				hanakoSum += hanakoNum;
			}


			boolean flg = true;
			int dis = taroSum - hanakoSum;


			if(dis % 2 == 0){
				dis /= 2;
				if(dis > 0){//???????????????????????????
//					System.out.println("???????????????");
					for(int i = 1; i + dis <= 100; i++){
						if(hanako.contains(i)){
							if(taro.contains(i+dis)){
								System.out.println((i+dis)+" "+i);
								flg = false;
								break;
							}
						}
					}
				}else if(dis < 0){
					dis *= -1;
//					System.out.println("??±????????????");
//					System.out.println(dis);
					for(int i = 1; i <= 100; i++){
						if(taro.contains(i)){
//							System.out.println("?????????"+i);
							if(hanako.contains(i+dis)){
								System.out.println(i+" "+(i+dis));
								flg = false;
								break;
							}
						}
					}
				}else if(dis == 0){
					for(int i = 1; i <= 100; i++){
						if(taro.contains(i) && hanako.contains(i)){
							System.out.println(i+" "+i);
							flg = false;
							break;
						}
					}
				}
				if(flg){
					System.out.println(-1);
				}
			}else{
				System.out.println(-1);
			}

//			System.out.println(taro);
//			System.out.println(hanako);
		}

	}

	public static void main(String[] args) {
		new Main();
	}


}

Measured memory_bytes: 21068
/*
	a * i = b * j + c
	
	 0  x  2  3  4  5  x  o  8  9
	10  x 12 13  o 15  x 17 18 19
	20 ox 22 23 24 25  x 27  0 29
*/

#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;
using ulli = unsigned long long int;

int main(void){
	ulli a, b, c;
	
	cin >> a >> b >> c;
	
	vector<string> mem(a * b);
	for(int i = 0; i < mem.size(); ++i){
		mem[i] = to_string(i);
	}
	for(int i = 0; i < mem.size(); i += a){
		mem[i] = "A";
	}
	for(int i = 0; i < mem.size() - c; i += b){
		mem[i + c] = (mem[i + c] == "A") ? "AB" : "B";
	}
	
	/*
	for(int i = 0; i < mem.size(); i += 10){
		for(int j = 0; j < 10; ++j){
			printf("\t%s", mem[i + j].c_str());
		}
		cout << endl;
	}*/
	
	for(int i = 0; i < mem.size(); ++i){
		if(mem[i] == "AB"){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	
	return 0;
}

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

typedef long long int ll;

int main() {
  ll n;
  cin >> n;
  ll d = 0;
  ll t = 1;
  while (d < abs(n)) {
    d += t;
    t++;
  }
  cout << t - 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,k,a,b;
    cin >> n >> k;
    vpll v(n);
    rep(i,n){
        cin >> a >> b;
        v[i]=m_p(a,b);
    }
    sort(all(v));
    rep(i,n){
        k-=v[i].second;
        if(k<=0){
            cout << v[i].first << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
int main()
{
  int n1,n2,*a,*b,i,n;
  
  scanf("%d",&n1);

  a = (int *)malloc(n1 * sizeof(int));

  for(i=0;i<n1;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&n2);

  b = (int *)malloc(n2 * sizeof(int));

  for(i=0;i<n2;i++){
    scanf("%d",&b[i]);
  }

  n = Search(a,b,n1,n2);

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

  free(a);
  free(b);

  return 0;
}

int Search(int *a,int *b,int n1,int n2)
{
  int c=0,i,j,l,r,m;

  for(i=0;i<n2;i++){
    l = 0;
    r = n1;
    m = (l+r)/2;
    while(l<r){
      if(a[m]==b[i]){
	c++;
	break;
      }
      else if(a[m]<b[i]){
	l = m+1;
	m = (l+r)/2;
      }
      else if(a[m]>b[i]){
	r = m;
	m = (l+r)/2;
      }
    }
  }
  
  return c;
}



Measured memory_bytes: 2048
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 100100;

int a[4][4];
bool ok[4][4] = {false};

int main() {
  rep(i, 3) {
    rep(j, 3) {
      cin >> a[i][j];
      // bool ok[i][j] =;
    }
  }
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) cin >> b[i];

  rep(i, 3) {
    rep(j, 3) {
      rep(k, n) {
        if (b[k] == a[i][j]) {
          ok[i][j] = true;
        }
      }
    }
  }

  if ((ok[0][0] && ok[0][1] && ok[0][2]) ||
      (ok[1][0] && ok[1][1] && ok[1][2]) ||
      (ok[2][0] && ok[2][1] && ok[2][2]) ||
      (ok[0][0] && ok[1][0] && ok[2][0]) ||
      (ok[0][1] && ok[1][1] && ok[2][1]) ||
      (ok[0][2] && ok[1][2] && ok[2][2]) ||
      (ok[0][0] && ok[1][1] && ok[2][2]) ||
      (ok[2][0] && ok[1][1] && ok[0][2])) {
    cout << "Yes";
  } else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)

int main(void) {
	int A, B;
	scanf("%d %d", &A, &B);
	if (A == 1) A = 14;
	if (B == 1) B = 14;
	if (A > B) {
		printf("Alice");
	}
	else if (B > A) {
		printf("Bob");
	}
	else {
		printf("Draw");
	}
	return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a==b && a!=c || a==c && a!=b || b==c && a!=b)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

L = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]



print((L/3)**3)


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

bldgs = [[[0]*10 for j in range(3)] for i in range(4)]

#print(bldgs)
for i in range(n):
    b, f, r, v = map(int, input().split())
    bldgs[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        print(" ", end="")
        print(" ".join(map(str, bldgs[b][f])))
    if b != 3:
        print("#"*20)



Measured memory_bytes: 5612
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int N, M;

class Color{
public:
    double L, a, b;
    Color(double L, double a, double b): L(L), a(a), b(b){};
};

double dist(Color c1, Color c2){
    return (c1.L-c2.L)*(c1.L-c2.L) + (c1.a-c2.a)*(c1.a-c2.a) + (c1.b-c2.b)*(c1.b-c2.b);
}

void solve(){
    vector<Color> colors;
    for(int i=0; i<N; i++){
        double L, a, b; cin >> L >> a >> b;
        colors.push_back(Color(L, a, b));
    }
    
    double ans = 0;
    
    for(int i=0; i<1<<N; i++){
        vector<int> vec;
        if(__builtin_popcount(i) != M) continue;
        
        for(int j=0; j<N; j++)
            if(i>>j&1)
                vec.push_back(j);
        
        double t = 0;
        for(int j=0; j<M; j++)
            for(int k=j+1; k<M; k++)
                t += dist(colors[vec[j]], colors[vec[k]]);
        ans = max(ans, t);
    }
    
    //cout << ans << endl;
    printf("%.6f\n", ans);
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    
    cin >> N >> M;
    solve();
    
    return 0;
}

Measured memory_bytes: 1288
# https://atcoder.jp/contests/abc094/tasks/abc094_b

import itertools
import collections
import bisect

def main():
    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))

    pos = bisect.bisect_left(A, X)
    # print(A[:pos])
    # print(A[pos:])
    print(min(len(A[:pos]), len(A[pos:])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

string ss,s,t;
bool check(int n){
  for(int i=0;i<t.size();i++){
    if(s[i+n]=='?') continue;
    else if(s[i+n]!=t[i]){
      return false;
    }
  }
  return true;
}

int main(void){
  cin>>s>>t;
  for(int i=s.size()-t.size();i>=0;i--){
    if(check(i)){
      s.replace(i,t.size(),t);
      for(int i=0;i<s.size();i++){
	if(s[i]=='?') cout<<'a';
	else cout<<s[i];
      }
      cout<<endl;
      return 0;
    }
  }
  cout<<"UNRESTORABLE"<<endl;
  return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int N, K;
	cin >> N >> K;
	int inisum = 0;
	vector<int> V(N);
	rep(i, N) {
		cin >> V[i];
		inisum += V[i];
	}

	int ans = -INF;
	for (int a = 0; a <= N; a++) {
		for (int b = 0; b <= N; b++) {
			if (a + b > N) continue;
			if (a + b > K) continue;
			vector<int> t;
			for (int i = 0; i < a; i++) t.push_back(V[i]);
			for (int i = 0; i < b; i++) t.push_back(V[N - 1 - i]);
			sort(t.begin(), t.end());
			int sum = 0;
			rep(i, t.size()) sum += t[i];

			for (int i = 0; i < max(0LL,(K - (a + b))); i++)
				if (i < t.size() && t[i] < 0) sum -= t[i];

			if (sum > ans) ans = sum;
		}
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
# D
N = int(input())
a_list = [0]*N
for i in range(N):
    a_list[i] = int(input())

L = 90001
LARGE = 998244353

DP = [0]*L
DP[0] = 1
for i in range(N):
    for j in range(L-1, a_list[i]-1, -1):
        DP[j] = (2*DP[j] + DP[j - a_list[i]]) % LARGE
    for j in range(a_list[i]-1, -1, -1):
        DP[j] = (2*DP[j]) % LARGE

DP2 = [0]*L
DP2[0] = 1
for i in range(N):
    for j in range(L-1, a_list[i]-1, -1):
        DP2[j] = (DP2[j] + DP2[j - a_list[i]]) % LARGE
    for j in range(a_list[i]-1, -1, -1):
        DP2[j] = (DP2[j]) % LARGE
S = sum(a_list)
if S % 2 == 0:
    h = S // 2
    res = ((3**N % LARGE) - (3*sum(DP[(h):]) % LARGE) + 3*DP2[h]) % LARGE
else:
    h = S // 2 + 1
    res = ((3**N % LARGE) - (3*sum(DP[(h):]) % LARGE)) % LARGE
print(res)

Measured memory_bytes: 45148
#include<bits/stdc++.h>
using namespace std;
map<long long int,int> Hash;
void factorize(long long int n) 
{ 
    int count = 0; 
    while (!(n % 2)) 
    { 
        n >>= 1;
        count++; 
    } 
    if (count) 
        Hash[2]=count;
    for (long long i = 3; i <= sqrt(n); i += 2) 
    { 
        count = 0; 
        while (n % i == 0)
        { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            Hash[i]=count; 
    } 
    if(n>2)
        Hash[n]=1;
}
int main()
{
    long long int N;
    cin>>N;
    long long int ans=0;
    factorize(N);
    for(auto it:Hash)
    {
        long long int z=it.second;
        long long int i;
        for(i=1;i<=50;i++)
        {
            if( (i*(i+1))/2==z)
            {
                break;
            }
            else if((i*(i+1))/2>z)
            {
                i=i-1;
                break;
            }

        }
        ans+=i;        
    }
    cout<<ans;

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define sz(x)          (int) x.size()
#define MOD 1000000007
#define EPS 1e-7
#define lol    {cout<<i<<" "<<-j<<endl; goto here;}
#define lol2    {cout<<i<<" "<<j<<endl; goto here;}

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

bool compare(const pii &a, const pii &b){
    return a.first > b.first;
}
int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    int n; cin>>n;
    int c1[n+1], c2[n+1];
    map<ll, ll> mp;
    for(int i = 1; i<=n; i++){
        int a; cin>>a;
        c1[i] = i + a;
        c2[i] = i - a;
        mp[c2[i]]++;
    }
    ll cnt = 0;
    for(int i =1; i<=n; i++){
        mp[c2[i]]--;
        if(mp.count(c1[i])) cnt += mp[c1[i]];
    }
    cout<<cnt;
	return 0;
}


Measured memory_bytes: 16772
#include <stdio.h>
 
int main(void){
  int i,j,n,taro_p=0,hana_p=0;
  char taro[101], hana[101];
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%s %s", taro, hana);
 
    for(j=0;;j++){
      if(taro[j] > hana[j]){
        taro_p += 3;
        break;
      }else if(taro[j] < hana[j]){
        hana_p += 3;
        break;
      }else if(taro[j] + hana[j] == 0){
        hana_p++;
        taro_p++;
        break;
      }
    }
  }
 
  printf("%d %d\n", taro_p , hana_p);
  return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int a, b; std::cin >> a >> b;
    std::cout << a * b << "\n";
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int d; cin >> d;
    vector<int> clis(26);
    vector<vector<int>> slis(d, vector<int>(26));
    vector<int> anslis(d);
    vector<int> prelas(26, 0);
    int ma = -1;
    int iii;
    REP(i, 0, 26){
        cin >> clis[i];
        if(chmax(ma, clis[i])){
            iii = i;
        }
    }
    REP(i, 0, d){
        int idx = 0, max = -1;
        REP(l, 0, 26){
            cin >> slis[i][l];
        }
    }
    REP(i, 0, d){
        int k = rand() % 26;
        anslis[i] = k;
    }
    vector<int> last(26, 0);
    int anspre = 0;
    REP(i, 0, d){
        last[anslis[i]] = i+1;
        anspre += slis[i][anslis[i]];
        int minus = 0;
        REP(l, 0, 26){
            minus += clis[l] * ((i+1) - last[l]);
        }
        anspre -= minus;
        //cout << anspre << endl;
    }
    REP(i, 0, 1e4){
        int from = rand() % 26;
        int to = rand() % 26;
        if(anslis[from] == to){continue;}
        int old = anslis[from];
        anslis[from] = to;
        int anspre1 = 0;
        //スコア計算
        REP(l, 0, d){
            last[anslis[l]] = l+1;
            anspre1 += slis[l][anslis[l]];
            int minus = 0;
            REP(j, 0, 26){
                minus += clis[j] * ((l+1) - last[j]);
            }
            anspre1 -= minus;
        }
        //cout << anspre1 << endl;
        if(anspre > anspre1){
            anslis[from] = old;
        }else{
            anspre = anspre1;
        }
    }
    REP(i, 0, d){
        cout << (anslis[i] + 1) % d << endl;
    }
    //cout << anspre << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
using namespace std;

int main()
{
	double PI = 4 * atan(1);
	int l, t1, t2 = 0, c = 0;
	double x = 0, y = 0;
	while(scanf("%d,%d", &l, &t1) && (l != 0 || t1 != 0)){
		x += (double)l * sin(PI * (double)t2 / 180);
		y += (double)l * cos(PI * (double)t2 /180);
		t2 += t1;
	}
	cout << (int)x << endl;
	cout << (int)y << endl;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e5 + 5; 
using namespace std;

int n;
char s[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	scanf("%s", s + 1), n = strlen(s + 1); 
	if(s[1] == s[n]) puts(n & 1 ? "Second" : "First"); 
	else puts(n & 1 ? "First" : "Second"); 
	return 0; 
}


Measured memory_bytes: 3208