akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

    B1 -= A1;
    B2 -= A2;
    if (B1 < 0) {
        B1 *= -1;
        B2 *= -1;
    }
    ll a = T1 * B1;
    ll b = T2 * B2;

    if (a+b == 0) {
        cout << "infinity" << endl;
        return 0;
    }

    if (a+b > 0) {
        cout << 0 << endl;
        return 0;
    }

    ll k = a / (-a-b);
    if (a % (-a-b) == 0) {
        cout << 2*k << "\n";
    } else {
        cout << 2*k+1 << endl;
    }
}

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

using namespace std;
typedef long long lint;

void output(int a, int b) {
    cout << a << " " << b << endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int maxAbs = -1, index = -1;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (maxAbs < abs(A[i])) {
            index = i;
            maxAbs = abs(A[i]);
        }
    }
    cout << 2*N << endl;
    if (A[index] < 0) {
        output(index+1, index+1);
        output(index+1, N);
        output(N, N-1);
        for (int i = N-2; i >= 1; i--) {
            output(i+1, i+1);
            output(i+1, i);
        }
        output(1, 1);
    } else {
        output(index+1, index+1);
        output(index+1, 1);
        output(1, 2);
        for (int i = 1; i < N-1; i++) {
            output(i+1, i+1);
            output(i+1, i+2);
        }
        output(N, N);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    int ans = p + q + r - max(p, max(q, r));
    cout << ans << endl;
}

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

using namespace std;

const double pi = acos(-1);

int main() {
    double a, b, x, v;
    cin >> a >> b >> x;
    v = a*a*b;
    if(2*x > v) {
        printf("%.10lf\n", 180.0*atan2(2*(v-x),(a*a*a))/pi);
    } else {
        printf("%.10lf\n", 180.0*atan2(b*b*a,2*x)/pi);
    }
    return 0;
}


Measured memory_bytes: 384
n = input()
l = len(n)
now = 0
m = 1
p = 0
for i in range(l):
  d = int(n[i])
  M = [m,p]
  P = [m,p]
  M[0] += 9-d
  P[0] += 10-d
  M[1] += 1+d
  P[1] += d
  m = min(M)
  p = min(P)
  #print(M,P)
m += 1
print(min(m,p))

Measured memory_bytes: 5492
// Contest: AtCoder Beginner Contest 176 (https://atcoder.jp/contests/abc176)
// Problem: E: Bomber (https://atcoder.jp/contests/abc176/tasks/abc176_e)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    int h, w; cin >> h >> w;
    vi col(w), row(h);
    int m; cin >> m;
    set<pi> bomb;
    rep(_, m) {
        int y, x; cin >> y >> x; --x, --y;
        bomb.emplace(y, x);
        col[x]++, row[y]++;
    }

    int mxc = *max_element(all(col)), mxr = *max_element(all(row));
    vi idxc, idxr;
    rep(i, w)
        if (col[i] == mxc)
            idxc.push_back(i);
    rep(i, h)
        if (row[i] == mxr)
            idxr.push_back(i);
    trav(y, idxr) trav(x, idxc) {
        if (!bomb.count(pi(y, x))) {
            cout << (mxc + mxr) << '\n';
            return 0;
        }
    }

    cout << (mxc + mxr - 1) << '\n';
    return 0;
}


Measured memory_bytes: 23816
#include <iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	
		int a1 = a + b;
		int a2 = a - b;
		int a3 = a * b;
		int max1 = max(a1, a2);
		max1 = max(max1, a3);
		cout << max1 << endl ;
		
	
	return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())

h = list(map(int,input().split()))

res =  [True] * n

for _ in range(m):
    x1, x2 = map(int,input().split())

    if h[x1 - 1] <= h[x2 - 1]:
        res[x1 - 1] = False
    if h[x2 - 1] <= h[x1 - 1]:
        res[x2 - 1] = False

print(sum(res))

