akhauriyash/Code-Regression huggingface dataset:
/*input
5 2 3
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const int maxn=1e5+5;
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if(abs(a-b)%2){
		cout<<min(a-1,n-b)+1+(b-a-1)/2;
	}
	else{
		cout<<abs(a-b)/2;
	}
}

Measured memory_bytes: 768
def resolve():
    '''
    code here
    '''
    import math
    N = int(input())
    As = [int(item) for item in input().split()]

    
    res = 2000**2

    for mid in range(min(As), max(As)+1):
        temp_res = 0
        for item in As:
            temp_res += (item - mid)**2
        res = min(temp_res, res)
    print(res)

if __name__ == "__main__":
    resolve()


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

using namespace std;

const int MOD = 1e9 + 7;

int n, k;
int a[2111];

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	int x = 0, y = 0;
	for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j) x += a[i] > a[j];
	x = (long long) x * k % MOD;
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) if (i != j && a[i] > a[j]) y++;
	y = (long long) y * ((long long) k * (k - 1) / 2 % MOD) % MOD;
	cout << ((long long) x + y) % MOD << "\n";
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  int a=1,b=n;
  for(int i=1; i*i<=n; i++){
    if(n%i==0){
      a = i;
      b = n/i;
    }
  }
  if(1<=a && a<=9 && 1<=b && b<=9) cout<<"Yes";
  else cout<<"No"<<'\n';
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
vector<string> p3, p4, p5, p6;
vector<string> ans;
void solve(int n){
	int ch = 0, sh = 0;
	for(int v : {4, 5, 6}){
		if(n - v == 0){
			ch = v;
			break;
		}
		if(n - v != 1 && n - v != 2 && n - v != 7){
			ch = v;
			sh = n - v;
			break;
		}
	}
	if(n - ch) solve(n - ch);
	vector<string> c;
	if(ch == 4) c = p4;
	if(ch == 5) c = p5;
	if(ch == 6) c = p6;
	for(int i = 0; i < ch; i++){
		for(int j = 0; j < ch; j++){
			ans[sh + i][sh + j] = c[i][j];
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	p4.resize(4);
	p4[0] = "aabc";
	p4[1] = "ddbc";
	p4[2] = "bcaa";
	p4[3] = "bcdd";
	p5.resize(5);
	p5[0] = "..abc";
	p5[1] = "..abc";
	p5[2] = "aaddb";
	p5[3] = "bba.b";
	p5[4] = "ccacc";
	p6.resize(6);
	p6[0] = "ddbaa.";
	p6[1] = "a.b..c";
	p6[2] = "acc..c";
	p6[3] = "bb.ddb";
	p6[4] = "..ca.b";
	p6[5] = "..cacc";
	if(n == 2) cout << -1 << endl;
	else {
		if(n == 7){
			ans.resize(n);
			for(int i = 0; i < n; i++) ans[i].resize(n);
			for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) ans[i][j] = '.';
			for(int i = 0; i < n - 1; i += 3){
				for(int j = 0; j < n - 1; j += 3){
					ans[i][j + 2] = 'a';
					ans[i + 1][j + 2] = 'a';
					ans[i + 2][j] = 'b';
					ans[i + 2][j + 1] = 'b';
				}
			}
			for(int i = 0; i < n - 1; i += 2) ans[n - 1][i] = ans[n - 1][i + 1] = 'd' + i;
			for(int i = 0; i < n - 1; i += 2) ans[i][n - 1] = ans[i + 1][n - 1] = 'd' + i;
			for(int i = 0; i < n; i++) cout << ans[i] << endl;
		}
		else if(n == 3){
			cout << "aa.\n..b\n..b\n";
		} else {
			ans.resize(n);
			for(int i = 0; i < n; i++) ans[i].resize(n);
			for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) ans[i][j] = '.';
			solve(n);
			for(int i = 0; i < n; i++) cout << ans[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n);i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int n;
  cin >> n;
  vector<string> v;
  map<string, int> mp;
  rep(i, n)
  {
    string s;
    cin >> s;
    if(!mp[s]){
      v.push_back(s);
      mp[s]++;
    }
  }
  cout << v.size() << endl;
}

Measured memory_bytes: 25072
from collections import Counter
N = int(input())
src = list(map(int,input().split()))
ctr = Counter(src)

ans = 0
for n in range(1,10**5+1):
    tmp = ctr[n-1] + ctr[n] + ctr[n+1]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 14564
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
const int MAX=1000001;

int main(){
    int n,m;cin>>n>>m;
    int a[50],b[50],c[50],d[50];
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    for(int i=0;i<m;i++) cin>>c[i]>>d[i];
    
    for(int i=0;i<n;i++){
        int point=0;
        int mind=abs(c[0]-a[i])+abs(d[0]-b[i]);
        for(int j=1;j<m;j++)if(mind>abs(c[j]-a[i])+abs(d[j]-b[i])){
            mind=abs(c[j]-a[i])+abs(d[j]-b[i]);
            point=j;
        }
        cout<<point+1<<endl;
    }
}    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
// #include <string>
// #include <set>
// #include <algorithm>

using namespace std;
// typedef unsigned long long ull;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;

    vector<int> A(N);
    vector<vector<int>> x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        x[i].resize(A[i]);
        y[i].resize(A[i]);
        for (int j = 0; j < A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
            x[i][j] -= 1;
        }
    }

    int count_max = 0;
    for (int s = 0; s < (1 << N); s++) {
        vector<int> honest(N);
        for (int i = 0; i < N; i++) {
            honest[i] = (s >> i) & 1;
        }
        // p(s, honest);

        bool possible = true;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < A[i]; j++) {
                // p(i, honest[i], x[i][j], "is", y[i][j]);
                if (honest[i] && y[i][j] != honest[x[i][j]]) {
                    possible = false;
                    break;
                }
            }
            if (!possible) {
                break;
            }
        }
        // p("possible", possible);

        if (possible) {
            int count = 0;
            for (int i = 0; i < N; i++) {
                count += honest[i];
            }
            if (count > count_max) {
                count_max = count;
            }
        }
    }

    cout << count_max << endl;

    return 0;
}


Measured memory_bytes: 256
fn main() {
    let n: usize = read();    
    let mut cities: Vec<(f64, f64)> = Vec::new();
    for _ in 0..n {
        let (x, y): (i64, i64) = read_tuple();
        cities.push((x as f64, y as f64));
    }

    let mut ans = 0.0;
    let perm: Vec<Vec<usize>> = dfs(&mut vec![], &mut vec![false; n]);
    for permutaion in perm.iter() {
        for i in 0..(n - 1) {
            let j = i + 1;
            let (xi, yi) = cities[permutaion[i]];
            let (xj, yj) = cities[permutaion[j]];

            let dist = f64::sqrt((xi - xj).powf(2.0) + (yi - yj).powf(2.0));
            ans += dist;
        }
    } 


    ans /= (1..(n + 1)).map(|v| v as f64).product::<f64>();

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


fn dfs(cur: &mut Vec<usize>, flag: &mut Vec<bool>) -> Vec<Vec<usize>> {
    if flag.iter().all(|x| *x) {
        return vec![cur.clone()]
    }

    let mut res = Vec::new();
    for i in 0..flag.len() {
        if !flag[i] {
            flag[i] = true;

            cur.push(i);
            res.append(&mut dfs(cur, flag));
            cur.pop();

            flag[i] = false;
        }
    }

    res
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

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


Measured memory_bytes: 8444
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    int n,k; cin >> n >> k;
    ll h[n]; cinf(n,h);
    ll dp[n]; for(int i=0;i<n;i++) dp[i] = INF;
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i>=j) chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int maxn=200050;
const int inf=0x3f3f3f3f;
ll n,k;
ll a[maxn],f[maxn];
bool cmp(int a,int b){return a>b;}
bool calc(ll mid)
{
	ll cost=0;
	F(i,1,n) if(a[i]*f[i]>mid) cost+=a[i]-(mid/f[i]);
	return (cost<=k);
}
int main()
{
	read(n),read(k);
	F(i,1,n) read(a[i]);
	F(i,1,n) read(f[i]); 
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,cmp);
	ll l=0,r=1e12;
	while(l<r)
	{
		ll mid=(l+r)/2;
		if(calc(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int N, K;
	cin >> N >> K;
	vector<pair<int,int>> s;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		s.push_back(make_pair(a, b));
	}
	sort(s.begin(), s.end());
	long long int sum = 0;
	for (int i = 0; i < N; i++) {
		sum = sum + s[i].second;
		if (sum >= K) {
			cout << s[i].first;
			return 0;
		}
	}
}

Measured memory_bytes: 1400
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n/x)*t + (n%x ? 1: 0)*t << endl;
    return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    int N, B[110];
    cin >> N;
    rep1(i,N-1) cin >> B[i];

    int ans = B[1];
    for (int i = 2; i <= N-1; i++) {
        ans += min(B[i], B[i-1]);
    }
    cout << ans + B[N-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;



int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   cout << fixed << setprecision(20);
   
  int n,k,p=0; cin >> n >> k;
  string s; cin >> s;
  
  int i = 0;
  int j = 0;
  int ans = 0;
  while(j < n){
      while(j < n && s[j] == '1')
          ++ j;
      ans = max(ans, j - i);
      while(j < n && s[j] == '0')
          ++ j;
      -- k;
      if(k < 0){
          while(i < n && s[i] == '1')
              ++ i;
          while(i < n && s[i] == '0')
              ++ i;
      }
      ans = max(ans, j - i);
  }
  cout << ans << endl;
 
}



Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int x,y;
	cin>>x>>y;
	if(x==y)cout<<0;
	else if(x>=0){
		if(y>x){
			cout<<y-x;
		}
		else if(y>0){
			cout<<2+(x-abs(y));
		}
		else if(y>=-x){
			cout<<1+(y-(-x));
		}
		else cout<<1-(y+x);
	}
	else{
		if(y<x){
			cout<<2+(x-y);
		}
		else if(y<=0)cout<<y-x;
		else if(y<-x)cout<<1+(-y-x);
		else cout<<1+(y-(-x));
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main(){
  int S,h,m,s;
  cin >> S;
  h=S/3600;
  m=(S/60)%60;
  s=S%60;
  cout << h << ":" << m << ":" << s <<endl;
  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int N; cin>>N;
  string S; cin>>S;
  int ans=0;
  for(int i=0; i<=N-3; i++){
    if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def dfs(u, colors, matrix, time, detect_time, finished_time):
    # ????????????????????¨??????????????????
    colors = colors
    detect_time = detect_time
    finished_time = finished_time
    time = time + 1
    stack = list()
    stack.append(u)
    colors[u] = 1
    detect_time[u] = time
    while len(stack):
        for i, val in enumerate(matrix[u]):
            if val == 1 and colors[i] == 0:
                time += 1
                stack.append(i)
                colors[i] = 1
                detect_time[i] = time
                u = i
                break
        else:
            time += 1
            e = stack.pop()
            colors[e] = 2
            finished_time[e] = time
            if len(stack):
                u = stack[-1]
    return time


if __name__ == '__main__':
    N = int(input())
    matrix = [[0] * N for _ in range(N)]
    color = [0] * N
    for i in matrix:
        node_info = [int(i) for i in input().split()]
        node_i = node_info[0] - 1
        if not node_info[1] == 0:
            for i in node_info[2:]:
                matrix[node_i][i - 1] = 1
    colors = [0] * len(matrix)
    detect_time = [0] * len(matrix)
    finished_time = [0] * len(matrix)
    time = 0
    for i, val in enumerate(colors):
        if val == 0:
            time = dfs(i, colors, matrix, time, detect_time, finished_time)

    for i in range(len(matrix)):
        print('{} {} {}'.format(i + 1, detect_time[i], finished_time[i]))

Measured memory_bytes: 7876
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
#define cint(...) ll __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__);

int main() {
	string s, t;
	cin >> s >> t;
	YESNO(s[2]==t[0]&&s[1]==t[1]&&s[0]==t[2]);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>


int main()
{
	long long n;

	std::cin >> n;

	std::map<long long, long long> m;
	m[8] = 0;
	for (size_t i = 0; i < n; i++) {
		long long rate;
		std::cin >> rate;
		if (rate >= 3200) {
			m[8]++;
		} else {

			m[rate / 400]++;
		}
	}

	long long min = m.size();

	if (m[8] == 0) {
		min--;
	}
	if (m.size() > 1) {
		if (m[8] > 0) {
			min--;
		}
	}

	long long max = m.size();
	if (m[8] == 0) {
		max--;
	}
	if (m[8] > 0) {
		max = max - 1 + m[8];
	}

	std::cout << min << " " << max << std::endl;
	return 0;
}

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

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

void solve() {
    int n;
    cin >> n;

    int res = n / 100;
    if(100*res <= n && n <= 105*res) cout << 1 << endl;
    else cout << 0 << endl;
}

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

Measured memory_bytes: 256
N = int(input())
S = input()


w_cnt = 0
e_cnt = 0
w_lst = []
e_lst = []

for s in S:
    if s == 'W':
        w_cnt += 1

    else:
        e_cnt += 1

    w_lst.append(w_cnt)
    e_lst.append(e_cnt)

ans = float('inf')
e_all = e_lst[-1]
for i in range(N):
    if S[i] == 'W':
        t = w_lst[i] - 1 + e_all - e_lst[i]
    else:
        t = w_lst[i] + e_all - e_lst[i]

    ans = min(ans, t)


print(ans)

Measured memory_bytes: 23500
N = int(input())
A,B = (int(x) for x in input().split())
a = []
b = []
c = []
for i in input().split():
    i = int(i)
    if(i<=A):
        a.append(i)
    elif(i<=B):
        b.append(i)
    else:
        c.append(i)
print(min(len(a),len(b),len(c)))

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


vector<pair<ll, ll> > vv;
const ll INF = 1e18;

int n;
ll dp[2][5100];
ll dp2[2][5100];

void out(ll a) {
	vector<int> o;
	while (a != 0)
		o.push_back(a % 10), a /= 10;
	reverse(o.begin(), o.end());
	for (int i: o)
		cout << i;
	if (o.size() == 0)
		cout << 0 << "\n";
}



int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int l, r;
		scanf("%d%d", &l, &r);
		vv.push_back(make_pair(l + r, l));
	}
	sort(vv.begin(), vv.end());
	reverse(vv.begin(), vv.end());
	for (int i = 0; i <= n; ++i)
		dp[0][i] = dp[1][i] = INF;
	dp[0][0] = 0;
	for (int i = 0; i < (int)vv.size(); ++i) {
		for (int j = 0; j <= n; ++j)
			dp2[0][j] = dp2[1][j] = INF;
		for (int j = 0; j <= i; ++j) {
			dp2[0][j + 1] = min(dp2[0][j + 1], dp[0][j] + vv[i].first * j + (vv[i].first - vv[i].second));
			dp2[0][j] = min(dp2[0][j], dp[0][j] + vv[i].first * (i - j) + (vv[i].second));
		}
		if (n % 2 == 0) {
			for (int j = 0; j <= n; ++j) {
				dp[0][j] = dp2[0][j], dp[1][j] = dp2[1][j];
			}
			continue;
		}
		for (int j = 0; j <= i; ++j) {
			dp2[1][j + 1] = min(dp2[1][j + 1], dp[1][j] + vv[i].first * j + (vv[i].first - vv[i].second));
			dp2[1][j] = min(dp2[1][j], dp[1][j] + vv[i].first * (i - j) + (vv[i].second));
			dp2[1][j] = min(dp2[1][j], dp[0][j] + ((n - 1) / 2) * vv[i].first);
		}
		for (int j = 0; j <= n; ++j) {
			dp[0][j] = dp2[0][j], dp[1][j] = dp2[1][j];
		}
	}
	if (n % 2 == 0) {
		out(dp[0][n / 2]);
	}
	else {
		out(dp[1][n / 2]);
	}
	return 0;
}




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

# print((abs(abs(X)-K*D)/D)%2)
if abs(X) >= K*D:
    print(abs(abs(X)-K*D))
elif ((abs(X)-K*D)/D)%2 == 0:
    print(0)
elif ((abs(X)-K*D)/D)%2 <= -1:
    print(abs((abs(X)-K*D)+D*((abs(abs(X)-K*D))//D+1)))
elif ((abs(X)-K*D)/D)%2 < 0:
    print(abs((abs(X)-K*D)+D*((abs(abs(X)-K*D))//D)))
    
elif (abs((abs(X)-K*D)/D))%2 < 1:
    print(abs((abs(X)-K*D)+D*abs(((abs(abs(X)-K*D))//D))))
elif (abs((abs(X)-K*D)/D))%2 >=1 :
    print(abs((abs(X)-K*D)+D*abs(((abs(abs(X)-K*D))//D+1))))

Measured memory_bytes: 9312
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  char s[n+1];
  scanf("%*c%s",s);
  int i,count=0,max=0;
  for(i=0;i<n;i++){
    if(s[i]=='D')
      count--;
    else
      count++;
    if(max<count)
      max=count;
  }
  printf("%d\n",max);
  return 0;
}

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

int main() {
	//vars;
	string str;
	//input;
	cin >> str;
	//process;
	for (int i = 0; i < str.size(); i++) {
		if (str[0] == 'B') {
			str.erase(str.begin());
			i--;
		}
		if (str[i] == 'B'&&i > 0) {
			str.erase(str.begin() + i - 1, str.begin() + i+1);
			i -= 2;
		}
	}
	//output;
	cout << str;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
        Scanner sc1 = new Scanner(System.in);
        int n = sc1.nextInt();
        int k = sc1.nextInt();
        int x = sc1.nextInt();
        int y = sc1.nextInt();
        int sum = 0;
        if(n < k){
            for(int j = 0; j < n; j++){
                sum += x;
            }
            System.out.print(sum);
        }else{
           for(int i = 0; i < k; i++){
                sum += x;
            }
            for(int j = 0; j < n-k; j++){
                sum += y;
            }
            System.out.print(sum);
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;





int main(){
  ll X; cin>>X;
  ll F = 100;

  ll cnt = 0;

  if(X <= 100) {cout<<cnt<<endl; return 0;}

  for(;;){
    cnt++;
    ll delta = F / 100;
    F += delta;
    if(F >= X ) break;
  }
  
  cout<<cnt<<endl;


  
  return 0;
  
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll N, T;
  cin >> N >> T;

  vl A(N);
  rep(i, N) cin >> A[i];

  vl B(N - 1);
  ll maxi = A[N - 1];

  rep_inv(i, N - 2, -1){
    B[i] = maxi - A[i];

    if(maxi < A[i]) maxi = A[i];
  }

  stable_sort(B.begin(), B.end(), greater<ll>());

  ll ans = N - 1;
  
  rep(i, N - 1){
    if(B[i] != B[0]){
      ans = i;
      break;
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2176
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
L,T,D=reads()
count=0
for i in range(L,T+1):
  if i%D==0:
    count+=1
print(count)



Measured memory_bytes: 67980
#include <bits/stdc++.h>
#define int long long int
#define MAXN 1000000007
#define endl '\n'
using namespace std;

//int binomialCoeff(int n, int k){
//    int res = 1;
//    if ( k > n - k )
//        k = n - k;
//    for (int i = 0; i < k; ++i){
//        res *= (n - i);
//        res /= (i + 1);
//    }
//    return res;
//}

void solve(){
    int n, k, sum = 0; cin >> n >> k;

    for(int i = k ; i <= n+1; ++i){
        sum += i*n - i*(i-1)/2 - (i-1)*i/2 + 1;
    }
    cout << sum % MAXN << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<i64> a(n);
  rep(i, 0, n) cin >> a[i];

  i64 ans = LINF;
  {
    i64 res = 0, sum = 0;
    int s = 1;
    rep(i, 0, n) {
      sum += a[i];
      if(sum * s <= 0) {
        res += abs(sum - s);
        sum = s;
      }
      s *= -1;
    }
    ans = min(ans, res);
  }
  {
    i64 res = 0, sum = 0;
    int s = -1;
    rep(i, 0, n) {
      sum += a[i];
      if(sum * s <= 0) {
        res += abs(sum - s);
        sum = s;
      }
      s *= -1;
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    sort(all(A));
    vector<ll> B,C;
    rep(i,N) {
        if (A[i] < 0) B.emplace_back(A[i]);
        else if (A[i] > 0) C.emplace_back(A[i]);
    }
    ll M = B.size();
    ll L = C.size();
    ll S = N-M-L;
    ll cntmi = M*L;
    ll cnt0 = S*(M+L) + S*(S-1)/2;
    ll cntpr = M*(M-1)/2 + L*(L-1)/2;
    if (K > cntmi && K <= cntmi+cnt0) {
        cout << 0 << ln;
        return 0;
    }
    if (K <= cntmi) {
        reverse(all(B)); reverse(all(C));
        ll left = -1e18-1;
        ll right = 0;
        while (right - left > 1) {
            ll mid = (right + left) / 2;
            ll num = 0, cnt = 0;
            rep(i,M) {
                while (num < L && B[i]*C[num] <= mid) {
                    num++;
                }
                cnt += num;
            }
            if (cnt < K) left = mid;
            else right = mid;
        }
        cout << right << ln;
    } else {
        K -= cntmi+cnt0;
        reverse(all(B));
        ll left = 0;
        ll right = 1e18+1;
        while (right - left > 1) {
            ll mid = (right + left) / 2;
            ll num = M-1, cnt = 0;
            rep(i,M) {
                while (num >= 0 && B[i]*B[num] > mid) {
                    num--;
                }
                cnt += max(0LL,num-i);
            }
            num = L-1;
            rep(i,L) {
                while (num >= 0 && C[i]*C[num] > mid) {
                    num--;
                }
                cnt += max(0LL,num-i);
            }
            if (cnt < K) left = mid;
            else right = mid;
        }

        cout << right << ln;
    }
}

Measured memory_bytes: 4084
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
#include<limits.h>
#include<stdbool.h>
typedef unsigned long long ull;
typedef long long ll;
#define MOD 10000000000　+　7  //10億　= 10^9になってる
#define juu 100000 //10万 10e5
#define hyaku 1000000 //100万　10e6
#define mINF -922337200085470000 //llのmax-1桁の小さい方
#define pINF 922337203600070000 //llのmax-1桁のデカい方
#define uINF 1844674407300000000 //ullのmax-1桁してる
#define pi 3.1415926535897932384
ll factor[300];
ll memory[300]; 
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num){
    int i = 0,kosuu=0;
    while(*(factor+i) != 0){
        while(num % *(factor+i)==0){
            num /= *(factor+i);
            memory[*(factor+i)] +=1;
        }
        if(num==1)break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろforは<*/
