akhauriyash/Code-Regression huggingface dataset:
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int INF = 1e9 + 5;
const int MOD = 1000000007;
const int MAX = 10000005;
const double PI = acos(-1.0);
#define pb push_back
#define vll vector<long long int>
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define       ll         long long
#define       ull        unsigned long long
#define       pii        pair <ll,ll>
#define       mii        map <ll,ll>
#define       msi        map <string,ll>
#define       pb         push_back
#define       nl         "\n"
#define       sp         " "
#define       vl        vector<ll>
#define       vi        vector<int>
ll toDigit(char ch) 
{ 
    return (ch - '0'); 
} 

int main()
{
    FastIO;
	
	string n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<n.size();i++)
	{
		ans+= toDigit(n[i]);
	}
	if(ans%9==0)
	{
		cout<<"Yes";
	}
	else
	cout<<"No";
    return 0;
}


Measured memory_bytes: 3672
N = int(input())
A = [int(l) for l in input().split()]


count1 = 0
k = 0
while True:
  count2 = 0
  for i in range(N):
      if A[i]/2** k % 2 !=0:
        break
      else:
        count2 += 1
  if count2 == N:
    count1 += 1
  else:
    break
  k += 1

print(count1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, s;
    cin >> n >> s;
    for(long long i = 2; i <= sqrt(n); i++){
        long long cnt = 0, p = n;
        while(p > 0){
            cnt += p % i;
            p = p/i;
        }
        if(cnt == s){
            cout << i;
            return 0;
        }
    }
    long long ans = 1e18;
    for(long long i = 1; i <= sqrt(n - s); i++){
        if((n - s) % i == 0){
            long long k = (n - s)/i + 1;
            if(k > sqrt(n)){
                long long r = n/k + n % k;
                if(r == s){
                    ans = min(ans, k);
                }
            }
        }
    }
    if(s == n){
        ans = min(ans, n + 1);
    }
    if(ans == 1e18){
        cout << "-1";
    }
    else{
        cout << ans;
    }
    return 0;
}

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

using namespace std;

