akhauriyash/Code-Regression huggingface dataset:
import math

A, B = map(int, input().split())
a = math.ceil(A / 0.08)
b = math.ceil(B / 0.1)
ans = max(a, b)

if math.floor(ans * 0.08) == A and math.floor(ans * 0.1) == B:
    print(ans)
else:
    print(-1)


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

int main(){
string s; cin >> s;
if(s=="SUN") cout << 7 << endl;
else if(s=="MON") cout << 6 << endl;
else if(s=="TUE") cout << 5 << endl;
else if(s=="WED") cout << 4 << endl;
else if(s=="THU") cout << 3 << endl;
else if(s=="FRI") cout << 2 << endl;
else if(s=="SAT") cout << 1 << endl;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.LongStream;

/**
 * 解説に書かれた合計式を展開した計算方法
 */
public class Main {

	private static final long MOD = 1_000_000_007;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt(), k = scanner.nextInt();
			// 1からnまでのi*(n-i)は (n-1)n(n+1)/6
			long xSum = (powMod(n, 3) - n + MOD) % MOD * powMod(6, MOD - 2) % MOD * m % MOD * m % MOD;
			long ySum = (powMod(m, 3) - m + MOD) % MOD * powMod(6, MOD - 2) % MOD * n % MOD * n % MOD;
			System.out.println((xSum + ySum) % MOD * combinationMod(n * m - 2, k - 2) % MOD);
		}
	}

	/**
	 * n_C_m mod MOD を計算する
	 * 
	 * @param n
	 * @param m
	 * @return n_C_m mod MOD
	 */
	private static long combinationMod(long n, int m) {
		long min = Math.min(m, n - m), max = Math.max(m, n - m);
		long factorialMin = LongStream.rangeClosed(1, min).reduce(1L, (result, next) -> result * next % MOD);
		long factorialMax = LongStream.rangeClosed(min + 1, max).reduce(factorialMin,
				(result, next) -> result * next % MOD);
		long factorialN = LongStream.rangeClosed(max + 1, n).reduce(factorialMax,
				(result, next) -> result * next % MOD);
		return factorialN * powMod(factorialMin, MOD - 2) % MOD * powMod(factorialMax, MOD - 2) % MOD;
	}

	/**
	 * n^m mod MOD を計算する
	 * 
	 * @param n
	 * @param m
	 * @return n^m mod MOD
	 */
	private static long powMod(long n, long m) {
		long result = 1L;
		while (m > 0) {
			if (1 == (1 & m)) {
				result = result * n % MOD;
			}
			n = n * n % MOD;
			m >>= 1;
		}
		return result;
	}
}


Measured memory_bytes: 36008
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=100005;

void solve(){
	ll n,s;
	cin>>n>>s;
	if(s>n){
		cout<<-1;
		return;
	}
	if(n==s){
		cout<<n+1;
		return;
	}
	for(ll i=2;i<=1000000;i++){
		ll cr=n,sum=0;
		while(cr&&sum<=s){
			sum+=cr%i;
			cr/=i;
		}
		if(sum==s){
			cout<<i;
			return;
		}
	}
	ll ans=1e18;
	for(ll i=1;i<=min(s,1000000ll);i++){
		ll j=s-i;
		ll ki=n-j;
		if(ki%i==0&&(ki+j)==n&&j<(ki/i)){
			debug(ki,j,ki/i);
			ans=min(ans,(ki/i));
		}
	}
	if(ans==1e18){
		ans=-1;
	}
	cout<<ans;
	
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    //~cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 256
def main():
 n,y = map(int,input().split())
 flag = 0
 for i in range(n + 1):
     for j in range(n - i + 1):
         if flag == 0 and  i * 10000 + j * 5000 + 1000 * (n - i - j) == y and n - i - j >= 0:
             flag = 1
             print(i,j,n - i - j)
 if flag == 0:
     print('-1 -1 -1')
main()

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long ,long> ii; 	
typedef complex<long double> com;
 
const ll mod = 998244353;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

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

  int height= b-a;
  int y=0;
  for(int i=1 ; i<=height ;i++)
    y+=i;
    cout <<y-b<<endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<ll> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	sort(a.begin(), a.end());

	map<ll, ll> mp;
	for (int i = 0; i < N; ++i) {
		mp[a[i]] += 1;
	}

	ll res = 0;
	for (int t = 35; t >= 0; --t) {
		ll x = pow(2, t);
		if (a[N - 1] + a[N - 2] < x) { continue; }
		for (int i = N - 1; i >= 0; --i) {
			if (mp[a[i]] == 0) { continue; }
			if (a[i] > x) { continue; }

			ll y = x - a[i];
			if (y == a[i]) {
				if (mp[y] >= 2) {
					mp[y] -= 2;
					++res;
				}
			} else if (mp[y] > 0) {
				mp[a[i]] -= 1;
				mp[y] -= 1;
				++res;
			}
		}
		if (N - res*2 < 2) { break; }
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 40192
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 405;

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

lli g[MAXN][MAXN], vis[MAXN][MAXN];
lli h, w;

void dfs(lli x, lli y, lli color, plli &val) {
    if (x < 0 or x > h - 1 or y < 0 or y > w - 1) return;
    if (vis[x][y]) return;

    vis[x][y] = 1;
    int next;
    if (color == 1)
        next = 0;
    else
        next = 1;

    if (color == 1) val.second++;
    else val.first++;

    for (int i = 0; i < 4; ++i) {
        lli p = x + dx[i], q = y + dy[i];
        if (p < 0 or p > h - 1 or q < 0 or q > w - 1) continue;
        if (g[p][q] != next) continue;
        dfs(p, q, next, val);
    }
}

void solve() {
    cin >> h >> w;
    lli ans = 0;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            if (s[j] == '.') g[i][j] = 0;
            else g[i][j] = 1;
        }
    }

    memset(vis, 0, sizeof(vis));

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (vis[i][j]) continue;
            plli p;
            p.first = 0, p.second = 0;
            dfs(i, j, g[i][j], p);
            ans += p.first * p.second;
        }
    }

    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;

    solve();

    return 0;
}