int elast(ll number){    
    ll tmp=0;
    int flag=0;
    *factor = 2;
    for(int i=3;i <= number;i++){
        flag=0;
        for(int j=0;j <= tmp ;j++){
            if(i % (*(factor+j)) == 0){
                flag=1;
                break;
            }
        }
        if(flag)continue;
        tmp += 1;
        *(factor+tmp) = i;
    }
        return tmp+2;
}
/*整数をqsortする為だけのもの*/
long long compare(const long long*a,const long long *b){
    if(*a<*b)
      return -1;
    else if(*a>*b)
      return 1;
    return 0;
}
/*intで収まる範囲であってくれ*/
ll nCr(int n,int r){
  ll val=1;
  int i;
  if(r==0)return 1;
  for(i=0;i<n-r;i++){
		val *= (n-i);
		val /= (i+1);
	}
  return val;
}
/*intで収まる範囲であってくれ*/
ll nPr(int n,int r){
  ll val=1;
  int i;
  for(i=0;i<r;i++){
    val *= (n-i);
  }
  return val;
}
/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/
int main(){
    char array[1000];
    char a[100];
    char b[100];
    memset(array,0,1000);
    memset(a,0,100);
    memset(b,0,100);
    ll N,K,i,j;
    scanf("%lld",&N);
    scanf("%s",array);
    if(N%2 ==1){
        printf("No");
        return 0;
    }
    else{
        strncpy(a,array,N/2);
        strncpy(b,array+N/2,N/2);
        if(strcmp(a,b) == 0){
            puts("Yes");
            return 0;
        }
        else{
            puts("No");
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 128
lastday=[-1]*26
def last(d):
  sum=0
  for i in range(26):
    sum+=c[i]*(d-lastday[i])
  return sum
def myFunc(i,Score,depth):
  tmp_score=Score
  tmp_max_choice=0
  tmp_score-=last(i)
  tmp_max_score=tmp_score
  for k,j in enumerate(s[i]):
    if tmp_max_score<tmp_score+j+c[k]*(i-lastday[k]):
      tmp_max_choice=k
      tmp_max_score=tmp_score+j+c[k]*(i-lastday[k])
  return tmp_max_score,tmp_max_choice
  

D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
Score=0
for i in range(D):
  score,choice=myFunc(i,Score,1)
  Score=score
  lastday[choice]=i
  print(choice+1)
  


Measured memory_bytes: 9392
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<string> s(N);
  REP(i, N) cin >> s[i];

  bool ans = true;

  set<string> set;
  REP(i, N){
    if(i != 0){
      if(s[i-1].back() != s[i][0]) ans = false;
    }
    if(set.count(s[i])) ans = false;
    set.insert(s[i]);
  }

  ans? Yes: No;


  return 0;
}

Measured memory_bytes: 256
//A - Task Scheduling Problem
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int A[3];
	int cost[3];
	for (int i = 0; i < 3; i++)cin >> A[i];
	int min = A[0] + A[1] + A[2];
	int tmp_min;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (i == j || i == k || j == k)continue;
				//cout << "i=" << i << "\tj=" << j << "\tk=" << k << endl;
				if (i == 0) {
					cost[0] = 0;
					if (j == 1) {
						cost[1] = abs(A[1] - A[0]);
						cost[2] = abs(A[2] - A[1]);
					}
					if (k == 1) {
						cost[1] = abs(A[2] - A[0]);
						cost[2] = abs(A[1] - A[2]);
					}
				}
				if (j == 0) {
					cost[0] = 0;
					if (i == 1) {
						cost[1] = abs(A[0] - A[1]);
						cost[2] = abs(A[2] - A[0]);
					}
					if (k == 1) {
						cost[1] = abs(A[2] - A[1]);
						cost[2] = abs(A[0] - A[2]);
					}
				}
				if (k == 0) {
					cost[1] = 0;
					if (j == 1) {
						cost[1] = abs(A[1] - A[2]);
						cost[2] = abs(A[0] - A[1]);
					}
					if (i == 1) {
						cost[1] = abs(A[0] - A[2]);
						cost[2] = abs(A[1] - A[0]);
					}
				}
				tmp_min = 0;
				for (int i = 0; i < 3; i++) {
					tmp_min += cost[i];
				}
				if (tmp_min < min) {
					min = tmp_min;
				}
			}
		}
		
	}
	cout << min<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{            
     
   public static void main(String[] args){
       Scanner sc = new Scanner(System.in);  
       
       int N = sc.nextInt();
       int a[] = new int[N];
       
       for(int i = 0;i < N;i++){
           a[i] = sc.nextInt();
       }
       
       int cnt[] = new int[200000];
       
       for(int i = 0;i < N;i++){
           if(a[i] != 0)cnt[a[i]-1]++;
           cnt[a[i]]++;
           cnt[a[i]+1]++;
       }
       
       int res = 0;
       
       for(int i = 0;i < cnt.length;i++){
           res = Math.max(res,cnt[i]);
       }
       
       System.out.println(res);
       
       
   }
}
               
        

