akhauriyash/Code-Regression huggingface dataset:
def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline

    N = int(input())
    S = [input().rstrip() for _ in range(N)]

    ctr = Counter(S)

    for target in ('AC', 'WA', 'TLE', 'RE'):
        print(target, 'x', ctr[target])


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 16608
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> p(n);
    REP(i,n){
        cin >> p[i].first >> p[i].second;
    }
    SORT(p);
    ll cnt = 0;
    ll index = 0;
    while(cnt<k){
        cnt += p[index++].second;
    }
    put(p[index-1].first);
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
 
public class Main {
	public static void main(String args[] ) throws Exception {

		Scanner sc = new Scanner(System.in);
		String[] ss = sc.nextLine().trim().split(" ") ;
		long N = Long.valueOf ( ss[0] ) ;
		long X = Long.valueOf ( ss[1] ) ;
		int M = Integer.valueOf ( ss[2] ) ;
		
		int[]  arr  = new int[M] ;
		arr[(int)X] = 1; 

		List<Integer> list2 = new ArrayList<>() ;
		list2.add ( (int)X ) ;

		int x1 = -1 ; 
		int x2 = -1 ;
		for ( int j=2 ; j<M*2+2 ; j++ ) {
			X = ( X * X ) % M ;
			if ( arr[(int)X] == 0 ) {
				arr[(int)X] = j  ;
				list2.add ( (int)X ) ;
			} else {
				x1 = arr[(int)X] ;
				x2 = j ;
				break ;
			}
		}
		
		if ( list2.size() >=  N ) {
			long t =0 ;
			for ( int j=0 ; j<N ; j++ )
				t += (long)list2.get(j).intValue() ;
			System.out.println( t ) ;
		} else if ( list2.get(list2.size()-1).intValue() == 0 ) {

			long t =0 ;
			for ( int j=0 ; j<N ; j++ ) {
				if ( list2.get(j).intValue() ==0 ) break ;
				t += (long)list2.get(j).intValue() ;
			}
			System.out.println( t ) ;
		} else {

			long t =0  ;
			for ( int j=0 ; j<x1-1 ; j++ )  {
				t += (long)list2.get(j).intValue() ;
			}
			long tx = 0 ;
			for ( int j=x1-1  ;j<x2-1 ; j++ ) 
				tx += (long)list2.get(j).intValue() ;

			N -= ( x1 -1 ) ;
			t += ( N / ( x2 - x1 ) ) * tx  ;

			long vmod =  N % ( x2 - x1 ) ;
			for ( int j=x1-1  ;j<x1-1+vmod ; j++ )  {
				t += (long)list2.get(j).intValue() ;
			}
			System.out.println( t ) ;



		}

	}
}


Measured memory_bytes: 30380
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long

signed sosu(int n){
    int s = 1;
    for(int i = 2;i <= sqrt(n);i ++){
        if(n % i == 0) s = 0;
    }
    if(n == 2 || n == 3) s = 1;

    return s;
}



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

    int a,b; cin >> a >> b;

    vector<int> ay(0),by(0);

    int ra = sqrt(a),rb = sqrt(b);
    int i = 2;
    while(i <= ra){
        while(a % i == 0){
            ay.push_back(i);
            a /= i;
        }
        i ++;
    }
    if(a > 1) ay.push_back(a);

    i = 2;
    while(i <= rb){
        while(b % i == 0){
            by.push_back(i);
            b /= i;
        }
        i ++;
    }
    if(b > 1) by.push_back(b);

    ay.erase( unique(ay.begin(),ay.end()), ay.end());
    by.erase( unique(by.begin(),by.end()), by.end());

    vector<int> ays(0),bys(0);
    for(int i = 0;i < ay.size();i ++){
        if(sosu(ay.at(i))){
            int t = ay.at(i);
            ays.push_back(t);
        }
    }

    for(int i = 0;i < by.size();i ++){
        if(sosu(by.at(i))){
            int t = by.at(i);
            bys.push_back(t);
        }
    }

    int ans = 0;
    for(int i = 0;i < ays.size();i ++){
        for(int j = 0;j < bys.size();j ++){
            if(ays.at(i) == bys.at(j)) ans ++;
        }
    }

    cout << ans + 1 << endl;
}




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