int main(){

    int long long N, num, temp, sum = 0;

    cin >> N;

    num = N;

    while(num != 0){
        sum += num % 10;
        num /= 10;
    }

    if(N % sum == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;
    cin>>n;
    double l=log2(n);
    if(floor(l)==ceil(l))
    cout<<n;
    else
    cout<<pow(2,floor(l));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

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


Measured memory_bytes: 4316
// Print a Rectangle
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A
//
// Accepted

#![allow(non_snake_case)]

use std::io::{BufRead, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    loop {
        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();

        let mut data = buf.split_whitespace();

        let H: i32 = data.next().unwrap().parse().unwrap();
        let W: i32 = data.next().unwrap().parse().unwrap();

        if H == 0 && W == 0 {
            break;
        }

        for _ in 0..H {
            for _ in 0..W {
                print!("#");
            }
            println!();
        }
        println!()
    }
}


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

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

  int N; cin >> N;
  int U; cin >> U; U--;
  int V; cin >> V; V--;

  Graph G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<int> par(N, -1);
  vector<int> DA(N, -1);
  queue<int> q;
  q.push(V);
  DA[V] = 0;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (int i = 0; i < G[p].size(); i++) {
      int n = G[p][i];
      if (DA[n] != -1) continue;
      DA[n] = DA[p] + 1;
      par[n] = p;
      q.push(n);
    }
  }
  // cout << DA[0]; for (int i = 1; i < DA.size(); i++) { cout << ' ' << DA[i]; }

  int depth = DA[U];
  int ans = (depth - 1) / 2;

  int temp = U;
  for (int i = 0; i < ans; i++) {
    temp = par[temp];
  }

  vector<int> DT(N, -1);
  q.push(temp);
  DT[temp] = 0;
  int MAX = 0;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (int i = 0; i < G[p].size(); i++) {
      int n = G[p][i];
      if (DT[n] != -1) continue;
      if (DA[n] < DA[p]) continue;
      DT[n] = DT[p] + 1;
      MAX = max(MAX, DT[n]);
      q.push(n);
    }
  }
  // cout << DT[0]; for (int i = 1; i < DT.size(); i++) { cout << ' ' << DT[i]; }
  // cout << '\n';
  // cout << MAX;

  ans += MAX;
  if (depth % 2 == 0) ans++;

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    vector<vector<ll>> dp(s.size()+1, vector<ll>(13, 0));
    dp[0][0] = 1;
    REP(i, s.size()){
        rep(j, 13){
            if(s[i-1] == '?'){
                rep(k, 10){
                    dp[i][(j * 10 + k) % 13] += dp[i-1][j]; 
                    dp[i][(j * 10 + k) % 13] %= mod;
                }
            }
            else{
                int x = s[i-1] - '0';
                dp[i][(j * 10 + x) % 13] += dp[i-1][j];
                dp[i][(j * 10 + x) % 13] %= mod;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
}

Measured memory_bytes: 13696
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>
#include <bitset>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef pair<long long, long long> pllll;
typedef pair<long long, int> plli;
typedef pair<int,long long> pill;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    int n; cin>>n;

    string s = to_string(n);

    bool good = false;
    for (auto ch: s) {
        good |= (ch=='7');
    }

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

}

Measured memory_bytes: 3704
fun main(args: Array<String>) {
    val (a, b, x) = readLine()!!.split(' ').map(String::toDouble)
    if (a * a * b <= x * 2) {
        val k = 2 * (a * b - x / a) / a
        val atan = Math.atan(k / a)
        val degree = Math.toDegrees(atan)
        println(degree)
    } else {
        val baseDeg = Math.toDegrees(Math.atan(b / a))
        val half = a * a * b / 2
        val k = a * x / half
        val atan = Math.atan(k / b)
        val degree = 90.0 - Math.toDegrees(atan)
        println(degree)
    }
}

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

const int MAXN = 1e7+5;

int cnt[MAXN];

int main()
{
    long long N;
    scanf("%lld", &N);

    long long ans = 0;

    for(long long i = 1; i <= N; ++i)
    {
        long long mul = N / i;
        ans += i * ((1 + mul) * mul) >> 1;
    }

    cout << ans << endl;

    return 0;
}
/*
4 6 7 5
*/


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

int main(void) {
  double a, b;
  cin >> a >> b;

  cout << (int)a/(int)b << " " << (int)a%(int)b << " " << fixed << setprecision(5) << a/b << endl;
  return 0;
}


Measured memory_bytes: 3236
#include <iostream>

using namespace std;
const int kBalln = 10;
int ball[kBalln];

bool ExistAsceOrder(int i, int a, int b){
  // 終了条件
  if (i == kBalln)  return true;

  // ボールiを筒Bに入れる場合
  if (a < ball[i] && ExistAsceOrder(i+1,ball[i],b)) return true;

  // ボールiを筒Cに入れる場合
  if (b < ball[i] && ExistAsceOrder(i+1,a,ball[i])) return true;

  // どちらの筒に入れても昇順にならない場合
  return false;
}

int main(){
  int n;

  cin >> n;
  for (int j = 0; j < n; ++j)
    {
      for (int i = 0; i < kBalln; ++i)
        {
          cin >> ball[i];
        }

      if(ExistAsceOrder(0,0,0))
        {
          cout << "YES" << endl;
        }
      else
        {
          cout << "NO" << endl;
        }
    }
  return 0;
}

Measured memory_bytes: 1152
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner myObj = new Scanner(System.in);
        String inputStr = myObj.nextLine();
        int money = Integer.parseInt(inputStr);

        int ans = 0;
        int happy1000 = 0;
        int happy500 = 0;

        while (money >= 500)
        {
            happy1000 += 1000;
            money -= 500;
        }
        while (money >= 5)
        {
            happy500 += 5;
            money -= 5;
        }
        ans = happy500 + happy1000;
        System.out.print(ans);
    }
}

Measured memory_bytes: 21204
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

const int INF = 1145141919;
int m, n, sum, ans;
int box[501][2], dp[501][10001];
vector<int> manju;

int main(){
	scanf("%d%d", &m, &n);
	for(int i = 1; i <= m; i++){
		int v;
		scanf("%d", &v);
		manju.push_back(v);
	}
	for(int i = 1; i <= n; i++)
		scanf("%d%d", &box[i][0], &box[i][1]);

	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++){
			dp[i][j] = INF;
		}
	}

	manju.push_back(INF);
	sort(manju.begin(), manju.end(), greater<int>());
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(box[i][0] >= j){
				dp[i][j] = min(dp[i - 1][j], box[i][1]);
			} else{
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - box[i][0]] + box[i][1]);
			}
		}
	}

	for(int i = 1; i <= m; i++){
		sum += manju[i];
		ans = max(ans, sum - dp[n][i]);
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 20732
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// if (str.find(str2) != string::npos)


template <typename T>
T pow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}






