akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 読み込んだ置き換え情報
type ReplaceInfo struct {
	maxReplaceCount int
	number          int
}
type ReplaceInfos []ReplaceInfo

func (infos ReplaceInfos) Len() int           { return len(infos) }
func (infos ReplaceInfos) Swap(i, j int)      { infos[i], infos[j] = infos[j], infos[i] }
func (infos ReplaceInfos) Less(i, j int) bool { return infos[i].number > infos[j].number }

//
func solve(q []int, info ReplaceInfos) int64 {
	sort.Ints(q)
	sort.Sort(info)

	useCardIndex := 0
	arrLen := len(q)
	replaceLen := len(info)
	replaceCount := 0
	for i := 0; i < arrLen; i++ {
		if replaceCount >= info[useCardIndex].maxReplaceCount {
			replaceCount = 0
			useCardIndex++
		}
		if useCardIndex >= replaceLen {
			break
		}
		if info[useCardIndex].number <= q[i] {
			break
		}
		q[i] = info[useCardIndex].number
		replaceCount++
	}
	total := int64(0)
	for _, v := range q {
		total += int64(v)
	}
	return total
}
func main() {
	var n, m int
	var q []int
	var info []ReplaceInfo

	fmt.Scanln(&n, &m)
	q = make([]int, n)
	info = make([]ReplaceInfo, m)
	//read initial numbers
	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		q[i] = a
	}
	//read each line
	for i := 0; i < m; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		info[i] = ReplaceInfo{a, b}
	}
	ans := solve(q, info)
	fmt.Println(ans)
}


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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


main(){
	string s;
	cin >> s;
	
	int m = 0;
	int t = 0;
	for(int i=0;i<3;i++){
		if(s[i]=='R'){
			m = max(t+1,m);
			t++;
		}else{
			t = 0;
		}
	}

	cout << m << endl;


	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

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

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();

		int numOfPass = 0;
		int rankB = 0;
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < n; i++) {
			char c = s.charAt(i);
			boolean isPass = false;

			switch (c) {
			case 'a':
				if (numOfPass < a + b) {
					numOfPass++;
					isPass = true;
				}
				break;
			case 'b':
				rankB++;
				if (numOfPass < a + b && rankB <= b) {
					numOfPass++;
					isPass = true;
				}
				break;
			case 'c':
				break;
			default:
				break;
			}

			sb.append(isPass ? "Yes\n" : "No\n");
		}

		System.out.println(sb.toString());

		sc.close();
	}

}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, long long L){

    vector<lli> a(N);
    lli sum = 0;
    lli num = INF;
    REP(i,0,N){
        sum += L+i;
        //if(DEBUG)cout<<"L+i="<<L+i<<endl;
        if(abs(num) > abs(L+i)){
            num = L+i;
        }
    }
    //if(DEBUG)cout<<"num="<<num<<endl;
    sum -= num;
    cout<<sum<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    func(N, L);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(a) for(int i=0; i<a; i++)
using namespace std;
typedef pair<int, int> P;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
bool cmp(int a, int b)
{
	return a > b;
}
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge one, two;
	one.from = a; one.to = b; one.weight = c;
	two.from = b; two.to = a; two.weight = c;
	V[a].push_back(one);
	V[b].push_back(two);
}


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


void solve()
{
	cin >> a >> str1;
	int ans = 0;
	int size = str1.size();
	loop(size)
	{
		int counting[26]; memset(counting, 0, sizeof(counting));
		int cnt = 0;
		for(int j = 0; j <= i; j++)
			counting[str1[j] - 'a'] = 1;
		for(int j = i + 1; j < size; j++)
			if(counting[str1[j] - 'a'] == 1)
			{
				cnt++;
				counting[str1[j] - 'a'] ++;
			}
		ans = max(ans, cnt);
//		printf("%d %d\n",i, cnt);
	}
	printf("%d\n",ans);
}
int main()
{
	int times = 1;
//	cin << times;
	loop(times)
	{
		solve();
		printf("\n");
	}
	return 0;
}

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

