akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

ll pow(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    ll d = pow(a, b / 2);
    return (d * d) % MOD;
  } else {
    ll d = pow(a, b - 1);
    return (a * d) % MOD;
  }
}

ll fact[3000001];
ll invfact[3000001];

int main(){
    ll x,y;
    cin >> x >> y;

    ll a = (2*x-y)/3;
    ll b = (2*y-x)/3;
    if(x != 2*a+b || y != a+2*b){
        cout << 0 << endl;
        return 0;
    }

    fact[0] = 1;
    fact[1] = 1;
    for(ll i = 2; i <= a+b; i++){
        fact[i] = fact[i-1]*i;
        fact[i] %= MOD;
    }
    invfact[a+b] = pow(fact[a+b], MOD-2);
    invfact[0] = 1;
    for(ll i = a+b-1; i > 0; i--){
        if(i ==0) exit(1);
        invfact[i] = invfact[i+1]*(i+1)%MOD;
    }

    ll ans = fact[a+b]*invfact[a] %MOD;
    ans = ans*invfact[b]%MOD; 
    cout << ans%MOD << endl;

    return 0;
}

Measured memory_bytes: 12544
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> iota(n); for (int i = 0; i < n; i++) iota[i] = i + 1;
	sort(iota.begin(), iota.end(), [&](int i, int j) {
		return a[i - 1] < a[j - 1];
		});
	for (int i = 0; i < n; i++) cout << iota[i] << " \n"[i + 1 == n];
	return 0;
}

Measured memory_bytes: 3920
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);
            var d = int.Parse(input[3]);
            var x = 0;
            var z = 0;
            if (a>c)
            {
                x = a;
            }
            else
            {
                x = c;
            }

            if (b<d)
            {
                z = b;
            }
            else
            {
                z = d;
            }

            //Console.WriteLine(z - x);
            if (z-x<=0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(z - x);
            }
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b, c) = sc.nextLine.split(" ").map(_.toInt)

    val maxNumber: Int = b / a
    if (maxNumber > c) {
      println(c)
    } else {
      println(maxNumber)
    }
  }
}

Measured memory_bytes: 25548
import numpy as np

n = int(input().strip())
A = list(map(int,input().strip().split(' ')))
sorted_A = sorted(A)
ai=sorted_A[-1]
print(ai)
del sorted_A[-1]
tmplist=np.array([min(i,ai-i) for i in sorted_A])
maxidx = np.argmax(tmplist)

print(sorted_A[int(maxidx)])

Measured memory_bytes: 23924
import sys
from collections import Counter

lines = 2
inp = list()

for _ in range(lines):
    inp.append(sys.stdin.readline().strip())


n = int(inp[0])
a_lst = inp[1].split()

c = Counter(a_lst)

for i in range(1, n + 1):
    print(c.get(str(i), 0))


Measured memory_bytes: 41128
# include <iostream>


using namespace std;

//日本語の本（本、ぽん、ぼん）の使い分け

int main(){

int n ;
  cin >> n ;
int res = n % 10;



  switch (res)
  {
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout << "hon" << endl;
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    cout << "pon" << endl;
    break;
  case 3:
    cout << "bon" << endl;
    break;
  }


}

