akhauriyash/Code-Regression huggingface dataset:
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,t,y=100000000000,m,w;
    	cin>>n>>k;
    	ll a[n];
    	ll b[n];
    	for(i=0;i<n;i++)
    	{
    		cin>>a[i]>>b[i];
		}
		ll dp[n+1][k+1];
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=k;j++)
			{
				if(i==0||j==0)
				dp[i][j]=0;
				else if(j>=a[i-1])
					dp[i][j]=max(dp[i-1][j-a[i-1]]+b[i-1],dp[i-1][j]);
				else
					dp[i][j]=dp[i-1][j];
				}
			}
		cout<<dp[n][k];
	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

Measured memory_bytes: 82400
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, x, t, cnt1 = 0, cnt2 = 0;
    scanf("%d %d %d", &n, &m, &x);
    n += 1;
    vi nvi(n, 0);
    rep(i, 0, m)
    {
        scanf("%d", &t);
        nvi[t] = 1;
    }
    rep(i, 0, x)
    {
        cnt1 += nvi[i];
    }
    rep(i, x, n)
    {
        cnt2 += nvi[i];
    }
    printf("%d",min(cnt1,cnt2));
    return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    int N;
    cin>>N;
    if(N/10==9||N%10==9) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <math.h>

using namespace std;

int main()
{
/*	int a, b, c, d, e;
	std::cin >> a >> b >> c >> d >> e;
	*/

	long long int N;
	std::cin >> N;
	long long int num[5];

	for (int i = 0; i < 5; i++) {
		std::cin >> num[i];
	}

	//最小出す
	long long int num_min = 99999999999999999;
	for (int i = 0; i < 5; i++) {
		if (num_min > num[i]) {
			num_min = num[i];
		}
		else {
		}
	}

	long long int time;

	time = N / num_min;
	if (N%num_min != 0) {
		time = time + 1;
	}

	time = time + 4;

	std::cout << time << endl;

}

Measured memory_bytes: 256
N, M = map(int, input().split())
lst = []
for _ in range(N):
    A, B = map(int, input().split())
    lst.append([A, -B])
lst.sort()

ans = 0
index = 0
import heapq
hq = []
for i in range(M):
    while index < N and lst[index][0] <= i + 1:
        heapq.heappush(hq, lst[index][1])
        index += 1
    if len(hq) > 0:
        ans -= heapq.heappop(hq)
    # print ('ans, i', ans, i)
print (ans)

    


Measured memory_bytes: 73944
import java.util.Scanner


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val c = sc.next()(0)
    c
  }

  def solve(c:Char): Char = {
    c match{
      case 'A' => 'T'
      case 'T' => 'A'
      case 'G' => 'C'
      case 'C' => 'G'
      case _ => 'X'
    }
  }


  def main(args: Array[String]): Unit = {
    val c = read()
    println(solve(c))
  }
}

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

int main() {
  vector<int> A(5);
  cin >> A.at(0) >> A.at(1) >> A.at(2) >> A.at(3) >> A.at(4);
  vector<int> index = {0, 1, 2, 3, 4};
  int besttime = 1000000000;
  do {
    int nowtime = 0;
    for (int i = 0; i < 5; i++) {
      while(nowtime %  10 != 0) nowtime++;
      nowtime += A.at(index.at(i));
    }
    besttime = min(besttime, nowtime);
  } while (next_permutation(index.begin(), index.end()));
  cout << besttime << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int n = Integer.valueOf(line.split(" ")[0]);
		int q = Integer.valueOf(line.split(" ")[1]);
		
		int[] array = new int[n];
		Arrays.fill(array, 0);
		for(int i = 0; i < q; i++){
			String query = sc.nextLine();
			int command = Integer.valueOf(query.split(" ")[0]);
			int x = Integer.valueOf(query.split(" ")[1]);
			int y = Integer.valueOf(query.split(" ")[2]);
			switch(command){
				case 0:
					add(array, x, y);
					break;
				case 1:
					System.out.println(sum(array, x, y));
					break;
			}
		}
		sc.close();
	}
	
	static void add(int[] array, int index, int x){
		array[index-1] += x;
	}
	
	static int sum(int[] array, int from, int to){
		int result = 0;
		for(int i = from-1; i <= to-1; i++){
			result += array[i];
		}
		return result;
	}
}

Measured memory_bytes: 165116
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// Priority Queue
// Item :
type Item struct {
	priority, value, index int
}

// PQ :
type PQ []*Item

// Len :
func (pq PQ) Len() int {
	return len(pq)
}

// Less :
func (pq PQ) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

// Swap :
func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

// Push :
func (pq *PQ) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

// Pop :
func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1
	*pq = old[0 : n-1]
	return item
}

// End Priority Queue

// Edge :
type Edge struct {
	to, cost int
}

// Path :
type Path struct {
	edges []Edge
}

// Route :
type Route struct {
	path []int
}