using namespace std;

#define maxn 100005
#define ll long long int
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<<endl
#define IN freopen("input.txt","r",stdin)

int dp[maxn];
int arr[maxn];
int n;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //IN;
    int k;
    cin>>n>>k;
    for(int i=1; i<=n; i++){
        cin>>arr[i];
    }
    dp[1] = 0;
    dp[2] = abs(arr[1]-arr[2]);
    for(int i=3; i<=n; i++){
        dp[ i ] = 1<<30;
       for(int j=i-1; j >= max(1,i-k); j--){
            dp[ i ] = min(dp[i],dp[j]+abs(arr[j]-arr[i]) ) ;
       }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, n;
  in(n);
  vector<ll> c(n);
  rep(i, n){
    in(c[i]);
    c[i]--;
  }
  a = 0;
  rep(i, n - 1){
    if(c[i] == i){
      swap(c[i], c[i + 1]);
      a++;
    }
  }
  if(c[n - 1] == n - 1)
    a++;
  out(a);
  memi;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}
 
 
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int c[] = new int[n];
		int s[] = new int[n];
		int f[] = new int[n];
		
		for(int i=0; i<n-1; i++) {
			c[i]=sc.nextInt();
			s[i]=sc.nextInt();
			f[i]=sc.nextInt();
		}
		
		ArrayList<Long> ans = new ArrayList<>();
		
		for(int i=0; i<n; i++) {
			long t = 0;
			t += s[i];
			t += c[i];
			
			for(int j=i+1; j<n-1; j++){
			    
				if(t<s[j]){
					t= s[j];
				}else if(t%f[j]!=0){
			    
					t += f[j]-(t%f[j]);
					
				}
				t += c[j];
			}
			ans.add(t);
		}
		
		for(int i=0; i<n; i++){
			System.out.println(ans.get(i));
		}
		
		sc.close();
	}
		
}


Measured memory_bytes: 39472
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
//
int main() {
  int N,a,b;
  a = 0;
  cin >> N;
  for(int i = 1;i < N;i++){
    a = a + ( ( N - 1 ) / i);
  }
  cout << a << endl;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		long K = sc.nextLong();

		long a_books[] = new long[N];
		for (int i = 0; i < N; i++) {
			a_books[i] = sc.nextLong();
		}
		long b_books[] = new long[M];
		for (int i = 0; i < M; i++) {
			b_books[i] = sc.nextLong();
		}

		long total = 0;
		int i=0, j=0;
		while (i < N && total + a_books[i] <= K) {
			total += a_books[i];
			i++;
		}
		while (j < M && total + b_books[j] <= K) {
			total += b_books[j];
			j++;
		}

		int ans = i + j;
		i--;
		for (; i >= 0; i--) {
			total -= a_books[i];
			while (j < M && total + b_books[j] <= K) {
				total += b_books[j];
				j++;
			}
			if (ans <= i + j) {
				ans = i + j;
			}
		}

		System.out.println(ans);
	}

	private static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 62216
X, K, D = map(int,input().split())
X = abs(X)