Measured memory_bytes: 3632
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  int H, W;
  cin >> H >> W;
  char map[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> map[i][j];
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << map[i][j];
    }
    cout << endl;
    for (int j = 0; j < W; j++) {
      cout << map[i][j];
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
S = input().rstrip()

ans = 0
for i in range(len(S)):
    if i%2==0 and S[i]=="p":
        ans -= 1
    elif i%2==1 and S[i]=="g":
        ans += 1

print(ans)


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

int min(int x,int y){return x<y? x: y;}
int max(int x,int y){return x<y? y: x;}

int main(void){
	int a,b,c,d,ans;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	ans = min(b,d)-max(a,c);
	if(ans<0) ans=0;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ll a;
		cin >> a;
		if (a % 2 != 0)ans++;
	}
	if (ans % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main()
{
    int D, G;
    cin >> D >> G;
    int p[D + 1];
    int c[D + 1];
    int rate[D + 1];
    for (int i = 1; i <= D; i++)
    {
        cin >> p[i] >> c[i];
    }

    int ans = INT_MAX;
    for (int i = 0; i < (1 << D); i++)
    {
        bitset<16> bit(i << 1);
        int score = 0;
        int count = 0;
        for (int j = 1; j <= D; j++)
        {
            if (bit[j] == 1)
            {
                score += j * 100 * p[j] + c[j];
                count += p[j];
            }
        }
        int idx = D;

        while (bit[idx] == 1)
        {
            if (idx < 0)
            {
                break;
            }
            idx--;
        }
        if (idx > 0)
        {
            for (int j = 0; j < p[idx] - 1; j++)
            {
                if (score >= G)
                {
                    break;
                }
                count++;
                score += idx * 100;
            }
        }
        if (score >= G)
        {
            ans = min(ans, count);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a[1001] = {0};
    int number;
    int i, j, k;
    int temp;

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

    for (j = 0; j < number - 1; j++) {
        printf("%d ", a[j]);
    }
    printf("%d\n", a[number - 1]);

    for (i = 1; i < number; i++) {
        for (j = 0; j < i; j++) {
            if (a[i] < a[j]) {
                for (k = i; k > j; k--) {
                    temp = a[k];
                    a[k] = a[k - 1];
                    a[k - 1] = temp;
                }
                break;
            }
        }
        
        for (j = 0; j < number - 1; j++) {
            printf("%d ", a[j]);
        }
        printf("%d\n", a[number - 1]);
    }
   
    return 0;
}

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

int main() {
  int N, P;
  cin >> N >> P;
  int X = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 1) X++;
  }
  if (X != 0) cout << ((long long int)1 << (N - 1)) << endl;
  else if (P == 1) cout << 0 << endl;
  else cout << ((long long int)1 << N) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define N 10001

int c[N][N];

int LCS(char X[], char Y[]){
  int m, n;
  int i, j;

  m = strlen(X);
  n = strlen(Y);

  for(i = 1; i <= m; i++) c[i][0] = 0;

  for(j = 0; j <= n; j++) c[0][j] = 0;

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(X[i - 1] == Y[j - 1]) c[i][j] = c[i - 1][j - 1] + 1;
      else if(c[i - 1][j] >= c[i][j - 1]) c[i][j] = c[i -1][j];
      else c[i][j] = c[i][j - 1];
    }
  }
  return c[m][n];
}

int main(){
  int n, i;
  int buf[N];
  char X[N],Y[N];
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s", X);

    scanf("%s", Y);

    buf[i] = LCS(X,Y);
}

  for(i = 0; i < n; i++) printf("%d\n", buf[i]);

  return 0;
}

Measured memory_bytes: 39952
#include <stdio.h>
int a[5];
int main(){
	int n,m,i,s,c;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)a[i]=-1;
	for(i=1;i<=m;i++){
		scanf("%d%d",&s,&c);
		if(a[s]!=-1&&a[s]!=c){//同一位上有不同数值
			printf("-1\n");
			return 0;
		}else{
			a[s]=c;
		}
	}
	if(n>1&&a[1]==0)printf("-1\n");//至少两位数，首位是0
	else if(n==1){//只有一位数
		if(a[1]==-1)printf("0\n");
		else printf("%d\n",a[1]); 
	}
	else{//多位数
		for(i=1;i<=n;i++)
			if(i==1&&a[i]==-1)printf("1");//若对首位没有说明，那么设置为1
			else if(a[i]==-1)printf("0");
			else printf("%d",a[i]);
		printf("\n");
	}
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a <= 5) {
    cout << 0 << endl;
  } else if (a <= 12) {
    cout << b / 2 << endl;
  } else {
    cout << b << endl;
  }
}