int solve( ){

int n;
vi a;
cin>>n;
int sum=0;
rep(i,0,n)
{
  int x;
  cin>>x;
  sum+=x;
a.pb(x);
}

sort(all(a));
sum-=a[n-1];
if(a[n-1]<sum)cout<<"Yes";
else cout<<"No";


return 0;

}


int main()
{  int t=1;


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


  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
    bool flag=true;
   while(t--)
     { 
      solve();
     }

         time_req = clock() - time_req;
    //cout << "Processor time taken is "
      // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}



Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int x,k,d;
    while(cin>>x>>k>>d){
       bool neg=0;
       if(x<0)neg=1;
       x=abs(x);
       int tm=x/d;
       if(tm>k){
            int ans=x%d + ((tm-k)*d);
            cout << ans << endl;
            continue;
       }
       else{
            int rem=k-tm;
            if(rem%2==0){
                cout << x%d << endl;
            }
            else {
                cout << abs((x%d)-d) << endl;
            }
       }
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3632
gohyaku = int(input())
hyaku = int(input())
goju = int(input())
saisyu = int(input())

pattern = 0

for i in range(gohyaku+1):
    imagohya = saisyu - (i * 500)
    if imagohya == 0:
        pattern += 1
    elif imagohya > 0:
        for j in range(hyaku+1):
            imahya = imagohya - (j*100)
            if imahya == 0:
                pattern += 1
            elif imahya > 0:
                for k in range(goju+1):
                    imagoju = imahya - (k * 50)
                    if imagoju == 0:
                        pattern += 1

print(pattern)


Measured memory_bytes: 3064
#include <stdio.h>

int BubbleSort(int *array, int len);

int main()
{
    int i,j,len;
    char buf[10];
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf,"%d",&len);
    int *array;
    array = malloc(len*sizeof(int));
    for (i=0;i<len;i++){
        scanf("%d",array+i);
    }
    int cnt;
    cnt = BubbleSort(array, len);
    for (i=0;i<len;i++){
        if (i==(len-1)) printf("%d\n",*(array+i));
        else printf("%d ",*(array+i));
    }
    printf("%d\n",cnt);
    return 0;
}

int BubbleSort(int *array, int len)
{
    int i,j,tmp,cnt;
    cnt = 0;
    for (i=0;i<len;i++)
    {
        for (j=(len-1);j>i;j--)
        {
            if (array[j] < array[j-1])
                {
                    tmp = array[j-1];
                    array[j-1] = array[j];
                    array[j] = tmp;
                    cnt += 1;
                }
        }
    }
    return cnt;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
int mod = 1000000007;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin  >> n;
    vll a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(all(a)); sort(all(c));

    ll cnt = 0LL;
    for(int i = 0; i < n; ++i) {
        auto iter = lower_bound(all(a), b[i]);
        ll index = iter - a.begin();
        auto iter2 = upper_bound(all(c), b[i]);
        ll index2 = c.end() - iter2;
        cnt += index * index2;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

bool isPrime[100020];
void set_prime() {
	for (int i = 1; i <= 100010; i++) {
		isPrime[i] = true;
	}
	isPrime[0] = false; isPrime[1] = false;
	for (int i = 2; i * i <= 100010; i++) {
		int j = 2;
		while (i * j <= 100010) {
			isPrime[i * j] = false;
			j++;
		}
	}
}

int main()
{
	int X;
	cin >> X;
	set_prime();
	int i = X;
	while (true) {
		if (isPrime[i]) {
			cout << i << endl;
			return 0;
		}
		i++;
	}
}


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

int main() {
    
    int n,a;

    cin >> n;

    long long int ans = 0;

    while(n--){
        cin >> a;
        while(a%2 == 0){
            ans++;
            a /= 2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    int cnt_odd = 0;
    REP(i, n){
        if(1 <= i + 1 and i + 1 < 10) cnt_odd++;
        else if(100 <= i + 1 and i + 1 < 1000) cnt_odd++;
        else if(10000 <= i + 1 and i + 1 < 100000) cnt_odd++;
    }
    cout << cnt_odd << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int> makeTable(string s) {
  int n = s.size();
  vector<int> ret(n+1);
  ret[0] = -1;
  int j = -1;
  rep(i,0,n) {
    while(j >= 0 && s[i] != s[j]) j = ret[j];
    ret[i+1] = ++j;
  }
  return ret;
}

// 文字列sの部分文字列が文字列wと一致する場所を調べる
vector<int> kmp(string s, string w) {
  vector<int> table = makeTable(w), ret;
  int m = 0, i = 0, n = s.size();
  while(m+i < n) {
    if (w[i] == s[m+i]) {
      if (++i == (int)(w.size())) {
        ret.push_back(m);
        m = m+i-table[i];
        i = table[i];
      }
    } else {
      m = m+i-table[i];
      if (i > 0) i = table[i];
    }
  }
  return ret;
}

int main() {
  string s,t;
  cin >> s >> t;
  s += s;
  vector<int> ans = kmp(s,t);
  if (!ans.empty()) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int q;
	cin >> q;
	rep(i, q) {
		ll a, b;
		cin >> a >> b;
		//a = 1; b = i + 1;
		ll c = a*b - 1;
		if (a*b > INT_MAX)c -= 100;
		ll d = sqrt(c);
		ll ans = d * 2;
		ll e = (a > b ? b : a);
		if (d*d == c)ans--;
		else if (d*(d + 1) > c) {
			ans--;
		}
		if (e <= d)ans--;
		//cout << d << " "<<c<<" ";
		//cout << d << "  ";
		if (a == 1 && b == 1)cout << 0 << endl;
		else cout << ans << endl;
	}

}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split(" ");
    var n = parseInt(input[0], 10);
	//文字列から10進数に変換するときはparseIntを使います
    var a = parseInt(input[1], 10);
    var b = parseInt(input[2], 10);
    var sum = 0;
    for(var checkVal = 0; checkVal <= n; checkVal++) {
        var tmpSum = 0;
        var tmpValForSum = checkVal;
        do {
            tmpSum += tmpValForSum % 10;
            tmpValForSum = Math.floor(tmpValForSum / 10);
        } while (tmpValForSum > 0);
        if(tmpSum >= a && tmpSum <= b) {
            sum+= checkVal;
        }
    }
	//出力
	console.log('%d',sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 10000;

int n;
int a[MAXN];
int mx, mn, cmx, cmn;

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

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

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	mx = mn = a[1];
	for(int i = 1; i <= n; i++)
		mx = max(mx, a[i]), mn = min(mn, a[i]);
	if(mx - mn >= 2)
		no();
	for(int i = 1; i <= n; i++)
		a[i] == mx ? cmx++ : cmn++;
	if(mx == mn)
	{
		if(mx == n - 1)
			yes();
		if(2 * mx <= n)
			yes();
		no();
	}
	else
	{
		// cerr << cmn << ' ' << cmx << endl;
		if(cmn + 1 <= mx && mx <= cmn + cmx / 2)
			yes();
		no();
	}


	return 0;
}


Measured memory_bytes: 768
H,W,K=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
C=[]
nx=set([])

for _ in range(H):
    C.append(list(input()))

def keiro(x,y,k):
    i=1
    while True:
        if y+i>W-1 or C[x][y+i]!='.' or i>k:
            break
        else:
            if (x,y+i) not in nx:
                nx.add((x,y+i))
            i+=1
    
    i=1
    while True:
        if y-i<0 or C[x][y-i]!='.' or i>k:
            break
        else:
            if (x,y-i) not in nx:
                nx.add((x,y-i))
            i+=1
    
    i=1
    while True:
        if x+i>H-1 or C[x+i][y]!='.' or i>k:
            break
        else:
            if (x+i,y) not in nx:
                nx.add((x+i,y))
            i+=1
    
    i=1
    while True:
        if x-i<0 or C[x-i][y]!='.' or i>k:
            break
        else:
            if (x-i,y) not in nx:
                nx.add((x-i,y))
            i+=1

    return 0

C[x1-1][y1-1]=0
keiro(x1-1,y1-1,K)
taisho=nx.copy()
result=1
for j in nx:
    C[j[0]][j[1]]=result

while C[x2-1][y2-1]=='.':
    nx=set([])
    if len(taisho)==0 or result>10**6:
        result=-1
        break
    for l in taisho:
        keiro(l[0],l[1],K)
    result+=1
    for j in nx:
        C[j[0]][j[1]]=result
    taisho=nx.copy()

print(result)


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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, k, i;
	cin >> n >> k;
	int arr[n];
	fo(i, n) cin >> arr[i];
	Fo(i, k, n) {
		cout << (arr[i] > arr[i - k] ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 4428
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    const T:usize = 301;
    const R:usize = 90001;
    let modular = 998244353;
    let mut dp:Box<Vec<Vec<i64>>> = Box::new(Vec::new()); //草
    let mut dp2:Box<Vec<Vec<i64>>> = Box::new(Vec::new());
    for _ in 0..T {
        let mut v = Vec::new();
        for _ in 0..R {
            v.push(0);
        }
        dp.push(v.clone());
        dp2.push(v);
    }
    let mut all = 1;
    input! {
        n:usize,
        a:[usize; n]
    }
    
    let mut sum:usize = 0;
    for i in 0..n {
        sum += a[i];
        all = (all * 3) % modular;
    }

    dp2[0][0] = 1;
    dp2[0][a[0]] = 1;
    dp[0][0] = 2;
    dp[0][a[0]] = 1;

    for i in 1..n {
        for k in 0..(sum + 1) {
            if k >= a[i] {
                dp[i][k] = (2 * dp[i - 1][k] + dp[i - 1][k - a[i]]) % modular;
                dp2[i][k] = (dp2[i-1][k] + dp2[i-1][k - a[i]]) % modular;
            } else {
                dp[i][k] = 2 * dp[i - 1][k] % modular;
                dp2[i][k] = dp2[i - 1][k];
            }
        }
    }

    let mid = (sum + 1) / 2;
    let mut s = 0;
    for i in mid..(sum+1) {
        s = (s + dp[n - 1][i]) % modular;
    }
    let ans = 
    if sum % 2 == 0 {
       (all + 3 * dp2[n - 1][mid] - 3 * s + 10 * modular) % modular
    } else {
        (all - 3 * s + modular * 10) % modular
    };

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



Measured memory_bytes: 620924
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string S;cin >> S;
    bool ok = false;
    if(S[2] == S[3])if(S[4] == S[5])ok = true;

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

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
   int a, b;
   scanf("%d %d",&a, &b);

   if(a > b) {
      for(int i = 0; i < a; i++) {
         printf("%d",b);
      }
   } else {
      for(int i = 0; i < b; i++) {
         printf("%d",a);
      }
   }
   return 0;
}


Measured memory_bytes: 1676
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
 
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>
 
using namespace std;
 
typedef long long LL;
typedef vector<int> VI;
 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
 
template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
 
int N, Q;
 
int R[200011];
int C[200011];
 
void MAIN() {
    scanf("%d%d", &N, &Q);
 
    LL black = (LL) (N-2) * (N-2);
 
    int down = N;
    int right = N;
 
    REP ($, Q) {
	int t, x;
	scanf("%d%d", &t, &x);
	if (t == 1) {
	    if (x < right) {
		black -= down - 2;
		for (int i=x+1; i<right; i++) C[i] = down;
		right = x;
	    } else {
		black -= C[x] - 2;
	    }
	} else {
	    if (x < down) {
		black -= right - 2;
		for (int i=x+1; i<down; i++) R[i] = right;
		down = x;
	    } else {
		black -= R[x] - 2;
	    }
	}
 
    }
 
    printf("%lld\n", black);
}
 
int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}
 

Measured memory_bytes: 5320
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  vector<int> v[n];
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  queue<int> que;
  que.push(0);
  int d[n];
  memset(d,-1,sizeof(d));
  d[0]=0;
  while(!que.empty()) {
    int x=que.front();que.pop();
    rep(i,v[x].size()) {
      int y=v[x][i];
      if(d[y]==-1) {
        d[y]=x;
        que.push(y);
      }
    }
  }
  pr("Yes");
  REP(i,1,n) pr(d[i]+1);
}

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


Measured memory_bytes: 10416
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[100100];
    rep(i,0,n) cin >> A[i];

    int cnt[3] = {0,0,0};
    ll ans = 1;

    rep(i,0,n){
        int pt = 2;
        rep(j,0,2){
            if(cnt[j+1] > A[i]){
                pt = j;
                break;
            }
        }
        ll tmp = 0;
        rep(j,0,3){
            if(cnt[j] == A[i]) tmp++;
        }
        cnt[pt]++;
        ans = ((ans * tmp) % MOD + MOD) % MOD;
    }

    ans %= MOD;
    cout << ans << enld;
    return 0;
 }


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ll n,k;
  cin>>n>>k;
  ll ans=k;
  rep(i,0,n-1){
    ans*=(k-1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3648
#! python3
# finding_a_word.py

W = input()
sents = []
while True:
    sent = input()
    if sent == 'END_OF_TEXT' :break
    sents.append(sent.lower())

word_ct = 0
for sent in sents:
    for word in sent.split(' '):
        word = word.strip('\.\,\:\"\'')
        if word == W:
            word_ct += 1

print(word_ct)



Measured memory_bytes: 5568
import math

def main():
  K = int(input())
  gcd = math.gcd

  total = 0

  ab = {i: {j: gcd(i, j) for j in range(1,K+1)} for i in range(1,K+1)}

  #print(ab)

  for a in range(1,K+1):
    for b in range(1,K+1):
      for c in range(1,K+1):
        total += gcd(ab[a][b], c)

  print(total)

main()

Measured memory_bytes: 10784
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

/** Problem0266 : Aka-beko and 40 Thieves **/
int main()
{
	int list[7][2] = {{1, 2}, {6, 3}, {1, 6}, {4, 5}, {5, 2}, {2, 1}, {6, 6}}, now;
	string p;
	while (cin>>p, p!="#") {
		now=0;
		rep(i, p.length())
			now = list[now][p[i]-'0'];
		cout << (now==5?"Yes":"No") << endl;
	}
	return 0;
}

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

int main(void) {
    int n, k, t, m;
    int count = 0;
    std::vector<int> a;

    std::cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < k; i++) {
        std::cin >> t;
        for(int j = 0; j < t; j++) {
            std::cin >> m;
            a[--m]++;
        }
    }

    for(int i = 0; i < n; i++) {
        if(a[i] == 0) {
            count++;
        }
    }
    std::cout << count << std::endl;

    return 0;
}


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

const int n_MAX = 100100;
const int mod = 1000000007;

int main() {
  long long n, m;
  long long a[n_MAX];
  bool broken[n_MAX] = {false};
  long long dp[n_MAX];

  cin >> n >> m;
  for (int i = 0; i < m; ++i) cin >> a[i];

  for (int i = 0; i < m; ++i) {
    broken[a[i]] = true;
  }

  dp[0] = 1;

  for (int i = 1; i <= n; ++i) {
    long long rep = 0;

    if (!broken[i]) {
      if (i == 1) {
        rep += 1;
      } else {
        if (!broken[i - 1]) {
          rep += dp[i - 1];
        }

        if (!broken[i - 2]) {
          rep += dp[i - 2];
        }
      }
    }

    dp[i] = rep % mod;
  }

  cout << dp[n] << endl;
  return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b;
  c = a * b;
  if (c % 2 == 0) {
    cout << "Even" << endl;
  }
 else {
   cout << "Odd" << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define mod 1000000007
#define inf 11451419198
using namespace std;

struct SegmentTree {
public:
	ll n;
	vl node;

public:
	// 元配列 v をセグメント木で表現する
	SegmentTree(ll sz) {
		// 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
		// セグメント木全体で必要なノード数は 2n-1 個である
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1, 0);
	}

	void update(ll x, ll val) {
		// 最下段のノードにアクセスする
		x += (n - 1);

		// 最下段のノードを更新したら、あとは親に上って更新していく
		node[x] += val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] += val;
		}
	}

	ll get(ll l, ll r, ll now, ll nl, ll nr){
		if (nl > r || nr < l) return 0;
		if (l <= nl && nr <= r) return node[now];
		return get(l, r, 2 * now + 1, nl, nr - (nr - nl) / 2-1) + get(l, r, 2 * now + 2, nl + (nr - nl) / 2+1, nr);
		//return get(l, r, 2 * now + 1, nl, nl) + get(l, r, 2 * now + 1, nr, nr);
	}

};

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	ll q; cin >> q;
	vector<SegmentTree> st(26,SegmentTree(n));
	vl ans;
	rep(i, n){
		st[s[i] - 'a'].update(i, 1);
	}
	rep(i, q){
		ll iq; cin >> iq;
		if (iq == 1){
			ll a; char c;
			cin >> a;
			cin >> c;
			a--;
			st[s[a] - 'a'].update(a, -1);
			st[c - 'a'].update(a, 1);

			s[a] = c;
		}
		else{
			ll l, r; cin >> l >> r;
			l--;
			r--;
			ll count = 0;
			rep(j, 26) if(st[j].get(l,r,0,0,st[0].n-1) > 0){
				count++;
			}cout << count << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 222212
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x, y;
  cin >> n >> x >> y;
  VI ans(n, 0);
  REP2(int, i, 1, n) REP2(int, j, i+1, n+1) ++ans[min(min(abs(j-i), abs(x-i)+1+abs(y-j)), abs(y-i)+1+abs(x-j))];
  REP2(int, k, 1, n) cout << ans[k] << endl;

  return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define ROOP(i,n) for(i=0;i<n;i++)

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdint(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main(void) {
	int n, i;
	n = getint();
	i = getint();
	showint(n - i + 1);
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdint(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 405;
int n, a[N];
long long sum[N], mem[N][N];
bool vis[N][N];

long long dp(int i, int j) {
	if (i == j) {
		return 0;
	}
	if (vis[i][j]) {
		return mem[i][j];
	}
	vis[i][j] = true;

	long long ans = LLONG_MAX;
	for (int m = i; m < j; m++) {
		ans = min(ans, dp(i, m) + dp(m + 1, j));
	}

	long long cost = sum[j] - sum[i - 1];
	return mem[i][j] = cost + ans;
}

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

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}

	cout << dp(1, n) << '\n';

	return 0;
}


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

using ll = long long;

ll nc2(ll a) {
    if (a == 1 || a == 0) {
        return 0;
    }
    return (a * (a - 1)) / 2;
}

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

    ll ans = 0, mx_element = 0;
    vector<ll> arr(n), freq(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        freq[arr[i]]++;
        mx_element = max(mx_element, arr[i]);
    }

    for (int i = 1; i <= mx_element; i++) {
        ans = ans + nc2(freq[i]);
    }

    for (int i = 0; i < n; i++) {
        ll temp = ans - nc2(freq[arr[i]]);
        temp = temp + nc2(freq[arr[i]] - 1);
        cout << temp << endl;
    }
}

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

int main (){
    string S, T;
    cin>>S>>T;
    
    vector<string> WordS(S.size()), WordT(T.size());
    for(int i=0; i<S.size(); i++){
        WordS.at(i)=S.at(i);
        WordT.at(i)=T.at(i);
    }
    bool Check=false;

    for(int i=0; i<S.size(); i++){
        int Count=0;
        for(int j=0; j<S.size(); j++){
            if(WordS.at(j)==WordT.at(j)){
                Count ++;
            }
            else{
                break;
            }
        }
        if(Count==S.size()){
            Check=true;
            break;
        }
        string A=WordS.at(0);
        for(int j=0; j<S.size()-1; j++){
            WordS.at(j)=WordS.at(j+1);
        }
        WordS.at(S.size()-1)=A;
    }

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

Measured memory_bytes: 256
N = int(input())
P = [0]+list(map(int,input().split()))+[N+1]
ans = 0
b = [0]*(N+2)
for i in range(N+2):
    b[P[i]] = i
l1 = [max(0,i-1) for i in range(N+2)]
l2 = [max(0,i-2) for i in range(N+2)]
r1 = [min(N+1,i+1) for i in range(N+2)]
r2 = [min(N+1,i+2) for i in range(N+2)]

for i in range(N+1):
    m = b[i]
    x2,x1,y1,y2 = l2[m],l1[m],r1[m],r2[m]
    hoge= i*(abs((m-x1)*(y2-y1)) + abs((y1-m)*(x1-x2)))
    ans += hoge
    #x1
    r1[x1] = y1
    r2[x1] = y2
    #y1
    l1[y1] = x1
    l2[y1] = x2
    #x2
    r1[x2] = x1
    r2[x2] = y1
    #y2
    l1[y2] = y1
    l2[y2] = x1
print(ans)

Measured memory_bytes: 61544