akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=200010;
const ll mod=1e9+7;

int main(){
  vector<int> a(9);
  rep(i,9){ cin >> a[i]; }
  int n;
  cin >> n;
  set<int> st;
  rep(i,n){ int x; cin >> x; st.insert(x); }

  if((st.find(a[0])!=st.end() && st.find(a[1])!=st.end() && st.find(a[2])!=st.end())||
    (st.find(a[3])!=st.end() && st.find(a[4])!=st.end() && st.find(a[5])!=st.end())||
    (st.find(a[6])!=st.end() && st.find(a[7])!=st.end() && st.find(a[8])!=st.end())||
    (st.find(a[0])!=st.end() && st.find(a[3])!=st.end() && st.find(a[6])!=st.end())||
    (st.find(a[1])!=st.end() && st.find(a[4])!=st.end() && st.find(a[7])!=st.end())||
    (st.find(a[2])!=st.end() && st.find(a[5])!=st.end() && st.find(a[8])!=st.end())||
    (st.find(a[0])!=st.end() && st.find(a[4])!=st.end() && st.find(a[8])!=st.end())||
    (st.find(a[2])!=st.end() && st.find(a[4])!=st.end() && st.find(a[6])!=st.end())){
    cout << "Yes" << endl; return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

A_sum=[0,A[0]]
B_sum=[0,B[0]]
for i in range(1,N):
    A_sum.append(A_sum[i]+A[i])
for i in range(1,M):
    B_sum.append(B_sum[i]+B[i])

b_read=0
ans=0
for i in range(N,-1,-1):
    for j in range(b_read,M+1):
        if A_sum[i]+B_sum[j]<=K:
            ans=max(ans,i+j)
            b_read=j
        else:
            break
print(ans)


Measured memory_bytes: 47368
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W ;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0){
            break;
        }
        for(int i=0;i<H;i++){
          for(int j=0;j<W;j++){
            cout << "#";
          }
          cout << endl;
        }
      cout << endl;
     }
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=1e5+10;
char ch[M];
bool o[M];
int k,n;
int main(){
	scanf("%s",ch+1); k=read();
	n=strlen(ch+1);
	int len1=1,len2=0; o[1]=1;
	bool flag=0;
	F(i,2,n)  
	if (ch[i]==ch[1]) o[i]=1,len1++;
	else break;
	
	DF(i,n,1) 
	if (ch[i]==ch[1]) o[i]=1,len2++,flag=1;
	
	else break;
	if (len1==len2 && len1==n){
		cout<<1ll*n*k/2<<"\n";
		return 0;
	}
	int l=0;
	LL ans=0;
//	if (k==1) flag=0;
	F(i,1,n){
//		if (!flag && o[i]) continue;
		l++;
		if (ch[i]!=ch[i+1]){
			ans+=l/2;
			l=0;	
		}
	}
	cout<<1ll*ans*k+flag*((len1&1) && (len2&1))*(k-1)<<"\n";
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int check753(int s){
    int n,seven=0,five=0,three=0;
    while(seven==0||five==0||three==0){
        if(s==0) return 0;
        n=s%10;
        s/=10;
        if(n==7){
            seven=1;
        }else if(n==5){
            five=1;
        }else if(n==3){
            three=1;
        }
    }
    return 1;
}

int count753(int n,int s){
    if(s>n) return 0;
    int ret;
    if(check753(s)){
        ret=1;
    }else{
        ret=0;
    }
    if(s*10+3>0){
        ret+=count753(n,s*10+3);
    }
    if(s*10+5>0){
        ret+=count753(n,s*10+5);
    }
    if(s*10+7>0){
        ret+=count753(n,s*10+7);
    }
    return ret;
}

int main(void){
    int n;
    scanf("%d",&n);
    printf("%d\n", count753(n,0));
    return 0;
}

Measured memory_bytes: 128
S=input()
T=input()
N=int(input())
abcd = [tuple(map(int,input().split())) for _ in range(N)]

NS = len(S)
NT = len(T)
cs0 = [0]*(NS+1)
cs1 = [0]*(NS+1)
ct0 = [0]*(NT+1)
ct1 = [0]*(NT+1)
for i in range(NS):
    cs0[i+1] = cs0[i]
    cs1[i+1] = cs1[i]
    if S[i]=='A':
        cs0[i+1] += 1
    else:
        cs1[i+1] += 1
for i in range(NT):
    ct0[i+1] = ct0[i]
    ct1[i+1] = ct1[i]
    if T[i]=='A':
        ct0[i+1] += 1
    else:
        ct1[i+1] += 1

for a,b,c,d in abcd:
    anum = cs0[b] - cs0[a-1]
    bnum = cs1[b] - cs1[a-1]
    num = 0
    if anum%3 == bnum%3 == 0:
        num = 0
    elif anum > bnum:
        num = (anum-bnum)%3
    else:
        num = 2*(bnum-anum)%3
    anum2 = ct0[d] - ct0[c-1]
    bnum2 = ct1[d] - ct1[c-1]
    num2 = 0
    if anum2%3 == bnum2%3 == 0:
        num2 = 0
    elif anum2 > bnum2:
        num2 = (anum2-bnum2)%3
    else:
        num2 = 2*(bnum2-anum2)%3
    
    if num == num2:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 35152
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    n, k = [int(e) for e in input().split(" ")]
    s = ""
    for i, r in enumerate(input()):
        if i == k-1:
            s += r.lower()
        else:
            s += r
    print(s)

main()


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Bigint
{
    static const long long MAX = 1000000000LL;
    vector<long long> a;
    bool sign;
public:
    Bigint(){
        sign = true;
    }
    Bigint(long long x){
        if(x < 0){
            sign = false;
            x *= -1;
        }
        else{
            sign = true;
        }
        while(x > 0){
            a.push_back(x % MAX);
            x /= MAX;
        }
    }
    Bigint(const string& s){
        sign = true;
        long long tmp = MAX;
        for(int i=s.size()-1; i>=0; --i){
            if(tmp == MAX){
                a.push_back(0);
                tmp = 1;
            }
            if('0' <= s[i] && s[i] <= '9'){
                a.back() += (s[i] - '0') * tmp;
                tmp *= 10;
            }
            else if(i == 0 && s[0] == '-'){
                sign = false;
            }
            else{
                throw(exception());
            }
        }
        while(!a.empty() && a.back() == 0)
            a.pop_back();
        if(a.empty())
            sign = true;
    }
    long long getNum(){
        long long ret = 0;
        for(int i=a.size()-1; i>=0; --i){
            ret *= MAX;
            ret += a[i];
        }
        return ret * (sign? 1:-1);
    }
    string getStr() const{
        ostringstream oss;
        if(a.size() == 0)
            return "0";
        if(!sign)
            oss << '-';
        for(int i=a.size()-1; i>=0; --i){
            oss << a[i];
            oss << setw(9) << setfill('0');
        }
        return oss.str();
    }
    Bigint operator*(const Bigint& x) const{
        if(a.size() == 0 || x.a.size() == 0)
            return 0;
        Bigint ret;
        ret.sign = !(sign ^ x.sign);
        ret.a.assign(a.size() + x.a.size(), 0);
        for(unsigned i=0; i<a.size(); ++i){
            for(unsigned j=0; j<x.a.size(); ++j){
                ret.a[i+j] += a[i] * x.a[j];
                ret.a[i+j+1] += ret.a[i+j] / MAX;
                ret.a[i+j] %= MAX;
            }
        }
        if(!ret.a.empty() && ret.a.back() == 0)
            ret.a.pop_back();
        return ret;
    }
};

const string jinkoki[] = {"", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko",
                          "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};

int main()
{
    for(;;){
        int m, n;
        cin >> m >> n;
        if(m == 0)
            return 0;

        Bigint x = 1;
        for(int i=0; i<n; ++i)
            x = x * m;

        string s = x.getStr();
        int a = (s.size() + 3) / 4;
        s = string(a * 4 - s.size(), '0') + s;

        for(int i=0; i<a; ++i){
            int y = stoi(s.substr(i*4, 4));
            if(y > 0)
                cout << y << jinkoki[a-1-i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <climits>

using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int amin = INT_MAX;
    int aminId = -1;
    int amax = INT_MIN;
    int amaxId = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (amax < a[i]) {
            amax = a[i];
            amaxId = i;
        }
        if (amin > a[i]) {
            amin = a[i];
            aminId = i;
        }
    }

    cout << n * 2 - 1 << endl;
    if (abs(amin) < abs(amax)) {
        // maxを全部に足す
        for (int i = 0; i < n; i++) {
            cout << amaxId + 1 << " " << i + 1 << endl;
        }
        // 先頭から累積和をとる
        for (int i = 0; i < n - 1; i++) {
            cout << i + 1 << " " << i + 1 + 1 << endl;
        }
    } else {
        // minを全部に足す
        for (int i = 0; i < n; i++) {
            cout << aminId + 1 << " " << i + 1 << endl;
        }
        // 末尾から累積和をとる
        for (int i = 1; i < n; i++) {
            cout << n - i + 1 << " " << n - i - 1 + 1 << endl;
        }
    }
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
ll n;
string s[210];
ll col[210];
bool dfs(ll x,bool c){
  if(col[x]>=0){
    return c==col[x];
  }
  col[x]=c;
  for(int j=0;j<n;j++){
    if(s[x][j]=='1'){
      if(dfs(j,c^1)==0)return 0;
    }
  }
  return 1;
}
ll wf[210][210];
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
    for(int j=0;j<n;j++){
      if(s[i][j]=='1')wf[i][j]=1;
      else wf[i][j]=1e17;
      if(i==j)wf[i][j]=0;
    }
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
      chmin(wf[i][j],wf[i][k]+wf[k][j]);
    }
  }
  for(int i=0;i<n;i++)col[i]=-1;
  if(dfs(0,0)==0)cout<<-1<<endl;
  else{
    ll ans=0;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
      chmax(ans,wf[i][j]);
    }
    cout<<ans+1<<endl;
  }
  return 0;
}


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

int main()
{
    vector<int> ans;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int year, month, day, days = 0;

        cin >> year >> month >> day;

        if (year % 3 == 0)
        {
            days += 20 - day + 1;
            days += (10 - month) * 20;
        }
        else
        {
            if (month % 2 != 0)
            {
                days += 20 - day + 1;
            }
            else
            {
                days += 19 - day + 1;
            }

            for (int j = month + 1; j <= 10; j++)
            {
                if (j % 2 != 0)
                {
                    days += 20;
                }
                else
                {
                    days += 19;
                }
            }
        }

        int oddNum = 333 - (year / 3);

        days += oddNum * 200 + (999 - year - oddNum) * 195;

        ans.push_back(days);
    }

    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3136
import java.math.*

fun main(args: Array<String>) {
    val (N, A, B, C) = readInputLine().split(" ").map{it.toInt()}
    
    val takes = IntArray(N)
    
    for (i in 0 until N) {
        takes[i] = readInputLine().toInt()
    }
    
    println(dfs(N, A, B, C, takes, 0, 0, 0, 0))
}

fun readInputLine(): String {
    return readLine()!!
}

fun dfs(N: Int, A: Int, B: Int, C: Int, takes: IntArray, cnt: Int, a: Int, b: Int, c: Int): Int {
    if (cnt == N) {
        return if (a == 0 || b == 0 || c == 0) 1000000000 else Math.abs(A - a) + Math.abs(B - b) + Math.abs(C - c) - 30
    }
    
    var ret = Int.MAX_VALUE
    ret = Math.min(ret, dfs(N, A, B, C, takes, cnt + 1, a + takes[cnt], b, c) + 10)
    ret = Math.min(ret, dfs(N, A, B, C, takes, cnt + 1, a, b + takes[cnt], c) + 10)
    ret = Math.min(ret, dfs(N, A, B, C, takes, cnt + 1, a, b, c + takes[cnt]) + 10)
    ret = Math.min(ret, dfs(N, A, B, C, takes, cnt + 1, a, b, c))
    
    return ret
}

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

using namespace std;

const int MAX = 100000;

int powint(int x, int n) {
    int ret = 1;
    while (n > 0) {
        ret *= x;
        --n;
    }
    return ret;
}

int dp(int curr, int N, const vector<int>& withdrawable, vector<vector<int>>& memo) {
    if (curr == withdrawable.size()) {
        return N;
    }
    if (memo[curr][N] >= 0) {
        return memo[curr][N];
    }

    int w = withdrawable[curr];
    int n = N / w;
    int ret = MAX;
    for (int i = 0; i <= n; ++i) {
        if (N - w * i >= 0) {
            int d = i + dp(curr + 1, N - w * i, withdrawable, memo);
            ret = min(ret, d);
        }
    }
    memo[curr][N] = ret;
    return ret;
}

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

    vector<int> withdrawable;
    for (int i = 1; i <= 5; ++i) {
        withdrawable.push_back(powint(9, i));
    }
    for (int i = 1; i <= 6; ++i) {
        withdrawable.push_back(powint(6, i));
    }
    vector<vector<int>> memo(withdrawable.size() + 10, vector<int>(N + 10, -1));
    int ans = dp(0, N, withdrawable, memo);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 11884
// C.

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <numeric>
#include <bitset>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	const int m = 2000 * 2000 + 1;
	bitset<m> bs;
	bs.set(0);
	for (int i = 0; i < n; ++i) {
		bs |= (bs << a[i]);
	}
	int sum = accumulate(a.begin(), a.end(), 0LL);
	int mid = (sum + 1) / 2;
	for (int i = mid; i <= sum; ++i) {
		if (bs.test(i)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define Mod 1000000007
using namespace std;
int fpow(int a,int b)
{
	int ans=1,t=a;
	while(b)
	{
		if(b&1)ans=(long long)ans*t%Mod;
		t=(long long)t*t%Mod;
		b>>=1;
	}
	return ans;
}
int f[21][1<<16];
int a[21];
int fac[(1<<16)+10],inv[(1<<16)+10];
int C(int x,int y)
{
	if(x<0||y<0||x-y<0)return 0;
	return (long long)fac[x]*inv[y]%Mod*inv[x-y]%Mod;
}
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int N=1<<n;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&a[i]);
		a[i]=N-a[i];
	}
	reverse(a+1,a+m+1);
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=(long long)fac[i-1]*i%Mod;
	inv[N]=fpow(fac[N],Mod-2);
	for(int i=N;i>=1;i--)
		inv[i-1]=(long long)inv[i]*i%Mod;
	f[0][0]=1;
	for(int i=0;i<m;i++)
		for(int s=0;s<N;s++)
			if(f[i][s])
			{
				add(f[i+1][s],f[i][s]);
				for(int x=1;x<N;x<<=1)
					if(!(s&x))
						add(f[i+1][s|x],(long long)f[i][s]*C(a[i+1]-s,x-1)%Mod);
			}
	int ans=0;
	for(int s=0;s<N;s++)
	{
		int sum=f[m][s];
		int t=N-s-1;
		for(int x=1;x<N;x<<=1)
			if(!(s&x)){
				sum=(long long)sum*C(t,x)%Mod;
				t-=x;
			}
		int cnt=0;
		for(int x=1;x<N;x<<=1)
			if(s&x)cnt++;
		if(cnt&1)ans=(ans-sum+Mod)%Mod;
		else add(ans,sum);
	}
	for(int x=1;x<N;x<<=1)
		ans=(long long)ans*fac[x]%Mod;
	ans=(long long)ans*N%Mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<iomanip>
using namespace std;
double round3d (double d) {
	return (double)((int)(d * 1000.0 + 0.5 - (d < 0) )) / 1000.0;
}
int main(){
	while (true) {
		double a, b, c, d, e, f;
		cin >> a >> b >> c >> d >> e >> f;
		if (cin.eof()) break;
		double x = (b * f - e * c) / (b * d - a * e);
		double y = (c * d - a * f) / (b * d - a * e);
		cout << setprecision(3) << fixed << round3d(x) << " " << round3d(y) << "\n";
	}
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int n,x,y;
int check(int a,int b);

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

  map<int,int> mp;

  for(int i=1; i<n; i++){
    for(int j=i+1; j<n+1; j++){
      mp[check(i,j)]++;
    }
  }

  for(int i=1; i<n; i++){
    cout << mp[i] << endl;
  }

}

int check(int a,int b){//xからyの距離
    int tmp1=b-a;
    int s=x-a,t=1,u=b-y;
    if(s<0)s=-s;
    if(u<0)u=-u;
    int tmp2=s+t+u;
    return min(tmp1,tmp2);
}


Measured memory_bytes: 384
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: u64,
        x: u64,
        t: u64,
    }

    println!(
        "{}",
        if n % x == 0 {
            n / x * t
        } else {
            (n / x + 1) * t
        }
    );
}


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

