akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		System.out.println(n/3);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;
vector<int> A;

bool judge(int lim){
  set<pair<int,int>> se;
  int now=0;
  for(int i=0;i<N;i++){
    auto itr=se.upper_bound(mkp(A[i],-1));
    if(itr==se.begin()){
      if(now>=lim) return false;
      se.insert(mkp(A[i],now+1));
      now++;
    }else{
      itr--;
      auto f=*itr;
      auto nex=mkp(A[i],f.second);
      se.erase(f);
      se.insert(nex);
    }
  }
  return true;
}

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

  int ok=N,ng=0;
  while(ok-ng>1){
    int mid=(ok+ng)/2;
    if(judge(mid)) ok=mid;
    else ng=mid;
  }

  cout<<ok<<endl;

  return 0;
}


Measured memory_bytes: 5376
/*
    Mbak Sana Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<int> vi;
int pref[30030][10];
int main()
{
    int n,m,i,j,k,x,y,ans,curr,temp;
    string a;
    cin >> n;
    cin >> a;
    int len = a.length();
    string s = " " + a;
    for(i=1;i<=len;i++)
    {
        curr = s[i] - '0';
        for(j=0;j<10;j++) pref[i][j] += pref[i-1][j];
        pref[i][curr]++;
    }
    set<string> st;
    for(i=2;i<len;i++)
    {
        for(j=0;j<10;j++)
        {
            for(k=0;k<10;k++)
            {
                if(pref[i-1][j] == 0 || pref[len][k] - pref[i][k] == 0) continue;
                char kiri, tengah, kanan;
                kiri = j + '0';
                kanan = k + '0';
                tengah = s[i];
                string jadi = "";
                jadi += kiri;
                jadi += tengah;
                jadi += kanan;
                st.insert(jadi);
            }
        }
    }
    int sana = st.size();
    printf("%d\n",sana);
    return 0;
}


Measured memory_bytes: 1536
# coding: utf-8
# Your code here!

def divisor_list(N): #約数のリスト
    if N == 1: return [1]
    res = []
    for i in range(1,N):
        if i*i >= N: break
        if N%i == 0:
            res.append(i)
            res.append(N//i)
    if i*i == N: res.append(i)
    return res#sorted(res)

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read


N = int(input())
div = divisor_list(N)
div2 = divisor_list(N-1)

ans = set()
for d in div:
    if d==1: continue
    n = N
    while n%d==0:
        n//=d
    if n%d==1: ans.add(d)

#print(ans,div2)

ans = len(ans)+len(div2)-1
print(ans)


Measured memory_bytes: 39152
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
ab=array(N)
N.times do|i|
    ab[i]=get_i
end
cd=array(N)
N.times do|i|
    cd[i]=get_i
end
ab.sort!{|x,y| y[0]<=>x[0]}
cd.sort!{|x,y| x[1]<=>y[1]}
visit=array(N,false)
ans=0
ab.each do|a,b|
    N.times do|i|
        if not visit[i] and a<cd[i][0] and b<cd[i][1]
          ans+=1
          visit[i]=true
          break
        end
    end
end
puts ans

Measured memory_bytes: 14308
N = int(input())
A = [int(s) for s in input().split()]
num = {}
for a in A:
    if a in num:
        num[a] += 1
    else:
        num[a] = 1
total = 0
for a in num:
    n = num[a]
    total += int(n * (n-1) / 2)
for a in A:
    print(total - num[a] + 1)

Measured memory_bytes: 25768
import sys
input = sys.stdin.readline
N,K=map(int,input().split())
A=list(map(int,input().split()))
nA=[a for a in A if a<0]
zero=[a for a in A if a==0]
pA=[a for a in A if a>0]
nA.sort(reverse=True)
pA.sort()

pR=0
neg=len(nA)*len(pA)*2
zzz=len(zero)*(N-len(zero)+N-1)

#積がx以下になる組み合わせの数
def f(x):
    global pR
    ret=0
    if x<0:
        pR=len(pA)-1
        for na in nA:
            while pR>=0:
                if na*pA[pR]>x: break
                pR-=1
            ret+=len(pA)-pR-1
    elif x==0:
        ret+=neg
        ret+=zzz
        ret//=2
    else:
        ret+=neg
        ret+=zzz
        pR=len(nA)-1
        for na in nA:
            while pR>=0:
                if na*nA[pR]<=x: break
                pR-=1
            ret+=pR+1
            ret-=1 if na*na<=x else 0
        pR=len(pA)-1
        for pa in pA:
            while pR>=0:
                if pa*pA[pR]<=x: break
                pR-=1
            ret+=pR+1
            ret-=1 if pa*pa<=x else 0
        ret//=2
    return ret
#組み合わせがK個未満になる最大のxを求める(l)
l=-10**18-1
r=10**18
while r-l>1:
    m=(r+l)//2
    if f(m)<K: l=m
    else: r=m
print(r)


Measured memory_bytes: 87636
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
//#define f first
//#define s second
//#define mp make_pair
#define gg return 0;
#define pii pair < int, int>
 
using namespace std;
 
const int maxn = 132675;
const int INF = (int)1e9;
 
ll a,b[maxn],c,d,cnt,e[(int)2e3 + 1][(int)2e3 + 1],cost[maxn],tout[maxn],mn = INF,mx = -INF,l,r;
 
ll x[maxn],y[maxn],x2[maxn],y2[maxn];
 
ll kol;

bool u[maxn], m, f;
 
vector <int> v;
 /*
void forn( int s, int f, int inter){
	for(int i = s; i <= f; i += inter){
		b[i] = i;
	}
}
*/ 
ll ans;
 