// Dijkstra :
func Dijkstra(N, S int, path []Path) ([]int, []Route) {
	pq := make(PQ, 0)
	heap.Init(&pq)
	d := make([]int, N+1)
	r := make([]Route, N+1)
	// init
	for i := 0; i <= N; i++ {
		d[i] = math.MaxInt32
	}
	d[S] = 0
	r[S].path = []int{S}
	heap.Push(&pq, &Item{0, S, 0})
	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		v := item.value
		if d[v] < item.priority {
			continue
		}
		for _, e := range path[v].edges {
			if d[e.to] > d[v]+e.cost {
				d[e.to] = d[v] + e.cost
				r[e.to].path = make([]int, len(r[v].path))
				copy(r[e.to].path, r[v].path)
				r[e.to].path = append(r[e.to].path, e.to)
				heap.Push(&pq, &Item{d[e.to], e.to, 0})
			}
		}
	}
	return d, r

}

type pair struct {
	x, y int
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()
	path := make([]Path, N)
	e := make(map[pair]int)
	for i := 0; i < M; i++ {
		f, t, c := getInt()-1, getInt()-1, getInt()
		path[f].edges = append(path[f].edges, Edge{t, c})
		path[t].edges = append(path[t].edges, Edge{f, c})
		if f > t {
			e[pair{t, f}] = 0
		} else {
			e[pair{f, t}] = 0
		}
	}

	for i := 0; i < N; i++ {
		_, r := Dijkstra(N, i, path)
		for _, v := range r {
			if len(v.path) <= 1 {
				continue
			}
			p := v.path
			for j := 1; j < len(p); j++ {
				if p[j-1] > p[j] {
					e[pair{p[j], p[j-1]}]++
				} else {
					e[pair{p[j-1], p[j]}]++
				}
			}
		}
	}
	ans := 0
	for _, v := range e {
		if v == 0 {
			ans++
		}
	}
	out(ans)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
vector<vector<vector<P> > >v;
int dp[51][51][51][51];
string s[51];
int h,w;
int dfs(int ly,int lx,int ry,int rx){

  int res=-1e7;

  if(ly<0||ry<0||ly>=h||ry>=h)return -1e7;
  if(lx<0||rx<0||lx>=w||rx>=w)return -1e7;
  if(s[ly][lx]=='#'||s[ry][rx]=='#')return -1e7;
  if(ly==ry&&lx==rx)return dp[ly][lx][ry][rx]=0;
  if(ly==ry&&lx==rx+1)return dp[ly][lx][ry][rx]=0;
  if(ly==ry+1&&lx==rx)return dp[ly][lx][ry][rx]=0;
  if(ly==ry+1&&lx==rx+1)return dp[ly][lx][ry][rx]=0;
  if(ly>ry||lx>rx)return -1e7;
  if(dp[ly][lx][ry][rx]!=-1e8)return dp[ly][lx][ry][rx];

  res=max(res,dfs(ly+1,lx,ry,rx));
  res=max(res,dfs(ly,lx+1,ry,rx));
  res=max(res,dfs(ly,lx,ry-1,rx));
  res=max(res,dfs(ly,lx,ry,rx-1));

  if(islower(s[ly][lx])){

    if(isupper(s[ry][rx])&&s[ly][lx]==tolower(s[ry][rx])){
      res=max(res,dfs(ly+1,lx,ry-1,rx)+1);
      res=max(res,dfs(ly,lx+1,ry-1,rx)+1);
      res=max(res,dfs(ly+1,lx,ry,rx-1)+1);
      res=max(res,dfs(ly,lx+1,ry,rx-1)+1);
    }

    else r(i,v[ly][lx].size()){
      int y=v[ly][lx][i].first;
      int x=v[ly][lx][i].second;
      if(!(ly<=y&&y<=ry&&lx<=x&&x<=rx))continue;
      res=max(res,dfs(ly,lx,y,x)+dfs(y,x,ry,rx));
    }

  }

  return dp[ly][lx][ry][rx]=res;
}
int main(){
  while(cin>>h>>w,h){
    r(i,51)r(j,51)r(k,51)r(l,51)dp[i][j][k][l]=-1e8;
    v.clear();
    v.resize(h,vector<vector<P> >(w));
    r(i,h)cin>>s[i];
    r(i,h)r(j,w)r(y,h)r(x,w){
      if(i<=y&&j<=x){
        if(islower(s[i][j])&&isupper(s[y][x])){
          if(s[i][j]==tolower(s[y][x])){
            v[i][j].push_back(P(y,x));
          }
        }
      }
    }
    cout<<(dfs(0,0,h-1,w-1)<0?-1:dp[0][0][h-1][w-1])<<endl;
  }
}


Measured memory_bytes: 29680
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
int ans[200005];
int L[200005];
vector<int> adjlist[200005];
void dfs(int u, int p, int l){
    //printf("%d %d %d\n",u,p,l);
    int pos = lower_bound(L,L+l,a[u])-L;
    int temp = L[pos];
    L[pos] = a[u];
    if (pos == l) l++;
    ans[u] = l;
    for (auto v:  adjlist[u]){
        if (v == p) continue;
        dfs(v,u,l);
    }
    L[pos] = temp;
}
int main(){
    scanf("%d",&n);
    for (int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
    }
    for (int i = 1; i < n; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        adjlist[u].push_back(v);
        adjlist[v].push_back(u);
    }
    dfs(1,-1,0);
    for (int i = 1; i <= n; i++){
        printf("%d\n",ans[i]);
    }
}


Measured memory_bytes: 30600
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;


using ll=long long int;


int main() {

	int x;
	cin >> x;

	if (x == 3 || x == 5 || x == 7) {
		cout << "YES" << endl;
	}

	else {
		cout << "NO" << endl;
	}

	return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  char s[3];
  scanf("%s", &s);
  
  switch(s[0]){
    case 'S':
      switch(s[1]){
        case 'U':
      	printf("7");
      	break;
        case 'A':
        printf("1");
        break;
      }
      break;
    case   'M':
      printf("6");
      break;
    case   'T':
      switch(s[1]){
        case 'U':
	    printf("5");
      	break;
        case 'H':
        printf("3");
        break;
      }
      break;
    case   'W':
      printf("4");
      break;
    case   'F':
      printf("2");
      break;
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    if(n%10==3)cout<<"bon"<<endl;
    else if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon"<<endl;
    else cout<<"hon"<<endl;


    return 0;
}


Measured memory_bytes: 3648
while True:
    m, d = map(int, input().split())
    if m == d == 0:
        break
    dim = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
    ds = dim[m] + d -1
    print({0:'Thursday', 1:'Friday', 2:'Saturday', 3:'Sunday', 4:'Monday', 5:'Tuesday', 6:'Wednesday'}[ds % 7])

Measured memory_bytes: 7568
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>
#include<cmath>
#include <iomanip>

using namespace std;

int main(){
    int a = 0; cin >> a;
    double* x = (double*)malloc(sizeof(double)*a);
    double* y = (double*)malloc(sizeof(double)*a);
    for(int i = 0; i < a; i++){
        cin >> x[i];
        cin >> y[i];
    }
    double ans = 0;
    for(int pi = 1;pi < a; pi++){
        for(int j = 0;j < a - pi; j++){
            int i = j+pi;
            double l = sqrt(pow((x[i]-x[j]), 2)+pow((y[i]-y[j]),2));
            ans += (l*2)/a;
            //cout << l << endl;
        }
    }
    cout <<fixed;
    cout <<setprecision(6) << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    int ma=a[0]+a[1];
    for(int i=2;i<N;i++)
    {
        int t=a[i-2]+a[i-1]+a[i];
        if(t>ma)ma=t;
    }
    cout<<ma<<endl;
    return 0;
}



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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  
  int i = 1;
  int flag = 0;
  if( (a % b) != 0 ){
    while(i <= 100){
      if( ((a * i) % b) == c ){
        flag = 1;
        break;
      }
      i++;
    }//while
  }//if
  
  if(flag == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3588
#pragma GCC optimize("-O2")
#include<bits/stdc++.h>
#define int long long
#define vi vector<int> 
#define pb push_back
#define eb emplace_back
#define For(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define MAX 100005
#define endl '\n'
using namespace std;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	// freopen("output1.txt", "w", stdout);
	#endif
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int res=INT_MIN;
	res = max(a*d*1LL,a*c*1LL);
	res = max(res,b*c*1LL);
	res= max(res,b*d*1LL);
	cout<<res<<endl;
}

Measured memory_bytes: 3596
#pragma GCC optimize ("O3")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
typedef struct {
	int l, r;
} range;

int IniSize(int num) {
	// 要素数 num が収まるセグ木のサイズを返す
	int n = 1;
	while (n <= num)
		n <<= 1;
	return (n << 1) - 1;
}

void UpdateAdd(int pos, int n, vector<vector<int>>& d) {
	// 位置 pos(0-index) の値を n で更新する
	// セグ木のサイズは 2^n - 1
	int i = pos + (d.size() >> 1);
	d[i][n]++;
	while (i > 0) {
		i = (i - 1) >> 1;
		d[i][n]++;
	}
	return;
}

void UpdateSub(int pos, int n, vector<vector<int>>& d) {
	// 位置 pos(0-index) の値を n で更新する
	// セグ木のサイズは 2^n - 1
	int i = pos + (d.size() >> 1);
	d[i][n]--;
	while (i > 0) {
		i = (i - 1) >> 1;
		d[i][n]--;
	}
	return;
}

vector<int> Query(int pos, const range tag, range x, vector<vector<int>> &d) {
	if (tag.r <= x.l || x.r <= tag.l)
		return vector<int>(26, 0);
	if (tag.l <= x.l && x.r <= tag.r)
		return d[pos];
	int i;
	vector<int> a, b;
	a = Query((pos << 1) + 1, tag, { x.l, (x.l + x.r + 1) >> 1 }, d);
	b = Query((pos << 1) + 2, tag, { (x.l + x.r + 1) >> 1, x.r }, d);
	rep(i, a.size())
		a[i] += b[i];
	return a;
}

int main(void) {
	int num, i, j, m, n = 1, k, a, b, ans;
	string s, c;
	cin >> num >> s >> m;
	num = IniSize(num);
	vector<int> d;
	vector<vector<int>> st(num, vector<int>(26, 0));
	rep(i, s.size()) {
		UpdateAdd(i, s[i] - 'a', st);
	}
	rep(i, m) {
		cin >> k >> a;
		a--;
		if (k - 1) {
			cin >> b;
			d = Query(0, { a, b }, { 0, (num >> 1) + 1 }, st);
			ans = 0;
			rep(j, d.size()) {
				if (d[j])
					ans++;
			}
			cout << ans << "\n";
		}
		else {
			cin >> c;
			UpdateSub(a, s[a] - 'a', st);
			UpdateAdd(a, c[0] - 'a', st);
			s[a] = c[0];
		}
	}
	return 0;
}

Measured memory_bytes: 140036
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;
    rep(i, 0, s.size()-1)
        if (s[i] == s[i+1])
            score++;
    cout << min(n-1, score + 2*k);
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
using Graph = vector<vector<ll> >;
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; }
const ll INF = 1e18;

//input
ll r,c,K;
ll dp[3010][3010][5];
ll item[3010][3010];

int main(){
    cin >> r >> c >> K;
    rep(i,K){
        ll a,b,v;
        cin >> a >> b >> v;
        a--;b--;
        item[a][b]=v;
    }
    dp[0][0][1]=item[0][0];
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            for(int k=0;k<=3;k++){
                if(j>0)chmax(dp[i][j][k],dp[i][j-1][k]);
                if((j>0)&&(k>0))chmax(dp[i][j][k],dp[i][j-1][k-1]+item[i][j]);
                if(k==0&&i>0){
                    for(int pk=0;pk<=3;pk++){
                        chmax(dp[i][j][0],dp[i-1][j][pk]);
                        chmax(dp[i][j][1],dp[i-1][j][pk]+item[i][j]);
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int k=0;k<=3;k++){
        chmax(ans,dp[r-1][c-1][k]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 426840
#include <bits/stdc++.h>
using namespace std;
# define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define Mod 998244353
#define ha "YES"
#define na "NO"
#define sp " "
typedef long long ll;

void IO()
{
#ifndef ONLINE_JUDGE
	freopen("pracin.txt", "r", stdin);
	freopen("pracout.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	fast;
}
vector<bool> used;
vector<vector<int>> adj;
vector<int> dir[200005];
vector<int> a, b;
//bipartite graph or not using bfs

void bfs(int i)
{
	queue<int> q;
	q.push(i);
	used[i] = 1;
	a.push_back(i);
	while (!q.empty())
	{	i = q.front();
		q.pop();
		for (auto vertex : adj[i])
		{
			if (used[vertex] == -1)
			{
				used[vertex] = used[i] ^ 1;
				if (used[vertex] == 1) a.push_back(vertex);
				else b.push_back(vertex);
				q.push(vertex);
			}
			if (used[vertex] == used[i]) {
				cout << -1;
				exit(0);
			}

		}


	}
}
// binnary exponention (logn)
ll binary_exponention(ll a, ll b) {
	if (b == 0)
		return 1;
	ll res = binary_exponention(a, b / 2);
	if (b % 2)
		return res * res * a % Mod;

	return res * res % Mod;
}


// remember the question's fine details
// BE CAREFUL OF EDGE CASES....
// always check for edges cases
//  n == 1, n = size - 1, n is prime ,we



int dfs(vector<int> adj[], int n, vector<int> &dp, int i)
{
	if (dp[i] != -1 ) return dp[i];
	if (adj[i].size() == 0 ) return dp[i] = 0;
	int ans = 1;

	for (int j : adj[i])
	{
		int cur = 1;
		cur += dfs(adj, n, dp, j);
		ans = max(cur, ans);

	}

	return dp[i] = ans ;


}
void solve()
{


	int n, m; cin >> n >> m;
	vector<int> adj[n];
	while (m--)
	{
		int a, b; cin >> a >> b;
		adj[--a].push_back(--b);
	}


	vector<int> dp(n, -1);
	for (int i = 0; i < n; i++)
		dfs(adj, n, dp, i);

	cout << *max_element(all(dp));


}



int main()
{
	IO();

	// int t; cin >> t; while (t--)
	solve();
}

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

typedef long long ll;

ll N, K;
vector<ll> A, B;

int main() {
  cin >> N >> K;
  A.resize(N);
  B.resize(N + 1);
  for (ll &a : A) cin >> a;
  for (ll repeat = 0; repeat < K; ++repeat) {
    for (ll &b : B) b = 0;
    for (ll i = 0; i < N; ++i) {
      ++B[max(0ll, i - A[i])];
      --B[min(N, i + A[i] + 1)];
    }
    bool end = true;
    for (ll i = 0; i < N; ++i) {
      A[i] = B[i];
      if (i > 0) A[i] += A[i - 1];
      if (A[i] != N) end = false;
    }
    if (end) break;
  }
  for (ll i = 0; i < N; ++i) cout << (i == 0 ? "" : " ") << A[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 6404
//atcoder ABC 137 D题

#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

int n, m;
int a[100005];
pair <int, int> job[100005];
priority_queue <int> que;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, x, val; i <= n; ++i) {
		scanf("%d%d", &x, &val);
		job[i].fi = m - x + 1;
		job[i].se = val;
	}

	long long ans = 0;
	sort (job + 1, job + n + 1);
	for (int i = m, j = n; i; --i) {
		for (; j; --j) {
			if (job[j].fi < i) break;
			que.push(job[j].se);
		}
		if (!que.empty()) {
			ans += que.top();
			que.pop();
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1660
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    d = [0]*N
    for i in range(N-1):
        d[i] = abs(A[i+1] - A[i])
    d[-1] = A[0] + K - A[-1]
    print(K-max(d))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 26420
n_m,m_l,ans=[],[],[]

first_num=[int(w) for w in input().split()]

for w in range(first_num[0]):
    vector=[]
    for i in range(first_num[2]):
        vector.append(0)
    ans.append(vector)
        

for w in range(first_num[0]):
    n_m.append([int(i) for i in input().split()])

for w in range(first_num[1]):
    m_l.append([int(i) for i in input().split()])

for w in range(first_num[0]):
    for i in range(first_num[1]):
        for n in range(first_num[2]):
            ans[w][n]+=n_m[w][i]*m_l[i][n]
            
for w in range(first_num[0]):
    print(' '.join(map(str,ans[w])))    


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

int main() {
    int x;
    cin >> x;
    ll s = 0;
    int t = 0;
    while (s < x) {
        t++;
        s += t;
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
n, x = map(int,input().split())
A = list(map(int,input().split()))

ans = 0

for i in range(n-1):
    # print(A)
    if A[i] + A[i+1] > x:
        if A[i] <= x:
            ans += A[i+1] + A[i] - x
            A[i+1] = x-A[i]
        else:
            ans += A[i+1] + A[i] - x
            A[i] -= x-A[i+1]
            A[i+1] = 0

print(ans)

Measured memory_bytes: 63984
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <cmath>
#include <iterator>
#include <complex>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <utility>
#include <string>
#include <cassert>
#include <iomanip>
#include <cstdlib>
#include <numeric>

using namespace std;
typedef long long ll;
string ar[] = { "dream" , "dreamer", "erase" , "eraser"};
bool pos[100005];
bool getpos(int i, string& s)
{
	if(i==s.length())
		return pos[i]=true;
	pos[i] = false;
	int l = s.length();
	for(int id=0; id<4; id++)
	{
		int sl = ar[id].length();
		int j=0, k=i;
		while(k<l&&j<sl)
		{
			if(ar[id][j]!=s[k])
				break;
			j++;
			k++;
		}
		if(j==sl)
			pos[i] = pos[i] || getpos(k,s);
	}
	return pos[i];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	bool ps = getpos(0,s);
	if(ps)
		cout<<"YES\n";
	else
		cout<<"NO\n";
}

Measured memory_bytes: 2256
#!/usr/bin/env python3
#M-SOLUTIONS プロコンオープン D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
cnt = [0]*n
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    cnt[a-1] += 1
    cnt[b-1] += 1
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
c = LI()
m = sum(c) - max(c)
print(m)
d = [0]*n
for i in range(n):
    if cnt[i] == 1:
        d[i] = max(c)
        break
c.sort(reverse = True)
c = c[1:]
que = deque(c)
def dfs(x,p):
    for v in graph[x]:
        if v != p:
            if d[v] == 0:
                d[v] = que.popleft()
                dfs(v,x)
dfs(i,-1)
print(*d)


Measured memory_bytes: 52956
#import numpy as np
n,w=map(int,input().split())
#重さをdpにする
#dp=[[0]*n,[0]*w] #n番目の品,重さ。価値が値として入る
#dp=np.zeros((n+1,w+1))
dp=[[0] * (w+1) for i in range(n+1)]
#print(dp)
#print(len(dp[0]))
#print(len(dp[n][w]))
W=[]
V=[]
for i in range(n):
    a,b=map(int,input().split())
    W+=[a]
    V+=[b]

#print(dp[0][0])
#print(W)
for i in range(n):
    #print(i)
    for sum_w in range(w+1):
        #print(sum_w)
        #足した時に価値が上がるケース
        if sum_w>=W[i]:
            dp[i+1][sum_w]=max(dp[i][sum_w],dp[i][sum_w - W[i]] + V[i])
    
        #選ばない時
        else:
            dp[i+1][sum_w]=dp[i][sum_w]

#print(dp)
print(int(dp[n][w]))

Measured memory_bytes: 120300
s = input()
q = int(input())
turn = 0
# ともにSに近い方から並べる
before = "" 
after = ""
for _ in range(q):
    tmp = input()
    if tmp=="1":
        turn += 1
    else:
        _,f,c = tmp.split()
        f = int(f)
        if (turn + f) % 2 == 1:
            before += c
        else:
            after += c
if turn%2==0:
    out = before[::-1] + s + after
else:
    out = after[::-1] + s[::-1] + before
print(out)


Measured memory_bytes: 4340
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
	int i,j,k,l,m=0,n;
	scanf("%d",&n);
	while(n--){
		scanf("%d",&i);
		while(i%2==0){
			i/=2;
			m++;
		}
		
		
		
		
		
		
	}
	printf("%d",m);
		
		
		
		
return 0;
}

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

int f (int n) {
  int res = 1;
  while (res*res < n)
    res++;
  return res - 1;
}

//整数nが素数かどうか判定する
bool isPrime (int n) {
  bool res = true;
  for (int i = 2; i < f(n) + 1; i++) {
    if (n % i == 0) res = false;
  }
  return res;
}

int main () {
  int x;
  cin >> x;
  while (!isPrime(x))
    x++;
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
inData = str(input())
ansList = []
dataLen = len(inData)
zeroCnt = 0
oneCnt = 0
for i in range(0, dataLen):
    if inData[i] == '0':
        zeroCnt += 1
    else:
        oneCnt += 1

print(2 * min([zeroCnt, oneCnt]))

Measured memory_bytes: 3188
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
cnt = 0
for aa in a:
    for i in range(aa):
        if aa % 2 == 0:
            cnt += 1
            aa //= 2
        else:
            break
print(cnt)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int n, f, s[15][15], h, ans;
int main()
{
    scanf("%d %d", &n, &f);
    for (int i = 1, t = 0; i <= 11; i++)
        for (int j = 1; j <= 7; j++)
            t++, s[i][j] = t;
    for (int i = 1, t = 0; i <= 11; i++)
        for (int j = 1; j <= 5; j++, h += (t % 11 == f), t = 0)
            for (int k = 0; k < 3; k++)
                for (int l = 0; l < 3; l++)
                    t += s[(i + k - 1) % 11 + 1][j + l];
    ans += max(0, (n / 11 - 1)) * h;
    if (n / 11 > 0)
        n -= (n / 11 - 1) * 11;
    for (int i = 1, t = 0; i <= n - 2; i++)
        for (int j = 1; j <= 5; j++, ans += (t % 11 == f), t = 0)
            for (int k = 0; k < 3; k++)
                for (int l = 0; l < 3; l++)
                    t += s[(i + k - 1) % 11 + 1][j + l];
    return printf("%d\n", ans), 0;
}

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

int main(){
  string str;
  cin>>str;
  int co[4]={};
  for(int i=0;i<str.size();i++){
    if(str[i] == 'K') co[0]++;
    else if(str[i] == 'U') co[1]++;
    else if(str[i] == 'C') co[2]++;
    else if(str[i] == 'P') co[3]++;
  }
  int res=10000;
  for(int i=0;i<4;i++) res = min(res,co[i]);
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1188
use proconio::input;

macro_rules! chmax {
    ($max_v: expr, $v: expr) => {
        if $v > $max_v {
            $max_v = $v;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        a: [i64; n],
        b: [i64; m],
    };
    let ca = std::iter::once(0)
        .chain(a.iter().scan(0, |acc, a_i| {
            *acc += a_i;
            Some(*acc)
        }))
        .collect::<Vec<_>>();
    let cb = std::iter::once(0)
        .chain(b.iter().scan(0, |acc, b_i| {
            *acc += b_i;
            Some(*acc)
        }))
        .collect::<Vec<_>>();

    let mut ans = 0;
    let mut j = cb.len() - 1;
    for (i, &ca_i) in ca.iter().enumerate() {
        while j > 0 && ca_i + cb[j] > k {
            j -= 1;
        }
        if ca_i <= k && cb[j] <= k && ca_i + cb[j] <= k {
            chmax!(ans, i + j);
        }
    }

    // 二分探索 (superslice の upper_bound) を使う方法
    // for i in 0..=n {
    //     let x = k - ca[i];
    //     if x < 0 {
    //         continue;
    //     }
    //     let j = cb.upper_bound(&x);
    //     chmax!(ans, i + j - 1);
    // }

    println!("{}", ans);
}


Measured memory_bytes: 12552
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
//cout<<"Case #"<<v1+1<<": ";
 
ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {     
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}

int main()
{
    fastio
	ll t,i,j,x,n;
	
	string a,b;
	cin>>a>>b;
	int f=0;
	if(a.size()+1!=b.size())
	cout<<"No";
	else
	{
	    for(i=0;i<26;i++)
	    {
	        string z=a;
	        char x=i+'a';
	        z=z+x;
	        if(z==b)
	        {
	            f=1;
	            break;
	        }
	    }
	    if(f)
	    cout<<"Yes";
	    else cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 3656
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_100().doIt();
	}
	class Test_100{
		void doIt() {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int ans = a * b;
			if(ans % 2 == 0)System.out.println("Even");
			else System.out.println("Odd");
		}
	}
}


Measured memory_bytes: 21972
#include <stdio.h>

int main(void) {
  int a[5], i;

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

  printf("%d\n", (a[0]+a[1]+a[2]+a[3]+a[4]) / 5);

  return 0;
}

Measured memory_bytes: 600
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        Action exit = () => { Console.WriteLine("No"); Environment.Exit(0); };
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        Dictionary<int, int> dict = new Dictionary<int, int>();
        foreach (var item in a)
        {
            if (!dict.ContainsKey(item)) dict.Add(item, 0);
            dict[item]++;
        }

        int ll = dict.First().Key;
        int l = dict.Last().Key;
        int first = ll;
        dict[ll]--;
        dict[l]--;

        if (dict[ll] == 0)
            dict.Remove(ll);

        if (dict[l] == 0)
            dict.Remove(l);
        while (dict.Count > 0)
        {
            var next = l ^ ll;
            if (!dict.ContainsKey(next))
                exit();
            dict[next]--;
            if (dict[next] == 0)
                dict.Remove(next);
            ll = l;
            l = next;
        }
        if (first != (l ^ ll))
            exit();
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 26464
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;

////////////////////////////////////////////////

fn calc(a:i64,b:i64,c:i64)->i64{
    (a-b).abs() + (b-c).abs()
}


fn main(){
    let x = read_ints();
    let mut m = 999;

    for y in vec![
        [0,1,2],
        [0,2,1],
        [1,2,0],
        [1,0,2],
        [2,1,0],
        [2,0,1]]{
        let (i,j,k) = (y[0],y[1],y[2]);
        m = cmp::min(m,calc(x[i],x[j],x[k]));
    }
    
    println!("{}",m);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>

using namespace std;

vector<pair<long long, long long>> prime_factorization(long long N){
	vector<pair<long long, long long>> ret;

	long long temp = N;

	for (long long i = 2; i * i <= N; i++){
		if (temp % i != 0){
			continue;
		}

		long long exp = 0;
		while(temp % i == 0){
			exp++;
			temp /= i;
		}
		ret.push_back({i, exp});
	}
	if(temp != 1){
		ret.push_back({temp, 1});
	}
	return ret;
}

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

	vector<pair<long long, long long>> v = prime_factorization(N);

	long long ans = 0;
	for (auto p : v){
		long long sum = 0;
		for (long long i = 1;; i++){
			if(sum + i <= p.second){
				sum += i;
			} else {
				ans += i - 1;
				break;
			}
		}
	}

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


Measured memory_bytes: 3608
import java.util.Scanner;

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


        int taro_count = 0;
        int hana_count = 0;
        for (i = 0; i < n; i++) {
            String a = scan.next();
            String b = scan.next();
            if (a.compareTo(b) == 0) {
                taro_count += 1;
                hana_count += 1;
            } else if (a.compareTo(b) < 0) {
                hana_count += 3;
            } else {
                taro_count += 3;
            }
        }
        System.out.println(taro_count + " " + hana_count);
    }
}

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

int main(){
    int n=0,ans=0;
    cin >> n;
    vector<int> l(n),r(n);
    for(int i=0;i<n;i++){
        cin >> l.at(i) >> r.at(i);
        ans += r.at(i) - l.at(i) + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author houghstc
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <cstring>
#include <climits>

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

const int MOD = 1e9+7;

class CSumOfProductOfPairs {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        ll pre;
        in >> pre;
        ll res = 0;
        for(int i = 2; i <= n; ++i)
        {
            ll a;
            in >> a;
            res = (res + a * pre) % MOD;
            pre += a;
            pre %= MOD;
        }
        out << res << endl;
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    CSumOfProductOfPairs solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    ll x; cin >> x;
    ll ans = x / 11 * 2;
    x %= 11;  
    if (x > 6) ans += 2;
    else if (x > 0) ans += 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = input()
K = int(input())
m = len(N)
dp = [[[0] * (K+1) for _ in range(2)] for _ in range(m+1)]
dp[0][0][0] = 1

for i in range(1,m+1):
    l = int(N[i-1])
    for k in range(K+1):
        dp[i][1][k] += dp[i-1][1][k]
        if l != 0:
            dp[i][1][k] += dp[i-1][0][k]
        else:
            dp[i][0][k] += dp[i-1][0][k]
        if k-1>=0:
            dp[i][1][k] += 9*dp[i-1][1][k-1]
            if l!=0:
                dp[i][0][k] += dp[i-1][0][k-1]
                dp[i][1][k] += (l-1) * dp[i-1][0][k-1]

print(dp[m][0][K] + dp[m][1][K])

Measured memory_bytes: 62284
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    *t++;
    while(t != V.end()) {
        cout << " " << *t++;
        // if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int n;

void maxHeapify(vector<int> &A, int i) {
    int largest;
    int l = i * 2;
    int r = i * 2 + 1;
    if(l <= n && A.at(l) > A.at(i)) {
        largest = l;
    } else {
        largest = i;
    }
    if(r <= n && A.at(r) > A.at(largest)) {
        largest = r;
    }

    if(largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}
void buildMaxHeap(vector<int> &A) {
    for(int i = n / 2; i >= 1; i--)
        maxHeapify(A, i);
}

int main() {
    cin >> n;
    vector<int> Heap(n + 1);
    rep(i, 1, n + 1) cin >> Heap[i];
    buildMaxHeap(Heap);
    vecout(Heap);
}



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

int main() {
    ll X;
    cin >> X;
    for (ll A = -300; A < 300; A++) {
        for (ll B = -300; B < 300; B++) {
            ll A5 = A * A * A * A * A;
            ll B5 = B * B * B * B * B;
            if (A5 - B5 == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3652
@memo = [0, 1]
M = 10 ** 9 + 7

def fact num
  return @memo[num] if @memo[num]
  res = 1
  2.upto(num) do |i|
    return @memo[i] if @memo[i]
    res = @memo[i - 1] * i
    @memo[i] = res % M
  end
  res
end

n, m = gets.split.map(&:to_i).sort

if m - n >= 2
  puts 0
  exit
end

if m - n == 1
  puts (fact(m) * fact(n)) % M
  exit
end

puts (fact(m) * fact(n) * 2) % M


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

int main(){
  int N;
  cin >> N;
  int H[N];
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  int maxH = 0;
  int res = 1;
  for(int i = 0; i < N-1; i++){
    maxH = max(maxH, H[i]);
    if(H[i+1] >= H[i] && H[i+1] >= maxH){
      res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define ll long long
#define vi vector<long long>
#define pi pair<long long, long long>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9;
const ll N = (1<<5);
const double PI = 3.1415926535897;

double n, a, b, ans=0;
vector< pair<double, double> > towns;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a >> b;
        towns.pb({a, b});
    }
    sort(all(towns));
    do{
        for(int i=0; i<sz(towns)-1; i++){
            double dx = towns[i+1].F - towns[i].F, dy = towns[i+1].S - towns[i].S;
            ans += sqrt(dx*dx + dy*dy);
        }

    } while(next_permutation(all(towns)));
    for(double i=2; i<=n; i++){
        ans /= i;
    }
    cout << fixed << setprecision(9) << ans;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  int n,m,t;
  cin>>n>>m>>t;
  vector<bool> ok(t, true);
  REP(i,n) {
    int a;
    cin>>a;
    FOR(j,max(0,a-m),min(t,a+m)) ok[j] = false;
  }
  cout << count(ALL(ok), true) << endl;
  return 0;
}

Measured memory_bytes: 3076
def getStr(s, index, length)
  if S.length > index+length 
    s[index..(index+length)]
  end
end

def solve(s, indexs, length, res)
  if indexs.min+length == s.length || length > 5
    return res
  end
  indexs.each{|i|
    res.push(getStr(s, i, length))
  }
  solve(s, indexs, length+1, res)
end

S = gets.chop
K = gets.to_i
min = "a"
result = Array.new()
while result.length < K do
  res = Array.new()
  min_indexs = Array.new()
  offset = 0
  while S.index(min, offset) != nil do
    min_indexs.push(S.index(min, offset))
    offset = min_indexs[-1]+1
  end
  if min_indexs.length > 0 
    res.push(min)
    result.concat(solve(S, min_indexs, 1, res).compact.uniq)
  end
  min = min.succ
end

puts  result.sort[K-1]


Measured memory_bytes: 3324
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
typedef long long int lli;

int main(){
    lli r, d, x;
    cin >> r >> d >> x;
    for(lli i = 0; i < 10; ++i){
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    while True:
        
        a,b = map(int, input().split())
         
        if a == 0 and b == 0:
            sys.exit()
        elif a > b:
            print(str(b) + " " + str(a))
        else:
            print(str(a) + " " + str(b))
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 5744
N = int(input())
A_list = list(map(int,input().split()))

Buka_list = []

for i in range(N):
    Buka_list.append(0)
    
for j in A_list:
    Buka_list[j-1] += 1

for k in range(N):
    print(Buka_list[k])

Measured memory_bytes: 32368