int main(void){
  int n;
  cin>>n;
  vector<int> in(n*2);
  for(int i = 0 ; i < n * 2 ; i ++){
    cin>>in[i];
  }
  sort(in.begin(),in.end());
  int ret = 0;
  for(int i = 0 ; i < n*2 ; i += 2){
    ret += in[i];
  }
  cout<<ret<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int h, w;
    string tmp;
    int flag = 0;
    cin >> h >> w;
    vector<string> data(h);
    vector<vector<char> > r(w, vector<char>(h));
    vector<vector<char> > rr(h, vector<char>(w));

    // データを挿入
    for (int i = 0; i < h; i++)
    {
        cin >> data.at(i);
    }

    // 横列全部白のものを削除
    int k = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (data.at(i)[j] == '.')
            {
                continue;
            }
            if (data.at(i)[j] == '#')
            {
                flag++;
            }
        }
        // cout << "debug" << endl;
        if (flag > 0)
        { // 同じでなかったらデータを入れる
            for (int j = 0; j < w; j++)
            {
                r.at(j).at(k) = data.at(i)[j]; // 縦と横を回転
            }
            k++;
        }
        flag = 0;
    }
    // cout << endl;
    // cout << "w: "<< w <<" k: "<< k << endl;
    // // debug
    // for (int i = 0; i < w; i++)//最後にk++する分をマイナスする
    // {
    //     for (int j = 0; j < k; j++)
    //     {
    //         cout << r.at(i).at(j);
    //     }
    //     cout << endl;
    // }

    // 縦列全部白のものを削除
    int l = 0;
    for (int i = 0; i < w; i++)
    {
        flag = 0;
        for (int j = 0; j < k; j++)
        {
            if (r.at(i).at(j) == '.')
            {
                continue;
            }
            if (r.at(i).at(j) == '#')
            {
                flag++;
            }
        }
        if (flag > 0)
        { // 同じでなかったらデータを入れる
            for (int j = 0; j < k; j++)
            {
                rr.at(j).at(l) = r.at(i).at(j); // 縦と横を回転
            }
            l++;
        }
    }
    // cout << "l: "<< l <<" k: "<< k << endl;

    // 表示
    for (int i = 0; i < k; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cout << rr.at(i).at(j);
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n, k;
    int ans = INF;
    cin >> n >> k;
    VE h;
    rep(i, n) {
        int enter;
        cin >> enter;
        h.pb(enter);
    }
    sort(h.begin(), h.end());
    rep(i, n - k + 1) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main(){
    int D, T, S;
    cin >> D >> T >> S;
    if(D % S == 0){
        if(D / S <= T){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(D / S + 1 <= T){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 int N = scan.nextInt();
		 int kai = 0;
		 int index = 0;
		 
		 for (int i = 0; i < N; i++ ) {
			 index = scan.nextInt();
			 while (index % 2 == 0) {
				 kai += 1;
				 index /= 2;
			 }
		 }
		 
		 System.out.println(kai);
		 
		 scan.close();
	}

}


Measured memory_bytes: 35924
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];//Union-find
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

//セグメント木？？？


double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

//Unionfind ,Disjointset
class UnionFind{
public:
//親の番号を格納する　親の場合-（その集合のサイズ）
    vector<int> Parent;
    //作るときはParentの値を全て-１にする
    UnionFind(int n){
        Parent = vector<int>(n,-1);
    }
    //Aがどのグループに属するか
    int root(int A){
        if(Parent[A] < 0)return A;
        return Parent[A]=root(Parent[A]);
    }
    //自分のグループの頂点数
    int size(int A){
        return -Parent[root(A)];
    }
    //AとBをくっつける
    int connect(int A,int B){
        //AとBを直接ではなくAのrootとBのrootをくっつける
        A = root(A);
        B = root(B);
        if(A==B){
            return false;//すでにくっついている
        }
        if(size(A)<size(B)) swap(A,B);
        //Aのサイズ更新
        Parent[A]+=Parent[B];
        //Bの親をAに変更する
        Parent[B]=A;

        return true;
    }
};

int main(){
    ll n,m;
    cin >> n>>m;
    vector<ll>ans(m);
    ans[m-1]=n*(n-1)/2;

    UnionFind Uni(n);
    int A[m],B[m];
    rep(i,m){
        cin >> A[i]>>B[i];
        A[i]--;B[i]--;
    }
    for(int i=m-1;i>=1;i--){
        ans[i-1]=ans[i];
        //繋がったとき
        if(Uni.root(A[i]) !=Uni.root(B[i])){
            ans[i-1]-=Uni.size(A[i])*Uni.size(B[i]);
            Uni.connect(A[i],B[i]);
        }
    }
    rep(i,m){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3328
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> a, std::vector<long long> b){
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n % 2){
        cout << b[n / 2] - a[n / 2] + 1 << endl;
    }
    else{
        int lb = a[n / 2] + a[n / 2 - 1];
        int rb = b[n / 2] + b[n / 2 - 1];
        cout << rb - lb + 1 << endl;
    }
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


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

using namespace std;

typedef long long ll;

#ifdef RED
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int N = (int)1e6 + 5;
const int inf = (int)1e9 + 7;

int n;
int a[N], b[N], c[N];
int dp[N][5];

int main() {
#ifdef RED
  freopen("a.in", "r", stdin);
#endif
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    dp[i][1] = dp[i][2] = dp[i][3] = -inf;
  }
  dp[1][1] = a[1];
  dp[1][2] = b[1];
  dp[1][3] = c[1];
  for (int i = 2; i <= n; ++i) {
    dp[i][1] = max(dp[i][1], dp[i - 1][2] + a[i]);
    dp[i][1] = max(dp[i][1], dp[i - 1][3] + a[i]);
    dp[i][2] = max(dp[i][2], dp[i - 1][1] + b[i]);
    dp[i][2] = max(dp[i][2], dp[i - 1][3] + b[i]);
    dp[i][3] = max(dp[i][3], dp[i - 1][1] + c[i]);
    dp[i][3] = max(dp[i][3], dp[i - 1][2] + c[i]);
  }
  cout << max(dp[n][1], max(dp[n][2], dp[n][3])) << "\n";
  return 0;
}


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

typedef long long int ll;

int main(){
	int n;
	cin >> n;
   	vector<int> A(n, 0);
   	vector < vector<ll> > cost(n, vector<ll> (n, 0));
   	vector < vector<ll> > siz(n, vector<ll> (n, 0));
   	for(int i = 0; i < n; i++){
		cin >> A[i];
		cost[i][i] = 0;
		siz[i][i] = A[i];
	}
   
   	ll mini;
   	for(int k = 1; k < n; k++){
		for(int i = 0; (i + k) < n; i++){
          	mini = -1;
			for(int j = i; j < i+k; j++){
				if(mini == -1){
					mini = cost[i][j] + siz[i][j] + cost[j+1][i+k] + siz[j+1][i+k];
					siz[i][i+k] = siz[i][j] +  siz[j+1][i+k];
				}
				if(mini > cost[i][j] + siz[i][j] + cost[j+1][i+k] + siz[j+1][i+k] ){
					mini = cost[i][j] + siz[i][j] + cost[j+1][i+k] + siz[j+1][i+k];
					siz[i][i+k] = siz[i][j] +  siz[j+1][i+k];
				}
 			}
			cost[i][i+k] = mini;
		}
	}	
	
   	cout << cost[0][n-1] << endl;

   	return 0;
   
}


Measured memory_bytes: 6112
#include <bits/stdc++.h>
#ifdef BUG
  #include "debug.hpp"
#else
  #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char **argv) {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n;
  string str;
  cin >> n >> str;
  const size_t nw = count(str.begin(), str.end(), '.');
  size_t out = nw;
  for (size_t i = 0, rw = 0, rb = 0; i < str.size(); ++i) {
    rw += str[i] == '.';
    rb += str[i] == '#';
    const size_t val = rb + nw - rw;
    out = min(out, val);
  }
  cout << out;
  return EXIT_SUCCESS;
}


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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    if ( N % 2 == 0 )  {
        ll s = 0;
        for ( int i = 0; i < N/2; i++ ) {
            s -= A[i];
        }
        for ( int i = N/2; i < N; i++ ) {
            s += A[i];
        }
        s *= 2;
        s += A[N/2-1] - A[N/2];
        return s;
    } else {
        ll s1 = 0, s2 = 0;
        int mid = (N-1)/2;
        for ( int i = 0; i < mid; i++ ) {
            s1 -= A[i];
            s2 -= A[i];
        }
        for ( int i = mid+1; i < N; i++ ) {
            s1 += A[i];
            s2 += A[i];
        }
        s1 += A[mid];
        s2 -= A[mid];
        s1 *= 2;
        s2 *= 2;
        s1 -= A[mid] + A[mid+1];
        s2 += A[mid] + A[mid-1];
        return  max(s1,s2);
    }
    return 0;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
  int a, b , x, i, ans;
  scanf("%d %d",&a, &b);
  if(a > b) {
    x = a;
    a = b;
    b = x;
  }
  ans = 1;
  i = 2;
  while (i <= a) { 
    if (a % i == 0 && b % i == 0) {
      a = a / i;
      b = b / i;
      ans = ans * i;
      i = 1;
    }
    i++;
  }
  printf("%d\n",ans);
  return 0;

}

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