Measured memory_bytes: 50256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> divisors = divisor(n);
    for(int i = 0; i < divisors.size(); i++) divisors[i]--;
    ll ans = 0;
    for(int i = 0; i < divisors.size(); i++)
    {
        if(divisors[i] == 0) continue;
        if(n / divisors[i] == n % divisors[i]) ans += divisors[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int i,x,y,z,ans=0,a[10010];
int main(){
    cin>>x>>y>>z;
    for(i=0;i<x;i++){
        cin>>a[i];
        if(a[i]<y) ans++;
        if(a[i]>=z) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

double pi = 3.141592653589793;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double L = sqrt(A * A + B * B - 2.0 * A * B * cos((1.0 / 12.0 * (H + M / 60.0) +  - M / 60.0) * pi * 2.0));
    cout << fixed << setprecision(11) << L << endl;
}


Measured memory_bytes: 4108
class SegTree
  attr_reader :size, :e, :f
  attr_accessor :seg

  def self.create(a=[],e,f)
    n = 1
    n *= 2 while n < a.size
    this = new(n,e,f)
    a.size.times do |i|
      this.seg[i+n] = a[i]
    end
    (n-1).downto(1) do |i|
      this.seg[i] = f[ this.seg[i*2],this.seg[i*2+1] ]
    end
    this
  end

  def initialize(n=2**32,e,f)
    @size = n
    @e = e
    @f = f
    @seg = Array.new(size*2, e)
  end

  def [](i)
    i += size
    seg[i]
  end

  def []=(i,x)
    i += size
    seg[i] = x
  end

  def update(i,x)
    i += size
    seg[i] = x
    _update(i)
  end
  
  def _update(i)
    while i > 1
      i /= 2
      seg[i] = f[ seg[i*2], seg[i*2+1] ]
    end
  end

  def swap(i,j)
    i += size
    j += size
    seg[j][0],seg[i][0] = seg[i][0],seg[j][0]
    _update(i)
    _update(j)
  end

  def query(a,b)
    ans = e
    a += size; b += size
    while a < b
      (ans = f[ ans, seg[a] ]; a += 1) if a.odd?
      (b -= 1; ans = f[ ans, seg[b] ]) if b.odd?
      a /= 2; b /= 2
    end
    ans
  end

  def inspect
    # { size: size, seg: seg }.to_s
    puts "size: #{size}"
    seg.each.with_index do |a,i|
      printf("%02d: %s\n", i, a.to_s(2))
    end
  end
end

# SegTree.new(N,E,F) := 要素数N、単位元E、演算Fで初期化、ただしNは2の冪
# SegTree.create(A,E,F) := モノイドA、単位元E、演算Fで初期化で初期化
# update(i,x) := A[i]をxに更新
# query(a,b) := 半開区間[a,b)でのA[i]の演算結果
#
# 単位元を追加してモノイドにする例（gcd）
# E = -1
# F = -> x,y { x == E ? y : y == E ? x : x.gcd(y) }
# T = SegTree.create(a,E,F)

E = 0
F = -> x,y { x | y }
CONV = -> c { 1 << (c.ord - 97)} # "a".ord == 97

n = gets.to_i
a = gets.chomp.chars.map{ |v| CONV[v] }
m = gets.to_i

T = SegTree.create(a,E,F)

m.times do |j|
  x,y,z = gets.chomp.split
  if x == "1"
    i = y.to_i - 1
    c = CONV[z]
    T.update(i,c)
  else
    l = y.to_i - 1
    r = z.to_i
    a = T.query(l,r)
    ans = a.to_s(2).count("1")
    puts ans
  end
end



Measured memory_bytes: 44444
using System;

class Program
{
    static void Main () 
    {
        String[] inline = Console.ReadLine().Split(' ');
        ulong a = ulong.Parse(inline[0]);
        ulong b = ulong.Parse(inline[1]);
        ulong n = ulong.Parse(inline[2]);
        ulong ans = 0;
        if (b > n)
        {
            ;
            ans = (ulong) Math.Floor( (decimal) (a*n / b));
        }
        else if (b == n)
        {
            ans = (ulong) Math.Floor((decimal) (a*(n-1) / b));
        }
        else
        {
            ulong s = (ulong) Math.Floor((decimal) (a*(b-1) / b));
            ulong t = (ulong) (Math.Floor((decimal) (a*n / b)) - a * Math.Floor((decimal) (n / b)));
            ans = Math.Max(s,t);
        }
        Console.WriteLine(ans);
    }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

bool check(vector<VI>& a, int d)
{
	FOR (i, 0, SZ(a))
	{
		FOR (j, 0, SZ(a[i]))
		{
			FOR (k, 0, SZ(a))
			{
				FOR (s, 0, SZ(a[k]))
				{
					if (abs(i - k) + abs(j-s) != d) continue;
					if (a[i][j] == a[k][s]) return false;
				}
			}
		}
	}

	return true;

}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	/*vector<VI> a = brute(5, 5, 4);

	cout<<"Done"<<endl;*/

	int n, m;
	cin>>n>>m;
	int d;
	cin>>d;
	if (d % 2 == 1)
	{
		FOR (i, 0, n)
		{
			FOR (j, 0, m)
			{
				cout<<"GB"[(i + j) % 2];
			}
			cout<<endl;
		}
		return 0;
	}

	vector<VI> a(n, VI(m, 0));;

	FOR (i, 0, n)
	{
		FOR (j, 0, m)
		{
			/*if (((i + j) & 1))
			{
				cout<<' ';
				continue;
			}*/
			int x = i + j;
			int y = i - j;

			x += 1000;
			y += 1000;

			x /= 2;
			y /= 2;

			x /= (d / 2);
			y /= (d / 2);
			x %= 2;
			y %= 2;
			if (x < 0) x += 2;
			if (y < 0) y += 2;

			int ind = x * 2 + y;
			cout<<"RGBY"[ind];
			//cout<<ind;
			a[i][j] = ind;
		}
		cout<<endl;
	}

	//cout<<check(a, d)<<endl;

}


Measured memory_bytes: 1536
fun main(args: Array<String>) = yorukatsu8c()

fun yorukatsu8c() {
    val n = readLine()!!.toLong()
    val list = Array(5) { readLine()!!.toLong() }

    val answer = 4 + list.map { Math.ceil(n.toDouble() / it.toDouble()).toLong() }.max()!!

    println(answer)
}


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

const int MOD = 1000000007;
int main(){
  long long N, K;
  cin >> N >> K;
  long long res = 0;
  for (long long k = K; k <= N + 1; k++){
    long long begin = k * (k - 1) / 2;
    long long end = (2 * N - k + 1) * k / 2;
    long long add = end - begin + 1;
    res = (res + add) % MOD;
  }
  cout << res << endl;
  return 0;
}




Measured memory_bytes: 3640
N,M = map(int,input().split())
H = list(map(int,input().split()))
edge = [[]for _ in range(N)]
for _ in range(M):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  edge[a].append(b)
  edge[b].append(a)
can = [True]*N
ans = 0
for i,can_i in enumerate(can):
    if can_i:
        for nxt_i in edge[i]:
            if H[i] < H[nxt_i]:
                can[i] = False
            elif H[i] > H[nxt_i]:
                can[nxt_i] = False
            elif H[i] == H[nxt_i]:
                can[i] = False
                can[nxt_i] = False
        if can[i]:
            ans += 1
print(ans)

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

int gcd(int x, int y){
    if(x%y==0){
        return y;
    }
    else{
        return(gcd(y,x%y));
    }

}





int main() {

int K;
int64_t sum=0;
cin >> K;
for (int a = 0; a < K; a++) {
    for (int b = 0; b < K; b++) {
        for (int c = 0; c < K; c++) {
            sum += gcd(gcd(a+1,b+1),c+1);
        }
    }
 }
cout << sum << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main() {
   int n,x,t;
   int i=0;
   cin>>n>>x>>t;
   while(x*i<n){
       i++;
   }
   cout<<i*t<<endl;
}

Measured memory_bytes: 3636
line = input().split()
a,b,c,d = int(line[0]),int(line[1]),int(line[2]),int(line[3])

if b <= c:
    print(0)
elif d <= a:
    print(0)

else:
    base1 = max([a,c])
    base2 = min([b,d])
    print(base2-base1)

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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct UnionFind {
    vector<int> id;
    vector<vector<int> > groups;
    int gn; //number of groups
    UnionFind(int n){
        id = vector<int>(n);
        groups = vector<vector<int> >(n);
        gn = n;
        for(int i=0;i<n;++i){
            id[i]=i;
            groups[i]={i};
        }
    }
    void unite(int a, int b) {
        if(same(a,b)) return;
        gn--;
        int x = id[a];
        int y = id[b];
        if(groups[x].size()<groups[y].size()) swap(x,y);
        for(int j : groups[y]){
            id[j] = x;
            groups[x].push_back(j);
        }
        groups[y].clear();        
    }
    bool same(int a, int b) {
        return id[a] == id[b];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vint p(n);
    REP(i,n){
        cin>>p[i];
        p[i]-=1;
    }
    UnionFind uf(n);
    REP(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        uf.unite(x,y);
    }
    int ans = 0;
    REP(i,n){
        if(uf.same(p[i],i)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10360
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
  } else if (a <= 12 && a >= 6) {
    cout << b / 2 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

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

int gcd(int a, int b);
int lcm(int a, int b);
int main () {
  int N;
  cin >> N;
  cout << lcm(2, N) << endl;
}

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int lcm(int a, int b) {
  if( a == 0 && b == 0)return 0;
    return a / gcd(a, b) * b;
}


Measured memory_bytes: 256