Measured memory_bytes: 10368
def main():
    n = int(input())
    answer = 0
    dish = []
    for _ in range(n):
        a, b = map(int, input().split())
        dish.append(a + b)
        answer -= b
    dish.sort(reverse=True)
    for i in range(0, n, 2):
        answer += dish[i]
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7384
N = int(input())
S = []
for i in range(N):
    S.append(input())
history = {}
ans = 0

for i in range(N):
    sorted_s = ''.join(sorted(S[i]))
    num = history.get(sorted_s, 0)
    ans += num
    history[sorted_s] = num + 1

print(ans)


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

int n;
int h[101];

int main() {
    cin >> n;
    for(int i=0;i<n;i++) cin >> h[i];
    long long ans=0;
    h[n]=0;
    for(int i=1;i<=n;i++){
        if(h[i-1]>h[i]) ans+=h[i-1]-h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, t[10][10];

int main(){
	cin >> n;
	bool g = 0;
	REP(i, n){
		if (g)cout << endl;
		REP(i, 9)REP(j, 9)cin >> t[i][j];
		REP(i, 9){
			REP(j, 9){
				bool f = 0;
				REP(k, 9){
					if (j == k)continue;
					if (t[i][k] == t[i][j])f = 1;
				}
				REP(k, 9){
					if (i == k)continue;
					if (t[k][j] == t[i][j])f = 1;
				}
				//cout << endl;
				REP(k, 3){
					REP(l, 3){
						//cout << i / 3 * 3 + k << " " << j / 3 * 3 + l << endl;
						if (i / 3 * 3 + k == i&&j / 3 * 3 + l == j)continue;
						if (t[i / 3 * 3 + k][j / 3 * 3 + l] == t[i][j])f = 1;
					}
				}
				f ? cout << "*" : cout << " ";
				cout << t[i][j];
			}
			cout << endl;
		}
		g = 1;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
//-------------------------------------------MACROS---------------------------------------------
#define 	TIEMPO_CORRIDA		cerr << "tiempo: "<<1.0*clock()/CLOCKS_PER_SEC <<" seg.\n";
#define 	FILES				freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define 	FORIT(it,e)			for(it = e.begin() ; it != e.end() ; it++)
#define 	FOR(i,a,b)			for(i = a ; i < b ; i++)
#define 	RFOR(i,a,b)			for(i = a ; i >= b ;i--)
#define 	FORSW(i,a,b,sw)		for(i = a ; i < b && sw ; i++)
#define 	RFORSW(i,a,b,sw)	for(i = a ; i >= b && sw ; i--)
#define 	fast 				ios::sync_with_stdio(false),cin.tie(),cout.tie();
#define 	to_int(x) 			atoi(x.data())
#define 	to_long(x) 			atoll(x.data())
#define 	ALL(x) 				x.begin(),x.end()
#define 	RALL(x) 			x.rbegin(),x.rend()
typedef 	long long 			ll;
typedef 	pair<int,int> 		pi;
typedef 	pair<ll,ll> 		pl;
const		int 				modN = 1e9+7;
const		double 				PI = 3.1415926535897932384626433832795028841;
//---------------------------------------------------------------------------------------------

int N,W;
const int tam = 102;
const int oo = 1e9;
int items[tam][2];
ll memo[tam][100002];

ll f(int n,int w){
	if(w>W) return -oo;
	if(n==N) return memo[n][w]=0;
	if(memo[n][w]!=-1) return memo[n][w];
	return memo[n][w]=max(f(n+1,w),f(n+1,w+items[n][0])+items[n][1]);
}

int main(){
	int i,w,c;
	while(scanf("%d %d",&N,&W)==2){
		memset(memo,-1,sizeof memo);
		FOR(i,0,N)  scanf("%d %d",&items[i][0],&items[i][1]);
		printf("%lld\n",f(0,0));
	}
	return 0;
}

Measured memory_bytes: 83376
#include <stdio.h>

int main(void) {
	char ch[] = "#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.";
	int h, w, i;
	char c;
	while (1) {
		scanf("%d %d", &h, &w);
		if ((h == 0) && (w == 0)) {
			break;
		}
		i = 0;
		while (h--) {
			c = ch[w + i];
			ch[w + i] = 0;
			printf("%s\n", ch + i);
			ch[w + i] = c;
			i = 1 - i;
		}
		putchar('\n');
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

ll N;

int main(void){
    
    scanf("%lld", &N);
    
    ll num = sqrt(N);
    for(int i = num; i >= 1; --i){
        if(N % i == 0){
            string a = to_string(i), b = to_string(N / i);
            printf("%d\n", max((int)a.size(), (int)b.size()));
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
string s[15], S, R; unordered_set<string> g; int o[15], n, m, T;
int main()
{
	srand(19260817), n = read(), m = read(); for(rint i = 1; i <= n; o[i] = i, cin >> s[i++]); random_shuffle(s+1,s+n+1); T = clock();
	for(rint j = -1, i; j<0||(double)(clock()-T)/CLOCKS_PER_SEC<=1.95; )
	{
		for(j = 0; j < m; R = S, reverse(R.begin(),R.end()), g.count(R)?g.erase(R),0:(g.insert(S),0), j++) for(S = "", i = 1; i <= n; S += s[o[i++]][j]);
		if(!g.size()||(m&1&&g.size()==1&&(S=R=*g.begin(),reverse(R.begin(),R.end()),R==S))) return puts("YES"),0; g.clear(); random_shuffle(o+1,o+n+1);
	}	return puts("NO"),0;
}

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

namespace AtConderBeginnerContest054
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            string szTotal = Console.ReadLine();
            string[] szArr = szTotal.Split(' ');
            int n = int.Parse(szArr[0]);
            int m = int.Parse(szArr[1]);

            string[] a = new string[n];
            for( int i=0;i<a.Length;++i)
            {
                a[i] = Console.ReadLine();
            }
            string[] b = new string[m];
            for( int i=0;i<b.Length;++i)
            {
                b[i] = Console.ReadLine();
            }

            string result = Solve(a, b) ? "Yes" : "No";
            Console.WriteLine(result);
        }
        private static bool Solve(string[] a, string[] b)
        {
            // そもそもaが小さければ含まれない
            if( a.Length < b.Length) { return false; }

            int total = a.Length - b.Length;
            for( int i=0;i<= total;++i)
            {
                for(int j=0;j<=total;++j)
                {
                    // a[i][j] からマッチング判定



                    if(IsMatch(a, b, i, j))
                    {
                        return true;
                    }
                }
            }

            return false;
        }

        private static bool IsMatch(string[] a, string[] b, int startRow, int startCol)
        {
            for(int i=0;i<b.Length;++i)
            {
                for(int j=0;j<b.Length;++j)
                {
                    char ca = a[startRow + i][startCol + j];
                    char cb = b[i][j];
                    if( ca != cb) { return false; }
                }
            }
            return true;
        }
    }


}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#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++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> C(N);

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        C.at(a - 1)++;
        C.at(b - 1)++;
    }

    for(auto n : C) {
        cout << n << endl;
    }
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    double sum=0.0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        sum += (double)1/x;
    }
    sum = 1/sum;
    cout<<fixed<<setprecision(7)<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N;cin >> N;
    //1-indexed
    vector<int> retu(N+1);
    for(int i = 1;i<=N;i++) cin >> retu.at(i);
    vector<int> now(N+10,0);
    vector<int> ans;
    for(int i = N;i>=1;i--){
        //i >= (N+2)/2の時はiの倍数箱目を考える必要はない
        //(N+2)/2をすることでNが奇数の場合もカバー
        if(retu.at(i) && i >= (N+2)/2){
            ans.push_back(i);
            now.at(i) = 1;
        }
        else{
            //i <= N/2の時はiの倍数箱目を考える必要がある
            int sum = 0;
            for(int j = i;j<=N;j += i){
                sum += now.at(j);
            }
            if(sum%2 != retu.at(i)){
                ans.push_back(i);
                now.at(i) = 1;
            }
        }
    }
    cout << ans.size() << endl;
    for(int V : ans) cout << V << endl;
}


Measured memory_bytes: 3192
def show(A):
    L = list(map(str, A))
    print(" ".join(L))

N = int(input())
A = list(map(int, input().split()))

show(A)

for i in range(1, N):
    v = A[i]
    j = i - 1
    
    while j>=0 and A[j]>v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    
    show(A)


Measured memory_bytes: 5600
function readline_STDIN()
    return Base.readline(Base.STDIN)
end

function exawizards2019_B()

    # STEP.01
    # read out the number of people
    num_people = Base.parse(Base.Int64, readline_STDIN())

    # STEP.02
    # read out the string which represents the colors of the people
    colors_people = readline_STDIN()

    # STEP.03
    # count up the number of hats
    num_people_red  = Base.zero(num_people)
    num_people_blue = Base.zero(num_people)

    for itr in Base.range(1, 1, num_people)
        if colors_people[itr] == 'R'
            num_people_red += 1
        else
            num_people_blue += 1
        end
    end

    # STEP.04
    # output the result
    if num_people_red > num_people_blue
        return "Yes"
    else
        return "No"
    end

end

Base.println(Base.STDOUT, Main.exawizards2019_B())

Measured memory_bytes: 108156
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
ll N, K; vector<ll> Ap, Am, Az;
ll getCount(ll x) {
  ll cnt = 0;
  for(ll m = 0, p = Ap.size()-1; m < Am.size(); ++m) {
    while(p >= 0 && x >= -Am[m]*Ap[p]) --p;
    cnt += Ap.size()-p-1;
  }
  for(ll z = 1; x >= 0 && z <= Az.size(); ++z) {
    cnt += N-z;
  }
  for(ll l = 0, r = Ap.size()-1; l < r; ++l) {
    while(l <= r && x < Ap[l]*Ap[r]) --r;
    if(l < r) cnt += r-l;
  }
  for(ll l = 0, r = Am.size()-1; l < r; ++l) {
    while(l <= r && x < Am[l]*Am[r]) --r;
    if(l < r) cnt += r-l;
  }
  return cnt;
}
int main() {
  scanf("%ld %ld", &N, &K);
  for(ll i = 1, A; i <= N; ++i) {
    scanf("%ld", &A);
    if(A > 0) Ap.push_back(A);
    else if(A < 0) Am.push_back(-A);
    else Az.push_back(A);
  }
  sort(Ap.begin(), Ap.end());
  sort(Am.begin(), Am.end());
  ll l = -1e18, r = 1e18;
  while(r-l > 1) {
    ll m = (l+r)/2;
    if(getCount(m) >= K) r = m;
    else l = m;
  }
  printf("%ld\n", r);
}

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

using namespace std;

int main(){

  int a,b,c,d,p;
  int x,y;
  
  cin>>a>>b>>c>>d>>p;

  x=a*p;
  
  if(c>=p)
	y=b;
  else
	y=b+d*(p-c);

  cout<<min(x,y)<<endl;

}



Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		Longest longest=new Longest();
		longest.setdata(scan);

		if(longest.distance()){

			System.out.println(longest.d[longest.N-1]);

		}else{
			System.out.println("inf");
		}



	}

}

class Longest{
	int N;
	int M;
	long[] d;
	Edge[] es;
	long INF=-1000000000000000L;

	void setdata(Scanner scan){
		N=scan.nextInt();
		M=scan.nextInt();
		d = new long[N];
		es = new Edge[M];
		for(int i=0;i<M;i++){
			int a=scan.nextInt()-1;
			int b=scan.nextInt()-1;
			int c=scan.nextInt();
			es[i]=new Edge(a,b,c);
		}

		for(int i=0;i<N;i++){
			d[i]=INF;
		}
		d[0]=0;
	}

	boolean distance(){
		int cnt=0;
		boolean goal=false;
		while(true){
			boolean updata=false;
			for(int i=0;i<M;i++){
				Edge e =es[i];
				if(d[e.from]!=INF&&d[e.to]<d[e.from]+e.cost){
					d[e.to] =d[e.from]+e.cost;
					updata = true;
					if(cnt>=N&&e.to==N-1){
						goal=true;//ゴールも
					}
				}
			}
			if(!updata){
				return true;
			}
			if(cnt==2*N){
				if(!goal){
					return true;
				}
				return false;
			}
			cnt++;

		}

	}


}

class Edge{
	int from,to,cost;

	Edge(int f,int t,int c){
		from=f;
		to =t;
		cost =c;
	}
}

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

int main() {
    int h,w;
    cin>>h>>w;
    vector<string>a(h);
    for (int i = 0; i <= w+1; i++)
    {
        cout<<"#";
    }
    cout<<endl;
    for (int i = 0; i < h; i++)
    {
        cin>>a[i];
        a[i]="#"+a[i]+"#";
        cout<<a[i]<<endl;
    }
        for (int i = 0; i <= w+1; i++)
    {
        cout<<"#";
    }
    cout<<endl;
}



Measured memory_bytes: 256
'use strict'

function dfs(node, graph, visited){
  visited[node]=true;
  for(let i=0;i<graph[node].length;i++){
    if(graph[node][i]==false || visited[i]==true){continue;}
    dfs(i, graph, visited);
  }
}

function main(input){
  const lines = input.split('\n');
  const NM  =lines.shift().split(' ').map(x => parseInt(x));
  const N = NM[0];
  const M = NM[1];
  const sides = [];
  const graph = [];
  const visited = Array(N).fill(false);
  for(let i=0;i<N;i++){
    graph.push( Array(N).fill(false) );
  }

  for(let i=0;i<M;i++){
    let current = lines.shift().split(' ').map( x=>parseInt(x) );
    graph[current[1]-1][current[0]-1]=graph[current[0]-1][current[1]-1]=true
    sides.push(current);
  }

  let result=0;
  for(let i=0;i<M;i++){
    let current = sides[i];
    graph[current[1]-1][current[0]-1]=graph[current[0]-1][current[1]-1]=false

    for(let j=0;j<N;j++){visited[j]=false;}

    dfs(0, graph, visited);

    for(let j=0;j<N;j++){
      if(!visited[j]){
//console.log(current);
//console.log(visited);
//console.log('---');
        result++;
        break;
      }
    }
    graph[current[1]-1][current[0]-1]=graph[current[0]-1][current[1]-1]=true
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{
    string S;
    cin >> S;

    int ans = 0;
    for (int i = 1; i < S.size(); i++)
    {
        if (S[i - 1] != S[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
s=input()
for i in range(int(input())):
    ope=input().split()
    ope[1]=int(ope[1])
    ope[2]=int(ope[2])
    if ope[0]=="print":
        print(s[ope[1]:ope[2]+1])
    if ope[0]=="replace":
        s=s[:ope[1]]+ope[3]+s[ope[2]+1:]
    if ope[0]=="reverse":
        s=s[:ope[1]]+s[ope[1]:ope[2]+1][::-1]+s[ope[2]+1:]


Measured memory_bytes: 5616
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>

using namespace std;

const int Max = 1e9 + 7;
typedef long long ll;
ll ans;

int main(){
	char a, b, c;
	int n, m, i, j;
	while(~scanf("%c %c ", &a, &b)){
		if(a == 'H')  c = b;
		else{
			if(b == 'H') c = 'D';
			else c = 'H';
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
int main(int argc,char *argv[])
{
    ll a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld",a*b/gcd(a,b));
    return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
L = defaultdict(int)
R = defaultdict(int)
for i, a in enumerate(A):
    L[a+i] += 1
    R[i-a] += 1

ans = 0
for k, v in L.items():
    ans += R[k]*v

print(ans)


Measured memory_bytes: 73880
#include <iostream>

using namespace std;

int main()
{

int x,y;
cin>>x>>y;

x--;

for(int i=x;i>=0;i--){
    cout<<y-i<<" ";
}
for(int i=1;i<=x;i++){
    cout<<y+i<<" ";
}

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const int numcon = 26;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int D; cin>>D;
    vector<ll> C(numcon),last(numcon,0);
    vector<vector<ll> > S(D, vector<ll>(numcon));
    REP(i,numcon){
        cin>>C[i];
    }
    REP(i,D){
        REP(k,numcon){
            cin >> S[i][k];
        }
    }
    vector<ll> T(D);

    ll ans = 0;
    vector<ll> ansans(D);
    vector<ll> anscontest(D);

    REP(i,D){
        ll maxi = -inf;
        ll max_contest = -1;
        REP(k,numcon){ //どれが最大になるタイプか求める
            ll now = S[i][k];
            REP(j,numcon){  //タイプjのコンテスト分引く
                if(k != j){
                    now -= C[j] * (i+1 - last[j]);
                }
            }
            if(maxi < now){
                maxi = now;
                max_contest = k;  //k + 1番目のコンテストがその時点での最大値
            }
        }
        ans += S[i][max_contest];
        last[max_contest] = i+1;

        REP(k,numcon){
            ans -= C[k] * (i+1 - last[k]);
        }
        ansans[i] = ans;
        anscontest[i] = max_contest + 1;
    }

    REP(i,D){
        cout << anscontest[i] << endl;
    }
    
}

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

ll N,A,B,C,D;
ll c=0,a=0,bc=0,ans=0;
vector<char> S;
string s;

int main(){
	cin>>s;
	for(int i=0;i<s.size()-1;i++){
      if(s.substr(i,2)=="BC"){
        S.push_back('D');
        i++;
      }
      else
        S.push_back(s.at(i));
    }
  
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A')
      a++;
    else if(S.at(i)=='D')
      ans+=a;
    else
      a=0;
  }
  cout<<ans<<endl;
}

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

typedef complex<double> xy_t;

xy_t P[110];

int main(){
  int N;
  scanf("%d", &N);
  for (int i=0; i<N; i++){
    double x, y;
    scanf("%lf %lf", &x, &y);
    P[i] = xy_t(x,y);
  }
  double sum = 0.0;
  for (int i=2; i<N; ++i){
    xy_t a=P[0], b=P[i-1], c=P[i];
    sum += 0.5*((b.real()-a.real())*(c.imag()-a.imag())
		-(b.imag()-a.imag())*(c.real()-a.real()));
  }
  printf("%.1f\n", sum);
  return 0;
}

Measured memory_bytes: 2700
#include <iostream>
using namespace std;
 
int main(void) {
	double x;
    double h = 0;
  
	cin >> x;
  	h =  (int)(x / 500) * 1000;
    h += (int)(((int)x % 500) / 5) * 5;
  
  	printf("%.0lf\n", h);
      
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  cout << 180*(n -2) << "\n";
  
  //cout << fixed << setprecision(10) << n << "\n";

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int min = 100;  // 十分大きい数
  for (int a=1,b=n-1; a<n; ++a,--b) {
    int sum = 0;
    for (int i=a; i!=0; i/=10) {
      sum += i%10;
    }
    for (int i=b; i!=0; i/=10) {
      sum += i%10;
    }
    min = (min > sum) ? sum : min;
  }

  cout << min << endl;
  return 0;
}

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

#define ll long long
#define pb push_back

using namespace std;

const int N = 2e5 + 123;

ll n, k;

ll a[N], sz, used[N], in;

vector <ll> path, x;

int main () {
    cin >> n >> k;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
    }
    ll cur = 1;
    if (k <= 1e7) {
        while (k --) {
            cur = a[cur];
        }
        cout << cur;
        exit (0);
    }
    do {
        used[cur] = true;
        path.pb (cur);
        cur = a[cur];
    }while (!used[cur]);
    sz = path.size ();
    for (int i = 0;i < sz;i ++) {
        if (path[i] == cur) {
            for(int j = i;j < sz;j ++) {
                x.pb (path[j]);
            }break;
        }
    }
    in = sz - x.size ();
    sz = x.size ();
    k -= in;
    k %= sz;
    cout << x[k];
}


Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007; 

int main() 
{
	io();
	li n;cin>>n;
	map<string,li>m;
	while(n--)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"];
		ne;
		cout<<"WA x "<<m["WA"];
		ne;
		cout<<"TLE x "<<m["TLE"];
		ne;
		cout<<"RE x "<<m["RE"];
		ne;
}

Measured memory_bytes: 3664
N=int(input())
last_t,last_x,last_y=0,0,0
for _ in range(N):
    t,x,y = map(int,input().split())
    move = abs(x-last_x)+abs(y-last_y)
    time = t - last_t
    if (time >= move) and (time - move) % 2 == 0:
        last_t,last_x,last_y=t,x,y
    else:
        print("No")
        break
else:
    print("Yes")



Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    bool good = true;
    REP(i, s.size()-1){
        if(s[i+1] == s[i]) good = false;
    }
    cout << (good ? "Good" : "Bad") << endstr;
    return 0;
}


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

int asc(const void *a, const void *b) {
  long long *A = (long long *)a;
  long long *B = (long long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int main(void) {
  long long i, j;
  long long n;
  long long a;
  long long data;
  long long *sum;
  long long c1, c2;
  long long c_name;
  
  scanf("%lld", &n);
  
  sum = malloc(sizeof(long long) * (n + 1));
  
  data = 0;
  sum[0] = data;
  
  for (i = 1; i < n + 1; i++) {
    scanf("%lld", &a);
    sum[i] = data + a;
    data += a;
  }
  
  qsort(sum, n + 1, sizeof(long long), asc);
  
  c_name = sum[0];
  c1 = 0;
  c2 = 0;
  for (i = 1; i < n + 1; i++) {
    if (c_name == sum[i]) {
      c1++;
      c2 += c1;
    } else {
      c1 = 0;
      c_name = sum[i];
    }
  }
  
  printf("%lld\n", c2);
  
  free(sum);

  return 0;
}

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

int main() {
    string s;
    cin >> s;

    if (s.size() == 2 && s[0] == s[1]) {
        cout << 1 << " " << 2 << endl;
        return 0;
    }

    for (int i = 0; i + 3 <= s.size(); i++) {
        string t = s.substr(i, 3);
        map<char, int> counter;
        for (char ch : t) {
            counter[ch]++;
            if (counter[ch] >= 2) {
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << endl;

    return 0;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	sum := a + b
	sub := a - b
	mul := a * b

	fmt.Println(max(sum, sub, mul))
}

func max(args ...int) int {
	ret := -100000
	for _, v := range args {
		if ret < v {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

ll ans;
ll n, k, x, y;

int main(){

  n = in();
  k = in();
  x = in();
  y = in();

  REP( i , n ){
    if( i < k ){
      ans += x;
    } else {
      ans += y;
    }
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC";
	}else if (n < 2800) {
		cout << "ARC";
	}else {
		cout << "AGC";
	}
}


















Measured memory_bytes: 256
S = int(input())
a = S // 3
MOD = 10**9 + 7

#nCr求める
def inv(a):
  return pow(a,MOD-2,MOD)

fact=[0,1]
for i in range(2,S+1):
  fact.append((fact[-1]*i)%MOD)

def choose(n,r):
  if r==0 or r==n:
    return 1
  else:
    return fact[n]*inv(fact[r])*inv(fact[n-r])%MOD

ans = 0
for i in range(1,a+1):
    b = S - i*3
    ans += choose(b+i-1, b)
    ans %= MOD
else:
    print(ans)

Measured memory_bytes: 8900
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <cstring>
#include <climits>

#define RREP(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define INVREP(i,a,b) for(int i=a;i>=b;--i)
#define MOD 1000000007ll
#define BIT(i) (1ll<<i)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }//aに更新したいものを
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

//繰り返し2乗
ll modpow(ll N, ll P, ll M=MOD) {if (P == 0) return 1;if (P % 2 == 0) {ll t = modpow(N, P / 2, M);return t * t % M;}return (N * modpow(N, P - 1, M))%M;}
//階乗
pair<vector<ll>, vector<ll>> fact(ll n) {vector<ll>f(n, 1);RREP(i, 2, n) f[i] = (f[i - 1]*i) % MOD;vector<ll>invf(n, 1);invf[n - 1] = modpow(f[n - 1],MOD-2,MOD);INVREP(i, n - 1, 2) invf[i - 1] = (invf[i]*i) % MOD;return pair<vector<ll>, vector<ll> >(f,invf);}
ll modmult(ll a, ll b, ll M = MOD) { return (a*b) % M; }
ll modadd(ll a, ll b, ll M = MOD) { return (a + b) % M; }
ll comb(pair<vector<ll>, vector<ll>>p, int n, int r) {return modmult(modmult(p.first[n], p.second[r]), p.second[n - r]); }
/*
    auto a = fact(200009);
    cout << comb(a,15,5) << endl;
*/

void solve()
{
    /* collection
    ll n;
    cin >> n;
    vector<ll> A;
    REP(i, n) cin >> A[i];
    vector<pair<ll, ll>> AB;
    REP(i, n) {cin >> AB[i].first;cin >> AB[i].second;}
    
    sort(ALL(vec),greater<int>());

    map<ll, ll> mp;
    map<ll, ll, greater<ll>> mp;
    REP(i, 100) mp[i] = i * 10;
    cout << mp.lower_bound(50)->second<<endl;
    cout << mp.upper_bound(50)->second << endl;
    cout << next(mp.upper_bound(50))->second << endl;
    cout << prev(mp.upper_bound(50))->second << endl;
    */
    int n,q;
    string s;
    cin >> n >> s >> q;
    int a = (int)'a';
    set<int> chars[26];
    REP(i, 26){
        chars[i].insert(10000000);
    }
    REP(i,n){
        chars[(int)s[i]-a].insert(i+1);
    }
    
    REP(time,q){
        int type;
        cin>>type;
        if(type==1){
            int i;char c;
            cin >> i >> c;
            chars[int(s[i-1])-a].erase(i);
            s[i-1]=c;
            chars[(int)c-a].insert(i);
        }else{
            int l,r,ans=0;
            cin >> l >> r;
            for(auto &chr : chars){
                if (*(chr.lower_bound(l))<=r) ans++;
            }
            cout << ans << '\n';
        }
    }
}

int main(){
    solve();
}


Measured memory_bytes: 24184
def solve(x):
  if x == 1:
    print(1, 0)
    return
  if x == 2:
    print(1, -1)
    return
  for d in range(1, x):
    #print('0:', d)
    if d**2 > x:
      break
    if x % d:
      continue
    for a in range((d+1)//2, x):
      #print('1:', a, a - d)
      t = a**5 + (d - a)**5
      if t == x:
        print(a, a-d)
        return
      if t > x:
        break
                

X = int(input())
solve(X)

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

namespace ABC120D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = ReadInt();
            long N = NM[0];
            int M = NM[1];

            long[] anss = new long[M];
            int[] A = new int[M];
            int[] B = new int[M];
            for (int i = 0; i < M; i++)
            {
                var input = ReadInt();
                A[i] = input[0] - 1;
                B[i] = input[1] - 1;
            }

            var uf = new UnionFind((int)N);

            anss[M - 1] = N * (N - 1) / 2; //初期化
            for (int i = M - 2; i >= 0; i--)
            {
                if (uf.Same(A[i + 1], B[i + 1]))
                {
                    //変化なし
                    anss[i] = anss[i + 1];
                }
                else
                {
                    anss[i] = anss[i + 1] - uf.Size(A[i + 1]) * uf.Size(B[i + 1]);
                }
                uf.Unite(A[i + 1], B[i + 1]);
            }

            foreach (var a in anss)
            {
                Console.WriteLine(a);
            }
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
    class UnionFind
    {
        int[] par;
        int[] rank;
        int[] count;

        public UnionFind(int n)
        {
            Init(n);
        }

        void Init(int n)
        {
            par = new int[n];
            rank = new int[n];
            count = new int[n].Select(x=>1).ToArray();

            for (int i = 0; i < n; i++)
            {
                par[i] = i;
            }
        }

        public int Find(int x)
        {
            if (par[x] == x)
            {
                return x;
            }
            else
            {
                return par[x] = Find(par[x]);
            }
        }

        public void Unite(int x, int y)
        {
            x = Find(x);
            y = Find(y);
            if (x == y) return;

            if (rank[x] < rank[y])
            {
                par[x] = y;
                count[y] += count[x];
            }
            else
            {
                par[y] = x;
                count[x] += count[y];
                if (rank[x] == rank[y]) rank[x]++;
            }

        }
        public bool Same(int x, int y)
        {
            return Find(x) == Find(y);
        }

        public int Size(int x)
        {
            return count[Find(x)];
        }
    }
}


Measured memory_bytes: 22456
#include <bits/stdc++.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 1e8;
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int n;
  string s;
  cin >> s;
  int cnt = 0;
  int l = s.size();
  for(int i=0;i<l/2;i++){
    if(s[i] != s[l-i-1]){
      cnt++;
    }
  }
  cout << cnt << '\n';
}

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

	int main() {
		int A, B;
		cin >> A >> B;

		if (A >= 10 || B >= 10) {
			cout << "-1" << endl;
		}

		else {
			cout << A * B << endl;
		}
		
	}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nk[0];
			int k = nk[1];
			var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			var dic = new Dictionary<int, int>();
			for (int i = 0; i < n; i++) {
				if (dic.ContainsKey(a[i])) {
					dic[a[i]]++;
				} else {
					dic[a[i]] = 1;
				}
			}

			int keyCount = dic.Keys.Count;
			if (keyCount <= k) {
				Console.WriteLine(0);
				return;
			}

			var nums = dic.Keys.Select(x => dic[x]).OrderBy(x => x).ToArray();
			int m = keyCount - k;
			int ans = 0;
			for (int i = 0; i < m; i++) {
				ans += nums[i];
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 52900