Measured memory_bytes: 256
/*
Problem:AtCoder 084 c 
Algorithm:Three Poniters
Status:
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory.h>
#include <stack>
#include <stdio.h>
#include <string.h>

using namespace std;

const int INF=1e9+7;

int a[100005],b[100005],c[100005];

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&c[i]);
	}
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	long long ans=0;
	for(int j=0,i=0,k=0;j<n;j++){
		while(a[i]<b[j]&&i<n)i++;
		while(c[k]<=b[j]&&k<n)k++;
		ans+=((long long)i)*((long long)n-k);
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main(void){
    int D,T,S;
    double t;

    scanf("%d",&D);
    scanf("%d",&T);
    scanf("%d",&S);

    t=(double)D/S;
    if(T>=t){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;

}

Measured memory_bytes: 2080
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<int>> ans(h, vector<int>(w));
    int cnt = 0;
    rep(i, n)rep(j, a[i]){
        int y = cnt / w;
        int x = 0;
        if(y % 2 == 0) x = cnt % w;
        else x = w - cnt % w - 1;
        ans[y][x] = i + 1;
        cnt++;
    }
    rep(i, h){
        rep(j, w) cout << ans[i][j] << " ";
        cout << endl;
    }
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
class UnionFind {
private:
  int siz;
  vector<int> a;

public:
  UnionFind(int x) : siz(x), a(x, -1) {}

  int root(int x) {
    return a[x] < 0 ? x : a[x] = root(a[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    siz--;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] =x;
    return true;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return -a[root(x)];
  }
  
  int connected_component() {
  	return siz;
  }
};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  set<pair<int, int>> st;
  UnionFind uf(n);
  vector<int> deg(n);
  for (int i = 0; i < m; i++ ){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    deg[a]++;
    deg[b]++;
    uf.unite(a, b);
    st.insert(make_pair(min(a, b), max(a, b)));
  }
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (uf.same(a, b) && !st.count(make_pair(min(a, b), max(a, b)))) {
      deg[a]++;
      deg[b]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << uf.size(i) - deg[i] - 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <bitset>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  
  int b;
  vector<int> a(m), c(m);
  for (int i = 0; i < m; ++i) {
    cin >> a.at(i) >> b;
    int ci = 0;
    for (int j = 0; j < b; ++j) {
      int cc;
      cin >> cc;
      --cc;
      ci = ci | (1 << cc);
    }
    c.at(i) = ci;
  }
  vector<vector<int>> dp(m+1, vector<int>(1<<n, -1));
  dp.at(0).at(0) = 0;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < (1<<n); ++j) {
      if (j == 0) {
        dp.at(i+1).at(j) = 0;
      } else {
        int x = dp.at(i).at(j);
        int y = dp.at(i).at(j & (~c.at(i)));
        if (x == -1 and y == -1) {
          dp.at(i + 1).at(j) = -1;
        } else if (x == -1) {
          dp.at(i + 1).at(j) = y + a.at(i);
        } else if (y == -1) {
          dp.at(i + 1).at(j) = x;
        } else {
          dp.at(i + 1).at(j) = min(x, y + a.at(i));
        }
      }
    }
  }
  cout << dp.at(m).at((1<<n) - 1) << endl;
  return 0;
}


Measured memory_bytes: 16384
#include <complex>
#include <iostream>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define REP(i,n) FOR(i,0,n)
using namespace std;

typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b){ return (conj(a) * b).imag(); }

int main(){
    xy_t V[3],P;
    double x,y,cp[3];
    while(cin >> x >> y){
        REP(i,3){
            V[i] = xy_t(x,y);
            cin >> x >> y;
        }
        P = xy_t(x,y);
        cp[0] = cross_product(V[0] - P, V[1] - P);
        cp[1] = cross_product(V[1] - P, V[2] - P);
        cp[2] = cross_product(V[2] - P, V[0] - P);
        if(cp[0] * cp[1] > 0 && cp[1] * cp[2] > 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

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

using namespace std;

int main(){
    int n,r,t;
    cin>>n>>r>>t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    vector<int> b(r,0);
    int ans=n;
    vector<int> p(n,0);
    for (int i = 0; i < n; ++i) {
        p[i]=a[i]%r;
    }
    for (int i = 1; i < t; ++i) {
        for (int j = 0; j < n; ++j) {
            p[j]+=a[j];
            p[j]=p[j]%r;
            if(b[p[j]]==0){
                ++ans;
                ++b[p[j]];
            }
            --b[p[j]];
        }
        for (int j = 0; j < n; ++j) {
            ++b[p[j]];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

const int INF = (int)(2e+9);
int N;
vector<int> P;

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

	int min_v = INF;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (P[i] < min_v) {
			++ans;
			min_v = P[i];
		}
	}
	
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
a,b,c,d = map(int,input().split())
print("R"*(c-a)+"U"*(d-b)+"L"*(c-a)+"D"*(d-b+1)+\
    "R"*(c-a+1)+"U"*(d-b+1)+"L"+"U"+"L"*(c-a+1)+"D"*(d-b+1)+"R")

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

using namespace std;

int main(int argc, char *argv[]) {
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    vector<int> arr({A, B, C, D, E});

    int ans = INT_MAX;
    for (int i = 0; i < arr.size(); i++) {
        int last = arr[i];
        int sum = 0;
        for (int j = 0; j < arr.size(); j++) {
            if (i != j) {
                int one = arr[j];
                int m = one % 10;
                int plus = (m == 0) ? 0 : (10 - m);
                int t = one + plus;
                sum += t;
            } else {
                sum += last;
            }
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 5e3 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int n,k,p[N],c[N];
ll ans = LLONG_MIN;

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;

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

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

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

        ll sum = c[i];
        int cnt = 1;

        for (int j = p[i]; j != i; j = p[j]) {
            sum += c[j];
            ++cnt;
        }

        if(k >= cnt) {
            if(sum < 0) {
                ans = max(ans, sum);
            } else {
                ans = max(ans, k/cnt * sum);
            }
        }
        ll cum = 0;

        for (int j = p[i], steps = 0; j != i; j = p[j]) {
            cum += c[j];
            ++steps;
            if(k>=steps) {
                if(sum < 0) {
                    ans = max(ans, cum);
                } else {
                    ans = max(ans, cum + (k-steps)/cnt * sum);
                }

            }
        }

    }

    cout << ans << '\n';

    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

// ====================================================================

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> g(h);
  for (int i = 0; i < h; i++) cin >> g[i];

  int count = 0;
  int dist[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (g[i][j] == '#') count++;
      dist[i][j] = (g[i][j] == '#' ? INF : -1);
    }
  }

  dist[0][0] = 0;
  queue<pair<int, int>> q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      if (x + dx[i] < 0 || w <= x + dx[i] || y + dy[i] < 0 || h <= y + dy[i]) continue;
      if (dist[y + dy[i]][x + dx[i]] == -1) {
        dist[y + dy[i]][x + dx[i]] = dist[y][x] + 1;
        q.push(make_pair(y + dy[i], x + dx[i]));
      }
    }
  }

  if (dist[h - 1][w - 1] == -1)
    cout << -1 << endl;
  else
    cout << h * w - count - dist[h - 1][w - 1] - 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    map<ll,ll> ma,mb;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        ma[a[i]]++;
    }
    for(ll i=0;i<n;i++){
        cin>>b[i];
        mb[b[i]]++;
    }
    reverse(b.begin(),b.end());
    ll st=-1,ed=-1;
    for(ll i=0;i<n;i++){
        if(a[i]==b[i]){
            st=i;
            while(i<n && a[i]==b[i]) i++;
            ed=i-1;
        }
    }
    if(st==-1){
        cout<<"Yes\n";
        for(ll i:b) cout<<i<<" ";
        return 0;
    }
    ll p=a[st];
    ll tot=ed-st+1;
    ll k=n-(ma[p]+mb[p]-tot);
    //cout<<st<<" "<<ed<<" ";
    if(tot>k){
        cout<<"No";
        return 0;
    }
    ll j=st;
    for(ll i=0;i<st;i++){
        if(a[i]==p || b[i]==p) break;
        swap(b[i],b[j]); j++;
        if(j>ed) break;
    }
    for(ll i=ed+1;i<n;i++){
        if(j>ed) break;
        if(a[i]==p || b[i]==p) continue;
        swap(b[i],b[j]); j++;
    }
    cout<<"Yes\n";
    for(ll i: b)
        cout<<i<<" ";
    



 
 
    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 31420
#include <stdio.h>

int main(){

  long N,A[100000],i,x,a=1;

  

  scanf("%ld",&N);

  x=1;

  for(i=0;i<N;i++){

    scanf("%ld",&A[i]);

    if(A[i]==0){

      puts("0");

      return 0;

    }

    if((long)1e18/x/A[i]<1){

      a=0;

    }

    else x=x*A[i];

  }

  if(a==0)puts("-1");

  else printf("%ld\n",x);

  return 0;

}



Measured memory_bytes: 2504
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int ctoi(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

int main() {
	string n, test;
	//int ans;
	ll digit;
	ll num1;
	ll sum=0;
	int digitnum;
	int chkNum;
	vector<int> nEachDigit = {};
	//nEachDigit.resize(200000);
	cin >> n;
	test = n[0];
	digitnum = n.size();
	rep(i, n.size()) {
		chkNum = ctoi(n[i]);
		nEachDigit.push_back(chkNum);
	}
	sum = accumulate(nEachDigit.begin(), nEachDigit.end(), 0);
	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int a,b; cin >> a >> b;
	if (a%2==0 || b%2==0) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 256
def get_gcd(a, b):
    if a<b:a,b=b,a
    if b == 0 :return a
    else:return get_gcd(b,a%b)

n = int(input().rstrip())
a = list(map(int,input().rstrip().split()))

gcd = a[0]
for i in range(1,n):
    gcd = get_gcd(gcd,a[i])
print(gcd)

Measured memory_bytes: 20000
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007

int jump(vector<int>,int,int);

int main(){
    //fast
    int n,k;
    cin>>n>>k;
    vector<int> h;
    vector<int> dp(n,INT_MAX);
    f0(i,0,n){
        int temp;
        cin>>temp;
        h.pb(temp);
    }

    dp[0]=0;
    f0(i,0,n)
        f1(j,1,min(i,k))
            dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
    cout<<dp[n-1];
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define PI 3.14159265358979323846
int main(void){
    // Your code here!
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 double a,b,h,m,x;
 cin >> a >> b >> h >> m;
 x=abs(h*30.0+(m/2.0)-m*6.0);
 x=min(360.0-x,x);
 x=(x*PI)/180.0;
 cout << std::fixed << std::setprecision(20) << sqrt((a*a)+(b*b)-(2*a*b*cos(x)));
 return 0;
}

Measured memory_bytes: 4144
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1000000000;

int main() {
  //
  ll h, w;
  cin >> h >> w;
  if (h % 3 == 0 || w % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = INT_MAX;
  REP(i, h / 3, h / 3 + 2) {
    REP(j, w / 2, w / 2 + 2) {
      ll s1 = i * w;
      ll s2 = (h - i) * j;
      ll s3 = (h - i) * (w - j);
      ans = min(max(s1, max(s2, s3)) - min(s1, min(s2, s3)), ans);
    }
  }
  REP(j, w / 3, w / 3 + 2) {
    REP(i, h / 2, h / 2 + 2) {
      ll s1 = j * h;
      ll s2 = (w - j) * i;
      ll s3 = (h - i) * (w - j);
      // cout << i << ":" << j << ":" << s1 << "," << s2 << "," << s3 << endl;
      ans = min(max(s1, max(s2, s3)) - min(s1, min(s2, s3)), ans);
    }
  }
  ans = min(min(ans, w), h);
  cout << ans << endl;
  return 0;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) {
    cin >> i;
    i--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == i) {
      swap(a[i], a[(i + 1) % n]);
      ans++;
    }
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	int N;
    ll L;
    cin>>N>>L;
	vector<ll> A(N);
    rep(i,N) cin>>A[i];
    int pl=-1;
    for(int i=0;i+1<N;i++){
        if(A[i]+A[i+1]>=L) pl=i;
    }
    if(pl==-1){
        cout<<"Impossible"<<endl;
        return 0;
    }

    cout<<"Possible"<<endl;
    for(int i=0;i<pl;i++) cout<<i+1<<endl;
    for(int i=N-2;i>pl;i--) cout<<i+1<<endl;
    cout<<pl+1<<endl;
}

Measured memory_bytes: 1664
#include<iostream>

using namespace std;

int main()
{
	int a[200000];
	int n,i;
	cin>>n;
	for (i=0;i<n;i++)
	   cin>>a[i];
	if (n==1) cout<<a[0];
	else
	{
		for (i=n-1;i>=0;i-=2)
		cout<<a[i]<<' ';
		if (n%2==0) i=0;
		else i=1;
		for (;i<n;i+=2)
		cout<<a[i]<<' ';
		cout<<endl;
	}
	return 0;
} 

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n,t;
  cin >> n >> t;
  vector<pair<int, int>> ab(n);
  for(int i = 0; i < n; i++){
    int a,b; cin>> a >> b;
    ab[i] = {a,b};
  }
  vector<vector<int>> dpa(n+1, vector<int>(t, 0));
  vector<vector<int>> dpb(n+1, vector<int>(t, 0));

  for(int i = 0; i < n; i++){
    int a = ab[i].first;
    int b = ab[i].second;
    for(int cur = t-1; cur >= 0; cur--){
      if(cur+a >= t) continue;
      dpa[i+1][cur+a] = max(dpa[i][cur]+b, dpa[i+1][cur+a]);
    }
    for(int cur = 1; cur < t; cur++){
      dpa[i+1][cur] = max(dpa[i+1][cur], dpa[i+1][cur-1]);
      dpa[i+1][cur] = max(dpa[i][cur], dpa[i+1][cur]);
    }
  }
  for(int i = 0; i < n; i++){
    int a = ab[n-1-i].first;
    int b = ab[n-1-i].second;
    for(int cur = t-1; cur >= 0; cur--){
      if(cur+a >= t) continue;
      dpb[i+1][cur+a] = max(dpb[i][cur]+b, dpb[i+1][cur+a]);
    }
    for(int cur = 1; cur < t; cur++){
      dpb[i+1][cur] = max(dpb[i+1][cur], dpb[i+1][cur-1]);
      dpb[i+1][cur] = max(dpb[i][cur], dpb[i+1][cur]);
    }
  }

  int maxi = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < t; j++){
      if(maxi < dpa[i][j] + dpb[n-1-i][t-1-j] + ab[i].second){
        maxi = dpa[i][j] + dpb[n-1-i][t-1-j] + ab[i].second;
      }
    }
  }
  cout << maxi << endl;
}


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

int main() {
        stack<int> st;
	int a;

	while (cin >> a) {
		if (a == 0) {
			cout << st.top() << endl;
			st.pop();
		}
		else {
			st.push(a);
		}
	}
        return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
// const ll INF = 1LL << 30;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

int main() {
    ll a, b1, b2;
    char c;
    cin >> a >> b1 >> c >> b2;
    ll r = a*b1*100 + a*b2;
    co(r/100);

    return 0;
}



Measured memory_bytes: 3644
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/abc114/tasks/abc114_c
#C - 755
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
A = gi()
B = gi()

X = [0] * N
for i in range(N):
    X[i] = gi()

ans = 0

for i in range(1, N):
    fa = (X[i] - X[i - 1]) * A
    ans += min(fa, B)

print(ans)


Measured memory_bytes: 24148
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++)    cin >> a[i];
    ll ans = LLONG_MAX;
    for(ll i=0;i<=100;i++)
    {
    	ll sum = 0;
    	for(ll j=0;j<n;j++)
    	{
    		sum = sum + (abs(i-a[j])*abs(i-a[j]));
    	}
    	ans = min(ans,sum);
    } 
    cout<<ans; 
}
 
int main()
{
    FAST;
    ll t = 1;
    //  cin >> t;
    while(t--)
    {
    	solve();
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1000000009;
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first	
#define sc  second



int main() {

	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
		puts("+");
	} else if (a*b == 15) {
		puts("*");
	}else{
		puts("x");

	}


	return 0;
}

Measured memory_bytes: 256
"""
じょえチャンネルおもしろいよ～～～
https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
"""
n=int(input()[-1])
if n==3:ans="bon"
elif n in [0,1,6,8]:ans="pon"
else:ans="hon"
print(ans)

Measured memory_bytes: 9164
// 2分ヒープ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_H 250
const int INV = -2147483645;

int main(void)
{
    int H, node, parent, left, right;
    int ary_BinaryHeap[MAX_H + 1];

    for(int i = 0; i < MAX_H; i++)
    {
        // 配列の初期化
        ary_BinaryHeap[i] = INV;
    }

    cin >> H;

    for(int i = 1; i <= H; i++)
    {
        // ノードの値を格納
        cin >> node;
        ary_BinaryHeap[i] = node;
    }

    // 結果を表示
    for(int i = 1; i <= H; i++)
    {
        cout << "node " << i << ": ";
        cout << "key = " << ary_BinaryHeap[i] << ", ";

        parent = i / 2;
        left = 2 * i;
        right = ( 2 * i ) + 1;

        if( parent > 0 )
        {
            cout << "parent key = " << ary_BinaryHeap[parent] << ", ";
        }

        if( left <= H
            && ary_BinaryHeap[left] != INV )
        {
            cout << "left key = " << ary_BinaryHeap[left] << ", ";
        }

        if( right <= H
            && ary_BinaryHeap[right] != INV )
        {
            cout << "right key = " << ary_BinaryHeap[right] << ", ";
        }

        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3068
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
int N;
string S;
int Q;

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<int,20> bt[26];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	for(int i=0;i<N;i++) bt[S[i]-'a'].add(i,1);
	cin>>Q;
	while(Q--) {
		cin>>i;
		if(i==1) {
			cin>>x>>s;
			x--;
			bt[S[x]-'a'].add(x,-1);
			S[x]=s[0];
			bt[S[x]-'a'].add(x,1);
		}
		else {
			int L,R;
			cin>>L>>R;
			L--,R--;
			int cnt=0;
			for(int i=0;i<26;i++) {
				if(bt[i](R)-bt[i](L-1)) cnt++;
			}
			cout<<cnt<<endl;
		}
	}
	
}
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    solve();
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 107292
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())

if N == 105 :
  print (1)
  exit()
elif N < 105 :
  print (0)
  exit()
  
cnt = 1
for i in range(107, N+1, 2) :
  q = 0
  for j in range(1, i+1) :
    if i%j == 0 :
      q += 1
      #print (str(j))
  if q == 8 :
    cnt += 1
    #print ("Q:" + str(i))
print (cnt)


Measured memory_bytes: 38640
n=int(input())
x=list(map(int,input().split()))
m=int(input())
a=list(map(int,input().split()))
ax=[]
for j in range(m):
    if x[a[j]-1]+1 not in x and x[a[j]-1]<=2018:
        x[a[j]-1]+=1
for i in x:
    print(i)


Measured memory_bytes: 5612
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> graph[100001];
int dp[100001];

int solve(int src){
    if(dp[src] != -1){return dp[src];}
    int leaf = 1;
    int bestChild = 0;
    for(int child:graph[src]){
        leaf = 0;
        int val = 1+solve(child);
        bestChild = max(bestChild,val);
    }
    return dp[src] = leaf ? 0 : bestChild;
}
int32_t main(){
    int n,m;cin>>n>>m;
    
    for(int i=1;i<=m;i++){
        int x,y;cin>>x>>y;
        graph[x].push_back(y);
    }
    memset(dp,-1,sizeof dp);
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(ans,solve(i));
    }
    cout<<ans;
    

}

Measured memory_bytes: 11812
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t a,b;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> a >> b; if (a%b) { out << 1 << endl; }
	else { out << 0 << endl; }

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
uint64_t M;
uint64_t A[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> M;
	uint64_t res = 0;
	for (int32_t i = 0; i < N; i++)
	{
		in >> A[i];
		A[i] %= M;
		if (A[i] == 0) {

		}
	}

	for (int32_t i = 0; i < N; i++)
	{
		A[i + 1] += A[i];
		A[i + 1] %= M;
	}
	std::unordered_map<int32_t, int32_t> num;
	for (int32_t i = 0; i < N; i++)
	{
		++num[A[i]];
	}
	++num[0];


	for (auto& c : num)
	{
		int64_t len = c.second;
		res += len * (len - 1) / 2;
	}
	out << res << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
n = int(input())
red = [list(map(int,input().split())) for i in range(n)]
blue = [list(map(int,input().split())) for i in range(n)]
red.sort(key=lambda x:x[0],reverse = True)
blue.sort(key=lambda x:x[1])
ans = 0
for i in range(n):
    flag = False
    for j in range(len(red)):
        if blue[i][1] > red[j][1] and blue[i][0] > red[j][0] and not flag:
            ans += 1
            red[j][0] = 100000
            flag = True
print(ans)


Measured memory_bytes: 3064
#include <iostream>
    #include <cstdio>
    #include <cstdlib>
    using namespace std;
     
    int main()
    {
        long long x,y;
        scanf("%lld %lld",&x,&y);
        if(x%y==0) printf("-1\n");
        else{
            printf("%lld\n",x*(y-1));
        }
        return 0;
    }

Measured memory_bytes: 256
import sys
from collections import deque

h,w = map(int, sys.stdin.readline().split())
maze = [list(sys.stdin.readline()) for _ in range(h)]
dis = [[-1 for _ in range(w)] for _ in range(h)]

que = deque()
que.append((0,0))
dis[0][0] = 1

while que:
    y,x = que.popleft()
    for dx, dy in ((1,0), (0,1), (-1, 0), (0, -1)):
        nx = x + dx
        ny = y + dy
        if (nx < 0) or (nx > w-1) or (ny < 0) or (ny > h-1): continue
        if (maze[ny][nx] == '.') and (dis[ny][nx] == -1):
            dis[ny][nx] = dis[y][x] + 1
            que.append((ny, nx))

ans = 0
black_num = 0
for m in maze:
    black_num += m.count('#')

if dis[h-1][w-1] == -1:
    ans = -1
else:
    ans = w*h - black_num - dis[h-1][w-1]

print(ans)


Measured memory_bytes: 40560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll N, X;
ll B[SIZE], L[SIZE], U[SIZE];
vector<pair<ll,int> > vec;

bool check(ll x){
  bool used[SIZE] = {};
  ll sum = 0;

  for(int i=0;i<x/X;i++){
    used[vec[i].second] = true;
    sum += vec[i].first;
  }

  for(int i=0;i<N;i++){
    sum -= B[i] * L[i];
  }

  ll y = 0, z = 0;

  x = x % X;

  for(int i=0;i<N;i++){
    if(used[vec[i].second]) continue;
    z = max(z, vec[i].first);
  }

  debug(sum);

  for(int i=0;i<N;i++){
    int e = vec[i].second;
    if (used[e]) {
      ll r = -vec[i].first + z;
      if (x >= B[e]) {
        r += (ll)B[e] * L[e] + (ll)U[e] * (x - B[e]);
      } else {
        r += (ll)x * L[e];
      }

      y = max(y, r);
    } else {
      if (x >= B[e]) {
        y = max(y, (ll)B[e] * L[e] + (ll)U[e] * (x - B[e]));
      } else {
        y = max(y, (ll)x * L[e]);
      }
    }
  }

  sum += y;

  return sum >= 0;
}

int main(){

  scanf("%lld%lld", &N, &X);

  for(int i=0;i<N;i++){
    scanf("%lld%lld%lld", B+i, L+i, U+i);
  }

  ll l = 0, r = (ll)X * N;

  for(int i=0;i<N;i++){
    ll t = (ll)(X - B[i]) * U[i] + L[i] * B[i];
    vec.push_back({t, i});
  }

  sort(vec.begin(), vec.end(), greater<pair<ll,int> >());

  while(l < r){
    ll mid = (l+r)/2;

    if(check(mid)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }

  cout << l << endl;

  return 0;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define mp make_pair
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef long double ld;
//----head----
struct cir
{
	int x,y,r;
	cir(){}
	cir(int _x,int _y,int _r):x(_x),y(_y),r(_r){}
	void input(){scanf("%d%d%d",&x,&y,&r);}
}data[1005];
int n;
double cal(cir a,cir b)
{
	double dis=sqrt(1LL*(a.x-b.x)*(a.x-b.x)+1LL*(a.y-b.y)*(a.y-b.y));
	dis-=a.r+b.r;
	if(dis<=1e-10)return 0;
	else return dis;
}
vector< pair<int,double> > V[1005];
double len[1005];
void spfa()
{
	queue<int> q;
	q.push(0);
	len[0]=0;
	while(!q.empty())
	{
		int f=q.front();
		rep(i,0,sz(V[f]))
		{
			pair<int,double> nex=V[f][i];
			if(len[f]+nex.second<len[nex.first])
			{
				len[nex.first]=len[f]+nex.second;
				q.push(nex.first);
			}
		}
		q.pop();
	}
}
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	scanf("%d",&n);
	rep(i,1,n+1)data[i].input();
	data[0]=cir(a,b,0);
	data[n+1]=cir(c,d,0);
	for(int i=0;i<=n+1;i++)for(int j=0;j<=n+1;j++)
	{
		if(i==j)continue;
		else V[i].pb(mp(j,cal(data[i],data[j])));
	}
	for(int i=0;i<=n+1;i++)len[i]=1e15;
	spfa();
	printf("%.10lf\n",len[n+1]);
	return 0;
}


Measured memory_bytes: 17408