ans_1 = abs(X - X//D * D)
ans_2 = abs(ans_1-D)

if K <= X//D:
    print(X-K*D)

elif (K - X//D) % 2 == 0:
    print(ans_1)
else:
    print(ans_2)

Measured memory_bytes: 9180
s = input()
ans = 'YES'
while s:
    if s[-6:] == "eraser":
        s = s[:-6]
        continue
    elif s[-5:] == "dream" or s[-5:] =="erase":
        s = s[:-5]
        continue
    elif s[-7:] == "dreamer":
        s = s[:-7]
        continue
    else:
        ans = 'NO'
        break
print(ans)
    

Measured memory_bytes: 9192
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

class Mod:
    def __init__(self, m):
        self.m = m
    
    def add(self, a, b):
        return (a + b ) % self.m

    def sub(self, a, b):
        return (a - b) % self.m
    
    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, self.pow(b, self.m-2))

    def pow(self, x, y):
        if y == 0: 
            return 1
        elif y == 1: 
            return x % self.m
        elif y % 2 == 0: 
            return self.pow(x, y//2)**2 % self.m
        else: 
            return self.pow(x, y//2)**2 * x % self.m


@mt
def slv(N):
    if N==3:
        return 61

    m = Mod(10**9+7)
    dp = {}
    iv = [
        'agc',
        'acg',
        'gac',
        'aggc'
        'acgc',
        'atgc',
        'agac',
        'aggc',
        'agtc',
    ]
    for s in product('agct', repeat=4):
        s = ''.join(s)
        if not any(map(lambda x: x in s, iv)):
            dp[s] = 1

    for _ in range(N-4):
        dp_ = Counter()
        for k, v in dp.items():
            for c in 'agct':
                s = k + c
                s = s[1:]
                if s in dp:
                    dp_[s] = m.add(v, dp_[s])
        dp = dp_
    
    return reduce(lambda x, y: m.add(x, y), dp.values())


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5444
input_n = input() # お年玉をくれた人数
cash_all = 0

# データの獲得
list_cash = []
for i in range(int(input_n)):
  _ = input()
  list_cash.append(_)

# 変換して計算
list_tmp = []
for i in list_cash:
  list_tmp = i.split(' ')
  if list_tmp[1] == 'JPY':
    cash_all += int(list_tmp[0])
  else:
    cash_all += float(list_tmp[0]) * 380000.0
    
print(cash_all)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static StringBuilder sb = new StringBuilder();
static int N,M,K;
    static void Main()
    {
Read4();
      string tmp=Console.ReadLine();
      string tmp2;
      string tmp3="";
      if(tmp[K-1]=='A'){tmp3="a";}
           if(tmp[K-1]=='B'){tmp3="b";}
            if(tmp[K-1]=='C'){tmp3="c";}
      tmp2=tmp.Substring(0,K-1) + tmp3 + tmp.Substring(K);
                    Console.WriteLine(tmp2);

    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {

 
    }


}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << endl)

using namespace std;
using ll = unsigned long long;


int main() {
	string S;
	cin >> S;
	string s = "CODEFESTIVAL2016";
	int i, count = 0;
	for(i = 0; i < 16; i++) {
		if(S[i] != s[i]) count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

#define LL long long

inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF=9999999;
const int MAXN=100000;
LL A,B,C,D,A1,B1,C1,D1; 
LL N,M;

int main(){
    A1=A=read(),B1=B=read(),C1=C=read(),D1=D=read();
    N=read();
    A=A/0.25,B=B/0.5,D=D/2;
    if(A<B&&A<C&&A<D){printf("%lld\n",(long long)A1*N*4);}
	else if(B<A&&B<C&&B<D){printf("%lld\n",(long long)B1*N*2);}
	else if(C<A&&C<B&&C<D){printf("%lld\n",(long long)C1*N);}
	else{
        if(N&1) printf("%lld\n",(long long)(N/2)*D1+min(A1*4,min(B1*2,C1)));
		else printf("%lld\n",(long long)(N/2)*D1);
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
road = []
city = [0]*N
for i in range(M):
    road.append(list(map(int, input().split())))

for a, b in road:
    city[a - 1] += + 1
    city[b - 1] += + 1

for i in city:
    print(i)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

void no() {
  cout << "No" << endl;
  exit(0);
}

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

  while (true) {
    c -= b;
    if (c <= 0) {
      yes();
    }
    a -= d;
    if (a <= 0) {
      no();
    }
  }
}

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

int main() {
    int n;
    while(cin >> n, n != -1) {
        bitset<7> s[10] = {0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0100111, 0b1111111, 0b1101111};
        bitset<7> now(0);
        for(int i=0; i<n; ++i) {
            int d;
            cin >> d;
            cout << (now ^ s[d]) << endl;
            now = s[d];
        }
    }
}


Measured memory_bytes: 3088
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <numeric>
#include <limits>
#include <bitset>
using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
 
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INF = 1<<29;
const double EPS = 1e-10;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
    os<<'[';
    rep(i,a.size()) os<<(i?" ":"")<<a[i];
    return os<<']';
}

const int M = 1000000007;

// a^k
ll fpow(ll a, ll k){
  ll res = 1ll;
  ll x = a;
  while( k!=0 ){
    if((k&1) == 1)
      res = res*x;
    x = x*x;
    k >>= 1;
  }
  return res;
}

int used[31];

int loop(int a){

  if(used[a]!=-1)
    return used[a];

  if(a==1)
    return 1;
  else if(a==2)
    return 2;
  else if(a==3)
    return 4;
  else 
    return (used[a] = loop(a-1) + loop(a-2) + loop(a-3));
}


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(8);
  ios_base::sync_with_stdio(false);
  
  int n;
  while(cin>>n, n){
    memset(used,-1,sizeof(used));
    cout << (int)ceil( (double)loop(n)/365/10 )  << endl;
  }


  return 0;
}

Measured memory_bytes: 1196
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）

const ll INF=1e18;

const ll max_n=1000000;

ll a[30];
ll sgtree[2*max_n-1];
ll n,N;

void init(){
    n=1;
    while(n<N) n*=2;
    //rep(i,2*n-1) sgtree[i]=0;
    //for(int i=0;i<N;i++) sgtree[i+n-1]=a[s[i]-'a'];
}

void update(ll k,char c){
    k+=n-1;
    sgtree[k]=a[c-'a'];
    while(k>0){
        k=(k-1)/2;
        sgtree[k]=(sgtree[2*k+1]|sgtree[2*k+2]);
    }
}

ll query(ll a,ll b,ll k,ll l,ll r){
    if(b<=l||r<=a) return 0;
    if(a<=l&&r<=b) return sgtree[k];
    ll m=(l+r)/2;
    ll u=query(a,b,2*k+1,l,m);
    ll v=query(a,b,2*k+2,m,r);
    return (u|v);
}

signed main(){
    string s;
    cin>>N>>s;
    int q;
    cin>>q;
    a[0]=1LL;
    for(int i=1;i<26;i++) a[i]=a[i-1]*2;
    init();
    rep(i,N) update(i,s[i]);
    while(q--){
        int t;
        cin>>t;
        if(t==1){
            ll iq;
            char c;
            cin>>iq>>c;
            iq--;
            update(iq,c);
        }else{
            ll l,r;
            cin>>l>>r;
            l--;r--;
            ll ans=0;
            ll cnt=query(l,r+1,0,0,n);
            for(int i=0;i<26;i++){
                if(cnt&(1<<i)) ans++;
            }
            cout<<ans<<endl;
        }
    }
}

Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define MAX 100000
typedef long long ll;


int main(){
	int n;
	cin >> n;
	ll a[MAX];
	rep(i,n){
		cin >> a[i];
	}

	bool flag = 1;	//負始まり
	ll tem = 0;
	ll ans1 = 0;
	rep(i,n){
		tem = a[i] + tem;
	//	cout << tem << " " << flag << " " << ans1 <<  endl;
		if (tem>0 && flag){	//||(tem==0&&!flag)){
			ans1 += tem + 1;
			tem = -1;
		}
		else if (tem==0&&!flag) {
			ans1 += tem + 1;
			tem = 1;
		}
		else if (tem<0 && !flag) {//||(tem==0 && flag)){
			ans1 += 1 - tem;
			tem = 1;
		}
		else if (tem==0 && flag) {
			ans1 += 1 - tem;
			tem = -1;
		}
		if (flag) flag = 0;
		else flag = 1;

	}

	flag = 0;
	tem = 0;
	ll ans2 = 0;
	rep(i,n){
		tem = a[i] + tem;
		if (tem>0 && flag){	//||(tem==0&&!flag)){
			ans2 += tem + 1;
			tem = -1;
		}
		else if (tem==0&&!flag) {
			ans2 += tem + 1;
			tem = 1;
		}
		else if (tem<0 && !flag) {//||(tem==0 && flag)){
			ans2 += 1 - tem;
			tem = 1;
		}
		else if (tem==0 && flag) {
			ans2 += 1 - tem;
			tem = -1;
		}

		
		if (flag) flag = 0;
		else flag = 1;
	}
	//cout << ans1 << " " << ans2 << endl;
	cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 1152
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int n;
	cin >> n;
	string ans = "Yes";
	vector<string> w(n);
	set<string> words;
	rep(i, n) {
		string s;
		cin >> s;
		if (words.count(s)) ans = "No";
		words.insert(s);
		w[i] = s;
	}
	rep(i, n - 1) {
		string now = w[i];
		string next = w[i + 1];
		if (now[now.size()-1] != next[0]) ans = "No";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int ans = 0;

    int a = sc.nextInt();
    int b = sc.nextInt();
    ans = a+b;
    if(ans%2 != 0){
      ans /= 2;
      ans++;
    } else {
      ans /= 2;
    }
    
    System.out.println(ans);

    sc.close();
  }
}


Measured memory_bytes: 21844
#include <cstdio>
using namespace std;

using i64 = long long;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

int read() {
	int r = 0;
	while (true) {
		char c = getchar_unlocked();
		if (c & 16) {
			r = r * 10 + c - 48;
		} else {
			return r;
		}
	}
}

// x shoud be greater than or equal to zero
void write(i64 x) {
	char d[20];
	int i = 0;
	while (true) {
		d[i] = x % 10 + 48;
		x /= 10;
		++i;
		if (x <= 0) break;
	}
	while (i--) {
		putchar(d[i]);
	}
}

int A[100001];
signed main() {
	int n = read();
	REP(i, n + 1) {
		A[i] = read();
	}
	i64 s = 0;
	int a0;
	int a1 = A[0];
	REP(i, n) {
		a0 = a1;
		a1 = A[i + 1];
		int b = read();
		int m = a0 < b ? a0 : b;
		s += m;
		b -= m;
		m = a1 < b ? a1 : b;
		s += m;
		a1 -= m;
	}
	write(s);
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	public boolean checkHand(String hand) {
		char c = hand.charAt(0); // 先頭の牌
		if (hand.length() == 3) { // 最終ステップだった
			if (hand.equals(""+c+c+c)) return true; //刻子だった
			if ("12".equals(""+(hand.charAt(1)-c)+(hand.charAt(2)-c))) return true; // 順子だった
		} else { // 途中経過だった
			if (hand.startsWith(""+c+c+c)) { // 先頭を含む刻子が存在した
				return checkHand((new StringBuilder(hand)).delete(0, 3).toString());
			}
			if (hand.contains(String.valueOf((char) (c+1)))
				&& hand.contains(String.valueOf((char) (c+2)))) { // 先頭を含む順子が存在した
				int i1 = hand.indexOf(String.valueOf((char) (c+1)));
				int i2 = hand.indexOf(String.valueOf((char) (c+2)));
				return checkHand((new StringBuilder(hand))
					.deleteCharAt(i2).deleteCharAt(i1).deleteCharAt(0).toString());
			}
		}
		return false;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Main m = new Main();

		String line;
		while ((line = br.readLine()) != null) {
			String[] hand_org = new String[14];
			for (int i = 0 ; i < 13 ; i++) hand_org[i] = String.valueOf(line.charAt(i));
			String result = "";
			LOOP: for (int n = 1 ; n < 10 ; n++) {
				//System.out.println("Add "+n+"-------");
				String[] hand_a = Arrays.copyOf(hand_org, 14);
				hand_a[13] = ""+n; Arrays.sort(hand_a);
				String hand = hand_a[0]+hand_a[1]+hand_a[2]+hand_a[3]
						+hand_a[4]+hand_a[5]+hand_a[6]+hand_a[7]+hand_a[8]
						+hand_a[9]+hand_a[10]+hand_a[11]+hand_a[12]+hand_a[13];
				int idxF = hand.indexOf(""+n), idxL = hand.lastIndexOf(""+n);
				if (idxL-idxF == 4) continue LOOP;
				for (int j = 1 ; j < 10 ; j++) {
					idxF = hand.indexOf(""+j); idxL = hand.lastIndexOf(""+j);
					if (0 < idxL-idxF && idxL-idxF < 4) { // 追加した牌が２~４枚だった
						//System.out.println(hand+" : "+j+" ("+idxF+" "+idxL+")");
						String body = (new StringBuilder(hand)).deleteCharAt(idxL).deleteCharAt(idxF).toString();
						if (m.checkHand(body)) {
							//System.out.println("OK");
							result = result+" "+n;
							continue LOOP;
						}
					}
				}
			}
			System.out.println((result.equals(""))?0:result.trim());
		}


	}

}

Measured memory_bytes: 19708
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int r = scan.nextInt();
        System.out.println(r*r);
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b=0,c=0,d[110],e,f,g=0,h;
  cin >>a;
  for(int n=0;n<a;n++){
    cin >>d[n];
    b+=d[n];
  }
  b=b/a;
  f=b+1;
  for(int n=0;n<a;n++){
    e=d[n]-b;
    h=d[n]-f;
    c+=e*e;
    g+=h*h;
  }
  cout <<min(c,g)<<'\n';
  return(0);
}


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

const int N = 1e5 + 5, mod = 1e9 + 7;

int n, m, t = 0, a[N], par[N], visited[N], dp[N];
vector <int> adj[N];

void dfs(int v) {
	for (auto u : adj[v]) {
		if (visited[u]) continue;
		visited[u] = 1;
		dfs(u);
	}
	a[++t] = v;
}

signed main() {
	cin >> n >> m;
	for (int i = 1, u, v; i <= m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		par[v] = u;
	}
	for (int i = 1; i <= n; i++) {
		if (!visited[i] && !par[i]) {
			dfs(i);
		}
	}
	int ans = 0;
	for (int i = t; i >= 1; i--) {
		int v = a[i];
		for (auto u : adj[v]) {
			dp[u] = max(dp[u], dp[v] + 1);
			ans = max(ans, dp[u]);
		}
	}
	cout << ans;
}

Measured memory_bytes: 11904
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
n=int(input())
A=[]
for _ in range(n):
    x=input()
    A.append(x)
print(len(set(A)))


Measured memory_bytes: 107700
#include<stdio.h>

int main(void){
  
  int N,A,B;
  int p[100];
  int i,min;
  int under_A = 0,middle_AtoB,over_B = 0;
  
  scanf("%d",&N);
  scanf("%d %d",&A,&B);
  
  for(i = 0;i < N;i++){
   scanf("%d",&p[i]); 
  }
  
  for(i = 0;i < N;i++){
    if(p[i] <= A){
      under_A++;
    }else if(p[i] >= A + 1 && p[i] <= B){
      middle_AtoB++;
    }else if(p[i] >= B + 1){
      over_B++;
    }
  }
  
  if(under_A < middle_AtoB && under_A < over_B){
    min = under_A;
  }else if(under_A > middle_AtoB && middle_AtoB < over_B){
    min = middle_AtoB;
  }else if(over_B < middle_AtoB && under_A > over_B){
    min = over_B;
  }
  
  printf("%d",min);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(void)
{
    int s, w;
    cin >> s >> w;
    if (w >= s)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
    //cin>>test;
  
  while(test--)
  {
  string s,t;
  cin>>s>>t;

  if(s.size()==t.size()-1)
  {
    for(int i=0;i<s.size();i++)
    {
      if(s[i]!=t[i])
      {
        cout<<"No";
        return 0;
      }
    }
    cout<<"Yes";
    return 0;
  }
  else cout<<"No";

  // while loop ending
   }
  

return 0;
}

Measured memory_bytes: 3648
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


immutable MO = 10L^^9 + 7;

int N, K;
int[] A;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N];
      foreach (i; 0 .. N) {
        A[i] = readInt();
      }
      auto dp = new long[](K + 1);
      dp[0] = 1;
      foreach (i; 0 .. N) {
        auto dpSum = new long[](K + 2);
        foreach (j; 0 .. K + 1) {
          dpSum[j + 1] = (dpSum[j] + dp[j]) % MO;
        }
        foreach (j; 0 .. K + 1) {
          dp[j] = (dpSum[j + 1] - dpSum[max(j - A[i], 0)]) % MO;
        }
      }
      long ans = dp[K];
      ans = (ans % MO + MO) % MO;
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 11388
/*
 * ID: ITP1_1_D
 * Problem: watch (convert seconds to the form of "hh:mm:ss")
 */

#include <stdio.h>

int main(void)
{
    int hour, min, sec;
    scanf("%d", &sec);
    min = sec / 60;
    sec %= 60;
    hour = min / 60;
    min %= 60;
    printf("%d:%d:%d\n", hour, min, sec);

    return 0;
}



Measured memory_bytes: 2104
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n;
    int ans = 0;
    map<string, int> mp;
    REP(i,n){
        string s;
        cin >> s;
        mp[s]+=1;
    }
    cin >> m;
    REP(i,m){
        string s;
        cin >> s;
        mp[s]-=1;
    }
    for(auto p:mp){
        ans = max(ans,p.se);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s=input()
lim=10**9+7
dp = [[0 for _ in range(13)] for _ in range(len(s))]
if s[0] =="?":
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1

for i in range(1,len(s)):
    for j in range(13):
        if s[i] ==  "?":
            for k in range(10):
                dp[i][(j*10 + k)%13] = (dp[i][(j*10 + k)%13]+dp[i-1][j])%lim
        else:
            dp[i][(j*10 + int(s[i]))%13] = (dp[i][(j*10 + int(s[i]))%13]+dp[i-1][j])%lim
print(dp[-1][5])

Measured memory_bytes: 66268
// C - Minimization
// with operation
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define ote(x) cout<<(x)<<endl
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

void prn(vi & v){rp(i,1,v.size()){printf("%d ",v[i]);}puts("");}///

int N,K;

void ope(int g, vi &A){
	int minA = INT_MAX;
	int front = g*(K-1)+1;
	int back = min(N, (g+1)*(K-1)+1);
	rp(j, front, back+1) minA = min(minA, A[j]);
	rp(j, front, back+1) A[j] = minA;
	// prn(A);//
}

int main(){
	cin>>N>>K;
	int p = 0;
	vi A(N+1), G(N+1);// 1 origin
	A[0] = INT_MAX, G[0] = -1;
	rp(i, 1, N+1){
		cin>>A[i];
		if(A[p] > A[i]) p = i;
		G[i] = (i-1)/(K-1);
	}
	// prn(A);//
	// prn(G);//
	// puts("===");//
	int count = 0;
	irp(g, G[p], -1){ ope(g, A); count++; }
	// puts("--");//
	rp(g, G[p]+1, G[N]){ ope(g, A); count++; }
	// puts("--");//
	if(A[N] != A[p]){ ope(G[N], A); count++; }
	ote(count);
	// ote(G[N]+((N-1)%(K-1)!=0));//
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
  int64_t n, k;
  cin >> n >> k;

  n %= k;

  cout << min(n, k - n) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int money = 100000;
    int n;
    scanf( "%d",&n );
    for( int i = 0;i < n;i++ ){
       
        money = ( float )money * 1.05;
        if( money % 1000 > 0 ) money += 1000-( money%1000 );
    }
    printf( "%d\n",money );
    return 0;
}

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project2
{
    class Tenki
    {
        public static void Main()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int count = 0;

            for(int i=0; i<s.Length; i++)
            {
                if (s[i] == t[i])
                {
                    count += 1;
                }
            }

            Console.WriteLine(count);
        }
        
        
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin>>n;
    string s; cin>>s;
    
    rep(i,s.size()) {
        int x = s[i] - 'A';
        x+=n;
        x%=26;
        s[i]=(char)(x+'A');
    }
    
    cout << s << ln;
    return 0;
 }

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

int P[10010];
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);
}//対グラフ

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); }//投影
//対図形