Measured memory_bytes: 84984
/*input
100
*/
/**
    Author: Kristopher Paul
    Date Created: 16-11-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    cout << n*n << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
from collections import deque

def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  d = deque()
  for i in range(n):
    if i % 2 == 0:
      d.append(a[i])
    else:
      d.appendleft(a[i])
  while len(d) > 0:
    if n % 2 == 0:
      print(d.popleft(), end=' ')
    else:
      print(d.pop(), end=' ')
  print('')
  return

if __name__ == "__main__":
  resolve()


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;
    string s;
    set<string> kind;
    rep(i, n) {
        cin >> s;
        kind.insert(s);
    }
    cout << kind.size() << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


Measured memory_bytes: 19176
import sys
input = sys.stdin.readline

N = int(input())
A = [list(map(int, input().split()))  for _ in range(2)]

s = 0

result = [0] * N

for i in range(N):
    result[i] = sum(A[0][0:i+1]) + sum(A[1][i:]) 


print(max(result))


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(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(ret.begin(), ret.end());
    return ret;
}
int main(){
    string S;
    cin>>S;
    
    int cnt=0,m=0;
    REP(i,S.length()){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
            cnt++;
            m=max(cnt,m);
        }else cnt=0;
    }
    cout<<m;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

long long dp[100010];
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    string s;
    cin>>s;

    
    int n=s.size();

    long long mod=1e9+7;

    int cnt=0;
    dp[0]=1;
    long long c=0;
    long long dp2[100010]={};

    for(int i=0;i<n;i++){
        dp[i+1]=dp[i];
        dp2[i+1]=dp2[i];
        if(s[i]=='1'){
            cnt++;
            dp[i+1]=2*dp[i]%mod;
            dp2[i+1] = dp[i]+3*dp2[i]%mod;
            dp[i+1]%=mod;
            dp[i+1]%=mod;
        }
        else {
            dp2[i+1] = 3*dp2[i];
            dp2[i+1]%=mod;
        }
        
    }
    cout << (dp[n]+dp2[n])%mod;
}

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

int main(){
	int m,n,ma = 0;
	static int dp[2001][2001][2] = {};//0:O 1:I
	string s,t;
	cin >> m >> n >> s >> t;
	for(int i = m - 1;i >= 0;i--){
		if(s[i] == 'I') dp[i][n][1] = max(1,dp[i + 1][n][0] + 1);
		else if(dp[i + 1][n][1]) dp[i][n][0] = dp[i + 1][n][1] + 1;
	}
	for(int i = n - 1;i >= 0;i--){
		if(t[i] == 'I') dp[m][i][1] = max(1,dp[m][i + 1][0] + 1);
		else if(dp[m][i + 1][1]) dp[m][i][0] = dp[m][i + 1][1] + 1;
	}
	for(int i = m - 1;i >= 0;i--){
		for(int j = n - 1;j >= 0;j--){
			if(s[i] == 'I') dp[i][j][1] = dp[i + 1][j][0] + 1;
			else if(dp[i + 1][j][1]) dp[i][j][0] = dp[i + 1][j][1] + 1;
			if(t[j] == 'I') dp[i][j][1] = max(dp[i][j][1],dp[i][j + 1][0] + 1);
			else if(dp[i][j + 1][1]) dp[i][j][0] = max(dp[i][j][0],dp[i][j + 1][1] + 1);
			ma = max(ma,dp[i][j][1]);
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 34460
#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d",&N);
    int d[N];
    for(int i=0;i<N;i++){
        scanf("%d",&d[i]);
    }
    int tmp;
    for(int s=0;s<N-1;s++){
        for(int t=s+1;t<N;t++){
            if(d[s]<d[t]){
                tmp=d[t];
                d[t]=d[s];
                d[s]=tmp;
            }
        }
    }
    int X=1;
    for(int i=0;i<N;i++){
        if(d[i-1]>d[i])
            X++;
    }
    printf("%d\n",X);
    
    return 0;
}


Measured memory_bytes: 128
n=gets.to_i
xN=gets.chomp.split.map(&:to_i)
xNMiddle = ((xN.max + xN.min)/2).ceil
sums = []
(xN.min .. xN.max).each do |index|
  sum = 0
  xN.each do |x|
    sum += (x-index)**2
  end
  sums << sum
end
puts sums.min

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K,T;
int A[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>T;
	FOR(i,T) cin>>A[i];
	sort(A,A+T);
	int ma=A[T-1];
	int el=K-A[T-1];
	
	if(ma<=el+1) _P("%d\n",0);
	else _P("%d\n",ma-(el+1));
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;	//Scannerクラス：Java標準入力を取得する

class Main{
		public static void main(String[] args){
			int a = 0;
			int b = 0;
			int c = 0;
			int z = 0;
			try(Scanner sc = new Scanner(System.in)){
				a = sc.nextInt();
				b = sc.nextInt();
				c = sc.nextInt();
				for(int x=a;x <= b;x++) {

					if(c % x == 0)
						z++;
					}
				System.out.println(String.format("%d",z));
			}
		}
}



Measured memory_bytes: 26392
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int n, m;
vector<int> g[1000];
const int INF = 1e9;
int dist[1000];
int pre[1000];

vector<int> bfs(int s) {
  queue<int> que;
  REP(i, n) {
    dist[i] = INF;
    pre[i] = -1;
  }
  dist[s] = 0;
  que.push(s);
  while (que.size()) {
    int p = que.front();
    que.pop();
    REP(i, g[p].size()) {
      int q = g[p][i];
      if (dist[q] != INF) continue;
      dist[q] = dist[p] + 1;
      pre[q] = p;
      que.push(q);
    }
  }
  pair<int, int> mn = make_pair(INF, -1);
  REP(i, n) {
    if (i == s) continue;
    REP(j, g[i].size()) {
      int k = g[i][j];
      if (k == s) {
        mn = min(mn, make_pair(dist[i], i));
      }
    }
  }
  vector<int> res;
  if (mn.first == INF) {
    res.resize(n + 1);
  } else {
    int v = mn.second;
    while (v != -1) {
      res.push_back(v);
      v = pre[v];
    }
  }
  return res;
}

int main() {
  cin >> n >> m;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
  }
  vector<int> ans(n + 1);
  REP(i, n) {
    vector<int> tmp = bfs(i);
    if (tmp.size() < ans.size()) {
      ans = tmp;
    }
  }
  if (ans.size() == n + 1) {
    puts("-1");
    return 0;
  } else {
    cout << ans.size() << endl;
    REP(i, ans.size()) cout << ans[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int N, i, ans, all;
    int A[100010];

    scanf("%d", &N);

    A[0] = 0;

    for (i = 1; i < N + 1; i++)
        scanf(" %d", &A[i]);

    A[N + 1] = 0;

    all = 0;

    for (i = 0; i < N + 1; i++)
    {
        all += fabs(A[i+1] - A[i ]);
    }

    for (i = 1; i < N + 1; i++)
    {
        ans = all;

        ans += fabs(A[i+ 1] - A[i - 1]) - (fabs(A[i ] - A[i-1]) + fabs(A[i+1] - A[i]));

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

    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	string S;
	llint K;
	cin >> S;
	cin >> K;
	int cnt=0;
	char nxt;
	for(const char& c : S){
		if(c=='1'){
			cnt++;
		}else{
			nxt=c;
			break;
		}
	}

	if(K<=cnt){
		cout << 1 << endl;
	}else{
		cout << nxt << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int price=700;
	string s;
	while (cin >> s) {
		price = 700;
		for (int i = 0; i < 3; i++) {
			if (s[i] == 'o')
				price += 100;
		}
		cout << price << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>

//メイン関数
int main() {
	//入力の取得
	std::string input;
	std::getline(std::cin, input);

	//答え
	auto answer = 0;

	size_t start = input.find("A");
	size_t end = input.find_last_of("Z");

	answer = end - start + 1;

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;

int main() {
  double a,b;
  cin >> a >> b;
  cout << ceil(a/(b*2+1));
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
nums = input()
nums = nums.split()
for_num = int(nums[0])
min_num = int(nums[1])
max_num = int(nums[2])

ans_list = []

for i in range(0,for_num+1):
  num = int(i)
  tthou_num = int(num/10000)
  thou_num = int(num/1000) - tthou_num*10
  hun_num = int(num/100) - tthou_num*100 - thou_num*10
  ten_num = int(num/10) -tthou_num*1000 - thou_num*100 - hun_num*10
  one_num = num - tthou_num*10000 - thou_num*1000 - hun_num*100 - ten_num*10
  ans = tthou_num + thou_num + hun_num + ten_num + one_num
  if (ans >= min_num) and (ans <= max_num):
    ans_list.append(num)
print(sum(ans_list))
  

Measured memory_bytes: 3300
#include <stdio.h>
int main(){
  int e1,e2,e3,e4;
  scanf("%d%d%d%d",&e1,&e2,&e3,&e4);
    if (e1==e2&&e3==e4) printf("yes\n");
      
 else  if(e1==e3&&e2==e4) printf("yes\n");
  
 else    if(e1==e4&&e2==e3) printf("yes\n");
  
 else if (e1==e2==e3==e4) printf("yes\n");
    
  else  printf("no\n");
  
  
  return 0;
}

Measured memory_bytes: 2680
n, m = map(int, input().split())
a = [int(m) for m in input().split()]
a.sort(reverse=True)
dp = []
for i in range(10 * n):
    dp.append(0)

b = [0,2,5,5,4,5,6,3,7,6]
for i in range(1, n + 1):
    for j in range(len(a)):
        if i - b[a[j]] >= 0:
            if (dp[i - b[a[j]]] == 0 and i - b[a[j]] == 0) or dp[i - b[a[j]]] != 0:
                dp[i] = max(dp[i], dp[i - b[a[j]]] + a[j])
        else:
            pass
    if i != n:
        dp[i] *= 10

print(dp[n])

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

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

const long long MOD = 1000000007;

int main(){
  int a;
  string s;
  cin >> a >> s;
  
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool prime[50010];
	for (int i = 0; i < 50010; i++) {
		prime[i]=true;
	}
	prime[0] = prime[1]=false;
	for (int i = 2; i < 50010; i++) {
		if (!prime[i]) { continue; }
		for (int j = i * 2; j < 50010; j += i) {
			prime[j]=false;
		}
	}
	
	while (true) {
		int n;
		cin >> n;
		
		if (n == 0) { return 0; }
		int ans = 0;
		for (int i = 0; i <= n / 2; i++) {
			if (prime[i] && prime[n - i]) {
				ans++;
			}
		}
		cout << ans << endl;

	}
	return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int R[] = new int[n];
        for(int i = 0; i < n; i++){
            R[i] = sc.nextInt();
        }
        
    	int saidai = R[1] - R[0];
    	int saisyo = R[0];
        for(int i = 1; i < n; i++){
        	if(saidai < R[i]-saisyo){
        		saidai = R[i] - saisyo;
        	}
        	if(saisyo > R[i]){
        		saisyo = R[i];
        	}
        }
        System.out.println(saidai);
    }
}


Measured memory_bytes: 101652
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, ans;
string s;
int main()
{
    IO
    cin>>s;
    s+='*';
    n=s.size();
    int cnt=1, last=0;
    for(int i=1; i<n; i++)
    {
        if(s[i]==s[i-1])
            cnt++;
        else
        {
            if(last)
                last=0, cnt--, ans++;
            ans+=cnt/3*2;
            cnt%=3;
            if(cnt==2)
                ans++, last=1;
            if(cnt==1)
                ans++;
            cnt=1;
        }
    }
    cout<<ans;
}


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

using namespace std;

using ll = long long;

int main(){
  ll tmp;
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cin.ignore();

  ll x;
  x = c * d;

  if(c<d){
    tmp = c;
    c = d;
    d = tmp;
  }

  /* ユークリッドの互除法 */

  ll r;
  r = c % d;

  ll org_c = c;
  ll org_d = d;

  while(r != 0){
    c = d;
    d = r;
    r = c % d;

  }

  ll gcd;
  gcd = d;

  ll lcm;
  lcm = x / gcd;

  ll nc = (lcm - 1) / org_c;
  ll nd = (lcm - 1) / org_d;

  ll ncd = nc + nd + 1;

  // Bについて求める
  ll sumb = 0;
  ll n_b_lcm = b / lcm;

  sumb += ncd * n_b_lcm;

  //cout << ncd << endl;

  // Bについて、余り分
  ll m_b_lcm = b % lcm;
  sumb += m_b_lcm / org_c;
  sumb += m_b_lcm / org_d;

  // A-1について求める
  ll suma_ = 0;
  ll n_a_lcm = (a-1) / lcm;

  suma_ += ncd * n_a_lcm;

  // Bについて、余り分
  ll m_a_lcm = (a-1) % lcm;
  suma_ += m_a_lcm / org_c;
  suma_ += m_a_lcm / org_d;

  ll sum;
  sum = sumb - suma_;

  ll ans;
  ans = b - a + 1 - sum;
  cout << ans << endl;
  return 0;
}
  


