akhauriyash/Code-Regression huggingface dataset:
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  cout << n * (n-1) / 2 + m * (m-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,y,s,i,j,max,p1,p2,p;
	
	while(scanf("%d %d %d",&x,&y,&s))
	{
		if(x==0 && y==0 && s==0)
		{
			break;
		}
		
		max = 0;
		
		for(i=1;i<1001;i++)
		{
			for(j=1;j<1001;j++)
			{
				p1 = i*(100+x)/100;
				p2 = j*(100+x)/100;
				p = p1 + p2;
				
				if(p==s)
				{
			    	p1 = i*(100+y)/100;
		    		p2 = j*(100+y)/100;
					p = p1 + p2;
					
				    if(p>=max) max = p;
				}
			}
		}
		
		printf("%d\n",max);
	}
	
	return 0;
}
		
				


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

int main(){
 long long A,B,C;
  cin>>A>>B;
  C=1;
  for(int i=0;i<100;i++){
    A*=2;
    if(A<=B){
C++;
    }
   else{
     break;
  }
  }
  cout<<C<<endl;
}


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

signed main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

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

  vector<pair<int, int>> p(n);
  for (int i = 0; i < n; ++i) 
    cin >> p[i].first >> p[i].second;
  
  sort(p.begin(), p.end());
  int ans = 0;

  long long dam[n + 5], sum = 0;
  memset(dam, 0, sizeof dam);

  for (int i = 0; i < n; ++i) {
    int x = p[i].first, h = p[i].second;
    int j = upper_bound(p.begin(), p.end(), make_pair(x + 2*d, (int)1e9+5)) - p.begin();
    sum += dam[i];

    long long cur = (h - sum + a - 1) / a;
    cur = max(0ll, cur);
    dam[j] -= a * cur; 
    sum += a * cur;
    ans += cur;
  }

  cout << ans << '\n';
}

Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 28 19:39:02 2019