#define ll long long int
ll mod=1e9+7;

// vector<ll> g[200005];
// ll vis[200005];
// queue<ll> q;
// ll level[200005];

// void dfs(ll i)
// {
//     vis[i] = 1;
//     for(ll j=0;j<g[i].size();j++)
//     {
//         ll child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(ll i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         ll top = q.front();
//         ll len_adj = g[top].size();
//         ll j;
//         for(j=0;j<len_adj;j++)
//         {
//             ll v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        // cin >> n;
        string s,t;
        cin >> s;
        cin >> t;

        string s2 = t.substr(0,s.size());
        if(s2 == s)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
        

        
    }

    
    
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;

// GCD: a > b
ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }

int main(int argc,char *argv[])
{
	ul k;
	std::cin >> k;
	
	ul ans = 0;
	for (ul a = 1;a <= k;++a){ for (ul b = 1;b <= k;++b) { for (ul c = 1;c <= k;++c) { ans += gcd(gcd(a,b),c); } } }

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>

 int main() {

	 int n;
	 int m;
	 int sum = 2;


	 std::cin >> n >> m;

	 for (int i = 1; i < m; ++i) {
		 sum *= 2;
	 }
	 std::cout << sum * ((1900 * m) + (100*(n - m)) ) << std::endl;

	 return 0;

} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,p,aa[220000],cntl=0,ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,cc[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    rep(i,n-1){
        if(aa[i]==aa[i+1]){
            aa[i+1]=INF;
            cnt++;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3968
s = input()
t = input()

N, M = len(s), len(t)
min_len = min(N, M)

s_ = sorted(s)
t_ = sorted(t, reverse=True)


for a, b in zip(s_, t_):
    if a == b:
        continue
    elif a > b:
        print('No')
        exit()
    else:
        print('Yes')
        exit()

if N < M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
    int n;
    cin>>n;
    int stuff[n],boss[200010]={0};
    for(int i=2;i<=n;i++) cin>>stuff[i];
    for(int i=2;i<=n;i++) boss[stuff[i]]++;
    for(int i=1;i<=n;i++) printf("%d\n",boss[i]);
}

Measured memory_bytes: 5268
n = int(input())
ans = 0
for i in range(1, 6):
  if 10**i <= n and i%2==1:
    ans += 10**i - 10**(i-1)

  elif 10**i > n and i%2==0:
    break
  elif 10**i > n and i%2==1:
    ans += n - 10**(i-1) + 1
    break

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	string S;
	cin >> S;
	vector<string> X(S.size());
	for (int i = 0; i < S.size(); i++) {
		X.at(i) = "x";
	}
	for (int j = 0; j < S.size(); j++) {
		cout << X.at(j);
	}
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
using f32 = float;
using f64 = double;
using i8 = int_fast8_t;
using u8 = uint_fast8_t;
using i16 = int_fast16_t;
using u16 = uint_fast16_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
inline void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main(int argc, char *argv[]) {
    // fast_io();

    i32 l;
    scanf("%d", &l);
    f64 ans = f64(l) / 3;
    printf("%.12f", ans * ans * ans);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int ink[14][14]={{}};
    int i,j,x,y,s;
    int cnt=0,max;
    
    while(scanf("%d,%d,%d",&x,&y,&s) != EOF){
        x+=2;
        y+=2;
        switch(s){
            case 3 :ink[x][y-2]++;
                    ink[x-2][y]++;
                    ink[x+2][y]++;
                    ink[x][y+2]++;
            
            case 2 :ink[x-1][y-1]++;
                    ink[x+1][y-1]++;
                    ink[x-1][y+1]++;
                    ink[x+1][y+1]++;
            
            case 1 :ink[x][y-1]++;
                    ink[x-1][y]++;
                    ink[x][y]++;
                    ink[x+1][y]++;
                    ink[x][y+1]++;
                    break;
        }
    }
    
    max=ink[2][2];
    for(i=2;i<=11;i++){
        for(j=2;j<=11;j++){
            if(ink[i][j]==0)cnt++;
            if(max<ink[i][j]) max=ink[i][j];
        }
    }
    printf("%d\n%d\n",cnt,max);
    
    return 0;
}

Measured memory_bytes: 600
a,b,c,k = map(int, input().split())
ans = 0

if k > a:
    ans = a + ans
else:
    ans = k + ans
k = k - a

k = k -b

if k > 0:
    if k > c:
        ans = ans - c
    else:
        ans = ans - k
print(ans)

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  if((b / k - a / k) > 0 || b % k == 0 || a % k == 0) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());

		while(N != 0) {
			
			double min = 1000;
			double max = 0;
			double total = 0;
			for (int i = 0; i < N; i++) {
				int point = Integer.parseInt(br.readLine());
				if (min > point) min = point;
				if (max < point) max = point;
				total += point;
			}
			System.out.println((int) Math.floor((total - max - min) / (N-2)));
			
			N = Integer.parseInt(br.readLine());
		}
	}

}

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