int n,m,d[10009];
int h[10]={0, -2, -5, -5, -4, -5, -6, -3, -7, -6};
bool c[10];
int main(void){
    cin>>n>>m;
    fill(c, c+10, false);
    fill(d, d+1004, -1);
    for(int i=0;i<m;i++){
        int a;cin>>a;
        h[a]*=-1;
        c[h[a]]=true;
        d[h[a]]=1;
    }
    for(int i=2;i<=n;i++){
        for(int j=2;j<=7;j++){
            int p=d[max(0, i-j)];
            if(c[j]&&p>0&&d[i]<p+1)d[i]=p+1;
        }
        //cout<<"--- "<<i<<" : "<<d[i]<<endl;
    }
    d[0]=0;
    int r=n;
    while(r>0){
        for(int i=9;i>=1;i--){
            if(h[i]>0&&r-h[i]>=0&&d[r-h[i]]==d[r]-1){
                r-=h[i];
                cout<<i;
                break;
            }else if(i==1){
                cout<<"-"<<r<<"-"<<d[r]<<endl;
                return 0;
            }
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
S = S.split(" ")
n = int(S[0])
k = int(S[1])
arr = []
for i in range(n):
    arr.append(int(input()))


def calculate(n,k,arr):
    arr.sort()
    drr = []
    for i in range(1,n):
        drr.append(arr[i] - arr[i-1])

    j = 0
    s = 0
    sums = []
    for i in range(len(drr) - (k-1) + 1):
        while j < i + (k-1):
            s = s + drr[j]
            j = j + 1
        sums.append(s)
        s = s - drr[i]


    print(min(sums))


calculate(n,k,arr)



Measured memory_bytes: 15564
x=list(map(int,list(input())))
a=x[0]
b=x[1]
c=x[2]
d=x[3]

if a+b+c+d==7:   print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a-b+c+d==7: print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a+b+c-d==7: print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a-b+c-d==7: print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a+b-c+d==7: print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a-b-c+d==7: print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a+b-c-d==7: print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a-b-c-d==7: print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")

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

struct Node {
    int parent;
    int lc, rc;
};

#define NIL -1

vector<Node> tree;
vector<int> depth;
vector<int> height;

void setDepth(int u, int p) {
    depth[u] = p;
    if (tree[u].lc != NIL) setDepth(tree[u].lc, p+1);
    if (tree[u].rc != NIL) setDepth(tree[u].rc, p+1);
}

int setHeight(vector<int>& h, int u) {
    int hl = 0, hr = 0;
    if (tree[u].lc != NIL) hl = setHeight(h, tree[u].lc) + 1;
    if (tree[u].rc != NIL) hr = setHeight(h, tree[u].rc) + 1;

    return h[u] = max(hl, hr);
}

int main() {
    int n;
    cin >> n;
    int i;
    rep(i, n) { // init
        Node node;
        node.parent = NIL;
        node.lc = NIL;
        node.rc = NIL;
        tree.push_back(node);
    }
    rep(i, n) {
        depth.push_back(0);
    }
    rep(i, n) {
        height.push_back(0);
    }

    rep(i, n) { // input
        int id, l, r;
        cin >> id >> l >> r;
        tree[id].lc = l;
        tree[id].rc = r;
        if (l != NIL) tree[l].parent = id;
        if (r != NIL) tree[r].parent = id;
    }

    // search root
    int root;
    rep(i, n) {
        if (tree[i].parent == NIL)
            root = i;
    }

    setDepth(root, 0);
    setHeight(height, root);

    // print
    int sib, deg = 0;
    string type;
    rep(i, n) {
        sib = NIL;
        if (tree[i].parent != NIL) {
            if (tree[tree[i].parent].lc != i && tree[tree[i].parent].lc != NIL)
                sib = tree[tree[i].parent].lc;
            else if (tree[tree[i].parent].rc != i && tree[tree[i].parent].rc != NIL)
                sib = tree[tree[i].parent].rc;
        }

        deg = 0;
        if (tree[i].lc != NIL) deg++;
        if (tree[i].rc != NIL) deg++;

        cout << "node " << i << ": ";
        cout << "parent = " << tree[i].parent << ", ";
        cout << "sibling = " << sib << ", ";
        cout << "degree = " << deg << ", ";
        cout << "depth = " << depth[i] << ", ";
        cout << "height = " << height[i] << ", ";

        if (tree[i].parent == NIL) type = "root";
        else if (height[i] == 0) type = "leaf";
        else type = "internal node";

        cout << type << endl;
    }

    return 0;
}



Measured memory_bytes: 3172
#include<cstdio>
#include<iostream>
using namespace std;
long long a,b;
int main()
	{
		cin>>a>>b;
		if(a+b==15) cout<<'+'<<endl;
		else if(a*b==15) cout<<'*'<<endl;
		else cout<<'x'<<endl;
		return 0;
	}

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

using namespace std;

int D[1007][1007], H, W, md = (int) 1e9 + 7;
char a[1007][1007];

int main() {
  scanf("%d%d\n", &H, &W);
  int i, j;
  for (i = 1; i <= H; i++) {
    for (j = 1; j <= W; j++) {
      scanf("%c", &a[i][j]);
    }
    scanf("%*c");
  }
  for (i = 1; i <= H; i++) {
    if (a[i][1] == '.') D[i][1] = 1;
    else if (a[i][1] == '#') break;
  }
  for (j = 1; j <= W; j++) {
    if (a[1][j] == '.') D[1][j] = 1;
    else if (a[1][j] == '#') break;
  }
  for (i = 2; i <= H; i++) {
    for (j = 2; j <= W; j++) {
      if (a[i][j] == '#') continue;
      D[i][j] = (D[i-1][j] + D[i][j-1]) % md;
    }
  }
  printf("%d", D[H][W]);
  return 0;
}
      

Measured memory_bytes: 5120
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int, h: "List[int]"):
    dp = [float('inf')] * N
    dp[0] = 0

    for i in range(N):
        for j in range(1, K+1):
            if (i + j) < N:
                dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
    return dp[-1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, K, h)
    print(result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 81068
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {



        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        String result = "";
        int ab = a + b;
        int cd = c + d;
        if(ab < cd) {
        	result = "Right";
        } else if(ab == cd) {
        	result = "Balanced";
        } else if(ab > cd) {
        	result = "Left";
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 2100000000
#define MOD 1000000007

bool dbgflag = false; //debug

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

  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> num = {a, b, c};

  if (dbgflag) cout << num[0] << num[1] << num[2] << endl;

  vector<string> op(n);
  vector<char> doop(n);
  for (int i = 0; i < n; i++) cin >> op[i];

  if (((a == 0) && (b == 0) && (op[0] == "AB")) || ((a == 0) && (c == 0) && (op[0] == "AC")) || ((c == 0) && (b == 0) && (op[0] == "BC"))) {
    if (dbgflag) cout << "case1" << endl;
    cout << "No" << endl;
    return 0;
  }

  if (a + b + c == 1) {
    if (dbgflag) cout << "case2" << endl;
    for (int i = 0; i < n; i++) {
      if (dbgflag) cout << num[0] << num[1] << num[2] << endl;;
      char s = op[i][0];
      char t = op[i][1];
      if (num[s-'A'] == num[t-'A']) {
        if (dbgflag) cout << num[s-'A'] << num[t-'A'] << endl;
        cout << "No" << endl;
        return 0;
      }
      doop[i] = (num[s-'A'] == 0) ? s : t;
      swap(num[s-'A'], num[t-'A']);
    }

    cout << "Yes" << endl;
    for (int i = 0; i < n; i++) {
      cout << doop[i] << endl;
    }
    return 0;
  }

  for (int i = 0; i < n; i++) {
    if (dbgflag) cout << "case3" << endl;
    if (dbgflag) cout << num[0] << num[1] << num[2] << endl;
    char s = op[i][0], t = op[i][1];
    if ((num[s-'A'] != num[t-'A']) || (i+1 == n)) {
      if (num[s-'A'] > num[t-'A']) {
        num[s-'A']--;
        num[t-'A']++;
        doop[i] = t;
      }
      else {
        num[s-'A']++;
        num[t-'A']--;
        doop[i] = s;
      }
    }
    else if ((i+1 != n) && (num[s-'A'] == num[t-'A'])) {
      if ((num[s-'A'] == 1) && (op[i] != op[i+1])) {
        if (op[i] == "AB") {
          if (op[i+1] == "AC") {
            num[0]++;
            num[1]--;
            doop[i] = 'A';
          }
          else {
            num[1]++;
            num[0]--;
            doop[i] = 'B';
          }
        }
        else if (op[i] == "AC") {
          if (op[i+1] == "AB") {
            num[0]++;
            num[2]--;
            doop[i] = 'A';
          }
          else {
            num[0]--;
            num[2]++;
            doop[i] = 'C';
          }
        }
        else { //BC
          if (op[i+1] == "AC") {
            num[1]--;
            num[2]++;
            doop[i] = 'C';
          }
          else {
            num[1]++;
            num[2]--;
            doop[i] = 'B';
          }
        }
      }
      else {
        num[s-'A']--;
        num[t-'A']++;
        doop[i] = t;
      }
    }
  }

  cout << "Yes" << endl;
  for (int i = 0; i < n; i++) {
    cout << doop[i] << endl;
  }
}


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


void solve(std::vector<long long> x){
    for(int i=0;i<5;i++)if(x[i]==0)
    {
        cout<<i+1<<endl;
        return;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3696
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    //
    input! {
        s: Chars,
        t: Chars,
    }

    let sum = s
        .iter()
        .zip(t.iter())
        .fold(0, |acc, (a, b)| if a == b { acc } else { acc + 1 });
    println!("{}", sum);
}


Measured memory_bytes: 4024
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int y,m,d;
        cin>>y>>m>>d;
        int ans=0;
        int sum=0;
        for(int i=1;i<y;i++)
        {
            if(i%3==0)sum+=200;
            else sum+=195;
        }
        if(y%3==0)sum+=20*(m-1);
        else
        {
            for(int i=1;i<m;i++)
            {
                if(i%2==0)sum+=19;
                else sum+=20;
            }
        }
        sum+=d;
        ans=196470-sum+1;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>

using namespace std;
typedef long long ll;

ll N;
ll A[6] = {};
ll Min = 1e16;
ll ans = 0;

int main() {
	cin >> N;
	for (int i = 1; i <= 5; i++) {
		cin >> A[i];
		if (A[i] < Min)Min = A[i];
	}
	if (N%Min == 0) {
		ans = 5 + N / Min - 1;
	}
	else {
		ans = 5 + N / Min;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
A, B = map(int,input().split())

count=0
for C in range(1,4):
    if A*B*C %2 ==1:
        print("Yes")
        break #この時点で繰り返しを中断、終了する
    else:#A*B*Cが偶数のとき
        
        count = count +1# Noと繰り返しぶん表示させず１回の表示で済ますため、少なくとも１回A*B*Cが偶数なら「No」と１回表示するようにしている
if count>0:
    print("No")
        

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  int m;
  cin >> m;
  string t;
  bool closed = true;
  bool flag;
  for(int i=0;i<m;i++){
    cin >> t;
    flag=false;
    for(int j=0;j<n;j++){
      if(t==s[j]){
        closed=(!closed);
        cout << (closed?"Closed by ":"Opened by ") <<
            t << endl;
        flag=true;
      }
    }
    if(!flag){
      cout << "Unknown " << t << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3220
//package bigneer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub

		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
//		int t=Integer.parseInt(br.readLine());
//		while(t-->0) {
			int n=Integer.parseInt(br.readLine());
			String q[]=br.readLine().split(" ");
			int a[]=new int[n];
			for(int i=0;i<n;i++){
				a[i]=Integer.parseInt(q[i]);
			}
			int c=0;
		     for(int i=0;i<n;i+=2)
		    	 if(a[i]%2!=0)
		    		 c++;
		     System.out.println(c);
//		}
	}

}


Measured memory_bytes: 32740
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n,m=MI()
pref=[]
for i in range(m):
    p,y=MI()
    pref+=[(p,i,y)]
pref.sort(key=lambda x:x[0]*10**10+x[2])
c=0
pre=pref[0][0]
ans=[]
for p,i,y in pref:
    pid='0'*(6-len(str(p)))+str(p)
    if pre==p:
        c+=1
        cid='0'*(6-len(str(c)))+str(c)
    else:
        c=1
        cid='0'*(6-len(str(c)))+str(c)
    ans+=[(i,pid+cid)]
    pre=p
ans.sort(key=lambda x:x[0])
for i,iid in ans:
    print(iid)


Measured memory_bytes: 88920
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define chmin(i, j) i = min(i, j);
#define chmax(i, j) i = max(i, j);
#define rep(i, n) for(int i=0;i<n;i++)
int main() {
  long long x;
  cin >> x;
  cout << x / 500 * 1000LL + x % 500 / 5LL * 5 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long                           
#define pii pair<int,int>      
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define IOS ios_base::sync_with_stdio(false)
#define mp make_pair
#define pb push_back                                                                                                           
using namespace std;
int main(){
	int a, b, c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
int a[2010];
int n,ans=0;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	repeat(i,0,n)
		cin>>a[i];
	sort(a,a+n);
	repeat(i,0,n)
	repeat(j,i+1,n){
		int M=lower_bound(a+j+1,a+n,a[i]+a[j])-a-1;
		int m=j+1;
		//cout<<a[i]<<' '<<a[j]<<' '<<m<<' '<<M<<endl;
		ans+=M-m+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn sum_digits(i: i32) -> i32 {
    i.to_string().chars().map(|j| j as i32 - 48).fold(0, |sum, x| sum + x)
}

fn main() {
    let v = read_vec::<i32>();
    let n = v[0];
    let a = v[1];
    let b = v[2];

    let mut sumall = 0;
    for i in 1..n+1 {
        let s = sum_digits(i);
        if s >= a && s <= b {
            sumall += i;
        }
    }
    println!("{}", sumall);
}


Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextLong());
        }
        System.out.println(list.stream().sorted(Comparator.reverseOrder()).skip(k).collect(Collectors.summingLong(Long::longValue)));
    }
}

Measured memory_bytes: 67044
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
count = 0
for i in range(1, n + 1):
    if len(str(i)) % 2 == 1:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int a,b,c,d,e,f;
    vector<int> water;
    vector<int> sugar;
    cin>> a >> b >> c >> d >> e >> f;
    for(int i=0;i*100*a<=f;i++){
        for(int j=0;j*100*b<=f;j++){
            if(i*100*a+j*100*b<=f){
                water.push_back(i*100*a+j*100*b);
            }
        }
    }
    for(int i=0;i*c<=f;i++){
        for(int j=0;j*d<=f;j++){
            if(i*c+j*d<=f){
                sugar.push_back(i*c+j*d);
            }
        }
    }
    double ans=0.0;
    int w=0;
    int s=0;
    for(int i=0;i<water.size();i++){
        for(int j=0;j<sugar.size();j++){
            int sum = water[i]+sugar[j];
            if(sum<=f && sugar[j]<=((double)water[i]/100*e)){
               double ob = 100.0*sugar[j]/(sum);
               if(ob>=ans){
                   ans = ob;
                   w = water[i];
                   s = sugar[j];
               }
            } 
        }
    }
    cout << w+s << " " << s << endl;
    return 0;
}

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

using namespace std;

int main()
{
    string s;
    int a[26];
    memset(a,0,sizeof(a));
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        int d=(s[i]-97);
        a[d]++;
    }


    int c=0;
    for(int i=0;i<26;i++)
    {
        if(a[i]>1)
        {
            c++;
            break;
        }
    }
    if(c==0)
    {
        cout<<"yes"<<endl;
    }
    else
    {
        cout<<"no"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
import collections
import itertools
import functools
import math

if __name__ == "__main__":
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy
    path = 'U' * dy + 'R' * dx
    path += 'D' * dy + 'L' * dx
    path += 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
    path += 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'
    print(path)

Measured memory_bytes: 3700
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(string s) {
  s.insert(4," ");
  cout << s << endl;
}

int main() {
  string s;
  cin >> s;
  solve(s);
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = ['3', '5', '7']
ans = 0

(1..10).each do |i|
  a.repeated_permutation(i).to_a.each do |x|
    x_i = x.reduce(:+).to_i
    if (a - x).empty? && x_i <= n
      ans += 1
    end
  end
end

puts ans

Measured memory_bytes: 14844
//int -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(int i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int solve()
{
	int n;cin>>n;
	std::vector<int> inp(n);;
	int sum=0;
	REP(i,0,n-1)
	{
		cin>>inp[i];
		sum+=inp[i];
	}
	for(auto it:inp)
	{
		if((2*it)>=sum){cout<<"No\n";return 0;}
	}
	cout<<"Yes\n";
}
signed main(){
	speed
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int r,c;
	cin>>r>>c;
	int a[r+1][c+1];
	int i,j;
	for (i=0; i<=r; i++) {
		for (j=0; j<=c; j++) {
			a[i][j] = 0;
		}
	}
	for (i=0; i<r; i++) {
		for (j=0; j<c; j++) {
			cin >> a[i][j];
		}
	}
	for (i=0; i<r; i++) {
		for (j=0; j<c; j++) {
			a[i][c] += a[i][j];
		}
	}
	for (i=0; i<=c; i++) {
		for (j=0; j<r; j++) {
			a[r][i] += a[j][i];
		}
	}
	for (i=0; i<=r; i++) {
		for (j=0; j<=c; j++) {
			cout << a[i][j];
			if (j != c) cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
class BIT:
  def __init__(self,n):
    self.s = [0]*(n+1)
    self.n = n
  
  def add(self,val,idx):
    while idx < self.n+1:
      self.s[idx] = self.s[idx] + val
      idx += idx&(-idx)
    return
  
  def get(self,idx):
    res = 0
    while idx > 0:
      res = res + self.s[idx]
      idx -= idx&(-idx)
    return res
 
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
 
n = int(input())
S = [ord(s) - ord('a') for s in input()[:-1]]
 
bits = [BIT(n) for i in range(26)]
 
for i,s in enumerate(S):
  bits[s].add(1,i+1)
 
Q = int(input())
ans = []
for _ in range(Q):  
  flag,x,y = input().split()

  if flag == "1":
    i = int(x)
    c = ord(y) - ord('a')
    bits[S[i-1]].add(-1,i)
    bits[c].add(1,i)
    S[i-1] = c
  else:
    l = int(x)
    r = int(y)
    res = 0
    for i in range(26):
      res += (bits[i].get(r) > bits[i].get(l-1))
    ans.append(str(res))

print("\n".join(ans))

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

int main() {

	int N,K,ans=1;
  cin>>N>>K;
  
  for(int i=0; i<N; i++){
    if(ans*2>ans+K){ans+=K;}
    else{ans*=2;}}
  cout<<ans<<endl;

}



Measured memory_bytes: 256
S = list(map(str,input()))
T = list(map(str,input()))

def count_diff(a,b):
    """
    コードを単純化
    """
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

print(count_diff(S,T))

Measured memory_bytes: 104592
n, m = map(int, input().split())
count = 0

# [2, 0]
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        count += 1
# [0, 2]
for i in range(1, m + 1):
    for j in range(i + 1, m + 1):
        count += 1

print(count)


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

void solve() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    vector<int> deg(N);
    vector<P> pairs;
    for(int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        pairs.emplace_back(a, b);
        G[a].push_back(b);
        G[b].push_back(a);
        deg[a]++;
        deg[b]++;
    }
    int s, c = 0;
    for(int i = 0; i < N; ++i) {
        if(c < deg[i]) {
            c = deg[i];
            s = i;
        }
    }
    map<P, int> ma;
    auto dfs = [&](auto &&dfs, int cur, int pre, int pcol) -> void {
        int ncol = pcol;
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            ncol++;
            if(ncol > c) ncol = 1;
            ma[{cur, to}] = ncol;
            dfs(dfs, to, cur, ncol);
        }
    };
    dfs(dfs, s, -1, 0);
    cout << c << '\n';
    for(auto &p : pairs) {
        if(ma[p]) cout << ma[p] << '\n';
        else {
            cout << ma[{p.second, p.first}] << '\n';
        }
    }
}

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


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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
// Template END
const int mxv = (int)1e5 ;
bool compare( pair<int,int> a, pair<int,int> b ){
    return a.first > b.first ;
}


signed main(){
    int n ; cin >> n ;
    vector<int> a(n) ;
    for( int i = 0 ; i < n ; i++ ){ cin >> a[i] ; }
    int cnt1[ mxv + 1 ] = { 0 }, cnt2[ mxv + 1 ] = { 0 } ;
    for( int i = 0 ; i < n ; i += 2 ){
        cnt1[a[i]]++ ;
    }
    for( int i = 1 ; i < n ; i += 2 ){
        cnt2[a[i]]++ ;
    }
    vector<pair<int,int>> c1, c2 ;
    for( int i = 0 ; i <= mxv ; i++ ){
        if( cnt1[i] > 0 )
            c1.push_back( { cnt1[i], i } ) ;
        if( cnt2[i] > 0 )
            c2.push_back( { cnt2[i], i } ) ;
    }
    sort( all(c1), compare ) ;
    sort( all(c2), compare ) ;
    int c1Size = c1.size(), c2Size = c2.size() ;
    if( c1[0].second != c2[0].second ){
        cout << ( n - c1[0].first - c2[0].first ) ;
    }
    else{
        if( c1Size == 1 && c2Size == 1 ){
            cout << ( c1[0].first ) ;
        }
        else if( c1Size == 1 ){
            cout << ( n/2 - c2[1].first ) ;
        }
        else if( c2Size == 1 ){
            cout << ( n/2 - c1[1].first );
        }
        else{
            int f = n - c1[0].first - c2[1].first ;
            int s = n - c2[0].first - c1[1].first ;
            cout << min(f, s) ;
        }
    }
    return 0 ;   
}


Measured memory_bytes: 7176
#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)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

vector<ll> v, w;
vector<vector<pair<ll, ll>>> query;
// vector<ll> query_count;
vector<ll> ans;

const ll MAXL = 100001;

void solve(vector<ll>& path, const array<ll, MAXL>& dp){
    const ll cur = path.back();
    if(cur >= v.size()){ return; }
    const ll nxt1 = 2 * (cur + 1) - 1;
    const ll nxt2 = 2 * (cur + 1);

    if(path.size() <= 9){
        array<ll, MAXL> dp2(dp);
        RREP(i, dp.size()){
            if(i - w.at(cur) >= 0){
                dp2.at(i) = max(dp2.at(i), dp2.at(i - w.at(cur)) + v.at(cur));
            }
        }
        for(const auto p : query.at(cur)){
            ans.at(p.first) = dp2.at(p.second);
        }

        path.push_back(nxt1);
        solve(path, dp2);
        path.pop_back();

        path.push_back(nxt2);
        solve(path, dp2);
        path.pop_back();
    }else{
        if(query.at(cur).size()){
            vector<ll> tmp(path.begin() + 9, path.end());
            for(const auto p : query.at(cur)){
                ll tmpans = 0;
                REP(i, (1 << tmp.size())){
                    ll tmpv = 0, tmpw = 0;
                    REP(j, tmp.size()){
                        if((i >> j) & 1){
                            tmpv += v.at(tmp.at(j));
                            tmpw += w.at(tmp.at(j));
                        }
                    }
                    if(tmpw > p.second){ continue; }
                    tmpans = max(tmpans, tmpv + dp.at(p.second - tmpw));
                }
                ans.at(p.first) = tmpans;
            }
        }

        path.push_back(nxt1);
        solve(path, dp);
        path.pop_back();

        path.push_back(nxt2);
        solve(path, dp);
        path.pop_back();
    }
}

int main(){
    ll n;
    cin >> n;
    v.resize(n); w.resize(n);
    REP(i, n){
        cin >> v.at(i) >> w.at(i);
    }
    query.resize(n);

    ll q;
    cin >> q;
    REP(i, q){
        ll vi, li;
        cin >> vi >> li;
        vi--;
        query.at(vi).emplace_back(i, li);
    }
    ans.resize(q);

    array<ll, MAXL> dp;
    fill(ALL(dp), 0);
    vector<ll> path(1, 0);
    solve(path, dp);

    REP(i, q){
        cout << ans.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 25180
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        Integer[] numbers = new Integer[n];
        Set<Integer> d = new HashSet<>();
        
        for(int i = 0; i < n; i++){
            d.add(Integer.valueOf(br.readLine()));
        }
        
        out.println(d.size());
        out.close();
        
    }
}

Measured memory_bytes: 32740
#include <iostream>
#include <vector>
#include <cstdlib>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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;
const int MOD = 1000000007;
typedef long long ll;
using namespace std;

int main(void){
    string s;
    cin>>s;
    int cnt = 0;
    char hoge = s[0];
    rep(i,1,s.length()-1){
        if(s[i]==hoge){
            if(s[i]=='0') hoge = '1';
            else hoge = '0';
            cnt++;
        }
        else hoge = s[i];
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 512