Measured memory_bytes: 256
module Main where

import Control.Applicative ((<$>))
import Data.Array

data InputLine = InputLine Int Int Int Int deriving (Read)

nextState (InputLine b f r v) currentState = currentState // [((b,f,r), v + currentState ! (b,f,r))]

prettyShowApart state i = foldl appendToOutput "" [(j,k) | j <- [1..3], k <- [1..10]]
    where appendToOutput str idx = case idx of
            (j, 10) -> str ++ " " ++ (show $ state ! (i, j, 10)) ++ "\n"
            (j, k) -> str ++ " " ++ (show $ state ! (i, j, k))

main = do
    _ <- getLine
    inputStrLines <- lines <$> getContents
    let inputs = map ((read :: String->InputLine) . ((++) "InputLine ")) inputStrLines
    let initState = array ((1,1,1),(4,3,10)) [((b,f,r),0) | b <- [1..4],f <- [1..3], r <- [1..10]]
    let finalState = foldr nextState initState inputs
    putStr $ prettyShowApart finalState 1
    putStrLn "####################"
    putStr $ prettyShowApart finalState 2
    putStrLn "####################"
    putStr $ prettyShowApart finalState 3
    putStrLn "####################"
    putStr $ prettyShowApart finalState 4

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    if(b >= x-a && x >= a){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
def main():
    n, m, k = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]
    B = [int(e) for e in input().split()]

    AS = [0]
    for i in range(n):
        AS.append(AS[i] + A[i])

    BS = [0]
    for i in range(m):
        BS.append(BS[i] + B[i])

    ans = 0
    bi = 0
    for ai in range(n, -1, -1):
        if bi == m + 1:
            break

        if AS[ai] > k:
            continue

        while bi < m + 1 and AS[ai] + BS[bi] <= k:
            bi += 1

        ans = max(ai + bi - 1, ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 133556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, n) for (int i = 0; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    sort(all(h));
    int ans = 1e9;
    repi(i, N - K) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,k;
int a[200001];
int tmp[200001];

void input(){
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    vector<int> cnt;
    for(int i=0;i<n;i++) tmp[a[i]]++;
    for(int i=0;i<200001;i++) if (tmp[i] > 0) cnt.push_back(tmp[i]);
    int nk = cnt.size();
    if(nk <= k) cout << 0 << endl;
    else{
        sort(cnt.begin(), cnt.end());
        int sum = 0;
        for(int i=0;i<(nk - k);i++) sum += cnt[i];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 2936
import java.util.Scanner;

public class Main {
	public static int cnt = 0;
	public static int m = 0;
	public static int[] G = new int[100];

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int num = scan.nextInt();
		int[] array = new int[num];
		for(int i = 0;i < num;i++){
			array[i] = scan.nextInt();
		}
		shellSort(array,num);
		System.out.println(m);
		System.out.print(G[m-1]);
		for(int i = m-2; i >= 0;i--){
		System.out.print(" "+G[i]);
		}
		System.out.println();
		System.out.println(cnt);
		for(int i = 0; i < num ;i++){
			System.out.println(array[i]);
		}
		System.out.println();
		
	}

	/**
	 * 挿入ソート
	 * 
	 * @param A：オリジンの配列
	 * @param N：要素の個数
	 */
	public static void insertionSort(int[] A, int N, int g) {
		
		for (int i = g; i < N; i++) {
			int v = A[i]; // 1枚取り出す
			int j = i - g;
			while (j >= 0 && A[j] > v) {// 取り出した一枚より前の方に持っていたカードと比較
				A[j + g] = A[j];
				j = j - g;
				cnt++;
			}
			A[j + g] = v;
			// for (int k = 0; k < N; k++) {
			// if (k == N - 1) {
			// System.out.print(A[k]);
			// } else {
			// System.out.print(A[k] + " ");
			// }
			// }
			// System.out.println("");
		}

	}

	
	public static void insertionSort2(int[] A, int N, int g){
		for(int i = 1; i < N; i++){
			int insertionData = A[i];
			int j = i;
			for(; j >= 1 && A[j - 1] > insertionData; j--){
				A[j] = A[j - 1];
				cnt++;
			}
			A[j] = insertionData;
		}
		//System.out.println(Arrays.toString(array));

	}
	
	
	public static void insertionSort3(int[] A, int N, int g){
		for(int i = g; i < N; i++){
			int insertionData = A[i];
			int j = i -g;
			for(; j >= 1 && A[j - 1] > insertionData; j--){
				A[j] = A[j - 1];
				cnt++;
			}
			A[j] = insertionData;
		}
		//System.out.println(Arrays.toString(array));

	}
	
	// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2041983#1
	public static void shellSort(int[] A, int N) {
		cnt = 0;
		m = 0;
		// G[] = {?,?}
		for (int i = 1;; i = i * 3 + 1) {
			if (i > N) {
				break;
			}
			G[m] = i;
			m++;
		}
		for (int i = m - 1; i >= 0; i--) {
			insertionSort(A, N, G[i]);
		}
	}

	public static void shellSort2(int[] A,int N){
		
		for (int range = A.length / 2; range > 0; range /= 2) {
			m++;
			// 間隔内での移動
			for (int h = 0; h < m-1; h++) {
				// ここから挿入法
				// ソート対象データは間隔ごとの要素になるのでループの増分値はi += range
				insertionSort2(A,N,range);
			}
		}

		
	}
}



Measured memory_bytes: 299296
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
struct R {
	int x1,x2,add;
	R(int _x1,int _x2,int _add) {x1=_x1,x2=_x2,add=_add;}
};
vector<R> V[10001];
int field[2][10000];
int X1,X2,Y1,Y2;
int main() {
	int n,r;
	while(scanf("%d %d",&n,&r),n) {
		memset(field,0,sizeof(field));
		for(int i=0;i<=10000;i++) V[i].clear();
		X1=10000,Y1=10000,X2=0,Y2=0;
		for(int i=0;i<n;i++) {
			int x1,y1,x2,y2;
			scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
			V[y1].push_back(R(x1,x2,1));
			V[y2].push_back(R(x1,x2,-1));
			X1=min(x1,X1); Y1=min(y1,Y1);
			X2=max(x2,X2); Y2=max(y2,Y2);
		}
		int Y=1;
		int S=0,L=0;
		for(int y=Y1;y<=Y2;y++,Y=!Y) {
			for(int x=X1;x<X2;x++) field[Y][x]=field[!Y][x];
			for(int i=0;i<V[y].size();i++)
				for(int x=V[y][i].x1;x<V[y][i].x2;x++) field[Y][x]+=V[y][i].add;
			for(int x=X1;x<X2;x++) {
				if(0<field[Y][x]) {
					S++;
					if(x==0||field[Y][x-1]==0) L++;
					if(x==9999||field[Y][x+1]==0) L++;
				}
				if((field[Y][x]==0&&0<field[!Y][x])||(0<field[Y][x]&&field[!Y][x]==0)) L++;
			}
		}
		printf("%d\n",S);
		if(r==2) printf("%d\n",L);
	}
}

Measured memory_bytes: 1832
S=input()
k=int(input())
x=1
L=[]
for i in range(len(S)-1):
  if S[i]==S[i+1]:
    x+=1
  else:
    L.append(x)
    x=1
L.append(x)
s=sum([l//2 for l in L])
if S[0]!=S[-1]:
  print(s*k)
else:
  if len(L)>1:
    L[0]+=L[-1]
    print(s+sum([l//2 for l in L[:-1]])*(k-1))
  else:
    print(L[0]*k//2)

Measured memory_bytes: 9240
Ss = input()

lenS = len(Ss)
for S1, S2 in zip(Ss[:(lenS+1)//2], Ss[lenS-(lenS+1)//2:][::-1]):
    if set([S1, S2]) not in [{'b', 'd'}, {'p', 'q'}]:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 3188
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

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

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

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << max(a + b - n, 0) << endl;
}



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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

const long long mo = 1000000007;
long long n, a[333333], sum, ans;

int main(){
    n = read();
    for (int i = 1; i <= n; i++){
        a[i] = read() % mo;
        ans = (ans + (a[i] * sum) % mo) % mo;
        sum = (sum + a[i]) % mo;
    }
    printf("%llu\n", ans);
    return 0;
}

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

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

    int m;
    cin >> m;
    vector<int> p(m), x(m);
    for (int i = 0; i < m; i++)
    {
        cin >> p[i] >> x[i];
    }

    int total_time = accumulate(times.begin(), times.end(), 0);

    for (int i = 0; i < m; i++)
    {
        int minus = times[p[i] - 1] - x[i];
        cout << total_time - minus << endl;
    }
}

Measured memory_bytes: 256
N = gets.to_i
X,Y = Array.new(N){gets.split.map &:to_i}.transpose
C = (1..N).inject(:*)

sum = 0.0
(0..N-1).to_a.permutation.each do |ix|
  len = 0.0
  ix.each_cons(2) do |i,j|
    x = Math.sqrt((X[i]-X[j])**2 + (Y[i]-Y[j])**2)
    len += x
  end
  sum += len
end

puts sum / C


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int s;
    cin >> s;
    set<int> ns;
    ns.insert(s);

    s = (s & 1) ? 3 * s + 1 : s / 2;
    int i;
    for ( i = 2; ns.find(s) == ns.end(); i++) {
        ns.insert(s);
        s = (s & 1) ? 3 * s + 1 : s / 2;
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
using namespace atcoder;
int main() {
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> ft(n);
    for(int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        ft.add(i, x);
    }
    for(int i = 0; i < q; i++) {
        int t, a, b;
        cin >> t >> a >> b;
        if(t) {
            cout << ft.sum(a, b) << endl;
        } else {
            ft.add(a, b);
        }
    }
}

Measured memory_bytes: 8228
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <map>

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

bool pairCompare(const P& firstElof, const P& secondElof)
{
    //if(firstElof.first == secondElof.first) return firstElof.second > secondElof.second;
    return firstElof.second > secondElof.second;
}
int main() {
    ll N,H;
    cin >> N >> H;
    vector<P> pairs(N);
    ll mab=0;
    ll maa=0;
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        mab+=b;
        maa = max(a,maa);
        pairs[i] = make_pair(a,b);
    }
    /*
    if(mab>H){
        sort(pairs.begin(),pairs.end(),pairCompare);
        ll ct=0;
        ll ct2 = 0;
        while(H>0){
            if(pairs[ct].second>=maa){
                H-=pairs[ct].second;
                ct++;
            }
            else{
                H-=maa;
                ct2++;
            }
        }
        cout << ct+ct2 << endl;
        return 0;
    }
    */
    //else{
        ll ct = 0;
        sort(pairs.begin(),pairs.end(),pairCompare);
        while(maa<=pairs[ct].second && ct<N && H>0){
            H-=pairs[ct].second;
            ct++;
        }
        if(H<=0) cout << ct << endl;
        else cout << ((H%maa==0) ? ct+H/maa : ct+H/maa + 1) << endl;
    //}
}

Measured memory_bytes: 1792
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def string_to_number(a):
    return 1 << (ord(a) - ord("a"))

class SegmentTree:
    def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
    def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
    def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if a & 1 == 0:
                res |= self.seg[a]
            if b & 1 == 1:
                res |= self.seg[b]
                b -= 1
            a = a // 2
            b = (b - 1) // 2
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1")


def main():
    N = int(readline())
    s = readline().strip()
    seg = SegmentTree(list(s))
    #print(seg.seg)

    Q = int(readline())
    for _ in range(Q):
        q, a, b = map(str, readline().split())
        if q == "1":
            seg.update(int(a)-1, b)
        else:
            print(seg.query(int(a)-1, int(b)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 99472
from collections import defaultdict

N, M = map(int, input().split())
PS = [input().split() for _ in range(M)]

ac_set = set()
wa_count = defaultdict(int)
for p, s in PS:
    if s == 'AC':
        ac_set.add(p)
    else:
        if p not in ac_set:
            wa_count[p] += 1
print(len(ac_set), sum(wa_count[p] for p in ac_set))


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

int main(){
  int c1,c5,c10,c50,c100,c500;
  cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

  int money=0;
  money=c1+(c5*5)+(c10*10)+(c50*50)+(c100*100)+(c500*500);

  if(money>=1000){
    cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }

  return 0;

}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);

using namespace std;

int main(){_
    char c;
    int m,M;
    cin >> c;
    m = (c - 'a');
    M = (c - 'A');
    if(m < 0) cout << "A" << endl;
    else if(M < 0) cout << "a" << endl;
    else cout << (m < M ? "a" : "A") << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs(a-b)<EPS)

int main(){

	double l,r;

	int le[200];
	int re[200];
	memset(le,0,sizeof(le));
	memset(re,0,sizeof(re));

	while(cin>>l>>r){
		if(l>=1.1){
			le['A']++;
		}
		else if((l>0.6||EQ(l,0.6))&&l<1.1){
			le['B']++;
		}
		else if((l>0.2||EQ(l,0.2))&&l<0.6){
			le['C']++;
		}
		else if(l<0.2)
			le['D']++;

		if(EQ(r,1.1)||r>1.1){
			re['A']++;
		}
		else if((r>0.6||EQ(r,0.6))&&r<1.1){
			re['B']++;
		}
		else if((r>0.2||EQ(r,0.2))&&r<0.6){
			re['C']++;
		}
		else if(r<0.2)
			re['D']++;
	}
	for(char i = 'A'; i != 'E'; i++){
		cout<<le[i]<<" "<<re[i]<<endl;
	}

	return 0;
}

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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << setprecision(10) << (double)(w * h) / 2.0 << " ";
    if (x * 2 == w && y * 2 == h) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;
 
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif
  string s, t;
  cin >> s >> t;
  if (t.substr(0, (int)s.size()) == s) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>

using namespace std;

inline int sq(int x) {
  return x * x;
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int s[3];
    for (int j = 0; j < 3; j++)
      cin >> s[j];
    sort(s, s+3);
    if (sq(s[0]) + sq(s[1]) == sq(s[2]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
H, W = map(int, input().split())
s = [input() for i in range(H)]
flag = True
count = 0
loop_num = 0

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            for k in range(4):
                if 0 <= i+dy[k] < H and 0 <= j+dx[k] < W:
                    #数えるマスの数
                    loop_num += 1
                    if s[i+dy[k]][j+dx[k]] == '.':
                        #白い隣あったマスの数
                        count += 1
            #隣り合うマスが存在しないとき黒いマスは塗りつぶせないので目標は達成不可
            if count == loop_num:
                flag = None
                break
            else:
                count = 0
                loop_num = 0
        else:
            pass
    if flag == None:
        break

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 


ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}


int main(void){

  int n;
  cin>>n;

  vector<int> b(n);
  vector<int> ans;

  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    b[i] = x;
  }

  while(1){
    // for(int i=0;i<b.size();i++) cout<<b[i]<<" ";
    // cout<<endl;

    for(int i=b.size()-1; i>=0;i--){
      if(b[i] == i+1){
        ans.push_back(i+1);
       // cout<<i+1<<endl;
        for(int j=i;j<b.size()-1;j++){
          b[j] = b[j+1];
        }
        b.pop_back();
        break;
      }
      if(i==0 && b[0]!=1){
        cout<<"-1"<<endl;
        return 0;
      }
    }
    if(b.size()==0) break;
  }
  for(int i=ans.size()-1;i>=0;i--) cout<<ans[i]<<endl;
  return 0;
}

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

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

bool lorr(char c){
    string left = "qwertasdfgzxcvb";
    return left.find(c) != string::npos;
}

int main(){
    string str;
    while(cin>>str,str!="#"){
        bool left = lorr(str[0]); 
        int ans = 0;
        repi(i,1,str.size()){
            if(left != lorr(str[i])){
                ans++;
                left = !left;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1188