akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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 pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n,weight;cin>>n>>weight;
  ll w[n],v[n];rep(i,0,n)cin>>w[i]>>v[i];

  const ll N=100010;
  ll dp[n+1][N];
  rep(j,0,N)dp[0][j]=mod;
  dp[0][0]=0;
  rep(i,1,n+1){
    rep(j,0,N){
      if(j<v[i-1])dp[i][j]=dp[i-1][j];
      else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
    }
  }

  repr(j,N-1,0){
    if(dp[n][j]<=weight){
      out(j);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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




int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,p,ans=0;
    string s;
    cin >> n >> p >> s;
    if(p == 2 || p == 5){
        rep(i,n){
            if((s[i] - '0') % p == 0){
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<ll>mod(p),num(n);
    num[n-1] = (s[n-1]-'0')%p;
    mod[num[n-1]]++;
    ll keta=1;
    for(int i = n-1; i >= 1 ; --i){
        keta = keta*10%p;
        num[i-1] = (num[i] + keta*(s[i-1]-'0'))%p;
        mod[num[i-1]]++;
    }
    mod[0]++;
    rep(i,p){
        ans += mod[i]*(mod[i]-1)/2;
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 5176
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    mp[n]++;
  }
  ll ans = 0;
  vector<ll> s(51);
  for (int i = 0; i < 50; ++i) {
    s[i + 1] = s[i] + (i + 1);
  }
  for (auto a : mp) {
    ll key = a.first;
    ll value = a.second;
    ll res = upper_bound(s.begin(), s.end(), value) - s.begin() - 1;
    ans += res;
  }
  cout << ans << endl;
  return 0;
}

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

bool isAlpha(char ch){
  return ('a'<=ch&&ch<='z');
}

int main(){
  char ch;
  string str;
  while(getline(cin,str)){
    for(int i=0;i<(int)str.size();i++){
      ch=str[i];
      if(isAlpha(ch))ch-=32;
      cout<<ch;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#!/usr/bin/env python3
import sys


def solve(S: str):
    ans = ''
    for _ in range(len(S)):
        ans += 'x'
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# import numpy as np
n=list((input()))  #数値入力

n = [int(s) for s in n]
count = 0

for i in range(len(n)-1):
    onezero = n[i]
    #print('i = '+str(n[i]))
    if onezero == n[i+1]:
        count += 1
        if n[i+1] == 0:
            n[i+1] = 1
        else:
            n[i+1] = 0

        
print(count)

Measured memory_bytes: 4652
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
map<ll,ll,greater<ll> > mp;
int main(){
    cin>>N>>M;
    for(ll i=0;i<N;i++){
        ll a;
        cin>>a;
        mp[a]++;
    }
    for(ll i=0;i<M;i++){
        ll b,c;
        cin>>b>>c;
        mp[c]+=b;
    }
    ll ans=0;
    ll now=0;
    for(auto p:mp){
        if(now+p.second<=N){
            now+=p.second;
            ans+=p.second*p.first;
        }else{
            ans+=(N-now)*p.first;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<62;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;

    vector<int> x(n), y(n);
    vector<int> xary, yary;

    rep(i, n) {
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }

    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());

    ll ans = LINF;
    for (int xi = 0; xi < n; ++xi) {
        for (int xj = xi+1; xj < n; ++xj) {
            for (int yi = 0; yi < n; ++yi) {
                for (int yj = yi+1; yj < n; ++yj) {
                    int num = 0;
                    ll lx = xary[xi], rx = xary[xj];
                    ll by = yary[yi], uy = yary[yj];

                    for (int i = 0; i < n; ++i) {
                        if (lx <= x[i] and x[i] <= rx and by <= y[i] and y[i] <= uy) {
                            num++;
                        }
                    }
                    if (num >= k) chmin(ans, 1LL * (rx - lx) * (uy - by));
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n;
    cin >> n;
    LL ans = n * (n-1) / 2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
h,w = map(int, input().split())
s = [input() for _ in range(h)]

for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      ok = False
      for x,y in [(0,1), (0,-1), (1,0), (-1,0)]:
        new_i, new_j = i+x, j+y
        if new_i < 0 or new_i >= h or new_j < 0 or new_j >= w: continue
        if s[new_i][new_j] == "#": 
          ok = True
          break
      if not ok:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long int n,a,r,r1,sm,st,ar[100005],br[100005];

int main()
{
    cin>>n;
    for(a=0;a<n;a++)
    {
        cin>>ar[a]>>br[a];
    }
    sm=0;
    for(a=n-1;a>=0;a--)
    {
        r=(sm+ar[a])%br[a];
        if(r!=0)
        {
            r1=(sm+ar[a])/br[a];
            st=((r1+1)*br[a])-(sm+ar[a]);
            sm=sm+st;
            
        }
    }
    cout<<sm<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main (){
int a,b,c,s,i[100],m=0,l,count=0;
scanf ("%d %d %d",&a,&b,&c);

for (s=1;s<=c;s++){
if (c%s==0){
	i[m]=s;
m++;
}
}

for (s=a;s<=b;s++){
	for (l=0;l<=m;l++){
	if (s==i[l]){
	count++;
		}
	}
}

printf ("%d\n",count);


return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>

using namespace std;

int main() 
{
    vector<int> vec;
    string str;
    cin>>str;
    for(int i=0;i<4;i++){
        vec.push_back(((int)str[i] - 48));
    }

    if(accumulate(vec.begin(), vec.end(), 0)==7){
        str = "A+B+C+D=7";
        replace(str.begin(), str.end(), 'A', to_string(vec[0])[0]);
        replace(str.begin(), str.end(), 'B', to_string(vec[1])[0]);
        replace(str.begin(), str.end(), 'C', to_string(vec[2])[0]);
        replace(str.begin(), str.end(), 'D', to_string(vec[3])[0]);
        cout<<str<<endl;
        return 0;
    }

    for(int i=1;i<4;i++){
        vec[i]*=-1;
        if(accumulate(vec.begin(), vec.end(), 0)==7){
            vec[i]*=-1;
            str = "A+B+C+D=7";
            str[i*2-1] = '-';
            replace(str.begin(), str.end(), 'A', to_string(vec[0])[0]);
            replace(str.begin(), str.end(), 'B', to_string(vec[1])[0]);
            replace(str.begin(), str.end(), 'C', to_string(vec[2])[0]);
            replace(str.begin(), str.end(), 'D', to_string(vec[3])[0]);
            cout<<str<<endl;
            return 0;
        }
        vec[i]*=-1;
    }

    vec[1]*=-1;vec[2]*=-1;vec[3]*=-1;
    for(int i=1;i<4;i++){
        vec[i]*=-1;
        if(accumulate(vec.begin(), vec.end(), 0)==7){
            vec[i]*=-1;
            vec[1]*=-1;vec[2]*=-1;vec[3]*=-1;
            str = "A-B-C-D=7";
            str[i*2-1] = '+';
            replace(str.begin(), str.end(), 'A', to_string(vec[0])[0]);
            replace(str.begin(), str.end(), 'B', to_string(vec[1])[0]);
            replace(str.begin(), str.end(), 'C', to_string(vec[2])[0]);
            replace(str.begin(), str.end(), 'D', to_string(vec[3])[0]);
            cout<<str<<endl;
            return 0;
        }
        vec[i]*=-1;
    }
    vec[1]*=-1;vec[2]*=-1;vec[3]*=-1;

    str= "A-B-C-D=7";
    replace(str.begin(), str.end(), 'A', to_string(vec[0])[0]);
    replace(str.begin(), str.end(), 'B', to_string(vec[1])[0]);
    replace(str.begin(), str.end(), 'C', to_string(vec[2])[0]);
    replace(str.begin(), str.end(), 'D', to_string(vec[3])[0]);
    cout<<str<<endl;
    return 0;
}

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

int main()
{
  int x, y, mon[] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  cin >> x >> y;
  cout << (mon[x - 1] == mon[y - 1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
//
// Created by Sakurayama Kazuhiro on 2020/08/02.
//


#include<iostream>
using namespace std;
int main(){
    long N,D;
    cin >> N >> D;
    D = D*D;

    int cnt=0;
    long x,y;
    for (int i = 0; i < N; ++i) {
        cin >> x >> y;
        if ((x*x + y*y) <= D) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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


int main() {
    int n, ans=0;
    cin >> n;
    int B[n+1];
    for (int i=1; i<n; i++) cin >> B[i];
    B[0] = B[1];
    B[n] = B[n-1];

    for (int i=0; i<n; i++) ans += min(B[i], B[i+1]);
    cout << ans << endl;

    return 0;
}



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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> mp;
    for(ll i = 1; i <= N; i++){
        cin >> A[i-1];
        if(mp.count(A[i-1])){
            mp.at(A[i-1])++;
        }
        else{
            mp[A[i-1]] = 1;
        }
    }
    ll sum = 0;
    for(auto p : mp){
        auto value = p.second;
        sum += value*(value-1)/2;
    }
    rep(i, N){
        ll ans = sum - (mp.at(A[i])-1);
        cout << ans << endl;
    }
}

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

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

    long long res = 1001001001001001001;
    res = min({res, A * (B % 2) * C, (A % 2) * B * C});
    res = min({res, B * (C % 2) * A, (B % 2) * C * A});
    res = min({res, C * (A % 2) * B, (C % 2) * A * B});
    cout << res << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int N, K;

int f(vector<int>& A, int bit) {
    // cout << bit << " " << A.size() << " -> ";
    // rep(i, A.size()) {
    //     cout << A[i] << " ";
    // }
    // cout << endl;
    int cnt = 0;
    vector<int> B;
    for(int i = 0; i < A.size(); i++) {
        if (A[i] & ((int)1 << bit)) {
            B.push_back(A[i]);
            cnt++;
        }
    }
    if(cnt >= K && bit > 0) {
        return ((int)1 << bit) + f(B, bit - 1);
    } else if (cnt >= K) {
        return ((int)1 << bit);
    } else if (bit > 0) {
        return f(A, bit - 1);
    } else {
        return 0;
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    int a[1010];
    rep(i, N) cin >> a[i];
    vector<int> A;
    for(int i = 0; i < N; i++) {
        int sum = 0;
        for(int j = i; j < N; j++) {
            sum += a[j];
            A.push_back(sum);
        }
    }
    cout << f(A, 60) << endl;


    return 0;
}


Measured memory_bytes: 11244
#include<stdio.h>

#define MAX 100
#define INFTY 20000000
// 未訪問状態
#define WHITE 0
#define GRAY 1
#define BLACK 2

// 隣接行列
int gMatrix[MAX][MAX];

int prim(int n){
  int i, v;
    // 頂点
    int u;
    // 最小の重み
    int minV;
    // Tに属する頂点と(V - T)に属する頂点をつなぐ辺の中で、重みが最小の辺の重みを記録する
    int weight[MAX];
    // MSTにおける頂点vの親を記録する
    int parent[MAX];
    // 訪問状態を記録する
    int color[MAX];
    // 初期化
    for(int i = 0;i < n;++i){
        weight[i] = INFTY;
        parent[i] = -1;
        color[i] = WHITE;
    }
    // 初回探索地点をindex0にする
    weight[0] = 0;
    
    while(1){
        minV = INFTY;
        u = -1;
        // 隣接する地点で
        for(i = 0;i < n;++i){
            if(minV > weight[i] && color[i] != BLACK){
                // 最小の重みを記録する
                u = i;
                minV = weight[i];
            }
        }
        // 全て訪問した
        if(u == -1)break;
        // 訪問済み
        color[u] = BLACK;
        for(v = 0;v < n;++v){
            // uとvの間に辺が存在する
            if(color[v] != BLACK && gMatrix[u][v] != INFTY){
                if(weight[v] > gMatrix[u][v]){
                    // 隣接する辺に重みを割り当てる
                    weight[v] = gMatrix[u][v];
                    parent[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for(int i = 0;i < n;++i){
        if(parent[i] != -1) sum += gMatrix[i][parent[i]];
    }
    
    return sum;
}

int main(){
  int n,i,j;
    scanf("%d",&n);
    
    for(i = 0;i < n;++i){
        for(j = 0;j < n;++j){
            int edge;
            scanf("%d",&edge);
            gMatrix[i][j] = (edge == -1) ? INFTY : edge;
        }
    }

    printf("%d\n",prim(n));
    return 0;
}



Measured memory_bytes: 2104
n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int, input().split())))

from scipy.optimize import fmin

def calc(k):
    i,j = k
    return max((x-i)**2 + (y-j)**2 for x,y in xy)

x, y = fmin(calc,[500,500], disp = 0 )

print(calc([x,y])**0.5)

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

int main()
{


    int r, o, lll;
    cin >> r >> o >> lll;
    int k;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        if (lll <= o)
        {
            lll *= 2;
        }
        else if (r >= o)
        {
            o *= 2;
        }
    }


    
    if (r < o && o < lll)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const ll INF = 1e18, SZ = 200000;

ll N,Q,A,B, seg[3][2*SZ], curadd; // ori, add, subtract
// + N-1-i
vi x;

ll qmin(int ind, int l, int r) {  
  ll res = INF;
  for (l += SZ, r += SZ; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = min(res,seg[ind][l++]);
    if (r&1) res = min(res,seg[ind][--r]);
  }
  return res;
}

ll qmin2(int p) {
	return min(qmin(1,p,N)-p, qmin(2,0,p)-(N-1-p));
}

void modifymin(int p, ll value) {  // set value at position p
	int p1 = p;
  	for (seg[0][p += SZ] = value; p > 1; p >>= 1) seg[0][p>>1] = min(seg[0][p],seg[0][p^1]);
	p = p1;
	for (seg[1][p += SZ] = value+p1; p > 1; p >>= 1) seg[1][p>>1] = min(seg[1][p],seg[1][p^1]);
	p = p1;
	for (seg[2][p += SZ] = value+N-1-p1; p > 1; p >>= 1) seg[2][p>>1] = min(seg[2][p],seg[2][p^1]);
}

void init() {
	cin >> N >> Q >> A >> B; x.pb(A-1); x.pb(B-1);
	F0R(i,Q) {int x1; cin >> x1; x.pb(x1-1);}
	F0R(i,N) modifymin(i,INF);
	modifymin(x[0],0);
}

int main() {
	init();
	FOR(i,2,x.size()) {
		ll temp = qmin2(x[i])-abs(x[i]-x[i-1]);
		curadd += abs(x[i]-x[i-1]);
		if (temp < qmin(0,x[i-1],x[i-1]+1)) modifymin(x[i-1],temp);
	}
	cout << qmin(0,0,N)+curadd;
}

Measured memory_bytes: 10484
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;
template<typename Monoid, typename Operand>
class SegTree {
public:
	Monoid* tree;
	size_t size;
	int32 i;
	//?????????????????????
	SegTree(size_t length) {
		--length;
		size = length;
		if (size & 0xffff0000) { size = size & 0xffff0000; }
		if (size & 0xff00ff00) { size = size & 0xff00ff00; }
		if (size & 0xf0f0f0f0) { size = size & 0xf0f0f0f0; }
		if (size & 0xcccccccc) { size = size & 0xcccccccc; }
		if (size & 0xaaaaaaaa) { size = size & 0xaaaaaaaa; }
		if (length) { size <<= 1; }
		else { size = 1; }
		tree = (Monoid *)calloc(size << 1, sizeof(Monoid));
	}
	//?????????
	void set(bool merge) {
		i = size << 1;
		while (--i) { tree[i].set(); }
		if (merge) {
			i = size;
			while (--i) { tree[i] = tree[i << 1] + tree[i << 1 | 1]; }
		}
	}
	//tree[index]???data??§??´??°
	void update(size_t index, Operand &data) {
		index += size;
		tree[index] = tree[index] * data;
		while (index >>= 1) tree[index] = tree[index << 1] + tree[index << 1 | 1];
	}
	//[begin,end)??????????????????
	Monoid range(size_t begin, size_t end) {
		Monoid retL, retR;
		for (begin += size, end += size;begin < end;begin >>= 1, end >>= 1) {
			if (begin & 1) retL = retL + tree[begin++];
			if (end & 1)  retR = tree[end - 1] + retR;
		}
		return retL + retR;
	}
};
struct ADD {
	int64 e;
	ADD() { set(); }
	ADD(int64 x) { e = x; }
	void set() { e = 0; }
	ADD operator*(const ADD &other) {
		return ADD(e + other.e);
	}
};
struct SUM {
	int64 e;
	int64 s;
	SUM() { set(); }
	SUM(int64 x, int64 y) { e = x;s = y; }
	void set() { e = 0; s = 1; }
	SUM operator+(const SUM &other) {
		return  SUM(e + other.e, s + other.s);
	};
	SUM operator*(const ADD &other) {
		return SUM(e + (s*other.e), s);
	}
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	size_t n, q;
	cin >> n >> q;
	bool c;
	size_t x, y;
	ADD z;
	SegTree<SUM,ADD> t(n);
	t.set(0);
	while (q--) {
		cin >> c;
		if (c) {
			cin >> x >> y;
			printf("%lld\n", t.range(x-1, y).e);
		}
		else {
			cin >> x >> z.e;
			t.update(x-1, z);
		}
	}
	return 0;
}

Measured memory_bytes: 7284
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int pegs[10][10][10];

int dx[13] = {1 ,0  ,0  ,1  , 1 ,0  ,0  ,1  ,-1 ,1  ,-1 ,1  ,1};
int dy[13] = {0 ,1  ,0  ,1  ,-1 ,1  ,1  ,0  ,0  ,1  ,1  ,-1 ,1};
int dz[13] = {0 ,0  ,1  ,0  , 0 ,1  ,-1 ,1  ,1  ,1  ,1  ,1  ,-1};
bool ok(int t,int m){
    for(int x = 0; x < 10; x++){
        for(int y = 0; y < 10; y++){
            for(int z = 0; z < 10;z++){
                
                
                for(int k = 0; k < 13;k++){
                    bool win = true;
                    int nx = x,ny = y,nz = z;
                    
                    for(int _m = 0; _m < m; _m++){
                        if(nx < 0 || nx >= 10 || ny < 0 || ny >= 10 || nz < 0 || nz >= 10) {
                            win = false;
                            break;
                        }
                        if(pegs[nx][ny][nz] != t){ win = false; break; }
                        
                        nx = nx + dx[k];
                        ny = ny + dy[k];
                        nz = nz + dz[k];
                    }
                    
                    if(win) return true;
                }
            }
        }
    }
    return false;
}
bool pegset(int t,int m){
    int x,y; cin >> x >> y;
    x--; y--;
    for(int i = 0; i < 10;i++){
        if(pegs[x][y][i]==-1){
            pegs[x][y][i] = t;
            break;
        }
    }
    return ok(t,m);
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,m,p;
    while(cin >> n >> m >> p,n){
        fill(**pegs,**pegs+1000,-1);
        bool gameset = false;
        for(int i = 0; i < p;i++){
            int t = i&1;
            if(pegset(t,m)){
                if(gameset) continue;
                if(t == 0){
                    cout << "Black " << i+1 << endl;
                }else{
                    cout << "White " << i+1 << endl;
                }
                gameset = true;
            }
        }
        if(!gameset){
            cout << "Draw" << endl;
        }
    }
    return 0;
}



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

int k,a,b,sum;

int main(){
	cin>>k;
	cin>>a>>b;
	for(int i = a;i <= b;i ++){
		if (i % k == 0) sum++;
	}
	if(sum > 0){
		cout<<"OK"<<endl;
	}else{
		cout<<"NG"<<endl;
	}
}


Measured memory_bytes: 3624
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       k: usize,
       a:usize,
       b:usize,
    }

    let mut ans: usize = 0;
    for i in 0..1000 {
        if i * k >= a && i * k <= b {
            echo!("OK");
            return;
        }
    }
    echo!("NG");
}


Measured memory_bytes: 2164
#include<stdio.h>

int main(){

  int a[4], b[4], i, j, hit ,blow;

  while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF && 
	scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]) != EOF){



    hit = 0;
    blow = 0;

    for(i = 0; i < 4; i++){
      if(a[i] == b[i]){
	hit++;
      }
    }

    for(i = 0; i < 4; i++){
      for(j = 0; j < 4; j++){
	if(a[i] == b[j]){
	  blow++;
	}
      }
    }

    blow = blow - hit;

    printf("%d %d\n",hit,blow);
  }

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)

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

    int N,M; cin >> N >> M;
    vector<int> a(M);
    vector<int> c(M);
    rep(i, M){
        cin >> a[i];
        int b; cin >> b;
        int t=0;
        rep(j, b){
            int v; cin >> v; --v;
            t+=1<<(N-1-v);
        }
        c[i]=t;
    }

    const ll inf=1LL<<60;
    vector<vector<ll>> dp(M+5, vector<ll>(1<<N, inf));
    dp[0][0]=0;

    rep(i, M) rep(S, 1<<N){
        chmin(dp[i+1][S], dp[i][S]);
        if((S|c[i])>S) continue;
        for(int T=c[i]; T>0; T=(T-1)&c[i]) chmin(dp[i+1][S], dp[i][S^T]+a[i]);
    }
    
    if(dp[M][(1<<N)-1] == inf) cout << -1 << endl;
    else cout << dp[M][(1<<N)-1] << endl;
    
    return 0;
}



Measured memory_bytes: 32512
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int k=sc.nextInt();
Set<Integer> s=new HashSet<>();
while(k-->0)
{
int d=sc.nextInt();
while(d-->0)
{
int a=sc.nextInt();
s.add(a);
}
}

System.out.println(n-s.size());
}
}


Measured memory_bytes: 37352
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    string yes = "Possible", no = "Impossible";
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    auto cnt = [&] (int m) {
        return upper_bound(all(v), m) - lower_bound(all(v), m);
    };
    if(v.back()&1) {
        if(cnt(v.front()) != 2) {
            cout << no << endl;
            return 0;
        }
    }
    else {
        if(cnt(v.front()) != 1) {
            cout << no << endl;
            return 0;
        }
    }
    REP(i, v.front()+1, v.back()+1) {
        if(cnt(i) < 2) {
            cout << no << endl;
            return 0;
        }
    }
    cout << yes << endl;
    return 0;
}

Measured memory_bytes: 256
def digit_sum(num)
    sum = 0
    n = num
    while n > 0 do
        sum += n % 10
        n = n.div(10)
    end
    sum
end
N = gets.to_i
min = 100
1.upto(N.div(2)) do |a|
    b = N - a
    min = [min, digit_sum(a) + digit_sum(b)].min
end
puts min

Measured memory_bytes: 1788
import fractions
from functools import reduce

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

# 累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
  left[i + 1] = (fractions.gcd(left[i], a[i]))
  right[n - i - 1] = (fractions.gcd(right[n - i], a[n - 1 - i]))

ans = 0
for i in range(n):
  ans = max(ans, fractions.gcd(left[i], right[i + 1]))
print(ans)


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

int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", n * (n - 1) / 2 - n / 2);
    for (int i = 1; i <= n; i ++) 
        for (int j = 1; j < i; j ++)
            if (i + j != (n | 1)) printf("%d %d\n", i, j);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,a[N],f[N][2];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	if(a[1]&1)f[1][0]=1,f[1][1]=2;else f[1][0]=2,f[1][1]=1;
	for(int i=2;i<=n;i++)for(int j=0;j<2;j++){
		if(a[i]&1)f[i][j]+=f[i-1][j],f[i][j|1]+=f[i-1][j]<<1;
		else f[i][j]+=f[i-1][j]<<1,f[i][j|1]+=f[i-1][j];
	}
	cout<<f[n][1];
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 998244353;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[310];

ll dp[310][310*310];
ll dp2[310][310*310];

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

ll solve() {
    int sum = 0;
    for (int i = 0; i < n; i++) sum += a[i];

    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 310*310; j++) {
            dp[i][j] += dp[i-1][j] * 2;
            dp[i][j] %= mod;
            if (j >= a[i-1]) {
                dp[i][j] += dp[i-1][j-a[i-1]];
                dp[i][j] %= mod;
            }
        }
    }

    dp2[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 310*310; j++) {
            dp2[i][j] += dp2[i-1][j];
            dp2[i][j] %= mod;
            if (j >= a[i-1]) {
                dp2[i][j] += dp2[i-1][j-a[i-1]];
                dp2[i][j] %= mod;
            }
        }
    }

    ll res = mod_pow(3, n);
    for (int i = (sum+1)/2; i < 310*310; i++) {
        res += (mod - dp[n][i])*3;
        res %= mod;
    }
    if (sum % 2 == 0) {
        res += dp2[n][sum/2] * 3;
        res %= mod;
    }
    return res;
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 453636
import collections
n = int(input())
a = []
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)
a = collections.Counter(a)

count = 0
for i in a.values():
    for j in range(1,1000000):
        if i - j >= 0:
            count += 1
            i -= j
        else:
            break
print(count)

Measured memory_bytes: 9492
import sys
input1 = input().rstrip()
inputs = input().rstrip().split(' ')
count = 0
flg = 0
while True:
    for i in range(len(inputs)):
        if (int(inputs[i])%2 == 0):
            inputs[i] = int(inputs[i]) / 2
        else:
            flg = 1
    if (flg == 1):
        break
    count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;
int n;
int r[200000];
int minv;
int maxv;



int main()
{
	cin >> n;
	for (int i = 0; i <= n - 1; i++) {
		cin >> r[i];
	}
	minv = r[0];
	maxv = r[1]-r[0];
	for (int i = 1; i <= n - 1; i++) {
		if (r[i] - minv > maxv) maxv = r[i] - minv;
		if (r[i] < minv) minv = r[i];
	}
	cout << maxv << endl;
}

Measured memory_bytes: 1940
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Map<Character, Integer> list = new HashMap<>();
		for(int i = 0; i < 4; i++) {
			char tmp = s.charAt(i);
			if(list.containsKey(tmp)) {
				int val = list.get(tmp);
				val++;
				list.put(tmp, val);
			} else {
				list.put(tmp, 1);
			}
		}
		boolean flag = true;
		for(Map.Entry<Character, Integer> e : list.entrySet()) {
			if(e.getValue() != 2) {
				flag = false;
			}
		}
		if(flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

class Pair {
	private char c;
	private int num;

	protected Pair(char c, int num) {
		super();
		this.c = c;
		this.num = num;
	}

	public char getC() {
		return c;
	}

	public void setC(char c) {
		this.c = c;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int mod = 1e9+7;
int n,m,t;

inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret; 
}
inline int Mod(int x){
	return x>=mod?x-mod:x;
}
inline int Get(int n,int m){
	int ret=Mod(Mod(power(2,n)+power(2,m)));
	ret=Mod(ret+power(2,__gcd(n,m))),ret=Mod(ret+mod-3);
	return ret;
}

int main(){
	n=read(),m=read(),t=read();
	int x=n/__gcd(n,t),y=m/__gcd(m,t);
	printf("%d\n",power(Get(x,y),1ll*(n/x)*(m/y)%(mod-1)));
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();
int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

const int N = 105;
const int inf = 1e9 + 7;
int arr[N];
int S = 0;
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		S += arr[i];
	}	
	int mn = inf;
	int ans;
	for (int i = 1; i <= n; ++i) {
		if (llabs(S - n * arr[i]) < mn) {
			mn = llabs(S - n * arr[i]);
			ans = i;
		}
	}
	cout << ans - 1;
}	

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int n, ans = 0;
	string a, b, c;
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; ++i) {
		if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i]) { ans += 2; }
		else if (a[i] == b[i] && b[i] == c[i]) { continue; }
		else { ++ans; }
	}
	cout << ans << endl;
}


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

#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)

using ll = long long;


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

    ll c = 1;
    x <<= 1;
    while (x <= y) {
        x <<= 1;
        ++c;
    }

    log(c);

    return 0;
}



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

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

    cout << 3 * r * r << endl;
}


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

int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll nw=0, nb=0;
    rep(i,N){
        if(S[i] == '#'){
            nb++;
        }else{
            nw++;
        }
    }
    ll m = 1e10;
    m = min(m,nw);
    nb = 0;
    rep(i,N){
        if(S[i] == '.'){
            nw--;
        }else{
            //nw++;
            nb++;
        }
        m = min(m, nw+nb);
    }
    cout << m << endl;
    /*char now = '.';//.#.#.
    int cnt = 0;
    vector<ll> v;
    rep(i,N){
        if(now != S[i]){
            v.push_back(cnt);
            cnt = 1;
            if(now == '.'){
                now = '#';
            }else{
                now = '.';
            }
        }else{
            cnt++;
        }
    }
    if(cnt != 0) v.push_back(cnt);
    if(v.size() % 2 == 0) v.push_back(0);
    rep(i,v.size()){
        if(v[i] == 0){
            v.erase(i);
        }
    }
    vector<ll> s1(v.size() + 2),s2(v.size()+2);
    //cout << endl;
    for(int i = 0;i<v.size();i+=2){
        s1[i+2] = v[i] + s1[i];
        //cout << s1[i+2] << endl;
    }
    if(v.size % 2 == 1){
    for(int i = int(v.size()-2);i>0;i-=2){
        s2[i-1] = v[i] + s2[i+1];
    }
    }
    /*rep(i,v.size()+2){
        cout << s1[i] << " " << s2[i] <<endl;
    }
    ll m = 1e10;
    for(int i = 0;i<int(v.size()+2);i+=2){
        m = min(s1[i]+s2[i],m);
    }*/
    //cout << m << endl;
}

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

using namespace std;

typedef long long int ll;

const int mod = (int)1e9 + 7;

int main(){
	int n,k;
	cin >> n >> k;
	vector<ll> p(n+2);
	p[0] = 0;
	for(int i = 1; i <= n + 1; i++){
		p[i] = p[i-1] + i;
	}
	int res = 0;
	for(int i = k; i <= n; i++){
		ll t = (p[n] - p[n-i] - p[i-1] + 1)%mod;
		res = (res + t)%mod;
	}
	res+=1;
	if(res >= mod) res-=1;
	cout << res << "\n";
	return 0;
}


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

typedef struct{
    char suit;
    char num;
} Card;

void printCard(Card A[], int N){
    for(int i = 0; i < N; ++i){
        cout << A[i].suit << A[i].num;
        if(i == N - 1){
            cout << "\n";
        }
        else{
            cout << " ";
        }
    }
}

void bubbleSort(Card A[], int N){
    for(int i = 0; i < N; ++i){
        for(int j = N - 1; j >= i; --j){
            if(A[j].num < A[j - 1].num){
                std::swap(A[j], A[j - 1]);
            }
        }
    }
    printCard(A, N);
}

void selectionSort(Card A[], int N){
    for(int i = 0; i < N; ++i){
        int minIdx = i;
        for(int j = i; j < N; ++j){
            if(A[j].num < A[minIdx].num){
                minIdx = j;
            }
        }
        std::swap(A[i], A[minIdx]);
    }
    printCard(A, N);
}

bool isStable(Card A1[], Card A2[], int N){
    for(int i = 0; i < N; ++i){
        if(A1[i].suit != A2[i].suit){
            return false;
        }
    }
    return true;
}

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

    int N;
    Card Ab[36], As[36];

    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> Ab[i].suit >> Ab[i].num;
        As[i] = Ab[i];
    }

    bubbleSort(Ab, N);
    cout << "Stable" << "\n";
    selectionSort(As, N);
    if(isStable(Ab, As, N)){
        cout << "Stable";
    }
    else{
        cout << "Not stable";
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3176
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    int n,counts=0;
    cin>>n;
    char a[n];
    cin>>a;
    for(int i=0;i<strlen(a);i++)
    {
        if(a[i]=='A' && a[i+1]=='B' && a[i+2]=='C')
        {
            counts++;
        }

    }
    cout<<counts;
    }


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

using std::cin;
using std::cout;
using std::endl;
using std::string;;

int main(void) {
  int num = 0;
  int N;
  int S = 0;;

  cin >> N;

  num = N;

  while (num > 0) {
    S += num % 10;
    num /= 10;
  }

  if (N % S == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
     
  // cout << num << endl;
  return 0;
  
}


Measured memory_bytes: 888
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#define ln '\n'
#define sf scanf
#define pf printf

#define D(x) cout<< #x " = "<<x<<endl
#define cout(case)   cout << "Case " << ++cs << ": " ;
#define foreach(i,c) for(__typeof(c.begin())i=c.begin();i!=c.end();i++)


#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define _case cout<<"Case "<<++cs<<": "
#define lp(loop,start,end) for(ll loop=start;loop<=end;loop++)
#define lpd(loop,start,end) for(ll loop=end;loop>=start;loop--)



#define MOD 1000000007
#define countv(v,a) count(v.begin(),v.end(),a)
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define uniq(v) v.resize( unique(all(v)) - v.begin())


#define PI acos(-1)
#define ll long long int
#define ull unsigned long long

#define vi vector <int>
#define vll vector <ll>
#define vs vector <string>
#define pb push_back
#define mpii map <int,int>
#define mpsi map <string,int>
#define mpll map <long long,long long>
#define MP make_pair
#define F first
#define S second

#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) (a*(b/__gcd(a,b)))



#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())

#define all(v) v.begin(),v.end()
#define MEM(a, b) memset(a, b, sizeof(a))

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
#define INF 10e9
int dx[] = { 0, 0, 1, -1 }; /// 4 Direction
int dy[] = { 1, -1, 0, 0 };

/// int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
/// int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
/// int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


int unboundedKnapsack(int W, int n, int val[], int wt[])
{

	int dp[W+1];
	memset(dp, 0, sizeof(dp));

	int ans = 0;

	for (int i=0; i<=W; i++)
	for (int j=0; j<n; j++)
		if (wt[j] <= i)
			dp[i] = max(dp[i], dp[i-wt[j]]+val[j]);

	return dp[W];
}

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

	int val[n+7];
	int wt[n+7] ;

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


	cout << unboundedKnapsack(W, n, val, wt) << endl ;


}





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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<vector<char>> grids(h, vector<char>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> grids[i][j];
        }
    }
    bool over = true;
    bool allWhite = true;
    while (true) {
        over = true;

        for (int i = 0; i < grids.size(); ++i) {
            allWhite = true;
            for (int j = 0; j < grids[0].size(); ++j) {
                if (grids[i][j] == '#') {
                    allWhite = false;
                    break;
                }
            }
            if (allWhite) {
                grids.erase(grids.begin() + i);
                --i;
                over = false;
            }
        }

        for (int j = 0; j < grids[0].size(); ++j) {
            allWhite = true;
            for (int i = 0; i < grids.size(); ++i) {
                if (grids[i][j] == '#') {
                    allWhite = false;
                    break;
                }
            }
            if (allWhite) {
                for (int k = 0; k < grids.size(); ++k) {
                    grids[k].erase(grids[k].begin() + j);
                }
                --j;
                over = false;
            }
        }

        if (over) {
            break;
        }
    }
    for (int i = 0; i < grids.size(); ++i) {
        for (int j = 0; j < grids[0].size(); ++j) {
            cout << grids[i][j];
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 256