ll pref;
 
//vector <int> g[maxn],d[maxn];
 
ll lvlc,lvl[maxn];
ll pos;
/*
void dfs(int v){
	lvlc++;
	lvl[v] = lvlc;
	d[lvl[v]].pb(v);
	u[v] = 1;
	for(int i = 0; i < g[v].size(); ++i){
		int to = g[v][i];
		if(!u[to]){
			dfs(to);
		}
	}
	lvlc--;
}*/

map <int, int> mp; 
 
char ch;

string s; 

int main()
{	
	cin >> s;
	u[0] = 1;
	for(int i = 0; i < s.size(); ++i){
		if(u[i]){
			if(s.substr(i,5) == "dream"){
				u[i + 5] = 1;
			}
			if(s.substr(i,7) == "dreamer"){
				u[i + 7] = 1;
			}
			if(s.substr(i,5) == "erase"){
				u[i + 5] = 1;
			}
			if(s.substr(i,6) == "eraser"){
				u[i + 6] = 1;
			}
		}
	}
	if(u[s.size()]){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
	gg
}

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

int main(){
	int N,x;
	cin>>N>>x;
	
	int a[N];
	for(int i=0;i<N;i++)
		cin>>a[i];
	
	sort(a,a+N);
	
	int ans=0;
	for(int i=0;i<N;i++){
		x-=a[i];
		if(x>=0)
			ans++;
		else
			break;
	}
	if(x>0)
		ans--;
	
	cout<<ans<<endl;
	return 0;
		
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int p = i;
        int q = 1;
        while(p > 9){
            p /= 10;
            q++;
        }
        if(q % 2 == 1)
            ans ++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n % 10 == 0) {
        cout << 10 << endl;
        return 0;
    } else {
        int sum = 0;
        while (n > 0) {
            int digit = n % 10;
            sum += digit;
            n /= 10;
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;

int main(void){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int water = 0;
    int sato = 0;
    for(int i=0;i<=30;i++){
        for(int j=0;j<=30;j++){
            if(i==0 && j==0)continue;
            int t = 100*(a*i+b*j);
            if(t>f)continue;
            int lim = e*(a*i+b*j);
            for(int k=0;k<lim;k++){
                for(int l=0;l<lim;l++){
                    int s = c*k+d*l;
                    if(s>lim)continue;
                    int sum = t+s;
                    if(sum>f)continue;
                    if(water==0 && sato==0){
                        water = t;
                        sato = s;
                    }
                    else{
                        if(t*sato<s*water){
                            sato = s;
                            water = t;
                        }
                    }
                }
            }
        }
    }
    cout<<water+sato<<" "<<sato<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

const int MAX_A = 1000000;

int n,a[200010];
modint<MOD> coef[MAX_A + 5];

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 2;i <= MAX_A;i++) coef[i] = -modint<MOD>(i - 1) / modint<MOD>(i);
	coef[1] = 1;
	for(int i = 2;i * 2 <= MAX_A;i++){
		for(int j = i * 2;j <= MAX_A;j += i) coef[j] -= coef[i];
	}
	vector<vector<int>> dt(MAX_A + 5);
	modint<MOD> cnt[MAX_A + 5] = {},ans = 0;
	for(int i = 0;i < n;i++){
		modint<MOD> tmp = 0;
		if(dt[a[i]].size() == 0){
			for(int j = 1;j * j <= a[i];j++){
				if(a[i] % j == 0){
					dt[a[i]].push_back(j);
					if(j * j != a[i]) dt[a[i]].push_back(a[i] / j);
				}
			}
		}
		for(int d : dt[a[i]]){
			tmp += coef[d] * cnt[d];
			cnt[d] += a[i];
		}
		ans += tmp * modint<MOD>(a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    vector<long long> A(N);
    rep(i,N){
        cin>>A[i];
    }
    vector<long long> Sum(N+1);
    Sum[0]=0;
    rep(i,N){
        Sum[i+1]=Sum[i]+A[i];
    }
    //総和から累積和を引いて、累積和との差をメモる。
    //それの最小が答え
    long long ans=INF;
    rep(i,N){
        ans = min(ans,abs((Sum[N]-Sum[i])-Sum[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
n = int(input())
p = list(map(int,input().split()))
c = 0
k =0
L = n - 3
while(k <= L):
	if (p[k+1] - p[k])*(p[k+1] - p[k+2]) < 0:
		c += 1
	k +=1
print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
set<ll> st;
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
    	st.insert(2);
        // cout << 2 << " ";  
        n = n/2;  
    }  
    // cout<<n<<endl;
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
        	st.insert(i);
            // cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
    	st.insert(n);
        // cout << n << " ";  
}  
int main()
{
	ll a,b;
	cin>>a>>b;
	// cout<<__gcd(a,b)<<endl;
	ll num = __gcd(a,b);
	// cout<<num<<endl;
	primeFactors(num);
	st.insert(1);
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    int n;
    cin >> n;
    vector<i64> a(n);
    rep(i,n) cin >> a[i];

    if(n==1)
    {
        std::cout << n << endl;
        return 0;
    }

    int l = 0;
    int r = 0;
    i64 cnt = n;
    i64 tmp_sum = a[0];
    i64 tmp_xor = a[0];
    while(r < n-1 || l < n-1)
    {
        if(tmp_sum==tmp_xor)
        {
            while(r < n-1)
            {
                r++;
                tmp_sum += a[r];
                tmp_xor ^= a[r];
                if(tmp_sum==tmp_xor)
                {
                    cnt += r-l;
                }                    
                else
                {
                    break;
                }    
            }
            if(r == n-1 && tmp_sum==tmp_xor)
                break;
        }
        else
        {
            while(l < r)
            {
                l++;
                tmp_sum -= a[l-1];
                tmp_xor ^= a[l-1];
                if(tmp_sum==tmp_xor)
                {
                    cnt += r-l;
                    break;
                }                  
            }
        }
        
    }

    std::cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d) cout << "Left" << endl;
    else if(a+b == c+d) cout << "Balanced" << endl;
    else cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>

int arr[2000001];

int main()
{
    int a,b=1,c,i,k=0;
    scanf("%d",&a);
    for(i=1;i<=a;i++){
        scanf("%d",&c);
        arr[c]=arr[c-1]+1;
        k= arr[c]>k ? arr[c] : k ;
    }

    printf("%d",a-k);
    return 0;
}

Measured memory_bytes: 1024
n, x = [int(e) for e in input().split()]
m = []
for _ in range(n):
    m.append(int(input()))
m.sort(reverse = True)
x = x - sum(m)
count = len(m)
while len(m)>0:
    elem = m.pop()
    count = count + int(x / elem)
    x = x % elem
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ub upper_bound
    #define int long long
    #define vbe(sdk) sdk.begin(),sdk.end()
    #define pb push_back
    #define loop(i,a,b) for(int i=a;i<b;++i)
    #define rloop(i,a,b) for(int i=a;i>=b;--i)
    #define mp make_pair
    #define mod 1000000007
    #define endl '\n'
    #define vvll vector<vector<int> >
    #define vll vector<int>
    #define mint map<int,int> 
    #define sz(x) (int)x.size()
    #define sll set<int>
    #define pll pair<int,int>
    #define F first
    #define S second
    #define pi 3.14159265358979323846
    using namespace std;

  
    signed main()
    {
        int n,m;
        cin>>n>>m;
        if(n>1 && m>1)
        {
            cout<<n*(n-1)/2+m*(m-1)/2<<"\n";
        }
        else if(n>1)
        {
            cout<<n*(n-1)/2<<"\n";
        }
        else if(m>1)
        {
            cout<<m*(m-1)/2<<"\n";
        }
        else
        {
            cout<<"0\n";
        }
        

        

        return 0;
    }
 
 

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
ans = []


for i in range(n):
    ans.append(0)
    while a[i] % 2 == 0 and a[i] != 0:
        ans[i] += 1
        a[i] = a[i]//2
    
print(min(ans))


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

using namespace std;
 
typedef long long ll;
#define For(i,x,y) for(int i=x; i<y; ++i)
#define mem(x,y) memset(x,y,sizeof(x))
#define ALL(a) a.begin(),a.end()
#define PII pair<int,int>
#define INF 0x3f3f3f3f
#define DOF 0x7f7f7f7f
#define se second
#define fi first
#define endl '\n'
 
template <typename T>
inline void read(T &r){
    static char c; r=0; int f=1;
    for(c=getchar(); c<'0'||c>'9'; c=getchar()) if(c=='-')f=-1; 
    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());
    r*=f;
} // -_-

const int N = 220;

int main(){
    ll a, b; char c;
    scanf("%lld %c %lld",&a, &c, &b);
    if(c == '-') b = -b;
    printf("%lld\n", a + b);
    // system("pause");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  int b,c,d,e,f,g,h,i,j;
  cin >> a;
  b = a/10000000;
  c = a%10000000/1000000;
  d = a%1000000/100000;
  e = a%100000/10000;
  f = a%10000/1000;
  g = a%1000/100;
  h = a%100/10;
  i = a%10;
  j = b + c + d + e + f + g + h + i;
  if(a%j == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main()
{
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    long long l=1;
    for(long long i=1;i<=k;i++) l*=2;
    if(a>=b&&a>=c){
    	cout<<a*l+b+c<<endl;
	}
	else if(b>=a&&b>=c){
		cout<<b*l+a+c<<endl;
	}
	else{
		cout<<c*l+b+a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,b,c,d;
  cin >> n;
  
  a=n/1000;
  b=n/100-10*a;
  c=n/10-100*a-10*b;
  d=n-1000*a-100*b-10*c;
  
  if (a == b && b==c) {
    cout << "Yes" << endl;
  }
  else if (b== c && c==d) {
    cout << "Yes" << endl;
  } 
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3584
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    int ans;
    if (N % 111 == 0) {
        ans = N;
    } else {
        int base = N / 111;
        ans = (base + 1) * 111;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int X,A,B;
	scanf("%d %d %d",&X,&A,&B);

	printf("%d\n",(X-A)%B);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int main() {
    int S,h,m,s,a,b;
    scanf("%d",&S);
    h=S/3600;
    a=S%3600;
    m=a/60;
    s=a%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



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

int main() { 
    string a, b, c;
    cin >> a >> b >> c;

    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        t = (i, j, k)
        if Y == i*10000 + j*5000 + k*1000:
           print(*t)
           exit()
print('-1 -1 -1')

Measured memory_bytes: 68016
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>

#define ll long long

using namespace std;

const int NMAX = 1e5+5;

int v[NMAX];


int main()
{
    int n,i,j;

    cin>>n;
    bool ok = 1;
    for(i = 1 ; i <= n ; ++i)
    {
        cin>>v[i];
        if(v[i] > v[i-1])
            v[i]--;
        else if(v[i] < v[i-1])
            ok = 0;
    }

    if(ok)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

    int n;
    cin >> n;
    const double ans = (double)(n - n / 2) / n;

    cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  int c=0;
  for(int i=0;i<n;i++)
    cin>>v.at(i);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  if(n%2==0)
    for(int j=0;j<n;j+=2)
      c+=(v.at(j)-v.at(j+1));
  else{
    for(int k=0;k<n-2;k+=2)
      c+=(v.at(k)-v.at(k+1));
    c+=v.at(n-1);
          }
  cout<<c;
  return 0;
}

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

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);

typedef pair<int ,int> P;

#define max_m 1000001
//prime table : if index is prime then return true
bool prime[max_m];
//if index can be made , return true:
bool dp[max_m];

void sieve(){
    rep(i,max_m){
        prime[i] = true;
    }
    prime[0] = false;
    prime[1] = false;
    repi(i,2,max_m){
        for(int j=2*i;j<max_m;j+=i){
            prime[j] = false;
        }
    }
}


int main()
{
    sieve();
    while(1){
        int n,x;
        cin >> n >> x;
        if( n == 0 && x == 0 ) { break; }
        int dish[n];
        rep(i,max_m){ dp[i] = false; }
        rep(i,n){
            cin >> dish[i];
            dp[dish[i]] = true;
        }

        //puts(" dp initiated ");
        rep(i,n){
            rep(j,x){
                if( dp[j] && j+dish[i] < max_m){
                    //cout << j + dish[i] << "," << endl;;
                    dp[j + dish[i]] = true;
                    //cout << j + dish[i] << "," << endl;;
                }
            }
        }
        //puts(" dp finisehd ");

        bool isna=true;
        for(int i=x; 0<=i; i--){
            if( dp[i] && prime[i] ) { 
                cout << i << endl;
                isna = false;
                break;
            }
        }
        if(isna){ cout << "NA" << endl; }
        

    }
}

Measured memory_bytes: 3112
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using Graph =vector<vector<int>>;
//A 65
//a 97


int main(){
  int N,K;cin>>N>>K;
  string S;cin>>S;
  S[K-1]=S[K-1]+32;
  cout<<S<<endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    int res = 0;
    int tmp = 0;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        if (i > 0) {
            if (h[i-1] >= h[i]) {
                tmp++;
            } else {
                chmax(res, tmp);
                tmp = 0;
            }
        }
    }
    chmax(res, tmp);
    cout << res << endl;
}

Measured memory_bytes: 3760
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#define ll long long
#define MAX 20000000000
#define MOD 1000000007

int main(void){
int n,m;
scanf("%d%d",&n,&m);
printf("%d\n",(n-1)*(m-1));
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, M; cin >> N >> M;
    priority_queue<ll> A;
    rep(i, N) {
        ll num; cin >> num; A.push(num);
    }

    rep(i, M) {
        ll top = A.top(); A.pop(); top /= 2; A.push(top);
    }

    ll total = 0;
    while (A.size()) {
        total += A.top(); A.pop();
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
using namespace std;
int main(){
	int n;
	//x+y*y+z*z*zの、xが最少となるyとzの組み合わせを探す。
	while(cin>>n,n){
		int ans=10e8,now=n,now2=n,ans2=0,tmp=10e8;
			for(int i=0;i*i<=n;i++){
				for(int j=0;j*j*j<=n;j++){
					if(n-i*i-j*j*j>=0){
						tmp=min(n-i*i-j*j*j,tmp);
						ans=min(i+j+(n-i*i-j*j*j),ans);
					}
				}
			}
			cout<<ans<<endl;
		}
		return 0;
	}

Measured memory_bytes: 1164
def binary_search(l, t):
    left = 0
    right = len(l)

    while left < right:
        mid = (left + right)//2
        if l[mid] < t:
            left = mid + 1
        elif t < l[mid]:
            right = mid
        else:
            return True

def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    cnt = 0
    for et in t:
        bl = binary_search(s, et)
        if bl:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()



Measured memory_bytes: 16712
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ans = 0;

    if(n == k) cout << 1 << endl;
    else if(n <= 2*k - 2) cout << 2 << endl;
    else if(k == 2) cout << n-1 << endl;
    else {
        if(n % (k-1) == 0 || n % (k-1) == 1) {
            ans+=n/(k-1);
            cout << ans << endl;
        }
        else {
            ans+=(1 + n/(k-1));
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#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;

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

    vector<bool> check(n, false);
    int ans = 0;
    for(int d=1; d<=31; ++d){
        int k = -1;
        for(int i=0; i<n; ++i){
            if(!(a[i] <= d && d <= b[i]))
                continue;
            if(k == -1 || (!check[i] && check[k]) || (check[i] == check[k] && b[i] < b[k]))
                k = i;
        }
        if(!check[k]){
            ans += 100;
            check[k] = true;
        }
        else{
            ans += 50;
        }
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long LL;  //Attention!!
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

int n,m;
int i;
int j;

cin>>n>>m;

vector <pair<int,bool> > v(n,MP(1,false));
v[0].second = true;

int x,y;

for(i=0;i<m;i++)
	{
	cin>>x>>y;	
	x--;y--;
 	
	v[y].second |= v[x].second;	
  	v[x].first--;
  	v[y].first++;	

 	if(v[x].first == 0)
 		{	
 		v[x].second = false;
  		} 
  	}

int cnt = 0;
//for(i=0;i<n;i++)
//	cout<<v[i].first<<' '<<v[i].second<<endl;


for(i=0;i<n;i++)
	if(v[i].second)
		cnt++;
cout<<cnt<<endl;
}


Measured memory_bytes: 1024
s = input()
n = len(s)

candidate_1 = "10" * (n // 2) + "1" * (n % 2)
candidate_2 = "01" * (n // 2) + "0" * (n % 2)

cnt_1 = 0
cnt_2 = 0
for elem, can1, can2 in zip(s, candidate_1, candidate_2):
    if elem != can1:
        cnt_1 += 1
    if elem != can2:
        cnt_2 += 1
print(min(cnt_1, cnt_2))

Measured memory_bytes: 3316
N = int(input())
K = int(input())
l = len(str(N))
dp = [[[0]*(K+1) for _ in range(2)] for _ in range(l+1)]
# dp[i][smaller][j]
# i: 調べている桁
# smaller: 未満フラグ(未満のとき1)
# j: 0以外の数がj回出た

dp[0][0][0] = 1
for i in range(l):
  n = int(str(N)[i])
  for j in range(2):
    for k in range(K+1):
      for m in range(10):
        # 今までは一致
        if j == 0 and m > n:
          continue
        if j == 0 and m == n:
          nj = 0 # 今回も一致
          if m == 0:
            nk = k # 0なら回数は増えない
          else:
            if k < K:
              nk = k + 1 # 0以外の数がK-1回以下しかでていないなら増やす
            else:
              nk = k
              continue
        if j == 0 and m < n:
          nj = 1
          if m == 0:
            nk = k
          else:
            if k < K:
              nk = k + 1
            else:
              nk = k
              continue

        # すでに未満
        if j == 1:
          nj = j
          if m == 0:
            nk = k
          else:
            if k < K:
              nk = k + 1
            else:
              nk = k
              continue

        dp[i+1][nj][nk] += dp[i][j][k]

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



Measured memory_bytes: 41712
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll a, b, c;
  std::cin >> a >> b >> c;

  bool judge = a + b - c >= 0;
  if (judge) {
    print("Yes");
  } else {
    print("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
//#include <bits/stdc++.h>

#define ll long long int
#define pb push_back
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>

using namespace std;
// Function to print Excel column name for a given column number 
void printString(ll n) 
{ 
	char str[100]; 
	ll i = 0;

	while (n > 0) 
	{  
		ll rem = n % 26; 
		if (rem == 0) { 
			str[i++] = 'z'; 
			n = (n / 26) - 1; 
		} 
		else 
		{ 
			str[i++] = (rem - 1) + 'a'; 
			n = n / 26; 
		} 
	} 
	str[i] = '\0'; 

	// Reverse the string and print result 
	reverse(str, str + strlen(str)); 
	cout << str << endl; 
	return; 
} 
int main() 
{ 
	ll n;
	cin >> n;
	printString(n);
	return 0; 
} 


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

int main(){
   ll n; cin >> n;
   vector<ll> a(n);
   rep(i,n) cin >> a[i];
   ll q; cin >> q;
   vector<ll> b(q);
   vector<ll> c(q);
   rep(i,q){cin >> b[i] >> c[i];}
   vector<ll> flag(q);
   rep(i,n){
       flag[a[i]-1]++;
   }
   ll ans = 0;
   rep(i,n){ans += a[i];}
   ll cnt;
   rep(i,q){
       cnt = flag[b[i]-1];
       flag[c[i]-1] += cnt;
       flag[b[i]-1] = 0;
       ans = ans + (c[i]-b[i])*cnt;
       cout << ans << endl;
   }
   return 0;
}

Measured memory_bytes: 6356
#include <stdio.h>

#define N 20

int main() {
	static int aa[N], bb[N], cc[N];
	int n, i, sum;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]), aa[i]--;
	for (i = 0; i < n; i++)
		scanf("%d", &bb[i]);
	for (i = 0; i < n - 1; i++)
		scanf("%d", &cc[i]);
	sum = 0;
	for (i = 0; i < n; i++) {
		sum += bb[aa[i]];
		if (i > 0 && aa[i - 1] == aa[i] - 1)
			sum += cc[aa[i - 1]];
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 128
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
As = list(map(lambda x: int(x)-1, input().split())) #0-indexed
lovesWho = [-1]*N

ans = 0
for i, i_love in enumerate(As):
  if lovesWho[i_love] == i:
    ans += 1
  else:
    lovesWho[i] = i_love

print(ans)



Measured memory_bytes: 52664
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();
    let mut it = input.trim().split_whitespace();
    let r:u64 = it.next().unwrap().parse().unwrap();
    let d:u64 = it.next().unwrap().parse().unwrap();
    let x:u64 = it.next().unwrap().parse().unwrap();
    let mut res = x;
    for _ in 0..10 {
        res = res * r - d;
        println!("{}",res);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,m,a,b,c,d;
  cin>>n;
  vector<int> p(n+1,0),q(n+1,0);
  m=n*(n-1)/2;
  rep(i,m){
    cin>>a>>b>>c>>d;
    if(c==d){
      p[a]++;
      p[b]++;
    }
    else if(c==max(c,d))p[a]+=3;
    else if(d==max(c,d))p[b]+=3;
  }
  int ma=0,z=0,k=1,o=0;
  while(z!=n){
    rep(i,n+1){
      if(i!=0)ma=max(ma,p[i]);
    }
    rep(i,n+1){
      if(ma==p[i]){
	q[i]=k;
	p[i]=0;
	z++;
	o++;
      }
    }
    k+=o;
    ma=0;
    o=0;
  }
  rep(i,n+1){
    if(i!=0)cout<<q[i]<<endl;
  }
  return (0);
}

Measured memory_bytes: 3084
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int a=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='*'){
      cout<<a<<endl;
      break;
    }
    else if(s[i]=='(')a++;
    else a--;
  }
}

Measured memory_bytes: 3164
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

import scala.annotation.tailrec

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val scanner = new Scanner(in)
    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val _ = scanner.nextLine().toInt
      val ns = scanner.nextLine().split(" ").map(_.toInt)

      val result = ns.map { n =>
        if (n % 2 == 0) {
          f(0, n)
        } else {
          0
        }
      }.sum

      output.println(result)
    }

    @tailrec
    private def f(c: Int, n: Int): Int =
      if (n % 2 == 0) {
        f(c + 1, n / 2)
      } else {
        c
      }


  }

}


Measured memory_bytes: 31592
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ans = new int[n];
		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			ans[tmp - 1] = i + 1;
		}
		sc.close();
		for (int i = 0; i < n; i++) {
			System.out.print(ans[i]);
			if (i < n - 1)
				System.out.print(" ");
		}
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 61332
#include <iostream>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a >= b && a >= c){
    a *= 10;
  }else if(b >= a && b >= c){
    b *= 10;
  }else{
    c *= 10;
  }
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	unsigned int n;
	cin>>n;
	if(n<=1000)
	{
		cout<<1000 - n<<"\n";
	}
	else
	{
		if(n%1000==0)
		cout<<"0"<<"\n";
		else if(n>1000 && n<2000)
		cout<<1000*2-n<<"\n";
		else if(n>2000 && n<3000)
		cout<<1000*3-n<<"\n";
		else if(n>3000 && n<4000)
		cout<<1000*4-n<<"\n";
		else if(n>4000 && n<5000)
		cout<<1000*5-n<<"\n";
		else if(n>5000 && n<6000)
		cout<<1000*6-n<<"\n";
		else if(n>6000 && n<7000)
		cout<<1000*7-n<<"\n";
		else if(n>7000 && n<8000)
		cout<<1000*8-n<<"\n";
		else if(n>8000 && n<9000)
		cout<<1000*9-n<<"\n";
		else if(n>9000 && n<10000)
		cout<<1000*10-n<<"\n";		
	}
	return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();

		int ans = 0;
		long n = N;
		long before_yakusuu;
		long yakusuu = -1;
		long count = 0;	//指数
		long limit = 0;	//現在の必要上限(1, 2, 3, ...と増やしていく)
		while(n >= 2) {
			before_yakusuu = yakusuu;
			yakusuu = fact(n);
			if(yakusuu == -1) {
				break;
			}

			if(yakusuu != before_yakusuu) {
				count = 1;
				limit = 0;
			}else {
				count++;
			}

			if(count > limit) {
				ans++;
				limit++;
				count = 0;
			}
			n /= yakusuu;
		}

		System.out.println(ans);

	}

	//最小の約数を返す(素因数分解用)
	public static long fact(long n){
		if(n < 2)
			return -1;

		for(long i=2; i<=Math.sqrt(n); i++) {
			if(n % i == 0)
				return i;
		}

		return n;
	}
}


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

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

    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];// a+b, b+c, c+d, ...
    }

    long long int all = 0;
    for(int i=0; i<n; i++){
        all += a[i];
    }
    all /= 2;// a+b+c+...+x+y

    long long int odd_only = 0;
    for(int i=0; i<n; i += 2){
        odd_only += a[i];// a+b+c+...+x+y+a
    }

    vector<long long int> answer(n);
    answer[0] = odd_only - all;
    for(int i=1; i<n; i++){
        answer[i] = a[i-1] - answer[i-1];
    }

    for(int i=0; i<n; i++){
        cout << 2 * answer[i] <<" ";
    }
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,q,a,b,c;
    ll ans = 0;
    cin>>n;
    unordered_map<int,int>mp;
    rep(i,n){
        cin>>a;
        mp[a]++;
        ans += a;
    }
    cin>>q;
    rep(i,q){
        cin>>b>>c;
        ll sum = (c - b) * mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        ans += sum;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6976
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;

const int MAX_N = 300005;

int n, A[MAX_N];
vector<int> V;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        A[a]++;
    }
    
    int dod = 0;
    for(int i = 1; i <= n; i++) {
        if(A[i] > 0) {
            V.push_back(A[i]);
            dod++;
        }
    }
    sort(V.begin(), V.end());
    
    int suma = n;
    for(int i = 1; i <= n; i++) {

        bool go = true;
        while(go) {
            go = false;
            for(int j = dod - 1; j >= 0; j--) {
                if(V[j] <= suma / i) {
                    break;
                } 
                while(V[j] > suma / i) {
                    V[j]--;
                    suma--;
                    go = true;
                }
            }
        }
        if(i > dod) cout << 0 << endl;
        else cout << suma / i << endl;
    }

    return 0;
}


Measured memory_bytes: 3572