@author: avina
"""

n = int(input())
l = list(map(int, input().split()))
b = list(map(int, input().split()))

w = 0
for i in range(n):
    if b[i] > l[i]:
        w+= l[i]
        a = b[i] - l[i]
        if a >= l[i+1]:
            w += l[i+1]
            l[i+1] = 0
        else:
            w+= a
            l[i+1] -=a
    else:
        w+=b[i]
print(w)

Measured memory_bytes: 18476
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF INT_MAX
using namespace std;
typedef pair<int, int>P;
typedef long long ll;

string buf;

int main() {
	cin >> buf;
	for (int i = 1; i < buf.length(); i++) {
		if (buf[i] == buf[i - 1]) {
			printf("%d %d\n", i, i + 1);
			return 0;
		}
		if (i < buf.length() - 1) {
			if (buf[i - 1] == buf[i + 1]) {
				printf("%d %d\n", i, i + 2);
				return 0;
			}
		}
	}
	puts("-1 -1");
	return 0;
}

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

int main() {
	int n;
	string s[100];
	bool f = 1;

	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> s[i];

	for(int i = 0; i < n-1; i++){
		if(s[i].back() != s[i + 1][0]){
			f = 0;
			break;
		}
	}

	if(f){
		for(int i = 0; i < n - 1; i++){
			for(int j = i + 1; j < n;j++){
				if(s[i] == s[j]){
					f = 0;
					break;
				}
			}
			if(!f)
				break;
		}
	}

	if(f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;
#define ll long long int
vector<vector<ll>>v;
// map<pair<int,int>,int>mp;
// ll f(int c,int i){
//     if(i==v.size()) return 0;
//     if(mp.find({c,i})!=mp.end()) return mp[{c,i}];
//     ll x = 0;
//     ll ans = 0;
//     if(c == 1){
//         x = v[i][0];
//         ans =  x+max(f(2,i+1),f(3,i+1));
//         mp[{c,i}] = ans;
//         return ans;
//     }
//     else if(c == 2){
//         x = v[i][1];
//         ans = x+max(f(1,i+1),f(3,i+1));
//         mp[{c,i}] = ans;
//         return ans;
//     }
//     x = v[i][2];
//     ans = x+max(f(1,i+1),f(2,i+1));
//     mp[{c,i}] = ans;
//     return ans;
// }
ll KnapSack(ll val[], ll wt[], ll n, ll W) 
{ 
    // array to store final result 
    //dp[i] stores the profit with KnapSack capacity "i" 
    ll dp[W+1]; 
      
    //initially profit with 0 to W KnapSack capacity is 0 
    memset(dp, 0, sizeof(dp)); 
  
    // iterate through all items 
    for(int i=0; i < n; i++)  
        //traverse dp array from right to left 
        for(int j=W; j>=wt[i]; j--) 
            dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); 
    /*above line finds out maximum of  dp[j](excluding ith element value) 
      and val[i] + dp[j-wt[i]] (including ith element value and the 
      profit with "KnapSack capacity - ith element weight") */    
    return dp[W]; 
}
int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n+2],b[n+2];
    ll s = 0;
    for(int i=0;i<n;i++){
        ll x,y,z;
        cin>>x>>y;
        a[i]=x;
        b[i]=y;
        s+=x;
        //cout<<a[i]<<"\n";
    }
    // vector<ll>f(k+2,0);
    // f[0]=0;
    // for(int j=0;j<n;j++){
    //     for(int i=a[j];i<=k;i++){
    //         f[i] = max(f[i],f[i-a[j]]+b[j]);
    //             //cout<<i<<"       "<<a[j]<<"   "<<b[j]<<"\n";
    //     }
    // }
    // for(int i=1;i<=k;i++){
    //     for(int j=1;j<=n;j++){
    //         if(i-a[j]>=0){
    //             f[i] = max(f[i],f[i-a[j]]+b[j]);
    //             cout<<i<<"       "<<a[j]<<"   "<<b[j]<<"\n";
    //         }
    //     }
    // }
    cout<<KnapSack(b,a,n,k);
    return 0;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int c[100],v[100];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (c[i] < v[i]){
            ans+=v[i] - c[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = []
for n in range(N):
    a.append(input().split())

sum_ = 0.0
for d in a:
    if d[1] == "JPY":
        sum_ += int(d[0])
    else:
        sum_ += float(d[0]) * 380000.0

print(sum_)


Measured memory_bytes: 2940
#include <iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	int n ;
	cin >> n;
	
	if (n <= 1199)cout << "ABC" << endl;
	else if (n >= 2800) cout << "AGC" << endl;
	else cout << "ARC" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
abcd = input().split()

a = float(abcd[0])
b = float(abcd[1])
c = float(abcd[2])
d = float(abcd[3])

t = math.ceil(a/d)
a = math.ceil(c/b)

if (t>=a):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9060
#include <stdio.h>

int main(){
	int i,price,a;
	while(1){
		scanf("%d",&a);
		if (a == -1) break;
		price = 1150;
		for(i=11;i<=a;i++){
			if(i>30) price += 160;
			else if(i<=20) price += 125;
			else price += 140;
		}
		printf("%d\n",4280-price);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

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

		Integer x = sc.nextInt();

		if (x < 600) {
			System.out.println(8);
		} else if (x < 800) {
			System.out.println(7);
		} else if (x < 1000) {
			System.out.println(6);
		} else if (x < 1200) {
			System.out.println(5);
		} else if (x < 1400) {
			System.out.println(4);
		} else if (x < 1600) {
			System.out.println(3);
		} else if (x < 1800) {
			System.out.println(2);
		} else if (x < 2000) {
			System.out.println(1);
		}
	}

}

Measured memory_bytes: 35784
#include <iostream>
#include<string>
#include<map>
#include<queue>
using namespace std;
map<string, int> sop;string s;
bool check(int mid)
{
	for (int i =1; i <= s.size() - mid+1; i++) {
		string op = s.substr(i-1, mid);
		if (sop[op])
		{
			if (i - sop[op] >= mid)
				return true;
		}
		else
			sop[op] = i;
	}
	return false;
}
int main()
{
	int n;
	cin >> n;
	cin >> s;
	int l = 0, r = n / 2;
	while (l < r) {
		int mid =(l + r + 1)/2;
		if (check(mid))
			l = mid;
		else
			r = mid - 1;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 70528
def solve(xy):
    ans = 0
    pos = [xy[0] for _ in range(4)]

    for p in xy:
        if pos[0][0] + pos[0][1] < p[0] + p[1]:
            pos[0] = p
        if pos[1][0] + pos[1][1] > p[0] + p[1]:
            pos[1] = p
        if pos[2][0] - pos[2][1] < p[0] - p[1]:
            pos[2] = p
        if pos[3][0] - pos[3][1] > p[0] - p[1]:
            pos[3] = p

    return max(pos[0][0]+pos[0][1]-pos[1][0]-pos[1][1], pos[2][0]-pos[2][1]-pos[3][0]+pos[3][1])


if __name__ == "__main__":
    N = int(input())
    xy = [list(map(int, input().split())) for _ in range(N)]
    print(solve(xy))


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

int main(){
  string str;
  cin >> str;
  reverse(str.begin(),str.end());
  vector<string> text = {"dream","dreamer","erase","eraser"};
  for(int i = 0; i < 4; i++){
    reverse(text.at(i).begin(),text.at(i).end());
  }
  
  bool can = true;
  for(int i = 0; i < str.size();){
    can = false;
    for(int j = 0; j < 4; j++){
      string d = text.at(j);
      if(str.substr(i,d.size()) == d){
        can = true;
        i += d.size();
      }
    }
    if(!can){
      break;
    }
  }
  if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}
  

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a,b;
    cin>>a>>b;
    if(a=='A'){
        if(b=='A'){
            cout<<'='<<endl;
        }
        else{
            cout<<'<'<<endl;
        }
    }
    if(a=='B'){
        if(b=='A'){
            cout<<'>'<<endl;
        }
        if(b=='B'){
            cout<<'='<<endl;
        }
        else{
            cout<<'<'<<endl;
        }
    }
    if(a=='C'){
        if(b=='A'||b=='B'){
            cout<<'>'<<endl;
        }
        if(b=='C'){
            cout<<'='<<endl;
        }
        else{
            cout<<'<'<<endl;
        }
    }
    if(a=='D'){
        if(b=='D'){
            cout<<'='<<endl;
        }
        if(b=='E'||b=='F'){
            cout<<'<'<<endl;
        }
        else{
            cout<<'>'<<endl;
        }
    }
    if(a=='E'){
        if(b=='E'){
            cout<<'='<<endl;
        }
        if(b=='F'){
            cout<<'<'<<endl;
        }
        else{
            cout<<'>'<<endl;
        }
    }
    if(a=='F'){
        if(b=='F'){
            cout<<'='<<endl;
        }
        else{
            cout<<'>'<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

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

  if(n%500<=a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import heapq
N = int(input())
a = list(map(int, input().split()))
a1 = a[:N]
a2 = [-x for x in a[2 * N:]]
sum1, sum2 = sum(a1), -sum(a2)
heapq.heapify(a1)
heapq.heapify(a2)
s1, s2 = [sum1], [sum2]
for i in range(N):
    heapq.heappush(a1, a[N + i])
    m = heapq.heappop(a1)
    if a[N + i] > m:
        sum1 += a[N + i] - m
    s1.append(sum1)
    heapq.heappush(a2, -a[2 * N - 1 - i])
    m = -heapq.heappop(a2)
    if a[2 * N - 1 - i] < m:
        sum2 += a[2 * N - 1 - i] - m
    s2.append(sum2)
ans = -float("inf")
for i in range(N + 1):
    if ans < s1[i] - s2[N - i]:
        ans = s1[i] - s2[N - i]
print(ans)

Measured memory_bytes: 121488
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
#define FORk(N) for(int k=0;k<N;++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  string S;
  cin>>S;
  ll stat = 0;
  ll b=-1;
  ll f=false;
  ll e=-1;
  ll num=0;
  FORi(S.size()){
    if(stat==0){
      if(b!=-1&&e!=-1){
        ll a=0;
        ll n=0;
        for(ll k=b;k<=e;){
          if(S[k]=='A'){
            a++;
            k+=1;
          }else{
            n+=a;
            k+=2;
          }
        }
        num+=n;
        //カウントする
        b=-1;
        e=-1;
      }
      if(S[i]=='A'){
        stat=1;
        b=i;
      }
    }else if(stat==1){//前がA　or ABC
      if(S[i]=='A'){
        continue;
      }else if(S[i]=='B'){
        stat=2;
      }else{//AC
        stat=0;
        //違うので終わり
      }
    }else if(stat==2){//前がAB
      if(S[i]=='C'){//ABC
        e=i;//ABC完成
        stat=1;//Bを待つ
      }else if(S[i]=='B'){//ABB
        //違う
        stat=0;
      }else{//AB Aのときこれを判定しなおす
        stat=0;
        i-=1;
      }
    }
  }
  
  
  if(b!=-1&&e!=-1){
    ll a=0;
    ll n=0;
    for(ll k=b;k<=e;){
      if(S[k]=='A'){
        a++;
        k+=1;
      }else{
        n+=a;
        k+=2;
      }
    }
    num+=n;
  }
  cout<<num<<endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<set>
using namespace std;
typedef long long ll;
int main(){
  set<ll> st;
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(st.find(a)==st.end()) {st.insert(a); ans++;}
    else{st.erase(a);ans--;}
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4864
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	long long n, m; cin >> n >> m;
	long long a = 0;
	if (n == 1 && m == 1) a = 1;
	//else if (n <= 2 && m <= 2) a = 0;
	//else if (n == 1 && m > 2) a = m - 2;
	//else if (m == 1 && n > 2) a = n - 2;
	else if (m == 1) a = n - 2;
	else if (n == 1) a = m - 2;
	else {
		a = (n - 2)*(m - 2);
	}
	cout << a << endl;
	return 0;
}

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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N;
    cin >> N;
    ll a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    ll ans=0;
    ll res=0;
    for(int i=0;i<N;i++){
        if(a[i]==0){
            ans+=res/2;
            res=0;
        }else{
            res+=a[i];
        }
    }
    ans+=res/2;
    cout << ans << endl;
}

Measured memory_bytes: 4388
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n = int(input())
    strn = str(n)
    for i in range(len(strn)):
        if strn[i] == '7':
            print("Yes")
            return
    print("No")
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 10404
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

answer = 0
(1...n).each do |i|
  if a[i] < a[i - 1]
    answer += a[i - 1] - a[i]
    a[i] = a[i - 1]
  end
end

puts answer

Measured memory_bytes: 30256
<?php 
  fscanf(STDIN, "%d %d",$N, $M);
  $N_img = ""; $M_img = "";
  $ans = "No";

  for($i=0;$i<$N;$i++){
   $N_img[$i] = str_split(trim(fgets(STDIN)));
  }
  for($j=0;$j<$M;$j++){
    $M_img[$j] = str_split(trim(fgets(STDIN)));
  }

	for($i=0;$i<=$N-$M;$i++){
       for($j=0;$j<=$N-$M;$j++){	
		
         $count = 0;

         for($k=0;$k<$M;$k++){
           for($l=0;$l<$M;$l++){
			if($N_img[$i+$k][$j+$l] == $M_img[$k][$l]){
              $count++;
            }
          } 
        }
         if($count == $M*$M) $ans = "Yes";
      }
    }

	echo $ans;
  
  ?>

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
stack<int> sta[3];
int d[101][101];
int a[101][101];
vii aa;
signed main()
{
    int n,m;
    cin >> n >> m;
    rep(i,0,n){
        rep(j,0,n){
            if(i==j)d[i][j]=0;
            else d[i][j]=INF;
        }
    }
    rep(i,0,m){
        int x,y,c;
        cin >> x >> y >> c;
        d[x-1][y-1]=c;
        a[x-1][y-1]=c;
        d[y-1][x-1]=c;
       // a[y-1][x-1]=c;
        aa.pb(mp(x-1,y-1));
    }
    rep(k,0,n){
        rep(i,0,n){
            rep(j,0,n){
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int ans=0;
    for(pii k : aa){
        int f = k.first;
        int s = k.second;
        if(d[f][s]!=a[f][s])ans++;
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

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

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	Node *cur = nil->next;
	int isf = 0;
	while(1){
		if( cur == nil ) break;
		if( isf++ > 0 ) cout << " ";
		cout << cur->key;
		cur = cur->next;
	}
	cout << endl;
}

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

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

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key,n,i;
	int size = 0;
	string com;
	int np = 0, nd = 0;
	cin >> n;
	init();
	for( i = 0; i < n; i++){
		cin >> com;
		if( com[0] == 'i' ) { 
			cin >> key;
			insert(key); np++; size++; 
		}
		else if( com[0] == 'd' ){
			if( com.length() > 6 ){
				if( com[6] == 'F' ) deleteFirst();
				else if( com[6] == 'L' ) deleteLast();
			} else {
				cin >> key;
				deleteKey(key); nd++;
			}
			size--;
		}
	}
	
	printList();
	
	return 0;
}


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

using namespace std;

int main()
{
    long long n;
    cin >> n;
    long double d[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> d[i];
    }
    long double dp[n + 1][n + 1];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        dp[0][i] = 0;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            if (j > 0)
            {
                dp[i][j] = dp[i - 1][j - 1] * d[i] + dp[i - 1][j] * (1 - d[i]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j] * (1 - d[i]);
            }
        }
    }
    long double ans = 0;
    for (int j = (n + 1) / 2; j <= n; j++)
    {
        ans += dp[n][j];
    }
    cout << setprecision(12) << ans << "\n";
    return 0;
}

Measured memory_bytes: 140928
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;

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

    vector<vector<int>> edge(N, vector<int>());
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;

        a--;
        b--;

        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    priority_queue<int> c;
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;

        c.push(n);
    }

    priority_queue < pair<int, int>> task;
    int target = 0;
    for (int i = 0; i < N; i++) {
        if (edge[i].size() > edge[target].size())
            target = i;
    }
    task.push(make_pair((int)edge[target].size(), target));

    const int init = -1;
    vector<int> node(N, init);
    int ans = 0;
    while (task.empty() != true) {
        auto p = task.top();
        task.pop();

        int index = p.second;
        node[index] = c.top();
        c.pop();

        for (int i = 0; i < (int)edge[index].size(); i++) {
            int dst = edge[index][i];
            if (node[dst] == init) {
                task.push(make_pair((int)edge[dst].size(), dst));
            }
            else{
                ans += node[index];
            }
        }
    }

    cout << ans << endl;
    for (int i = 0; i < N; i++)
        cout << node[i] << (i == N - 1 ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 1152
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next(),ans="";
    for(int i=0;i<s.length();i++){
      if(s.charAt(i) == '1'){
        ans+=9;
      }else{
        ans+=1;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22740
#include <stdio.h>
#include <string.h>

int main(){
  int a,b;
  char s[10];

  scanf("%d",&a);
  while(1){
    scanf("%s",s);
    if ( strcmp(s, "=") == 0 )break;
    scanf("%d",&b);
    if ( strcmp(s, "+") == 0 ) a+=b;
    if ( strcmp(s, "-") == 0 ) a-=b;
    if ( strcmp(s, "*") == 0 ) a*=b;
    if ( strcmp(s, "/") == 0 ) a/=b;
  }
  
  printf("%d\n",a);

  return 0;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x = 0;
    cin >> x;
    cout << (x ^ 1) << '\n';

    return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
vector<int> divisor(1000010);
int max_a;
void sieve(int m, int max_a){
    for(int i = 1 * m; i <= max_a; i += m){
        divisor[i]++;
    }
}


int main(){
    int n; cin >> n;
    map<int,int> mp;
    int max_a = 0;
    rep(i, n){
        int a; cin >> a;
        max_a = max(a, max_a);
        mp[a]++;
    }
    vector<bool> exist(max_a + 1, false);
    _rep(i, 1, max_a + 1) divisor[i] = 0;

    for(auto it : mp){
        exist[it.first] = true;
        if(it.second > 1) divisor[it.first]++; //2つ以上あるものはカウントされないようにする
        sieve(it.first, max_a);
    }
    int ans = 0;
    for(auto it : mp){
        if(exist[it.first] and divisor[it.first] == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 16648
n, k = map(int, input().split())
a = list(map(lambda x: int(x)-1, input().split()))

visited = [1] + [0]*(n-1)
idx = [0] + [-1]*(n-1)
route = [0]
while True:
    now = a[route[-1]]
    if visited[now]:
        break
    visited[now] = 1
    idx[now] = len(route)
    route.append(now)

border = idx[a[route[-1]]]
non_loop = route[:border]
loop = route[border:]

print(non_loop[k]+1) if k < len(non_loop) else print(loop[(k-len(non_loop))%len(loop)]+1)


Measured memory_bytes: 32308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll h, r;
  cin >> h >> r;
  if (h+r < 0) {
    cout << -1 << endl;
  } else if (h+r == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 3112
import java.util.Scanner;

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

        int a, b;
        a = scanner.nextInt();
        b = scanner.nextInt();
        if(b % a == 0){
            System.out.println(a + b);
        }
        else{
            System.out.println(b - a);
        }
    }
}

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

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
// clang-format off
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
#ifdef DEBUG
#if !defined(DEBUG_OUT)
// #define DEBUG_OUT cerr
#endif
#define dump(...) [&](){auto __debug_tap=make_tuple(__VA_ARGS__);DEBUG_OUT<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<__debug_tap<<"\n";}()
template < class T > inline void dump2D(T &d, size_t sizey, size_t sizex) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << "\t"; for(size_t j = 0; j < sizex; j++) DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t"); DEBUG_OUT << endl; } }
template < class T, class = typename iterator_traits< typename T::iterator >::value_type > ostream &operator<<(ostream &o, const T &a) { o << "{"; for(auto ite = a.begin(); ite != a.end(); ++ite) o << (ite == a.begin() ? "" : ", ") << *ite; o << "}"; return o; }
#else
#define dump(...) (42)
#define dump2D(...) (42)
template < class T, class = typename iterator_traits< typename T::iterator >::value_type > ostream &operator<<(ostream &o, const T &a) { for(auto ite = a.begin(); ite != a.end(); ++ite) o << (ite == a.begin() ? "" : " ") << *ite; return o; }
#endif
// clang-format on
// }}}


int n;
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  vector<int> a(n);
  for(auto &e:a) cin >> e;
  vector<pair<ll, ll>> bestL(n), bestR(n);
  {
    int head = 1;
    ll sum = a[0] + a[1];
    ll tmp = a[0];
    for(int c = 2; c < n; c++) {
      while(head < n && head < c - 1 && abs(sum - tmp - tmp) > abs(sum - (tmp + a[head]) - (tmp + a[head]))) tmp += a[head++];
      bestL[c] = make_pair(tmp, sum - tmp);
      sum += a[c];
      // dump(c, tmp, sum - tmp);
    }
  }
  {
    int head = n-2;
    ll sum = a[n-1];
    ll tmp = a[n-1];
    for(int c = n-2; c >= 0; c--) {
      sum += a[c];
      while(head >= 0 && head > c && abs(sum - tmp - tmp) > abs(sum - (tmp + a[head]) - (tmp + a[head]))) tmp += a[head--];
      bestR[c] = make_pair(tmp, sum - tmp);
      // dump(c, tmp, sum - tmp);
    }
  }
  ll ans = 1e18;
  for(int c = 2; c < n - 1; c++) {
    vector<ll> x(4), y(4);
    tie(x[0], x[1]) = bestL[c];
    tie(x[2], x[3]) = bestR[c];
    iota(begin(y), end(y), 0);
    ll res = 0;
    do {
      res = max(res, abs(x[y[0]] - x[y[1]]));
    } while(next_permutation(begin(y), end(y)));
    // dump(c, res, x);
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<int> p;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		p.push_back(x);
	}
	sort(p.begin(), p.end());
	int c1 = 0, c2 = 0, c3 = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] <= a) {
			c1++;
		} else
		if (p[i] <= b) {
			c2++;
		} else {
			c3++;
		}
	}
	cout << min(c1, min(c2, c3)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

long long sumofxorunderA(long long a)
{
    int a4 = a % 4;
    if (a4 == 0)
    {
        return a;
    }
    else if (a4 == 1)
    {
        return 1;
    }
    else if (a4 == 2)
    {
        return a+1;
    }
    else
    {
        return 0;
    }
}
int main()
{
    long long A, B;
    cin >> A >> B;
    long long ans =sumofxorunderA(A-1) ^ sumofxorunderA(B);
    cout << ans<< endl;
}

Measured memory_bytes: 256
#define  REP(i, s, e) for(register int i = s; i <= e ;i++)
#define DREP(i, s, e) for(register int i = s; i >= e ;i--)

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <bitset>
#include <vector>
#include <queue>
#include <cmath>
#include <map>

using namespace std;

template <typename T> T read() {
	T ans(0), p(1);
	char c = getchar();
	while (!isdigit(c)) {
		if (c == '-') p = -1;
		c = getchar();
	}
	while (isdigit(c)) {
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * p;
}

int m, n, k;

int main() {
#ifdef CraZYali
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	string s;
	cin >> s;
	n = s.size()-1;
	n -= 8;
	REP(i, 0, n)
		cout << s[i];

	return 0;
}


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

char field[101][101];
bool check[101][101];

void tile(int x,int y) {
  if(check[y][x]) {
    check[y][x] = false;
  }
  else {
    cout << "LOOP" << endl;
    return;
  }

  if(field[y][x] == '>') {
    tile(x+1,y);
  }
  else if(field[y][x] == '<') {
    tile(x-1,y);
  }
  else if(field[y][x] == '^') {
    tile(x,y-1);
  }
  else if(field[y][x] == 'v') {
    tile(x,y+1);
  }
  else if(field[y][x] == '.') {
    cout << x << " " << y << endl;
    return;
  }
}

int main() {
  int W,H;
  string str;
  while(cin >> W >> H) {
    if(W==0 && H==0) break;
    getline(cin,str);//kill \n
    for(int i=0;i<W;i++) {
      getline(cin,str);
      for(int j=0;j<H;j++) {
        field[i][j] = *str.substr(j,1).c_str();
        check[i][j] = true;
      }
    }
    tile(0,0);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;
const int mo = 1e9 + 7;

int n;
vector<vector<int> > g;

pair<long long, long long> dfs(int u, int p) {
    long long a = 1, b = 1;

    for (int i = 0; i < g[u].size(); ++i) {
        int v = g[u][i];
        if (v != p) {
            pair<int, int> cur = dfs(v, u);
            a = a * ((cur.first + cur.second) % mo) % mo;
            b = b * cur.first % mo;
        }
    }

    return make_pair(a, b);
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n;
    g = vector<vector<int> >(n);

    for (int i = 0; i < n-1; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;

        g[x].push_back(y);
        g[y].push_back(x);
    }
    
    pair<long long, long long> ans = dfs(0, -1);
    cout << (ans.first + ans.second) % mo << endl;
	return 0;
}

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

using ll = long long;

constexpr ll inf = 1e18;

int main() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }

    vector<ll> cost(1 << n);
    for(int S = 0; S < (1 << n); ++S) {
        for(int i = 0; i < n; ++i) {
            if(!(S & (1 << i))) continue;
            for(int j = i + 1; j < n; ++j) {
                if(!(S & (1 << j))) continue;
                cost[S] += a[i][j];
            }
        }
    }

    vector<ll> dp(1 << n, -inf);
    dp[0] = 0;
    for(int S = 0; S < (1 << n); ++S) {
        const int mask = ((1 << n) - 1) - S;
        for(int T = mask; T > 0; T = (T - 1) & mask) {
            dp[S | T] = max(dp[S | T], dp[S] + cost[T]);
        }
    }
    cout << dp.back() << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=a;i<=b;i++)
#define For(i,a,b) for (register int i=a;i>=b;i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
using namespace std;
typedef long long ll;
const int N=2e6+5;
int n,a[N],tag=0,ans[N],b[N];
int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	n=read();
	FOR(i,1,n) a[i]=read();
	For(i,n,1)
	{
		int tmp=0;
		for (int j=i*2;j<=n;j+=i)
			tmp+=b[j];
		tmp%=2;
		if (a[i]==tmp) b[i]=0;
		else b[i]=1;
	}
	FOR(i,1,n) if (b[i]) ans[++ans[0]]=i;
	printf("%d\n",ans[0]);
	FOR(i,1,ans[0]) printf("%d ",ans[i]);
	return 0;
}

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

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if(abs(A - B) > 1e18) cout << "Unfair" << endl;
  else{
    if(K % 2 == 0) cout << A - B;
    else cout << B - A;
  }
}


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

class B
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var ABC = Enumerable.Range(0, 3).Select(i => Console.ReadLine()).ToList();
        Console.WriteLine(Enumerable.Range(0, N).Sum(i => {
            var eq = Enumerable.Range(0, 3).Count(j => ABC[j][i] == ABC[(j + 1) % 3][i]);
            return eq == 0 ? 2 : eq == 1 ? 1 : 0;
        }));
    }
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }
  for(int i = K; i < N; i++){
    if(p[i-K] < p[i]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3984
#include <iostream>
#include <algorithm>
#include <tuple>
#include <cstring>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> piii;

int uf[100000];
int root(int i) { return (uf[i] < 0 ? i : uf[i] = root(uf[i])); }
void merge(int i, int j) {
    if((i = root(i)) == (j = root(j))) return ;
    if(uf[i] < uf[j]) swap(i, j);
    uf[j] += uf[i];
    uf[i] = j;
    return ;
}

piii A[100000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    memset(uf, -1, sizeof uf);
    int n; cin >> n;
    int u, v;
    for(int i = 0; i < n; ++i) {
        cin >> u >> v;
        A[i] = piii(u, v, i);
    }
    
    sort(A, A + n);
    vector <piii> vex;
    ll mx = 0;
    for(int i = 1; i < n; ++i) {
        int i1, _, h1, i2, __, h2;
        tie(i1, _, h1) = A[i - 1];
        tie(i2, __, h2) = A[i];
        vex.emplace_back(i2 - i1, h1, h2);
    }

    sort(A, A + n, [](piii x, piii y) -> bool {
        int x1, x2, _1, _2, y1, y2;
        tie(x1, x2, _1) = x;
        tie(y1, y2, _2) = y;
        return x2 < y2;
    });
    
    
    for(int i = 1; i < n; ++i) {
        int _, __, i1, i2, h1, h2;
        tie(_, i1, h1) = A[i - 1];
        tie(__, i2, h2) = A[i];
        vex.emplace_back(i2 - i1, h1, h2);
    }
    
    sort(vex.begin(), vex.end());
    for(piii pix : vex) {
        int i, j, h;
        tie(h, i, j) = pix;
        if(root(i) != root(j)) {
            mx += h;
            merge(i, j);
        }
    }
    
    cout << mx;
    
    
    return 0;
}


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

int main () {
  int n,m,l,matrix_A[100][100]={ 0 },matrix_B[100][100]={ 0 };
  long matrix_C[101][101]={ 0 };
  cin >> n >> m >> l;

  for (int i=0;i<n;++i) {
    for (int j=0;j<m;++j) {
    cin >> matrix_A[i][j];
	}
  }

  for (int i=0;i<m;++i) {
    for (int j=0;j<l;++j) {
	  cin >> matrix_B[i][j];
	}
  }
  for (int i=0;i<n;++i) {
    for (int j=0;j<l;++j) {
      for (int k=0;k<m;++k) {
        matrix_C[i][j] += matrix_A[i][k] * matrix_B[k][j];
      }
	  ( j != l - 1) ? cout << matrix_C[i][j] << " " : cout << matrix_C[i][j] << endl;
	}
  }
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    long long x; cin >> x;
    vector<long long> v(n+1, 1), p(n+1, 1);
    for (int i = 0; i < n; ++i) {
        v[i+1] += v[i] * 2 + 2;
        p[i+1] += p[i] * 2;
    }
    long long ans = 0;
    while (x > 0 && n > 0) {
        x -= 1;
        if (x > v[n-1]) {
            ans += 1 + p[n-1];
            x -= v[n-1] + 1;
        }
        if (x >= v[n-1]) {
            ans += p[n-1];
            break;
        }
        n--;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,Q = map(int,readline().split())
ABPX = list(map(int,read().split()))
AB = iter(ABPX[:N+N-2])
PX = iter(ABPX[N+N-2:])

graph = [[] for _ in range(N+1)]
for a,b in zip(AB,AB):
    graph[a].append(b)
    graph[b].append(a)

val = [0] * (N+1)
for p,x in zip(PX,PX):
    val[p] += x

stack = [1]

parent = [0] * (N+1)
while stack:
    x = stack.pop()
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        val[y] += val[x]
print(*val[1:])

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

int main() {
    string s,t;
    cin>>s;
    cin>>t;
    int ans=0;
    for(int i=0;i<3;i++) {
        if(s[i]==t[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int i,count0,count1;
  string S,s;

  cin>>S;
  s=S;
  count0=0;
  count1=0;
  if(S.at(0)=='1')
  count0++;
  s.at(0)='0';

  for(i=1;i<s.size();i++){
    if(s.at(i-1)==s.at(i)){
      if(s.at(i-1)=='0')
      s.at(i)='1';
      else
      s.at(i)='0';
      count0++;
    }
  }

  s=S;
  if(S.at(0)=='0')
  count1++;
  s.at(0)='1';
  for(i=1;i<s.size();i++){
    if(s.at(i-1)==s.at(i)){
      if(s.at(i-1)=='0')
      s.at(i)='1';
      else
      s.at(i)='0';
      count1++;
    }
  }


  cout<<min(count0,count1)<<endl;
}


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

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

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

    return arr

import collections
def smallest_prime_factors(n):

    spf = [[] for _ in range(n+1)]
    for i in range(n+1):
        spf[i] = i
    i = 2
    while i*i <= n:
        if spf[i] == i:
            for j in range(i*i, n+1, i):
                if spf[j] == j:
                    spf[j] = i
        i += 1

    return spf

def factolization(x,spf):
    ret = []
    while (x != 1):
        ix = int(x)
        ret.append(spf[ix])
        x /= spf[ix]
    return sorted(ret)


import sys
# x,y = map(int,input().split())
n = int(input())
ans = 0
facts = factorization(n)
if n == 1:
    pass
else:
    for fact in facts:
        beki = fact[1]
        b = 1
        while b <= beki:
            beki -= b
            b += 1
            ans += 1
print(ans)

Measured memory_bytes: 9728
n,k=map(int,input().split())
a=list(map(int,input().split()))
l,r=10**9,0
while l-r>1:
    t=(l+r)//2
    if sum((i-1)//t for i in a)>k:
        r=t
    else:
        l=t
print(l)

Measured memory_bytes: 30848
#include<bits/stdc++.h>
        #define F first
        #define S second
        using ll = long long;
        const ll mod = 1000000007;
        const ll infi = 1000000000000000;
        const ll md = 998244353;
        using namespace std;
        using vl = vector<ll>;
        using pll =  pair<ll,ll>;
      
        
        void  solve(){
            int n;
            cin>>n;
          string s,t;
          cin>>s>>t;
          for(int i=0;i<n;i++){
              cout<<s[i]<<t[i];
          }
        }
      
        int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            
            solve();
            
            return 0;
        }

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

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

int main() {

    int a, b;
    scanf("%d %d", &a, &b);

    int n = b - a;
    int c = n * (1 + n) / 2;

    printf("%d\n", c - b);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char a [100][101] , b [102][102];
int main(){
int H , W ; cin >> H >> W ;
for ( int i = 0; i < H ; i ++)
          scanf ("%s" , a[ i ]);
for ( int i = 0; i < H + 2; i ++){
     for ( int j = 0; j < W + 2; j ++)
b [ i ][ j ] = '#';}

for ( int i = 0; i < H ; i ++)
      for ( int j = 0; j < W ; j ++)
          b [ i + 1][ j + 1] = a [ i ][ j ];
for ( int i = 0; i < H + 2; i ++) {
        for ( int j = 0; j < W + 2; j ++)
               cout << b [ i ][ j ];
      cout << endl ;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
 int n; cin>>n;
 //２つ最大値があれば十分
 int a[n];
 int max_a=0, max_a2=0,max_i=0;
 REP(i,n){
     cin>>a[i];
     if (a[i]>max_a){
         max_a=a[i];
         max_i=i;
     }else if(a[i]>max_a2){
         max_a2=a[i];
     }
     }
 REP(i,n){
     if(i==max_i)cout<< max_a2<<endl;
     else cout<<max_a<<endl;
 }
}

Measured memory_bytes: 2432
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A;
  in<string> Ss;
  
  vector<string> ss;
  string S = Ss;
  
  int r = 0;
  auto it = -1;
  
  do {
    it = S.find("ABC", it+1);
    r++;
  }while (it != string::npos);


  return r-1;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}




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

const int maxn = 303;
const LL seed = 1e9 + 7, mod = 1e9 + 9;
int n;
char s[maxn][maxn], fs[maxn][maxn];

LL sum[maxn][maxn], fsum[maxn][maxn],  pw[maxn], t[maxn], tt[maxn], inv[maxn];

void Hash()
{
    pw[0] = 1LL;
    for(int i = 1; i <= n; i ++)
        pw[i] = (pw[i - 1] * seed) % mod;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            sum[i][j] = (sum[i][j - 1] * seed + s[i][j] - 'a') % mod;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            fsum[i][j] = (fsum[i][j - 1] * seed + fs[i][j] - 'a') % mod;
}

LL getsum(int row, int L, int R)
{
    if(L > R)
        return 0LL;
    return (sum[row][R] - sum[row][L - 1] * pw[R - L + 1] % mod + mod) % mod;
}

LL getfsum(int row, int L, int R)
{
    if(L > R)
        return 0LL;
    return (fsum[row][R] - fsum[row][L - 1] * pw[R - L + 1] % mod + mod) % mod;
}


bool check(int A, int B)
{
    for(int i = 1; i <= n; i ++) {
        int nxt = ((i - 1) + A) % n + 1;
        t[nxt] = (getsum(i, 1, n - B) % mod + getsum(i, n - B + 1, n) * pw[n - B]) % mod;
    }

    for(int i = 1; i <= n; i ++) {
        int nxt = ((i - 1) + B) % n + 1;
        tt[nxt] = (getfsum(i, 1, n - A) % mod + getfsum(i, n - A + 1, n) * pw[n - A]) % mod;
    }


    for(int i = 1; i <= n; i ++)
        if(t[i] != tt[i])
            return false;
    return true;
}

int main()
{
    scanf("%d", &n);
    getchar();

    for(int i = 1; i <= n; i ++)
        scanf("%s", s[i] + 1);

    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            fs[i][j] = s[j][i];

    Hash();
    int ans = 0;
    for(int i = 0; i < n; i ++) {
        for(int j = 0; j < n; j ++) {
            if(check(i, j))
                ans ++;
        }
    }

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


Measured memory_bytes: 1920
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type,
less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;

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

const ll p = 1e7 + 7;
const int N = 5e3 + 1e2;
const ll MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

ll h[N], po[N];

ll mult(ll a, ll b) {
    return (a % MOD) * (b % MOD) % MOD;
}

void calc(string s) {
    for (int i = 0; i < sz(s); ++i) 
        h[i] = ((i ? h[i - 1] : 0ll) * p + s[i]) % MOD;
    po[0] = 1ll;
    for (int i = 1; i <= sz(s); ++i)
        po[i] = mult(po[i - 1], p);
}

ll get(int l, int r) {
    if (!l)
        return h[r];
    return (h[r] - mult(h[l - 1], po[r-l+1]) + MOD) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    calc(s);
    int l = 1;
    int r = n / 2;
    int ans = 0;
    while (l <= r) {
        int m = l + r >> 1;
        bool ok = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i + m; j <= n - m; ++j) 
                if (get(i, i+m-1) == get(j, j+m-1)) {
                    ok = 1;
                    break;
                }            
            if (ok)
                break;
        }
        if (ok) { 
            ans = m;
            l = m + 1;
        } else 
            r = m - 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 512