akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
	/*static double res=0;
	 static void help(int p,int r,int n){
		double tmp=p;
		for(int i=1;i<=n;i++){
			double x=1+(double)r/1200 ;
			tmp*=x;
		}
		res+=tmp;
		int k=100000,m=360;
		for(int i=m;i>0;i--){
			help(k,5,i);
		}
		System.out.println("paid amount "+k*m+" ");
		System.out.println((long)res);
	}
*/
public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n=s.nextInt();
		int k=s.nextInt(); int res=0;
		for(int i=0;i<n;i++){
			if(s.nextInt()>=k){res++;}
		}
		
		System.out.println(res);	
		}
    }
	
		
	













Measured memory_bytes: 46512
#include <iostream>
#include <string>
using namespace std;
int solve(int m, string a, string b, string c)
{
    int co = 0;
    for (int i = 0; i < m; i++)
    {
        if (a[i] == b[i] && b[i] == c[i])
        {
            co += 0;
    
        }
        else if (a[i] == b[i] && b[i] != c[i])
        {
            co+= 1;
          
            
        }
        else if (a[i] == c[i] && a[i] != b[i])
        {
            co+= 1;
          
        
          
        }
        else if (b[i] == c[i] && a[i] != b[i])
        {
            co += 1;
            
            
        }
        else
        {
            co += 2;
           
        }
        
    }
    return co;
}
int main()
{
    int n;
    int ans;
    string str1, str2, str3;
    cin >> n >> str1 >> str2 >> str3;
    ans =  solve(n, str1, str2, str3);
    cout << ans << endl;
}

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

int main() {
	int a, b;
  	cin >> a >> b;
  	if (a <= 0 && 0 <= b) cout << "Zero" << endl;
  	else if (a > 0 && b > 0) cout << "Positive" << endl;
  	else {
		if ((b - a) % 2 == 0) cout << "Negative" << endl;
      	else cout << "Positive" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur!=nil&&cur->key!=key){
      cur=cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t==nil) return;
  t->next->prev=t->prev;
  t->prev->next=t->next;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->prev=nil;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 36080
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int root(vi &par,int x){
  if(par.at(x) == x) return x;
  else par.at(x) = root(par,par.at(x));
}

void unit(vi &par,int x,int y){
  int rx = root(par,x);
  int ry = root(par,y);
  if(rx == ry) return;
  par.at(ry) = rx;
  return;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> p(n);
  rep(i,n){
    cin >> p.at(i);
    p.at(i)--;
  }
  vector<int> par(n);
  rep(i,n) par.at(i) = i;
  
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;y--;
    unit(par,x,y);
  }
  rep(i,n) par.at(i) = root(par,i);
  vector<vi> fam(n);
  rep(i,n){
    fam.at(par.at(i)).push_back(i);
  }
  int ans = 0;
  rep(i,n){
    set<int> st;
    for(int x : fam.at(i)){
      st.insert(p.at(x));
    }
    for(int x : fam.at(i)){
      if(st.count(x)) ans++;
    }
  }
  //rep(i,n) cout << par.at(i) << " ";
  cout << ans << endl;
}

