akhauriyash/Code-Regression huggingface dataset:
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nd: Vec<u32> = read_vec();
    let n = nd[0];
    let d = nd[1];
    let r = 2 * d + 1;
    if n % r == 0 {
        println!("{}", n / r);
    } else {
        println!("{}", n / r + 1);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    int ans = 0;
    ans += (a[2]-a[1])/2;
    ans += (a[2]-a[0])/2;
    if((a[2]-a[1])%2==1 && (a[2]-a[0])%2==1){ans += 1;}
    if((a[2]-a[1])%2==1 && (a[2]-a[0])%2==0){ans += 2;}
    if((a[2]-a[1])%2==0 && (a[2]-a[0])%2==1){ans += 2;}
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
words = [input() for i in range(n)]
if len(words) != len(set(words)):
    print("No")
    exit()
for i in range(1,n):
    if(words[i-1][-1] == words[i][0]):
        continue
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
const int maxn=5e5+5;
char ch,s[maxn];
int n,bit[maxn][30],opt,l,r,t;
int lowbit(int x){
    return x&(-x);
}
void update1(int x,int y){
//    printf("sssssssss%d %dssssssssss\n",x,y);
//    printf("1111");
    while(x<=n){
//           printf("444444");
        bit[x][y]++;
//        printf("1111");
        x=x+lowbit(x);
//        printf("1111");
    }
}
void update2(int x,int y){
    while(x<=n){
        bit[x][y]--;
        x=x+lowbit(x);
    }
}
int query(int x,int i){
    int ans=0;
    while(x>0){
        ans+=bit[x][i];
        x=x-lowbit(x);
    }
    return ans;
}
int main(){
    scanf("%d %s %d",&n,s+1,&t);
//    printf("222");
    for(int i=1;i<=n;i++){
//       printf("33333");
        update1(i,s[i]-'a');
    }
    while(t--){
        scanf("%d",&opt);
        if(opt==1){
            scanf("%d %c",&l,&ch);
            update2(l,s[l]-'a');
            update1(l,ch-'a');
            s[l]=ch;
        }else{
            scanf("%d %d",&l,&r);
            int ans=0;
            for(int i=0;i<=25;i++){
                if(query(r,i)-query(l-1,i)){
                    ans++;
                }
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 59264
#include <stdio.h>

int main() {
    int x;
    scanf("%d", &x);
    if (x >= 400 && x < 600) {
        printf("8\n");
    }
    else if (x >= 600 && x < 800) {
        printf("7\n");
    }
    else if (x >= 800 && x < 1000) {
        printf("6\n");
    }
    else if (x >= 1000 && x < 1200) {
        printf("5\n");
    }
    else if (x >= 1200 && x < 1400) {
        printf("4\n");
    }
    else if (x >= 1400 && x < 1600) {
        printf("3\n");
    }
    else if (x >= 1600 && x < 1800) {
        printf("2\n");
    }
    else if (x >= 1800 && x < 2000) {
        printf("1\n");
    }
    return 0;
}

Measured memory_bytes: 3164
import heapq

NM =input().split(" ")
A_LIST = input().split(" ")
N = int(NM[0])
M = int(NM[1])

A = []
for i in A_LIST:
    heapq.heappush(A, -1 * int(i))
    
for i in range(0, M):
    m = heapq.heappop(A)
    m = -1 * m
    m = m // 2
    heapq.heappush(A, -1 * m)

S = 0    
for i in A:
    S += (-1 * i)

print(S)
    




Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    // いらないカード同士を食べる
    // ペアがいなければ1枚犠牲にする
    int N;
    cin >> N;
    vector<int> A(N);
    map<int,int> m;
    rep(i,N){
        cin >> A[i];
        m[A[i]]++;
    }
    int cnt = 0; //いらないカード
    rep(i,N){
        if(m[A[i]]>0)cnt += m[A[i]]-1;
        m[A[i]] = 0; //1回数えたら重複して数えないようにリセットしておく
    }
    if(cnt%2==1) cout << N - cnt -1 << endl;
    else cout << N - cnt << endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define A 0
#define C 1
#define G 2
#define T 3

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

  int N;
  cin>>N;
  //AGC
  //ACG
  //GAC
  //A*GC
  //AG*C
  //i=1 date=3 n=1
  using v1=vector<ll>;
  using v2=vector<v1>;
  using v3=vector<v2>;
  using v4=vector<v3>;
  using v5=vector<v4>;
  v4 dp(N+1,v3(5,v2(5,v1(5,0))));
  dp[0][4][4][4]=1;
  for(int i=1;i<=N;i++){
    for(int i1=0;i1<5;i1++){
      for(int i2=0;i2<5;i2++){
        for(int i3=0;i3<5;i3++){
          for(int n=0;n<4;n++){
            if(i2==A&&i3==G&&n==C){}
            else if(i2==A&&i3==C&&n==G){}
            else if(i2==G&&i3==A&&n==C){}
            else if(i1==A&&i3==G&&n==C){}
            else if(i1==A&&i2==G&&n==C){}
            else dp[i][i2][i3][n]+=dp[i-1][i1][i2][i3]%MOD;
          }
        }
      }
    }
  }
  ll ans=0;
  for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++)
    ans=(ans+dp[N][i][j][k]%MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}


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

void compare(long int* a, long int* b){
  long int tem;
  if(*a < *b){
    tem = *a;
    *a = *b;
    *b = tem;
  }
}


int main(){
  long int a, b, k;
  long int x[1000][2];
  int n = 0;


  while(cin >> a >> b){
    k = a * b;
    while(1){
      if(a == b)
        break;
      compare(&a, &b);
      a = a - b;
    }
    x[n][0] = a;
    x[n][1] = k / a;
    n++;
  }

  for(int i = 0; i < n; i++)
    cout << x[i][0] << " " << x[i][1] << '\n';

  return 0;
}

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

using namespace std;

const int N = 1e6;

struct P { int num, id, ys; } a[N], b[N];

bool _sort(P x, P y) { return x.num > y.num; }
bool id_sort(P x, P y) { return x.id < y.id; }

int rk[N], wz[N], wtf[N], sum[N];

int main() {
    int n;
    int x;
    
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) {
        scanf("%d", &x);    
        a[i].num = x, a[i].id = i, wz[i] = wtf[i] = i;
    }
    for (int i = 1; i <= n; i ++) {
        scanf("%d", &x);    
        b[i].num = x, b[i].id = i;
    }
    sort(a + 1, a + n + 1, _sort);
    sort(b + 1, b + n + 1, _sort);
    for (int i = 1; i <= n; i ++) 
        rk[b[i].id] = i, a[i].ys = b[i].id;
    
    for (int i = 1; i <= n; i ++) {
        if(a[i].num > b[i].num) {
            printf("No\n");
            return 0;
        }
        if(i != n && a[i].num > b[i + 1].num)
            sum[i] = 1;
    }
    for (int i = 1; i <= n; i ++)
        sum[i] += sum[i - 1];
    
    for (int i = 1; i <= n; i ++) {
        if(a[i].num <= b[rk[a[i].id]].num) {
            if(i <= rk[a[i].id]) {
                printf("Yes\n");
                return 0;
            }
            else if(sum[i] - sum[rk[a[i].id] - 1] == 0) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    

    
    int cnt = 0;
    sort(a + 1, a + n + 1, id_sort);
    for (int i = 1; i <= n; i ++) {
        if(a[i].ys != wz[i]) {
            swap(wz[wtf[a[i].ys]], wz[i]);
            int j = wtf[a[i].ys];
            wtf[wz[j]] = j;
            wtf[wz[i]] = i;
            cnt ++;
        }
    }
    
    if(cnt <= n - 2) {
        printf("Yes\n");
        return 0;
    }
    
    printf("No\n");
    return 0;
}

/*

6
3 1 2 6 3 4
2 2 8 3 4 3

1 2 3 3 4 6
2 2 3 3 4 8


*/

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

int H, W;
string S[410];
bool visit[410][410];
int vx[] = { 0,1,0,-1 };
int vy[] = { 1,0,-1,0 };
ll white, black;
void dfs(int x, int y) {
	visit[y][x] = true;
	if (S[y][x] == '.') white++;
	else black++;
	for (int i = 0; i < 4; i++) {
		int nx = x + vx[i];
		int ny = y + vy[i];
		if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
		if (visit[ny][nx]) continue;
		if (S[y][x] == S[ny][nx]) continue;
		dfs(nx, ny);
	}
}
int main()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	ll ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (visit[i][j]) continue;
			//cout << i << " " << j << endl;
			white = 0; black = 0;
			dfs(j, i);
			ans += white * black;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 18176
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	auto index = 0;
	for (auto i = 0; i < N; ++i)
	{
		int A;
		cin >> A;
	}

	auto count = 1;
	for (N -= K; N > 0; N -= K - 1)
	{
		++count;
	}

	cout << count << endl;

	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll H;
    cin >> H;
    ll ans = 0;
    while (H) {
        H /= 2;
        ans++;
    }
    cout << (1LL << ans) - 1<< '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int main() {

  vector<int> A(5);
  for(int i=0; i<5; i++) cin >> A.at(i);
  int k, ans=0;
  cin >> k;
  
  for(int i=0; i<5; i++) {
    for(int j=i+1; j<5; j++) {
      if(A.at(j) - A.at(i) > k) ans = 1;
    }
  }
  
  if(ans == 0) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

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

int main()
{
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    long long int table[101][101];
    long long int rowSum, colSum, sum=0;
    int r, c;
    cin >> r >> c;
    
    for(int row=0;row<r;row++){
        colSum = 0;
        for(int col=0;col<c;col++){
            cin >> table[row][col];
            colSum += table[row][col];
        }
        table[row][c] = colSum;
        sum+=colSum;
    }

    
    for(int col=0;col<c;col++){
        rowSum = 0;
        for(int row=0;row<r;row++){
            rowSum += table[row][col];
        }
        table[r][col] = rowSum;
    }

    table[r][c] = sum;

    for(int row=0;row<r+1;row++){
        for(int col=0;col<c+1;col++){
            if(col == c) cout << table[row][col] << endl;
            else cout << table[row][col] << " ";
        }
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
int main(){
int N; 
cin >> N;  
for (int i = 1; i <= N; ++i) {
int a = i / 1000; 
int b = (i / 100) % 10; 
int c = (i / 10) % 10; 
int d = i % 10; 
 if(i % 3 == 0 || a == 3 || b == 3 || c == 3 || d == 3)
  cout << " " << i;  
}
cout << endl; 
}


Measured memory_bytes: 3096
// #pragma GCC target("avx512")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

ll sqint(ll num){

    ll l = 0;
    ll r = 1e10;

    while(r - l > 1){
        ll mid = (r + l) / 2;
        (mid * mid <= num ? l : r) = mid;
    }
    return l;
}

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;
 


int main()
{
    int n, k;
    cin >> n >> k;
    int sqr = sqint(n);
    vector<unordered_map<int,mint>> dp(k + 1);

    vector<int> val;
    for(int i = 1; i <= sqr; i++) {
        val.push_back(i);
        val.push_back(n / i);
    }
    val.push_back(0);
    sort(val.begin(), val.end());
    val.resize(unique(val.begin(),val.end()) - val.begin());
    int m = val.size();


    for(auto i : val)dp[0][i] = 1;

    // cerr << m << endl;

    for(int i = 0; i < k; i++) {
        for(int j = 1; j < m; j++) {

            dp[i + 1][val[j]] += dp[i][n / val[j]] * (val[j] - val[j - 1]);
            dp[i + 1][val[j]] += dp[i + 1][val[j - 1]];
        }
    }
    cout << dp[k][n] << endl;
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  int all = 0;
  rep(i, n) {
    cin >> a[i];
    all ^= a[i];
  }
  rep(i, n) {
    cout << (a[i] ^ all) << ' ';
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <map>
using namespace std;

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(){}
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct SCC      //StronglyConnectedComponents
{
    int n;
    int k;
    vector<vector<int>> g, rg;
    vector<bool> used;
    vector<int> cmp;
    vector<int> vs;
    
    void add_edge(int from, int to){
        g[from].push_back(to);
        rg[to].push_back(from);
    }
    
    SCC(int n) : n(n){
        g.resize(n);
        rg.resize(n);
        used.resize(n);
        cmp.resize(n);
        vs.resize(n);
    }
    
    void dfs(int u, int &l){
        used[u] = true;
        for(int v : g[u]){
            if(!used[v]) dfs(v, l);
        }
        vs[l] = u;
        l++;
    }
    
    void rdfs(int u, int k){
        used[u] = true;
        cmp[u] = k;
        for(int v : rg[u]){
            if(!used[v]) rdfs(v, k);
        }
    }
    
    int decomposition(){
        int l = 0;
        for(int i = 0; i < n; i++){
            if(!used[i]) dfs(i, l);
        }
        fill(used.begin(), used.end(), false);
        k = 0;
        for(int i = n - 1; i >= 0; i--){
            if(!used[vs[i]]){
                rdfs(vs[i], k);
                k++;
            }
        }
        return k;
    }
    
    int decomposition(Graph &dag){
        k = decomposition();
        dag.n = k;
        dag.g.resize(k);
        map<pair<int, int>, bool> mp;
        for(int u = 0; u < n; u++){
            for(int v : g[u]){
                if(!mp[pair<int, int> (cmp[u], cmp[v])] && cmp[u] != cmp[v]){
                    mp[pair<int, int> (cmp[u], cmp[v])] = true;
                    dag.add_edge(cmp[u], cmp[v]);
                }
            }
        }
        return k;
    }
};

vector<int> v[500005];

int main()
{
    int n, m;
    cin >> n >> m;
    SCC g(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    int k = g.decomposition();
    for(int i = 0; i < n; i++){
        v[g.cmp[i]].push_back(i);
    }
    cout << k << endl;
    for(int i = 0; i < k; i++){
        cout << (int)v[i].size();
        for(int j : v[i]) cout << " " << j;
        cout << endl;
    }
}


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

int main() {
  int n;
  scanf("%d", &n);
  int l = 0, r = n - 1, m;

  string sl, sr, sm;
  printf("%d\n", l);
  fflush(stdout);
  cin >> sl;
  printf("%d\n", r);
  fflush(stdout);
  cin >> sr;
  if (sl == "Vacant" || sr == "Vacant") return 0;

  while (l < r) {
    m = l + (r - l) / 2;
    printf("%d\n", m);
    fflush(stdout);
    cin >> sm;
    if (sm == "Vacant") return 0;
    if (((m - l) % 2 == 1 && sl != sm) || ((m - l) % 2 == 0 && sl == sm)) {
      l = m;
      sl = sm;
    } else {
      r = m;
      sr = sm;
    }
  }
  return 0;
}


Measured memory_bytes: 3856
import * as fs from "fs";
const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split(/\s/);
let cnt = 0;
for (
  let index = parseInt(input[0], 10);
  index <= parseInt(input[1], 10);
  index++
) {
  let s = index.toString();
  let n = s.split("").reverse().join("");
  if (s === n) cnt++;
}
console.log(cnt);

Measured memory_bytes: 37592
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class BIT:
    def __init__(self, L):
        self.n = len(L)
        self.bit = [0] * (self.n + 1)

    def update(self, idx, x):
        while idx <= self.n:
            self.bit[idx] += x
            idx += idx & (-idx)

    def query(self, idx):
        res = 0
        while idx > 0:
            res += self.bit[idx]
            idx -= idx & (-idx)
        return res

    def sec_sum(self, left, right):
        return self.query(right) - self.query(left)

    def debug(self):
        print(*[self.sec_sum(i - 1, i) for i in range(1, self.n + 1)])


def resolve():
    n = int(input())
    S = list(input().rstrip())
    q = int(input())
    query = [list(input().split()) for _ in range(q)]

    bits = [BIT(S) for _ in range(26)]
    for i in range(n):
        bits[ord(S[i]) - ord("a")].update(i + 1, 1)

    for j in range(q):
        if query[j][0] == "1":
            _, i, c = query[j]
            i = int(i) - 1
            bits[ord(S[i]) - ord("a")].update(i + 1, -1)
            bits[ord(c) - ord("a")].update(i + 1, 1)
            S[i] = c
        else:
            _, l, r = query[j]
            l, r = int(l), int(r)
            res = 0
            for k in range(26):
                if bits[k].sec_sum(l - 1, r):
                    res += 1
            print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 206676
package main

import (
	"fmt"
)

type Editor struct {
	string
}

func (ed *Editor) Push(key rune) {
	switch key {
	case '0', '1':
		ed.string += string(key)
	case 'B', 'b':
		if ed.string == "" {
			// do nothing
		} else {
			ed.string = ed.string[0 : len(ed.string)-1]
		}
	default:
		panic("There is no such key in this keyboard!")
	}
	return
}

func (ed *Editor) GetResult() string {
	return ed.string
}

func main() {

	var s string

	editor := Editor{""}

	fmt.Scanf("%s", &s)
	sRune := []rune(s)

	for _, c := range sRune {
		editor.Push(c)
	}

	fmt.Println(editor.GetResult())

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1; i<=n; i++){
        int cnt=0;
        for(int j=1; j<=i; j++){
            if(i%j==0)cnt++;
        }
        if(cnt==8 and i%2==1)ans++;
    }
    cout<<ans<<endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> p(N);
    for (auto &i : p) cin >> i;

    vector<bool> vec(505, true);
    for (auto &i : p) vec[i] = false;

    rep(i, 200) {
        if (0 <= X - i) {
            if (vec[X - i]) {
                cout << X - i << endl;
                return 0;
            } else if (vec[X + i]) {
                cout << X + i << endl;
                return 0;
            }
        } else {
            cout << X - i << endl;
            return 0;
        }
    }
}

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

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

	int N;
	scanf("%d", &N);

	int A;
	bool rest = false;
	long long result = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A);
		result += A / 2;
		if (A % 2 == 1) {
			if (rest) {
				result++;
				rest = false;
			} else {
				rest = true;
			}
		} else if (A == 0) {
			rest = false;
		}
	}

	cout << result;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

long all[51], allpat[51];

long dp(long i, long j){
  if(j == 0){
    return 0;
  }
  if(j == 1){
    if(i == 0) return 1;
    else return 0;
  }
  else if(j == all[i]){
    return allpat[i];
  }
  else{
    if(j <= all[i - 1] + 1){
      return dp(i - 1, j - 1);
    }
    else{
      return allpat[i] - dp(i - 1, all[i] - j - 1);
    }
  }
}

int main(){
  int n;
  long x;
  std::cin >> n >> x;
  all[0] = 1;
  allpat[0] = 1;
  for(int i = 0; i < n; i++){
    all[i + 1] = all[i] * 2 + 3;
    allpat[i + 1] = allpat[i] * 2 + 1;
  }
  std::cout << dp(n, x) << std::endl;
}

Measured memory_bytes: 256
s = input()

A_acc = 0
cnt = 0


i = 0
while i<len(s):
    if s[i] == 'A':
        A_acc += 1
    else:
        if s[i:i+2] == 'BC':
            cnt += A_acc
            i += 2
            continue
        else:
            A_acc = 0
    i += 1
print(cnt)


Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
int n, m, c, a[21][21], b[21], dem = 0, res;
int main()
{
    cin >> n >> m >> c;
    for(int i = 1; i <= m; ++ i) cin >> b[i];
    for(int i = 1; i <= n; ++ i)
    {
        for(int j = 1; j <= m; ++ j)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= n; ++ i)
    {
        res = c;
        for(int j = 1; j <= m; ++ j)
        {
            res += (a[i][j] * b[j]);
            //cout << res << endl;
        }
        if(res > 0) ++ dem;
    }
    cout << dem;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int a[111111],b[111111];
int main()
{
  int n,total=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    int k=a[i]-a[i-1];
    if(k<0)
      k=-k;
    b[i-1]=k;
    total+=k;
  }
  b[n]=a[n];
  if(b[n]<0)
    b[n]=-b[n];
  total+=b[n];
  for(int i=1;i<=n;i++){
    int ans=total;
    ans-=b[i]+b[i-1];
    int k=a[i+1]-a[i-1];
    if(k<0)
      k=-k;
    ans+=k;
    cout<<ans<<"\n";
  }
  return 0;
}


Measured memory_bytes: 2048
package main

import "fmt"

func max(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m < v {
			m = v
		}
	}
	return m
}

func min(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m > v {
			m = v
		}
	}
	return m
}
func main() {
	// Code for A - Subscribers
	var N, A, B int
	fmt.Scan(&N, &A, &B)

	fmt.Println(min(A, B), max(0, A+B-N))
}


Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const ll mod = 1e9 + 7;
const ll mx = 1e5 + 1;

void input(){
    ll h, n; cin >> h >> n;
    vector<ll>a(n);
    f(i, n) cin >> a[i];
    cout << ((accumulate(b_e(a), 0LL) >= h) ? "Yes" : "No") << endl;
}
int main(){
    input();
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	ll n;
	cin >> n;
	vector<ll> l(n);
	rep(i, n) cin >> l[i];
	int ans = 0;

	for (int i = 0; i < n; i++) {
		for (int i2 = 0; i2 < n; i2++) {
			for (int i3 = 0; i3 < n; i3++) {
				if (i < i2 and i2 < i3) {
					if (l[i] != l[i2] and l[i2] != l[i3] and l[i] != l[i3]) {
						if (l[i] + l[i2] + l[i3] > max(l[i], max(l[i2], l[i3])) * 2) ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    vector<ll> A;
    vector<ll> smallA;
    vector<ll> largeA;
    ll temp;
    list<ll> lst1,lst2; 
    list<ll>::iterator itr; 

    cin >> N;
    for(ll i = 0; i < N; i++){
        cin >> temp;
        A.push_back(temp);
    }
    VSORT(A);
    REP(i,N) smallA.push_back(A[i]);
    reverse(ALL(A));
    REP(i,N) largeA.push_back(A[i]);
    lst1.push_back(smallA[0]);
    lst2.push_back(largeA[0]);
    ll sf=1,sl=N-1;
    ll max = 0;
    if(N%2 == 0){
        for(ll i = 1; i < N/2 ; ++i){
            if(i%2==1){
                lst1.push_front(smallA[sl]);
                --sl;
                lst1.push_back(smallA[sl]);
                --sl;
            }else{
                lst1.push_front(smallA[sf]);
                sf++;
                lst1.push_back(smallA[sf]);
                sf++;
            }
        }
        lst1.push_front(smallA[sf]);
    }else{
        for(int i = 1; i < N/2+1 ; ++i){
            if(i%2==1){
                lst1.push_front(smallA[sl]);
                lst2.push_front(largeA[sl]);
                --sl;
                lst1.push_back(smallA[sl]);
                lst2.push_back(largeA[sl]);
                --sl;
            }else{
                lst1.push_front(smallA[sf]);
                lst2.push_front(largeA[sf]);
                sf++;
                lst1.push_back(smallA[sf]);
                lst2.push_back(largeA[sf]);
                sf++;
            }
        }
    }
    ll count = 0,l=0;
    for(itr=lst1.begin(); itr != lst1.end();itr++){
        smallA[l] = *itr;
        l++;
    }
    l=0;
    for(itr=lst2.begin(); itr != lst2.end();itr++){
        largeA[l] = *itr;
        l++;
    }

    REP(i,smallA.size()-1){
        count += abs(smallA[i] - smallA[i+1]);
    }
    max = count;
    count = 0;
    REP(i,largeA.size()-1){
        count += abs(largeA[i]-largeA[i+1]);
    }
    if(max < count) max = count;
    cout << max << endl;
    

    return 0;
}

Measured memory_bytes: 8820
/* ex 7_1
   riverstone */

#include <stdio.h>

//頂点を表す構造体
typedef struct point{
    int x_elem;
    int y_elem;
}point;

//関数shift_pointの定義
//ある基点point_baseから指定された移動方向に移動させたポイントを返す
point shift_point(point point_base,point point_shift){
    point point_ret;
    point_ret.x_elem = point_base.x_elem + point_shift.y_elem;
    point_ret.y_elem = point_base.y_elem + point_shift.x_elem; 
    return point_ret;
}

int main(void){
    point point1, point2, point3, point4,point_dif;
    //入力を受け取る
    scanf("%d %d %d %d", &point1.x_elem, &point1.y_elem, &point2.x_elem, &point2.y_elem);

    //残り2点の座標を求める
    //頂点1から頂点4へのベクトル(=頂点2から頂点3へのベクトル)を定義
    point_dif.x_elem = point2.x_elem - point1.x_elem;
    point_dif.y_elem = -point2.y_elem + point1.y_elem;
 
    //頂点2をベースに
    point3 = shift_point(point2,point_dif);
    //頂点1をベースに
    point4 = shift_point(point1,point_dif);

    //出力
    printf("%d %d %d %d\n", point3.x_elem, point3.y_elem, point4.x_elem, point4.y_elem);
    return 0;
}

Measured memory_bytes: 1736
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        long r = 0;
        long g = 0;
        long b = 0;
        for(int i = 0; i < n; i++){
            if(s.charAt(i) == 'R'){r++;}
            else if(s.charAt(i) == 'G'){g++;}
            else{b++;}
        }
        long ans = r * g * b;
        for(int i = 0; i < n-2; i++){
            for(int j = i+1; j < n; j++){
                int k = 2 * j - i;
                if(k >= n) break;
                if(s.charAt(i) != s.charAt(j) && s.charAt(i) != s.charAt(k) && s.charAt(k) != s.charAt(j)) ans--;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 37280
package main

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

// readi Scannerから1単語取り出して数値に変換して取得する
func readi(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

// readt Scannerから1単語取り出して取得する
func readt(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	const M = 1000000007 // 10^9+7
	N := readi(sc)       // 2 <= N <= 3*10^5
	A := make([]int, N)  // 0 <= Ai <= 2^60
	for i := 0; i < N; i++ {
		A[i] = readi(sc)
	}
	ans := 0
	// Ai が取り得る値の範囲を踏まえ、２進数の各桁で計算する
	for bit := 0; bit < 60; bit++ {
		sum1bit := 0
		for i := 0; i < N; i++ {
			sum1bit += A[i] & 1 // 右端のビットが1
			A[i] >>= 1          // 右側に1桁ビットシフト
		}
		sum0bit := N - sum1bit
		total := sum1bit * sum0bit    // t <= (3/2*10^5)*(3/2*10^5) > M なので
		total %= M                    // 上の結果 > M があり得るので
		total *= (1 << uint(bit)) % M // 1<<60 = 2^60 > Mなので
		total %= M                    // 上の結果 > M があり得るので

		ans += total // Aiの現在の桁の値の合計を総和に加える
		ans %= M     // 上の結果 > M があり得るので
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6912
#
# abc068 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 2
1 2
2 3"""
        output = """POSSIBLE"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 3
1 2
2 3
3 4"""
        output = """IMPOSSIBLE"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """100000 1
1 99999"""
        output = """IMPOSSIBLE"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """5 5
1 3
4 5
2 3
2 4
1 4"""
        output = """POSSIBLE"""
        self.assertIO(input, output)


def resolve():
    N, M = map(int, input().split())
    S = [0] * N
    E = [0] * N
    for i in range(M):
        a, b = map(int, input().split())
        if a == 1:
            S[b-1] = 1
        if b == N:
            E[a-1] = 1

    ans = "IMPOSSIBLE"
    for i in range(N):
        if S[i] == E[i] == 1:
            ans = "POSSIBLE"
            break
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main() {
	int n;
	double mean, std_dev;
	double scores[1000];

	while( true ){
	 	cin >> n;
	 	if(!n) break;

	 	mean = 0.0; std_dev = 0.0;
		for(int i=0; i<n; i++) cin >> scores[i];
		for(int i=0; i<n; i++) mean += scores[i] / (double)n;
		for(int i=0; i<n; i++) std_dev += pow( scores[i] - mean, 2) / (double)n;

		cout << fixed << setprecision(8) << sqrt(std_dev) << endl;
	}

	return 0;
}

Measured memory_bytes: 3188
#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()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, k, s;
	cin >> n >> k >> s;
	vector<int> v(n);
	rep(i, k) {
		v[i] = s;
	}
	int cur = s;
	if (cur == INF) cur = 1;
	else cur++;
	for (int i = k; i < n; i++) v[i] = cur;
	rep(i,n) {
		if (i != 0) cout << " ";
		cout << v[i];
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  vector<string> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(all(vec));
  string str = "";
  ll ans = 0;
  rep(i,n){
    if(str != vec[i]){
      ans++;
    }
    str = vec[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 9596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << max({A*C,A*D,B*C,B*D}) << '\n';
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3680
n = int(input())
a = list(map(int, input().split()))

state_of_up_or_down = False
money = 1000
min_price = a[0]
max_price = a[0]
for i in range(1, n):
    if a[i] > a[i - 1]:
        # min_price = min(a[i - 1], min_price)
        max_price = a[i]
        state_of_up_or_down = True
        if i == n - 1:
            money = (money // min_price) * max_price + money % min_price
    elif a[i] == a[i - 1]:
        if i == n - 1:
            money = (money // min_price) * max_price + money % min_price        
        pass
    else:
        if state_of_up_or_down:
            money = (money // min_price) * max_price + money % min_price
            state_of_up_or_down = False
        # max_price = a[i]
        min_price = a[i]
    # print(money, min_price, state_of_up_or_down)
print(money)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+20;
ll n,a[N],p[N],s[N];
int main()
{
	while(cin>>n)
	{
		s[n+1]=p[0]=0;
		for(int i=1;i<=n;i++)
			scanf("%lld",&a[i]),p[i]=p[i-1]+a[i];
		for(int i=n;i>=1;i--)
			s[i]=s[i+1]+a[i];
			
		ll ans=1e18,x=0;
		for(int i=1;i<n;i++)
			ans=min(ans,abs(p[i]-s[i+1]));//cout<<p[i]<<' '<<s[i+1]<<' '<<abs(p[i]-s[i+1])<<endl;
		cout<<ans<<endl;
	}
	
	
	return 0;
}

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

int num[3];

int main()
{
    for(int i = 0;i < 3;++i)
        scanf("%d",&num[i]);
    sort(num,num+3);
    if(num[0] == 5 && num[1] == 5 && num[2] == 7)
        puts("YES");
    else
        puts("NO");

    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  map<ll,ll>mp;
  ll ans=0;
  for(int i=n-1;i>=0;i--){
    ans+=mp[a[i]+i];
    mp[-(a[i]-i)]++;
  }
  cout<<ans<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> Ai(n);
  for(int i=0; i<n; i++){
    cin >> Ai[i];
  }

  vector<int> ans(n);
  for(int i=0; i<n; i++){
    ans[Ai[i]-1] = i + 1;
  }

  for(int i=0; i<n; i++) cout << ans[i] << ' ';
  cout << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
using namespace std;
 
int const NMAX = 1e5;
int const KMAX = 100;
int const INF = 1e9;
 
int nStones;
int hopLim;
int ans;
int dp[1+NMAX][1+KMAX];
int heights[NMAX];
 
int costHop(int from, int to){
    return abs(heights[to]-heights[from]);
}
 
int main() {
    cin >> nStones >> hopLim;
    for(int i=1; i<=nStones; i++) {
        cin >> heights[i];  
    }
    
    for(int i=1; i<=nStones; i++) {
        for(int j=1; j<=hopLim; j++){
            dp[i][j] = INF;
        }
    }
    
    for(int i=1; i<=hopLim; i++){
        dp[1][i] = 0;
    }
    for(int i=1; i<=nStones; i++) { 
        int startingOptimalCost = dp[i][1];
        for(int l=2; l<=hopLim; l++){
            startingOptimalCost = min(startingOptimalCost, dp[i][l]);
        }
        int lim = min(hopLim, nStones-i);
        for(int j=1; j<=lim; j++) {
            dp[i+j][j] = min(dp[i+j][j], startingOptimalCost + costHop(i, i+j));
        }
    }
    
    ans = dp[nStones][1];
    for(int i=2; i<=hopLim; i++) {
        ans = min(ans, dp[nStones][i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 40064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	vector<int> h;
	for (int i = 0; i < m; i++){
		cin >> x[i];
	}
	if (n >= m){
		cout << 0 << endl;
		return 0;
	}
	sort(x.begin(), x.end());
	for (int i = 1; i < m; i++){
		h.push_back(x[i] - x[i-1]);
	}
	sort(h.begin(), h.end(), greater<int>());
	ll ans = 0;
	for (int i = n-1; i < h.size(); i++){
		ans += h[i];
	}
	cout << ans << endl;
 	return 0;
 }

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

ll calcNumOfCombination(ll n, ll r){
        ll num = 1;
        for(ll i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

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

    string S[N];
    map<string, int> mp{};
    REP(i, N){
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
        mp[S[i]]++;
    }

    ll ans = 0;
    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        int x = mp[iter->first];

        ans += calcNumOfCombination(x, 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 14508
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
  x=b[i]
  y=bisect.bisect_left(a,x)
  z=bisect.bisect_right(c,x)
  ans+=(n-z)*y
print(ans)

Measured memory_bytes: 22720
a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

xyc = [map(int,input().split()) for i in range(m)]

ans = 100000000

for i in range(m):
    x,y,c = xyc[i]
    cost = A[x-1] + B[y-1] - c
    if ans > cost:
        ans = cost

if ans > min(A) + min(B):
    ans = min(A) + min(B)

print(ans)

Measured memory_bytes: 62308
import copy
import numpy as np


def count_black(c):
    count = 0
    for row in c:
        count += row.count('#')
    return count


h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans = 0

for h_p in range(2 ** h):
    for w_p in range(2 ** w):
        c_cp = np.array(copy.deepcopy(c))
        for i in range(h):
            if (h_p >> i) & 1:
                c_cp[i, :] = 'r'

        for j in range(w):
            if (w_p >> j) & 1:
                c_cp[:, j] = 'r'

        if count_black(c_cp.tolist()) == k:
            ans += 1
print(ans)


Measured memory_bytes: 27024
#include <bits/stdc++.h>
using namespace std;
int main(){
  double n,t,a;
  cin>>n>>t>>a;
  int ans;
  double mini=1e8;
  for(int i=0;i<n;i++){
    double h;
    cin>>h;
    double temp=t-h*0.006;
    if(abs(a-temp)<abs(a-mini)){
      mini=temp;
      ans=i;
    }
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 3772
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int i,n,ans=0;
	ll h,w,a,b;
	cin >> n >> h >> w;
	for(i=0; i<n; ++i){
		cin >> a >> b;
		ans += (a>=h&&b>=w);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
board = [list(input()) for i in range(H)]

ans = board
dist = [(1,1), (1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1),(0,1) ]
for i in range(H):
    for j in range(W):
        if board[i][j] == '#':
            continue
        count = 0
        for x, y in dist:
            now_x = j + x
            now_y = i + y
            if now_x >= W or now_x < 0:
                continue
            if now_y >= H or now_y < 0:
                continue
            if board[now_y][now_x] == '#':
                count += 1
        ans[i][j] = str(count)


for line in ans:
    print(''.join(line))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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;
}

int main()
{
  int H, W;
  char g[100][100];
  int black_num = 0;
  cin >> H >> W;

  rep(i, H) rep(j, W)
  {
    cin >> g[i][j];
    if (g[i][j] == '#')
      black_num++;
  }

  pair<int, int> start;
  start = {0, 0};

  queue<pair<int, int>> q;
  q.push(start);

  int dh[4] = {1, 0, -1, 0};
  int dw[4] = {0, -1, 0, 1};

  int d[100][100];

  rep(i, H) rep(j, W)
      d[i][j] = -1;

  d[0][0] = 1;
  while (!q.empty())
  {
    pair<int, int> tmp = q.front();
    q.pop();

    int tmp_h = tmp.first;
    int tmp_w = tmp.second;

    rep(i, 4)
    {
      int next_h = tmp_h + dh[i];
      int next_w = tmp_w + dw[i];

      if (next_h < 0 || next_h > H - 1 || next_w < 0 || next_w > W - 1)
        continue;
      if (g[next_h][next_w] == '#')
        continue;

      if (d[next_h][next_w] == -1)
      {
        d[next_h][next_w] = d[tmp_h][tmp_w] + 1;
        q.push({next_h, next_w});
      }
    }
  }

  if (d[H - 1][W - 1] == -1)
    cout << -1 << endl;
  else
    cout << H * W - d[H - 1][W - 1] - black_num << endl;

  return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n, t, a;
    cin >> n;
    cin >> t >> a;

    int h, ans;
    double diff, min_diff = double(1e9);
    rep(0, n) {
        cin >> h;
        diff = abs(a - (t - h * 0.006));
        if (diff < min_diff) {
            min_diff = diff;
            ans = i + 1;
        }
    }

    cout << ans << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 256