int main(){
    int n;
    cin >> n;
    pair<int,int>  p[n];//締め切り　仕事時間
    rep(i,n){
        cin >> p[i].second>>p[i].first;
    }   
    sort(p ,p+n);
    
    ll time=0;
    rep(i,n){
        time+=p[i].second;
        if(time>p[i].first){
            
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1792
n, m, q = map(int, input().split())
l = []
for i in range(q):
    l1, l2, l3, l4 = map(int, input().split())
    l.append([l1, l2, l3, l4])
B = []
for a in range(1, m + 1):
    for b in range(a, m + 1):
        for c in range(b, m + 1):
            for d in range(c, m + 1):
                for e in range(d, m + 1):
                    for f in range(e, m + 1):
                        for g in range(f, m + 1):
                            for h in range(g, m + 1):
                                for i in range(h, m + 1):
                                    for j in range(i, m + 1):
                                        L = [a, b, c, d, e, f, g, h, i, j]
                                        A = []
                                        for I in range(n):
                                            A.append(L[I])
                                        C = 0
                                        for k in range(q):
                                            if A[l[k][1] - 1] - A[l[k][0] - 1] == l[k][2]:
                                                C += l[k][3]
                                        B.append(C)
print(max(B))

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

using namespace std;
#define rep(i, N) for(int i=0;i<int(N);++i)
#define rep1(i, N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s, t;
    cin >> s >> t;
    int N = s.size();
    rep(i, N) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


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

  set<int> S;
  
  int q;
  cin>>q;
  while(q--){
    int cmd, num;
    cin>>cmd>>num;
    if(cmd == 0){
      S.insert(num);
      cout<<S.size()<<endl;
    }
    if(cmd == 1){
      cout<<S.count(num)<<endl;
    }
    if(cmd == 2){
      S.erase(num);
    }

    if(cmd == 3){
      int l = num, r;
      cin>>r;
      vector<int> ans;
      auto start = S.lower_bound(l);
      auto last= S.upper_bound(r);
      for(auto it = start; it != last; it++) cout<<*it<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 12472
def f(n):
    if n % 2== 0:
        return n // 2
    else:
        return 3 * n + 1

s = int(input())
ans = 2
if s == 1 or s == 2:
    print(4)
    exit()
while(s > 1):
    s = f(s)
    ans += 1
print(ans)


Measured memory_bytes: 38512
#include<stdio.h>

int main() {
	int n, q,i,Q[100000],j[100000],t=0,f=0;
	char a[100000][10],b[100000][10];
	scanf("%d%d",&n,&q);

for(i=0;i<n;i++) {
	scanf("%s%d",a[i],&Q[i]);
}

while(1) {
	for(i=0;i<n;i++) {
		if(Q[i]==0) continue;
	if(q>=Q[i]) {
		t+=Q[i];
		strcpy(b[f],a[i]);
		j[f]=t;
		f++;
		Q[i]=0;
		}
		else {
			t+=q;
			Q[i]-=q;
	}	
	}
		if(f==n) break;
		
}
		
		for(i=0;i<n;i++) {
			printf("%s %d\n",b[i],j[i]);
			}
			return 0;
			}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll GetDigit(ll num){
   ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main() {
ll N;
  cin >>N;
  
 ll x=sqrt(N);
  vl vec(x);
  repl(i,1,x+1) {
    ll a=GetDigit(i);
    if(N%i!=0) {
      vec.at(i-1)=INF;
      continue;
    }
    else {
    ll b=GetDigit(N/i);
    ll c=max(a,b);
    vec.at(i-1)=c;
    }
  }
  sort(all(vec));
  cout<<vec.at(0)<<endl;
}
 

Measured memory_bytes: 1024
import sys
r,g,b = map(int,input().split())
k = int(input())
#青＞緑＞赤
count = 0
if g*(2**k)>r:
    while g<=r:
        g*=2
        count += 1
else:
    print("No")
    sys.exit(0)

if b*(2**(k-count))>g:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61848
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
for b in B:
    for x in range(3):
        for y in range(3) :
            if A[x][y] == b:
                A[x][y] = 0

if A[0][0] + A[1][0] + A[2][0] == 0 \
or A[0][1] + A[1][1] + A[2][1] == 0 \
or A[0][2] + A[1][2] + A[2][2] == 0 \
or A[0][0] + A[0][1] + A[0][2] == 0 \
or A[1][0] + A[1][1] + A[1][2] == 0 \
or A[2][0] + A[2][1] + A[2][2] == 0 \
or A[0][0] + A[1][1] + A[2][2] == 0 \
or A[0][2] + A[1][1] + A[2][0] == 0:
    print("Yes")
else:
    print("No") 


Measured memory_bytes: 3064
import sys
import math
import bisect


def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    for i in range(n):
        A[i] -= B[i]
    ans = 0
    for a in A:
        if a > 0:
            ans += a
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}

/*
10
insert 30
insert 88
insert 12
insert 1
insert 20
find 12
insert 17
insert 25
find 16
print
*/


Measured memory_bytes: 26712