Measured memory_bytes: 8440
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n,ans=0;
    string si,sti;
    ll ssi;
    cin>>n;
    string sn = to_string(n);
    ll ssn = sn.size();
    for(int i=1;i<=n;i++){
        si = to_string(i);
        ssi = si.size();
        ll ti=0,ta,tb;
        if(si[0]==si[ssi-1]){
            ti=(si[0]-'0');
            ans++;
        }
        ta = (si[0]-'0');
        tb = (si[ssi-1] - '0');
        /*cout<<"A "<<ti<<" "<<ans<<endl;*/
        if(tb!=0 && tb*10+ta <= n){
            ti = tb*10+ta;
            ans++;
            ll ss1 = 1;
            ti = tb*pow(10,1+ss1)+ta;
            /*cout<<ti<<" "<<ans<<endl;*/
            while(ti<=n){
                if(sn.size()>ss1+2){
                    ans += pow(10,ss1);
                    ss1++;
                }else{
                    if((sn[0]-'0')-tb >0){
                        ans += pow(10,ss1);
                        break;
                    }else{
                        if((sn[ssn-1]-'0')>=ta){
                            ans +=(1+((n/10)-tb*pow(10,ss1)));
                            break;
                        }else{
                            ans +=((n/10)-tb*pow(10,ss1));
                            break;
                        }
                    }
                }
                ti = tb*pow(10,1+ss1)+ta;
            }
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;


int n, k;
string str;
int dp[302][302][151];

int recur(int st, int en, int left){
	if(st == en) return 1;
	if(st > en) return 0;
	if(dp[st][en][left] != -1) return dp[st][en][left];
	int ret = 0;
	if(str[st] == str[en]) ret = max(ret, 2 + recur(st + 1, en - 1, left));
	ret = max(ret, recur(st + 1, en, left));
	ret = max(ret, recur(st, en - 1, left));
	if(left) ret = max(ret, 2 + recur(st + 1, en - 1, left - 1));
	return dp[st][en][left] = ret;
}

int main(){
	cin >> str;
	cin >> k;
	n = str.size();
	memset(dp, -1, sizeof(dp));
	cout << recur(0, n - 1, min(k, 150)) << endl;
	return 0;
}


Measured memory_bytes: 54016
//14
#include<iostream>
#include<algorithm>
#include<numeric>

using namespace std;

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    int d[100][100];
    fill_n(d[0],10000,1<<29);
    for(int i=0;i<m;i++){
      int a,b,c;
      cin>>a>>b>>c;
      d[a][b]=d[b][a]=c;
    }
    int ds[100];
    fill_n(ds,100,1<<29);
    ds[0]=0;
    bool u[100]={};
    for(int i=0;i<n-1;i++){
      int m=1<<29;
      int v;
      for(int i=0;i<n;i++){
	if(!u[i]&&ds[i]<m){
	  m=ds[i];
	  v=i;
	}
      }
      u[v]=true;
      for(int i=0;i<n;i++){
	if(!u[i]){
	  ds[i]=min(ds[i],d[v][i]);
	}
      }
    }
    cout<<accumulate(ds,ds+n,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
AS=[A[0]]
for i in range(1,N):
    AS.append(AS[i-1]+A[i])
dp=[0 for i in range(N)]

dp[0]=A[0]+B[0]

for i in range(1,N):
    dp[i]=max(AS[i]+B[i],dp[i-1]+B[i])
print(dp[N-1])

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

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

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


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

  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1 != m2)cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]+=32;
    cout<<s;
	return 0;
}
//.........


Measured memory_bytes: 256
def ferris_wheel(A: int, B: int)->int:
    if A >= 13:
        return B
    elif A >= 6:
        return B//2
    else:
        return 0


if __name__ == "__main__":
    A, B = map(int, input().split())

    ans = ferris_wheel(A, B)
    print(ans)


Measured memory_bytes: 2940
from collections import Counter