const int maxn = 1 << 18;

int n;
int a[maxn][2];

void merge(int *x, int *y) {
	if (x[0] < y[0]) {
		x[1] = max(x[0], y[1]);
		x[0] = y[0];
	} else {
		x[1] = max(x[1], y[0]);
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	cin >> n;
	for (int i = 0; i < 1 << n; ++i) cin >> a[i][0];
	
	for (int i = 0; i < n; ++i) for (int x = 0; x < 1 << n; ++x) if ((x & (1 << i)) == 0) {
		merge(a[x | (1 << i)], a[x]);
	}
	
	int answer = 0;
	for (int i = 1; i < 1 << n; ++i) {
		answer = max(answer, a[i][0] + a[i][1]);
		cout << answer << "\n";
	}
	return 0;
}

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

namespace AtCoder.Contests.ABC158
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var nab = ReadLongArray();
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];

            if(a == 0)
            {
                Console.WriteLine(0);
                return;
            }

            var m = (n / (a + b)) * a;
            Console.WriteLine(m + Math.Min(n % (a + b), a));
        }

        #region Console
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
typedef long long int LLI;

int main()
{
	int a, b, c, d, first, second;
	cin >> a >> b >> c >> d;
	if( a > b )
		first = b;
	else first = a;
	
	if( c > d )
		second = d;
	else second = c;
	cout << first + second;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


int main(){
    ll n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    if(c == 0){
        ll tmp = 0;
        for(char ox : s){
            tmp += ox == 'o';
        }
        if(tmp == k){
            REP(i, n){
                if(s.at(i) != 'x'){
                    cout << i + 1 << endl;
                }
            }
        }else{
            cout << endl;
        }
        return 0;
    }

    vector<ll> lg(n, 0), rg(n, 0);

    ll pos = 0;
    while(pos < n){
        if(pos > 0){
            lg.at(pos) = lg.at(pos - 1);
        }
        if(s.at(pos) != 'x'){
            lg.at(pos)++;
            for(ll j = 0; j < c && pos + 1 + j < n; ++j){
                lg.at(pos + 1 + j) = lg.at(pos);
            }
            pos += c + 1;
        }else{
            pos++;
        }
    }

    for(ll pos = n - 1; pos >= 0; --pos){
        if(pos + 1 < n){
            rg.at(pos) = rg.at(pos + 1);
        }
        if(s.at(pos) != 'x'){
            if(pos + 1 + c < n){
                rg.at(pos) = max(1 + rg.at(pos + 1 + c), rg.at(pos));
            }else{
                rg.at(pos) = max(1LL, rg.at(pos));
            }
        }
    }

    vector<ll> diff(n, 0);
    REP(i, n + c){
        ll tmp = 0;
        if(i - c >= 0){
            tmp += lg.at(i - c);
        }
        if(i + 1 < n){
            tmp += rg.at(i + 1);
        }
        if(tmp >= k){
            if(i - c + 1 < n){
                diff.at(max(0LL, i - c + 1))++;
            }
            if(i + 1 < n){
                diff.at(i + 1)--;
            }
        }
    }

    ll cs = 0;
    REP(i, n){
        cs += diff.at(i);
        if(cs <= 0 && s.at(i) != 'x'){
            cout << i + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5252
#include<bits/stdc++.h>
using namespace std;
int x,y,z=0;
int main(){
	cin>>x>>y;
	z=x*pow(10,ceil(log10(y+1)))+y;
	if (int(sqrt(z))==sqrt(z)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
 

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<vector<int>>m(n+1,vector<int>(4,0));

    for(int i=1;i<=n;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        m[i][1]=a;
        m[i][2]=b;
        m[i][3]=c;
    }
    vector<vector<int>>dp(n+1,vector<int>(4,0));

   /* for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=3;j++)
        {
            cout<<m[i][j]<<' ';
        }
        cout<<endl;
    }
return 0;
*/
        dp[1][1]=m[1][1];
        dp[1][2]=m[1][2];
        dp[1][3]=m[1][3];
   for(int i=2;i<=n;i++)
    {
        for(int j=1;j<4;j++)
        {
            if(j==1)
            {
                dp[i][j]=m[i][j]+max(dp[i-1][2],dp[i-1][3]);
            }
            else if(j==2)
            {
                dp[i][j]=m[i][j]+max(dp[i-1][1],dp[i-1][3]);
            }
            else
            {
                dp[i][j]=m[i][j]+max(dp[i-1][1],dp[i-1][2]);
            }
        }
    }
   int ans=0;
   for(int j=1;j<=3;j++)
   {
       ans=max(ans,dp[n][j]);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
const int maxn = 200009;
int A[maxn << 2], B[maxn << 2];
void upd1(int rt, int l, int r, int p, int v) {
  if (l == r) {
    B[rt] = v;
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    upd1(rt << 1, l, mid, p, v);
  else
    upd1(rt << 1 | 1, mid + 1, r, p, v);
  B[rt] = max(B[rt << 1], B[rt << 1 | 1]);
}
void upd(int rt, int l, int r, int p, int v) {
  if (l == r) {
    A[rt] = v;
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    upd(rt << 1, l, mid, p, v);
  else
    upd(rt << 1 | 1, mid + 1, r, p, v);
  A[rt] = min(A[rt << 1], A[rt << 1 | 1]);
}
int query(int rt, int l, int r, int ll, int rr) {
  if (ll > rr) return maxn;
  if (ll <= l && rr >= r) return A[rt];
  int mid = (l + r) >> 1, res = maxn;
  if (ll <= mid) res = min(res, query(rt << 1, l, mid, ll, rr));
  if (rr > mid) res = min(res, query(rt << 1 | 1, mid + 1, r, ll, rr));
  return res;
}
int query1(int rt, int l, int r, int ll, int rr) {
  if (ll > rr) return -1;
  if (ll <= l && rr >= r) return B[rt];
  int mid = (l + r) >> 1, res = -1;
  if (ll <= mid) res = max(res, query1(rt << 1, l, mid, ll, rr));
  if (rr > mid) res = max(res, query1(rt << 1 | 1, mid + 1, r, ll, rr));
  return res;
}
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n + 2), y(n + 2), z(n + 2), xy(n + 2);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    upd1(1, 1, n, y[i], x[i]);
    upd(1, 1, n, y[i], x[i]);
    xy[x[i]] = y[i];
  }
  for (int i = 0; i < n; ++i) {
    if (query1(1, 1, n, y[i], y[i]) == -1) continue;
    vector<int> s;
    function<void(int, int)> dfs = [&](int cur, int v) {
      upd1(1, 1, n, cur, -1);
      upd(1, 1, n, cur, maxn);
      s.push_back(cur);
      while (1) {
        int res = query1(1, 1, n, cur + 1, n);
        if (res < v) break;
        dfs(xy[res], res);
      }
      while (1) {
        int res = query(1, 1, n, 1, cur - 1);
        if (res > v) break;
        dfs(xy[res], res);
      }
    };
    dfs(y[i], x[i]);
    for (auto j : s) {
      z[j] = SZ(s);
    }
  }
  for (int i = 0; i < n; ++i) cout << z[y[i]] << '\n';
  return 0;
}
//2020.09.20 20:35:17


Measured memory_bytes: 23872
def is_nine(x):
    res = 0
    while x > 0:
        t = x % 10
        res += t
        x //= 10
    return res

if __name__ == '__main__':
    N = list(input())
    e = 0
    for i in N:
        e += int(i)
        
    if (e % 9 == 0):
        print("Yes")
    else:
        print("No")

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

typedef long long ll;

typedef pair<ll, int> p;

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

    ll H, W;
    cin >> H >> W;

    ll ans = pow(10, 12);

    if(H >= 3LL) {
        if(H % 3LL) {
            ans = min(ans, W);
        } else {
            ans = 0;
        }
    }

    if(W >= 3LL) {
        if(W % 3LL) {
            ans = min(ans, H);
        } else {
            ans = 0;
        }
    }

    for(ll i = 1; i < H; i++) {
        ll a = i * W;
        ll b, c;
        if(W % 2LL) {
            b = (H - i) * (W / 2LL);
            c = (H - i) * (W / 2LL + 1LL);
        } else {
            b = (H - i) * (W / 2LL);
            c = (H - i) * (W / 2LL);
        }

        ll x = max(a, max(b, c));
        ll y = min(a, min(b, c));

        ans = min(ans, x - y);
    }

    for(ll i = 1; i < W; i++) {
        ll a = i * H;
        ll b, c;
        if(H % 2LL) {
            b = (W - i) * (H / 2LL);
            c = (W - i) * (H / 2LL + 1LL);
        } else {
            b = (W - i) * (H / 2LL);
            c = (W - i) * (H / 2LL);
        }

        ll x = max(a, max(b, c));
        ll y = min(a, min(b, c));

        ans = min(ans, x - y);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N ;
    
    ll insid = 0 ;
    ll a = 0 ;
    ll b = 0;
    ll ba = 0;
    rep(i, N){
        string inp; cin >> inp;
        rep(j, inp.size()){
            if(j!=0 && inp[j-1] == 'A' && inp[j] == 'B') insid ++;
        }
        if(inp[0] == 'B' && inp[inp.size()-1] == 'A') ba ++;
        else if(inp[0] == 'B') b ++;
        else if(inp[inp.size() -1] == 'A') a++;
    }
    
    ll ans = insid;
    if(ba == 0){
        ans += min(a,b);
    }else{
        if(a != 0){
            ans ++;
            a--;
        }
        if(b != 0){
            ans ++;
            b--;
        }
        ans += (ba-1);
        ans += min(a,b);
    }
    cout << ans << endl;

    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N=2e5+5;

i64 ans[N];
int x[N];
int s[N];
int c[N];
vector<int>e[N];

void dfs(int v,int p){
	int i,l=x[c[v]];s[v]=1;
	for(i=0;i<e[v].size();i++)
		if(e[v][i]!=p)
			x[c[v]]=0,dfs(e[v][i],v),s[v]+=s[e[v][i]],
			ans[c[v]]-=1ll*(s[e[v][i]]-x[c[v]])*(s[e[v][i]]-x[c[v]]+1)/2;
	x[c[v]]=l+s[v];
}

int main()
{
	int n,i,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
		ans[c[i]]=1ll*n*(n+1)/2;
	}
	for(i=1;i<n;i++)
		scanf("%d%d",&u,&v),
		e[u].push_back(v),
		e[v].push_back(u);
	dfs(1,0);
	for(i=1;i<=n;i++)
		if(ans[i])ans[i]-=1ll*(n-x[i])*(n-x[i]+1)/2;
	for(i=1;i<=n;i++)
		printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 34048
#include <iostream>

using namespace std;

int main ( void )
{
  int a, b;
  while (cin >> a >> b)
  {
    int c = a + b, digit = 0;

    do
    {
      c /= 10;
      ++digit;
    } while (c);

    cout << digit << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
def main():
    N, M = map(int, input().split())
    X = sorted(list(map(int, input().split())))

    if M == 1:
        print(0)
    elif N == 1:
        print(max(X) - min(X))
    else:
        if N > M:
            N = M
        dx = sorted([abs(X[m] - X[m + 1]) for m in range(M - 1)])
        print(sum(dx[:M - N]))


main()


Measured memory_bytes: 13960
import heapq
import math
def main():
  N, H = map(int, input().split())
  A = 0
  B = []
  for i in range(N):
    a, b = map(int, input().split())
    A = max(A, a)
    B.append(-1*b)
  lis = []
  heapq.heapify(B)
  while True:
    temp = -1*heapq.heappop(B)
    if temp > A:
      lis.append(-1*temp)
    if len(B) == 0:
      break
  wa = 0
  ans = 0
  for i in range(len(lis)):
    wa += -1*heapq.heappop(lis)
    ans += 1
    if wa >= H:
      break
  if wa < H:
    ans += math.ceil((H-wa)/A)
  print(ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 7516
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 500000
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

ll n;
ll a[MAX];
set<ll> c[MAX];
ll dp[MAX];

ll f(ll index){
	if(index==n) return 1;
	if(dp[index]!=-1) return dp[index];
	ll ans=0;
	ll first = f(index+1);
	ll second = 0;
	set<ll>::iterator it = c[a[index]].find(index);
	it++;
	if(it==c[a[index]].end()) ans = first%Mod;
	else if((*it)!=index+1){
		second = f((*it));
		ans = (first+second)%Mod;
	}else ans = first%Mod;
	dp[index] = ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>n;
	For(i,0,n) cin>>a[i];
	For(i,0,n) c[a[i]].insert(i);
	
	cout<<f(0)<<endl;











	
}

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string ans = s;
  rep(i,s.size()){
    rep(j,26){
      if(s.at(i) == alphabet.at(j)){
        ans.at(i) = alphabet.at(j+n);
      }}}
    cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string a,b;
    int ans=0;
    cin >> a >> b;
    for(int i=0;i<a.length();i++)
    {
        if(a[i]!=b[i]){
            ans++;
        }
    }
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3920
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter, deque
from bisect import *

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, M = reads()
edges = [[] for _ in range(N)]
rem = [0] * N
for i in range(N-1+M):
  a, b = reads()
  edges[a-1].append(b-1)
  rem[b-1] += 1

root = next(i for i in range(N) if rem[i] == 0)

par = [-1] * N
que = deque([root])

while len(que) != 0:
  x = que.popleft()
  for y in edges[x]:
    par[y] = x
    rem[y] -= 1
    if rem[y] == 0:
      que.append(y)

for i in range(N):
  print(par[i] + 1)

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

int main() {
  int N;
  int kazu = 0;
  cin >> N;
  for(int i = 0; i < N; i++)
  {
    int l, r;
    cin >> l;
    cin >> r;
    int sore = (r - l + 1);
    kazu += sore;
    if(i == N - 1)
      cout << kazu << endl;
  }
}


Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      if(A%2==0){
        System.out.println(A/2 * A/2);
      }else{
        System.out.println((A+1)/2 * (A-1)/2);
      }
    }
}

Measured memory_bytes: 35664
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, ans;
	vector<int> v;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n-1;i++) cin>> v[i];

	ans=v[n-2];
	for(int i=n-1;0<i;i--){
		ans+=min(v[i], v[i-1]);
	}
	ans+=v[0];

	cout<< ans << endl;

}

Measured memory_bytes: 256
// ABC126-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る

int n=100000;
vector<vector<ipair>> rinsetu(n+1);
vector<int> jisu(n+1,0);
vector<int> color(n+1,-1);
void dfs(int x){
    for(int i=0;i<jisu[x];i++){
        ipair q=rinsetu[x][i];
        int next=q.first,dis=q.second;
        if(color[next]>=0) continue;
        if(dis%2==0){
            color[next]=color[x];
        }else color[next]=1-color[x];
        dfs(next);
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int nn;
    cin>>nn;
    rep(i,nn-1){
        int u,v,w;
        cin>>u>>v>>w;
        rinsetu[u].e_b(ipair(v,w));
        rinsetu[v].e_b(ipair(u,w));
        jisu[u]++;
        jisu[v]++;
    }
    color[1]=0;
    dfs(1);
    for(int i=1;i<=nn;i++){
        cout<<color[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 12332
# ABピザ C

a, b, c, x, y = map(int, input().split())

# c * 2 <= a + b

sum_num = 0

if c * 2 <= a + b:
    sum_num = c * 2 * min(x, y)
    if x > y:
        sum_num += a * (x - y)
    else:
        sum_num += b * (y - x)
    if sum_num > c * 2 * max(x, y):
        sum_num = c * 2 * max(x, y)
else:
    sum_num += a * x + b * y

print(sum_num)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,i,d=1;
  cin >> a;
  char s[a+1];
  cin >> s;
  for(i=0;i<a-1;i++){
    if(s[i]!=s[i+1]){
      d++;
    }
  }
  cout << d << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int app() {
  int l,r,d;
  cin>>l>>r>>d;
  return r/d-(l-1)/d;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1LL << 60;

int main()
{
  ll a, b;
  cin >> a >> b;
  cout << (a * b) << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while(c<'0'||c>'9'){
        c=getchar_unlocked();
    }
    while(c>='0'&&c<='9'){
        x=(x<<1)+(x<<3)+c-'0';
        c=getchar_unlocked();
    }
    return x;
}
void dfs(int node,int parent,vector<int>ar[],int depth[]){
	if(depth[node])
		return;
	int m=0;
	for(int child:ar[node]){
		if(child==parent)
			continue;
		dfs(child,node,ar,depth);
		m=max(m,depth[child]+1);
	}
	depth[node]=m;
}
int main(){
	int n=scan(),m=scan();
	vector<int>ar[n+1];
	while(m--)
		ar[scan()].push_back(scan());
	int depth[n+1];
	for(int i=0;i<=n;i++)
		depth[i]=0;
	for(int i=1;i<=n;i++)
		dfs(i,-1,ar,depth);
	int ans=0;
	for(int i=0;i<=n;i++)
		ans=max(ans,depth[i]);
	printf("%d",ans);
}

Measured memory_bytes: 15104