def main():
    n = int(input())
    v = list(map(int, input().split(' ')))
    v_odd, v_even = list(), list()
    for i in range(n):
        if i % 2 == 0:
            v_even.append(v[i])
        else:
            v_odd.append(v[i])
    assert len(v_odd) == len(v_even)
    odd_top2 = Counter(v_odd).most_common(2)
    even_top2 = Counter(v_even).most_common(2)
    if odd_top2[0][0] != even_top2[0][0]:
        print(n - odd_top2[0][1] - even_top2[0][1])
    else:
        d1 = n - odd_top2[0][1] - (0 if len(even_top2) == 1 else even_top2[1][1])
        d2 = n - even_top2[0][1] - (0 if len(odd_top2) == 1 else odd_top2[1][1])
        print(min([d1, d2]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 15972
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

int main()
{
	int n, k;
	vector<int> arr(200000);
	long long val = 0;
	long long lmax;

	scanf("%d %d", &n, &k);

	for (int i = 0; i < k; i++)
	{
		scanf("%lld", &arr[i]);

		val += arr[i] + 1;
	}

	lmax = val;

	for (int i = k; i < n; i++)
	{
		scanf("%lld", &arr[i]);

		val += arr[i] + 1;

		val -= arr[i - k] + 1;

		if (val > lmax)
		{
			lmax = val;
		}
	}

	printf("%.8lf\n", (double)lmax / (double)2);

	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    val n = sc.nextLong()
    val a = sc.nextLong()
    val b = sc.nextLong()
    println((n / (a + b)) * a + Math.min(a, n % (a + b)))
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31388
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll ans;
    if(a%2==0||b%2==0||c%2==0) ans=0;
    else{
        ans=min(a*b,min(b*c,c*a));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void){
    // Here your code !
    int i,max,min,N,a[2000];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    max=a[0];
    min=a[0];
    for(i=1;i<N;i++){
        if(a[i]<min) min=a[i];
        if(a[i]>max) max=a[i];
    }
    printf("%d",max-min);
    return 0;
}


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

using namespace std;

int main(void)
{
  //5+ 1854-
  int N, M;
  long long L;
  cin >> N >> M >> L;

  vector<vector<int>> Load_to(N, vector<int>());
  vector<vector<int>> Load_cost(N, vector<int>());

  for (int i = 0; i < M; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    Load_to[a].push_back(b);
    Load_cost[a].push_back(c);
    Load_to[b].push_back(a);
    Load_cost[b].push_back(c);
  }

  //Map
  vector<vector<int>> CostMap(N, vector<int>(N, -1));

  //一回で行ける距離を判定
  for (int i = 0; i < N; i++)
  {
    priority_queue<pair<int, int>> que;

    que.push(make_pair(L, i));
    
    while (true)
    {
      if (que.empty())
      {
        break;
      }
      pair<int, int> S = que.top();
      que.pop();
      int tank = S.first;
      int from = S.second;
      if(CostMap[i][from] == 0){
        continue;
      }
      CostMap[i][from] = 0;
      for (int j = 0; j < Load_to[from].size(); j++)
      {
        int to = Load_to[from][j];
        int rest = tank-Load_cost[from][j];
        if (Load_cost[from][j] > tank || CostMap[i][to]==0)
        {
          continue;
        }
        if(tank!=0){
        que.push(make_pair(rest,to));
        }
      }
    }
  }
  int t = 0;
  while (true)
  {
    bool check = false;
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
      {
        if(i==j){
          CostMap[i][j]=0;
          continue;
        }
        if (CostMap[i][j] == t)
        {
          for (int k = 0; k < N; k++)
          {
            if (CostMap[j][k] != -1)
            {
              int cost = CostMap[i][j] + CostMap[j][k]+1;
              if (CostMap[i][k] == -1 || (CostMap[i][k] != -1 && CostMap[i][k] > cost))
              {
                CostMap[i][k] = cost;
                check = true;
              }
            }
          }
        }
      }
    }
    if (!check)
    {
      break;
    }
    t++;
  }
  
  int Q;
  cin >> Q;

  for (int i = 0; i < Q; i++)
  {
    int s, t;
    cin >> s >> t;
    s--;t--;
    cout << CostMap[s][t] << endl;
  }
  /* debacker
  for (int i = 0; i < N; i++){
    for(int j=0;j<N;j++){
      cout<<CostMap[i][j] <<" ";
    }
    cout<<endl;
  }
  */
  
  return 0;
}

Measured memory_bytes: 2700
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect
import heapq

MOD = float('inf')
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def warshall_floyd(d):
    """
    d[i][l]がi→lへのコストを示す隣接行列
    結果としてd[i][l]はi→lへの最短コストになる。
    """
    for i in range(len(d)):
        for l in range(len(d)):
            for k in range(len(d)):
                d[l][k] = min(d[l][k], d[l][i] + d[i][k])
    return d


while True:
    n = int(input())
    if n == 0:
        break
    else:
        abc = [list(map(int, input().split())) for _ in range(n)]
        info = [[INF for _ in range(10)] for _ in range(10)]
        for i in range(10):
            info[i][i] = 0
        for i in abc:
            info[i[0]][i[1]] = i[2]
            info[i[1]][i[0]] = i[2]
        result = warshall_floyd(info)
        ans = []
        for i in result:
            for l in range(len(i)):
                if i[l] == INF:
                    i[l] = 0
        for i in range(10):
            if sum(result[i]) != 0:
                ans.append([sum(result[i]), i])
        ans.sort()
        print(ans[0][1], ans[0][0])



Measured memory_bytes: 6916
fun main(args: Array<String>) {
    abc000X()
}

fun abc000X() {
    val (a, b, c) = readLine()!!.split(" ").map(String::toInt)

    if (c < a - b) {
        println(0)
    } else if (c >= a - b) {
        println(c - (a - b))
    }
}


Measured memory_bytes: 37724
import sys

#sys.setrecursionlimit(100000)
u=[]
k=[]
v=[]

time = 0

n=int(sys.stdin.readline().strip())
yattayatu=[False for i in range(n)]

s=[0 for i in range(n)]
f=[0 for i in range(n)]

for i in range(n):
	inp = sys.stdin.readline().strip().split(" ")
	inp = list(map(lambda x: int(x), inp))
	u.append(inp[0])
	k.append(inp[1])
	v.append(inp[2:])


def func(nodeid):
	global time
	if(yattayatu[nodeid-1]==True):
		return
	yattayatu[nodeid-1]=True
	time += 1
	s[nodeid-1] = time
	for i in range(k[nodeid-1]):
		func(v[nodeid-1][i])
	time +=1
	f[nodeid-1]=time
	return

for i in range(n):
	func(i+1)

for i in range(n):
	print(str(i+1)+" "+str(s[i])+" "+str(f[i]))

Measured memory_bytes: 7760
def solve():
    N, K, *p = map(int, open(0).read().split())
    
    idx = 0
    tmp, p_sum = sum(p[:K]), sum(p[:K])
    for i in range(N - K):
        tmp -= p[i]
        tmp += p[i + K]
        if p_sum < tmp:
            p_sum = tmp
            idx = i + 1
    
    cumsum = [i for i in range(1, 200001)]
    for i in range(1, 200000):
        cumsum[i] += cumsum[i - 1]
    
    ans = 0
    for i in range(idx, idx + K):
        ans += cumsum[p[i] - 1] / p[i]
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 25036
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s,t;
    cin>>s>>t;
    map<char,int> ms,mt;
    rep(i,s.size()){
        ms[s[i]]++;
        mt[t[i]]++;
    }
    vector<int> vs,vt;
    rep(i,s.size()){
        vs.push_back(ms[s[i]]);
        vt.push_back(mt[t[i]]);
    }
    rep(i,s.size()){
        if(vs[i]!=vt[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, a[200010];
long long ans = 0;
int main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	if (a[0]) {
		puts("-1");
		return 0;
	}
	for (int i = 1;i < n;i++) {
		if (a[i] <= a[i - 1])ans += a[i];
		else if (a[i] == a[i - 1] + 1)ans++;
		else {
			puts("-1");
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

long long modpow(long long a,long long n,long long mod){
    
    long long res = 1;
    while(n > 0){
        if(n&1)res = res*a%mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    int D[N];
    long long mod = 998244353;
    map<long long,int> d;
    for(int i = 0; i < N;i++){
        cin >> D[i];
        d[D[i]]++;
    }
    long long ans = 1;
    bool flag = false;
    for(int i = N -1; i >= 1;i--){
        if(d[i]!=0)flag = true;
        if(flag&&d[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    if(d[0]!=1){
        cout << 0 << endl;
        return 0;
    }
    if(D[0]!= 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i <N;i++){
        ans *= modpow(d[i-1],d[i],mod);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;
const int pp = 1e6+10;


int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15); 
    ll N; cin>>N;
    vector<bool> is_prime(pp+1,true);
    REP(i,pp+1){
        if(i == 0|| i == 1){
            is_prime[i] = false;
        }
        if(is_prime[i] == true){
            for(int k = 2*i; k <= pp; k+=i){
                is_prime[k] = false;
            }
        }
    }
    vector<int> prime(pp+1,0);
    int itr = 0;
    for(ll i = 2; i*i <= N; i++){
        if(is_prime[i]){
            while(N % i == 0){
                N /= i;
                prime[itr]++;
            }
            itr++;
            if(N == 1) break;
        }
    }
    if(N>1) {
        prime[itr]++;
        itr++;
    }
    
    int ans = 0;
    REP(i,itr){
        int k = 1;
        while(k * (k+1) / 2 <= prime[i]){
            k++;
        }
        k--;
        ans += k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7160
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll z = 1000000007 ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b){if(b == 0) return 1 ; ll c = power(a , b/2) ; if(b%2 == 0) return ((c*c)%z) ; else return ((((c*c)%z)*a)%z) ;}
ll inverse(ll a ,ll n){return power(a , n-2) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;



int main()
{
	
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	char c ;
	cin >> c ;
	cout << (char)(c+1) << '\n'; 
	
	return 0 ;
}

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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))

typedef long long ll;


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

    int n;
    cin>>n;
    int ar[n]={0},dp[n]={0};
    for(int i=0;i<n;++i){
        cin>>ar[i];
    }
    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);
    for(int i=2;i<n;++i){
        dp[i]=min((dp[i-2]+abs(ar[i]-ar[i-2])),(dp[i-1]+abs(ar[i]-ar[i-1])));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
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;
}
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    int n,ans(1000000);
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
        int m(0);
        while(1){
            if(a[i]%2==0){
                m++;
                a[i] = a[i]/2;
            }else{
                break;
            }
        }
        ans = min(ans,m);
    }
    put(ans);

    return 0;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  int X, A;
  cin >> X >> A;
  if (X < A) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }

  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define EPSILON numeric_limits<double>::epsilon()
int main()
{
    int n,d;
    cin >> n >> d;
    int arr[n][d];
    for(int i=0;i<n;i++)
        for(int j=0;j<d;j++)
        cin >> arr[i][j];
        int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            double sum = 0;
            for(int k=0;k<d;k++)
            { int ll = abs(arr[i][k]-arr[j][k]);
              sum += ll*ll;
            }
            sum = sqrt(sum);
            if(floor(sum)==ceil(sum)) ans++;
        }
    }
    cout << ans;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{

    ll i,j,c=0,n;
    vector<ll>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>j;
        v.push_back(j);
    }
    sort(v.begin(),v.end());
    v[n-1]=v[n-1]/2;
    for(i=0;i<n;i++)
    {
        c+=v[i];
    }
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 256
<?php
list($n) = ints();
list($s) = strs();
list($t) = strs();
for ($i = $n; $i >= 1; --$i)
    if (substr($s, $n - $i) === substr($t, 0, $i)) break;
echo $n * 2 - $i;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w[300];
  while(cin>>n,n){
    for(int i=0;i<n;i++)cin>>w[i];
    int dp[300][300]={};
    for(int i=1;i<n;i++)
      for(int j=0;j+i<n;j++){
	for(int k=j;k<j+i;k++)
	  dp[j][j+i]=max(dp[j][j+i],dp[j][k]+dp[k+1][j+i]);
	if(dp[j+1][j+i-1]==i-1&&abs(w[j]-w[j+i])<2)dp[j][j+i]=i+1;
      }
    cout<<dp[0][n-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3400
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll k;
    cin>>k;
    if(k%2==0) cout<<k/2*(k/2)<<endl;
    else cout<<(k/2)*(k/2+1)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int hcf(int n1, int n2);
int main()
{
   int n1, n2;
   scanf("%d%d",&n1,&n2);

   printf("%d\n",hcf(n1,n2));
   return 0;
}

int hcf(int n1, int n2)
{
    if (n2 != 0)
       return hcf(n2, n1%n2);
    else
       return n1;
}



Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  string s, t;
  int sm = 0;
  cin >> s >> t;
  rep(i, 0, 3){
    if(s[i] == t[i]){
      sm++;
    }
  }
  
  cout << sm << "\n";
}
      
    

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  ll tmp = 1;
  ll ans = 0;
  while (n > 0) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
h,w=map(int,input().split())
l=["" for i in range(w)]
yo=[]
for i in range(h):
    s=input()
    for a,j in enumerate(s):
        l[a]+=j
for i in l:
    if "#" in i:
        yo.append(i)
x=len(yo[0])
ans=["" for i in range(x)]
for i in yo:
    for a,j in enumerate(i):
        ans[a]+=j
for i in ans:
    if "#" in i: print(i)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

string s;
string t;

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

  int pos = -1;
  for (int i=0; i<s.size()-t.size()+1; i++) {
    bool matched = true;
    for (int j=0; j<t.size(); j++) {
      if (s.at(i+j) != '?' && s.at(i+j) != t.at(j)) {
        matched = false;
        break;
      }
    }
    if (matched) {
      pos = i;
    }
  }

  if (pos == -1) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  string ans;
  for (int i=0; i<s.size(); i++) {
    if (s.at(i) != '?') {
      ans.push_back(s.at(i));
    } else if (i < pos || i >= pos + t.size()) {
      ans.push_back('a');
    } else {
      ans.push_back(t.at(i-pos));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : A - Registration
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    KAMEHAMEHA
//    #ifdef _soumik
//        freopen("input.txt", "r", stdin);
//    #endif
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PI;

const int DEBUG = 0;

int main(void){
  int h, w, n;
  cin >> h >> w >> n;
  vector<PI> rem(n);
  REP(i, 0, n) {
    int u, v;
    cin >> u >> v;
    v--;
    rem[i] = PI(u, v);
    assert ((u + v) % 2 == 1);
  }
  assert (w % 2 == 0);
  sort(rem.begin(), rem.end());
  VI ary(w);
  REP(i, 0, w / 2) { ary[i] = i * 2; }
  REP(i, 0, w / 2) { ary[w / 2 + i] = w - 1 - 2 * i; }
  REP(i, 0, n) {
    PI t = rem[i];
    int bias = t.first / 2;
    int flipped = t.first % 2;
    int v = t.second;
    int mapped_v = w - 1 - v / 2;
    if (flipped) {
      mapped_v = v / 2;
    }
    int x = mapped_v;
    int y = flipped ? w - 1 - x : w - x;
    assert (0 <= y && y < w);
    x = (x + w - bias % w) % w;
    y = (y + w - bias % w) % w;
    if (DEBUG) { cerr << "x=" << x << ", y=" << y << endl; }
    swap(ary[x], ary[y]);
    if (DEBUG) {
      cerr << "step " << t.first << ":";
      REP(i, 0, w) {
	cerr << " " << ary[i];
      }
      cerr << endl;
    }
  }
  VI inv(w, -100);
  REP(i, 0, w) {
    int bias = (h / 2) % w;
    int flipped = h % 2;
    int mapped_i;
    if (i % 2 == 1) {
      mapped_i = w - 1 - i / 2;
    } else {
      mapped_i = i / 2;
    }
    if (flipped) {
      mapped_i = w - 1 - mapped_i;
    }
    int x = (mapped_i + w - bias % w) % w;
    inv[ary[x]] = i;
    if (DEBUG) {
      cerr << i << " ==> " << x << "(" << ary[x] << ")" << endl;
    }
  }
  REP(i, 0, w) {
    cout << inv[i] + 1 << endl;
  }
}

Measured memory_bytes: 5936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        boolean[] sieve = new boolean[104729 + 1];
        for (int p = 2; p < Math.sqrt(sieve.length); p++) {
            if (sieve[p]) {
                continue;
            }
            for (int q = p * 2; q < sieve.length; q += p) {
                sieve[q] = true;
            }
        }
        int[] sums = new int[10001];
        int k = 0;
        for (int p = 2; p < sieve.length; p++) {
            if (sieve[p]) {
                continue;
            }
            k++;
            sums[k] = sums[k - 1] + p;
        }

        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            int n = Integer.parseInt(reader.readLine());
            if (n == 0) {
                break;
            }
            out.println(sums[n]);
        }
    }
}

Measured memory_bytes: 9612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	map<string,int> mp;
	for(int i=1;i<=n;i++){
		string s = to_string(i);
		char f = s[0];
		char l = s.back();
		s.clear();
		s+=f;
		s+=l;
		mp[s]++;
	}
	ll ans = 0;
	for(auto p: mp){
		if(p.first[0]==p.first[1]){
			int x = p.second;
			ans += (ll)x*x;
		}
		else {
			string s = "";
			s += p.first[1];
			s += p.first[0];
			ans += (ll)mp[s]*p.second;
		}
	}
	cout<<ans;
	return 0;
}


































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

using namespace std;

int main()
{
  int H, W; cin >> H >> W;
  vector<string> C(2*H);
  for (int i = 0; i < 2*H; i+=2) {
    cin >> C[i];
    C[i+1] = C[i];
  }

  for (int i = 0; i < 2*H; ++i) {
    cout << C[i] << endl;
  }
}

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

int main() {
  int N,A,B;
  cin >> N;
  B=0;
  
  for(int i=0;i<N;i++){
    cin >> A;
    if((i+1)%2==1&&A%2==1){B++;}
  }
  cout << B << endl;
}

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

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

    //min_time[i][j] i色のj回以下の回転数で最小のa
    vector<vector<long long>> min_time(n, vector<long long>(n));
    for (int i = 0; i < n; i++) {
        long long m = 1ll << 60;
        for (int j = 0; j < n; j++) {
            int r = (i - j + n) % n;
            m = min(m, a.at(r));
            min_time.at(i).at(j) = m;
        }
    }

    long long ans = 1ll << 60;
    for (int r = 0; r < n; r++) {
        long long sum = r * x;
        for (int i = 0; i < n; i++) {
            sum += min_time.at(i).at(r);
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 31616
#include <stdio.h>

int main (void)
{
    long long n,i;
    scanf("%lld",&n);
    char ketac[]="abcdefghijklmnopqrstuvwxyz",name[100];
    for(i=0;n>0;i++)
    {
        n--;
        name[i]=ketac[n%26];
        n/=26;
    }
    for(i--;i>=0;i--)
    {
        printf("%c",name[i]);
    }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 1644
#include <stdio.h>

int N,K,Q,C[100100];

int main()
{
  scanf ("%d %d %d",&N,&K,&Q);
  for (int i=0;i<Q;i++){
int x; scanf("%d",&x); C[x]++;
  }
  for (int i=1;i<=N;i++){
C[i] += K-Q;
    puts(C[i]>0?"Yes":"No");
  }

return 0;
}

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

using namespace std;

const int INF = 1 << 30;

int main() {
  int A, B;
  cin >> A >> B;
  int ret = 0;
  for(int i = A; i <= B; i++) {
    string s = to_string(i);
    string t = s;
    reverse(t.begin(), t.end());
    if(s == t) ++ret;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O2")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn = 2e5 + 555;
using ld = long double;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x;
	cin >> x;
	cout << "ABC" << x;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B;
    string s;
    cin >> A >> B >> s;
    if (s.at(A) != '-')
    {
        cout << "No" << endl;
        return 0;
    }
    rep(0, i, s.size())
    {
        if (i == A)
        {
            continue;
        }
        if (s.at(i) == '-')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
D, G = map(int, input().split())

p = [None] * D
c = [None] * D

for i in range(D):
    p_i, c_i = map(int, input().split())
    p[i] = p_i
    c[i] = c_i

cnt = 100000
for i in range(1 << D):
    num = -1
    score = 0
    cnt_ = 0
    for j in range(D):
        if (i >> j) % 2 == 1:
            score += p[j] * 100 * (j+1) + c[j]
            cnt_ += p[j]
        else:
            num = j
    if score >= G:
        cnt = min(cnt, cnt_)
    else:
        if num == -1:
            pass
        else:
            n = p[num]
            while n > 0:
                n -= 1
                score += (num+ 1) * 100
                cnt_ += 1
                if score >= G:
                    cnt = min(cnt, cnt_)
                    break
print(cnt)



Measured memory_bytes: 3188
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

bool isOK(string s,string t){
    rep(i,0,s.size()){
        if(s[i]!='?'&&s[i]!=t[i])return 0; 
    }
    return 1;
}

int main (){ 
    string s,t;
    cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    for(int i=s.size()-t.size();i>=0;i--){
        string temp=s.substr(i,t.size());
        if(isOK(temp,t)){
            rep(j,0,s.size()){
                if(j<i||i+t.size()<=j){
                    if(s[j]=='?')cout<<"a";
                    else cout<<s[j];
                }else {
                    cout<<t[j-i];
                }
            }
            cout<<endl;
            return 0;
        }
    }
    cout<<"UNRESTORABLE"<<endl;

    return 0;
}


/*
abcde


*/


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int n;

	if (scanf("%d\n", &n) == EOF)
		return -1;

	if (n < 2)
		return -1;

	int count = n;

	if (scanf("%d\n", &n) == EOF)
		return -1;

	int maxdiff = -2147483648;
	int minvalue = n;

	for (int i = 0; i < count - 1; i++)
	{
		if (scanf("%d", &n) == EOF)
			return -1;

		maxdiff = fmax(maxdiff, n - minvalue);
		minvalue = fmin(minvalue, n);
	}

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

	return 0;
}



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

using namespace std;

int main(){

    int N;
    cin >> N;

    long long a = 1, b = 1;
    for (int i = 0; i < N; i++){
        int A;
        cin >> A;

        a = a * 3;
        if (A % 2 == 0){
            b = b * 2;
        }

    }

    cout << a - b << endl;
    


    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    dict = {}
    for i in range(N):
        if S[i] not in dict:
            dict[S[i]] = 1
        else:
            dict[S[i]] += 1
    ans = {}
    p = 0
    for i ,j in dict.items():
        if p < j : p = j

        if j not in ans:
            ans[j] = [i]
        else:
            ans[j].append(i)
    ans[p].sort()
    for i in range(len(ans[p])):
        print(ans[p][i])
if __name__ == '__main__':
    main()


Measured memory_bytes: 35220
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;

	cout << max(0LL, b * (n-1) + a - (a * (n-1) + b) + 1 )<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int ans,n,d;
vector<int> cord[20005];
bool dis(int i,int j){
    double cur =0.0;
    for(int k = 0; k<d; k++){
        cur+=abs(cord[i][k]-cord[j][k]) *abs(cord[i][k]-cord[j][k]) ;
    }
    double res = sqrt(cur);
    int in = (int) res;
    if(res == in)return true;
    return false;

}
 main()
{
    cin>>n>>d;
    for(int i =0 ; i<n; i++){
        for(int j = 0; j<d; j++)
        {
            int x;
            cin>>x;
            cord[i].push_back(x);
        }
    }

    for(int i =0; i<n; i++){
        for(int j = i+1; j<n; j++){
            if(dis(i,j))ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 768
s = input()
if len(s)%2==1:
	letter,a,x,y = s[(len(s)-1)//2],(len(s)-1)//2,len(s),-1
	for i in range(a+1,len(s)):
		if letter != s[i]:
			x = i
			break
	for i in range(a-1,-1,-1):
		if letter != s[i]:
			y = i
			break
	print(min(x,len(s)-y-1))
else:
	if s[len(s)//2] != s[len(s)//2-1]: print(len(s)//2)
	else:
		letter,a,x,y = s[len(s)//2],len(s)//2,len(s),-1
		for i in range(a+1,len(s)):
			if letter != s[i]:
				x = i
				break
		for i in range(a-2,-1,-1):
			if letter != s[i]:
				y = i
				break
		print(min(x,len(s)-y-1))

Measured memory_bytes: 3316
import java.util.*;

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

        int d = a / b;
        int r = a % b;
        double f = (double)a / b;

        System.out.printf("%d %d %.5f\n", d, r, f);

    }
}



Measured memory_bytes: 26376
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  vector<int> cs(n);
  for(int i=0;i<n;i++) cin>>cs[i],cs[i]--;

  vector<vector<int>> G(n);
  for(int i=1;i<n;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  using ll = long long;
  ll all=0;
  vector<ll> cnt(n,0),sub(n,0);

  vector<ll> ans(n,(ll)n*(n-1)/2);
  MFP([&](auto dfs,int v,int p)->int{
    sub[v]=1;
    ll bfr=cnt[cs[v]];
    for(int u:G[v]){
      if(u==p) continue;
      ll pre=all-cnt[cs[v]];
      sub[v]+=dfs(u,v);
      ll nxt=all-cnt[cs[v]];
      ans[cs[v]]-=(nxt-pre)*(nxt-pre-1)/2;
    }
    cnt[cs[v]]=bfr+sub[v];
    all++;
    return sub[v];
  })(0,-1);

  for(int c=0;c<n;c++){
    ll pre=0,nxt=n-cnt[c];
    ans[c]-=(nxt-pre)*(nxt-pre-1)/2;
  }
  for(int c:cs) ans[c]++;

  for(ll a:ans) cout<<a<<newl;
  return 0;
}


Measured memory_bytes: 47744