akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class46
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var check = Enumerable.Repeat(false, 8).ToArray();
            int count = 0;
            for(int i = 0; i < N; i++)
            {
                if (a[i] / 400 < 8)
                {
                    check[a[i] / 400] = true;
                }
                else
                    count++;
            }
            int min = check.Count(x => x == true);
            int max = min + count;
            if (min == 0) min = 1;
            Console.WriteLine($"{min} {max}");
           
        }
    }
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> T(N, 0);
    for (int i = 0; i < N; ++i){
        cin >> T[i];
    }
    int M;
    cin >> M;
    vector<pair<int, int>> P(M);
    for (int i = 0; i < M; ++i){
        int Pi, Xi;
        cin >> Pi >> Xi;
        P[i] = make_pair(Pi, Xi);
    }

    for (int i = 0; i < M;++i){
        int sum = 0;
        for (int j = 0; j < N;++j){
            if(j+1==P[i].first){
                sum += P[i].second;
            }else{
                sum += T[j];
            }
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// D - Maze Master
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using vi = vector<int>;
using vvi = vector<vi>;

int max_dist = 0;//解答
vvi dist_temp;//控え

// BFS (幅優先探索)
// 文字列迷路Sについて、S[sh][sw]から各マスまでの最短コストをdist[h][w]に求める
#define HMAX 20
#define WMAX 20
#define INF 100000
vvi dist(HMAX+2, vi(WMAX+2, INF));//外周を壁で囲む (-1:未訪問, 0~<INF:訪問済&コスト, INF:壁)
void bfs(int sh, int sw){
	int dx[4]={0,-1,0,1}, dy[4]={-1,0,1,0};
	dist = dist_temp;//初期設定
	dist[sh][sw] = 0;//最短コスト
	queue<pair<int,int>> q;
	q.push({sh,sw});
	while(!q.empty()){
		int ph,pw; tie(ph,pw) = q.front(); q.pop();
		rp(k, 0, 4){//四方向
			int h = ph + dy[k], w = pw + dx[k];
			if(dist[h][w] > -1) continue;//壁・訪問済み
			dist[h][w] = dist[ph][pw] + 1;//最短コスト
			q.push({h,w});
			max_dist = max(max_dist, dist[h][w]);//解答更新
		}
	}
}

int main(){
	int H,W; cin>>H>>W;
	rp(h, 1, H+1){
		string s; cin>>s;
		rp(w, 1, W+1) if(s[w-1]=='.') dist[h][w] = -1;//未訪問
	}
	dist_temp = dist;//控え
	rp(h, 1, H+1)rp(w, 1, W+1) if(dist_temp[h][w]<0) bfs(h,w);
	cout<< max_dist <<endl;
}

Measured memory_bytes: 256
#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 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 n;
vl a;

ll dfs(int idx, ll sum, ll ope) {
	if(idx == n) return ope;
	ll t = sum + a[idx];
	if(sum > 0) {
		if(t < 0) return dfs(idx+1, t, ope);
		return dfs(idx+1, -1, ope+t+1);
	}
	else {
		if(t > 0) return dfs(idx+1, t, ope);
		return dfs(idx+1, 1, ope-t+1);
	}
}

int main(){
	cin >> n;
	a.resize(n);
	rep(i, n) cin >> a[i];
	if(a[0] == 0LL) {
		cout << min(dfs(1, -1, 1), dfs(1, 1, 1)) << endl;
	}
	else if(a[0] > 0LL) {
		cout << min(dfs(1, a[0], 0), dfs(1, -1, a[0]+1)) << endl;
	}
	else {
		cout << min(dfs(1, a[0], 0), dfs(1, 1, -a[0]+1)) << endl;
	}
}


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

int main()
{
    int n;
    cin >> n;
    int d[10002];
    int l = 0;
    int neg = 0;
    for(int i = 0; i < n; i++){
        cin >> d[i];
        l += d[i];
        neg += d[i] * d[i];
    }
    cout << (l * l - neg) / 2 << endl;
}

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

void setup()
{
    //cinでファイルから読込
    ifstream in("./input.txt");
    cin.rdbuf(in.rdbuf());

    //cinの高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

    vector<int> p;
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        p.push_back(temp);
    }

    int k = 0;
    for (int i = 0; i < N; i++)
    {
        if ((i + 1) != p[i])
        {
            k++;
        }
    }
    cout << ((k <= 2) ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
xs,ys,xt,yt = map(int,input().split())
n = int(input())

v = [(xs,ys,0),(xt,yt,0)]
for i in range(n):
    x,y,r = map(int,input().split())
    v.append((x,y,r))
path = [[] for i in range(n+2)]
for i in range(n+1):
    for j in range(i+1,n+2):
        l = max(0, ((v[i][0] - v[j][0])**2 + (v[i][1] - v[j][1])**2)**0.5 - v[i][2] - v[j][2])
        path[i].append((j,l))
        path[j].append((i,l))

import heapq
def Dijkstra(edge,start,v):
    d = [float('inf')]*v
    d[start] = 0
    pq = [(0,start)]
    heapq.heapify(pq)
    while pq:
        dist,p = heapq.heappop(pq)
        if dist > d[p]:continue
        for to,cost in edge[p]:
            if d[to] <= dist + cost:continue
            d[to] = dist + cost
            heapq.heappush(pq, (d[to], to))
    return d

d = Dijkstra(path, 0, n+2)
print(d[1])


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

int sum[100010];  // sum[i] = i文字目(1-based)までで含まれているACの個数

int main() {
  string S;
  int N, Q;
  cin >> N >> Q >> S;
  sum[0] = sum[1] = 0;
  for (int k = 1; k < N; k++) {
    if (S[k - 1] == 'A' && S[k] == 'C')
      sum[k + 1] = sum[k] + 1;
    else
      sum[k + 1] = sum[k];
  }

  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << (sum[r] - sum[l]) << endl;
  }
  return 0;
}

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

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


int main(){
  int N;
  cin >> N;
  int64_t tmp;
  int64_t tmp0 = 2;
  int64_t tmp1 = 1;
  if (N==1){
    cout << 1 << endl;
    return 0;
  }
  for (int i=2; i<N ; i++){
    tmp = tmp0+tmp1;
    tmp0 = tmp1;
    tmp1 = tmp;
  }
  cout << tmp0+tmp1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <valarray>
#include <string>
#include <algorithm>
#include <set>
typedef unsigned long long ull;
typedef long long ll;

#define rep(i,n) for(ull i = 0;i<(n);i++)
#define rep1(i,n) for(ull i = 1;i<=(n);i++)
#define revrep(i,n) for(ull i = (n-1);i>=0;i--)
#define all(n) (n).begin(),(n).end()
#define show(x) (cout << "debug " << #x << ":" << x << endl, x);
#define showvec(x) cout << endl << "debug " << #x << ";" << endl; \
	for(ull __i = 0;__i < x.size();__i++){ \
		for(ull __j = 0;__j<x[0].size();__j++){ \
			cout << x[__i][__j] << " "; \
		} \
		cout << endl; \
	} \
	cout << endl;
using namespace std;
#define MOD 1000000007

ull patternNum(bool last, char p, char q, char r, bool cu, bool cn){
	ull ans = 0;
	int fst = (last ? 1 : 0);
	for(int a = fst;a < 10;a++){
		if(p != '?'){
			a = p - '0';
		}
		for(int b = fst;b < 10;b++){
			if(q != '?'){
				b = q - '0';
			}
			for(int c = fst;c < 10;c++){
				if(r != '?'){
					c = r - '0';
				}
				ull tmp = a + b + (cu ? 1 : 0);
				if(tmp % 10 == c){
					if(tmp >= 10 && cn){
						ans++;
					}
					if(tmp < 10 && !cn){
						ans++;
					}
				}
				if(r != '?'){
					break;
				}
			}
			if(q != '?'){
				break;
			}
		}
		if(p != '?'){
			break;
		}
	}
	return ans;
}

int main(){
	ull c0[52],c1[52];
	string A,B,C;
	while(cin >> A, A != "0"){
		cin >> B >> C;
		rep(i,52){
			c0[i] = c1[i] = 0;
		}
		for(int p = A.size()-1;p>=0;p--){
			if(p == A.size()-1 && A.size() != 1){
				c0[p] = patternNum(false,A[p],B[p],C[p],false,false) % MOD;
				c1[p] = patternNum(false,A[p],B[p],C[p],false,true) % MOD;
			}else if(p != 0){
				c0[p] = patternNum(false,A[p],B[p],C[p],false,false) * c0[p+1] + patternNum(false,A[p],B[p],C[p],true,false) * c1[p+1];
				c0[p] %= MOD;
				c1[p] = patternNum(false,A[p],B[p],C[p],false,true) * c0[p+1] + patternNum(false,A[p],B[p],C[p],true,true) * c1[p+1];
				c1[p] %= MOD;
			}else if(p == 0 && A.size() != 1){
				c0[p] = patternNum(true,A[p],B[p],C[p],false,false) * c0[p+1] + patternNum(true,A[p],B[p],C[p],true,false) * c1[p+1];
				c0[p] %= MOD;
				c1[p] = 0;
			}else{
				c0[0] = patternNum(true,A[p],B[p],C[p],false,false);
			}
		}
		cout << c0[0] + c1[0] << endl;
	}
}

Measured memory_bytes: 1180
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }

    return 0;
}

Measured memory_bytes: 380
import sys
input = sys.stdin.buffer.readline

n, m = map(int, input().split())
X = []
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    X.append((a, b))

X.reverse()

def Find(x, par):
    if par[x] < 0:
        return x
    else:
        par[x] = Find(par[x], par)
        return par[x]

def Unite(x, y, par, rank):
    x = Find(x, par)
    y = Find(y, par)

    if x != y:
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

def Same(x, y, par):
    return Find(x, par) == Find(y, par)

def Size(x, par):
    return -par[Find(x, par)]

temp = n*(n-1)//2
ans = [0]*m

par = [-1]* n
rank = [0]*n

for i in range(m):
    a, b = X[i]
    ans[i] = temp
    if Same(a, b, par):
        continue
    else:
        pre_a = Size(a, par)
        pre_b = Size(b, par)
        Unite(a, b, par, rank)
        temp -= pre_a*pre_b
        #if temp <= 0:
        #temp = 0

ans.reverse()
#print(ans)
for i in range(len(ans)):
    print(ans[i])

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

int main()
{
  string S, ans = "Good";
  cin >> S;
  
  for(int i = 1; i < S.size(); i++)
  {
    if(S.at(i - 1) == S.at(i))
    {
      ans = "Bad";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecs = vector<string>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

void register_dict(ll x, map<ll,ll> &mp) {
    if(mp.count(x)) mp[x]++;
    else mp[x] = 1;
}

int main() {
    int N; cin >> N;
    vecl A(N); REP(i,N) cin >> A[i];
    map<ll,ll> mp_l,mp_r;
    REP(i,N) {
        int l = -A[i]-(i+1);
        int r = A[i]-(i+1);
        //cout << i + 1 << " "<< l << " " << r << endl;
        register_dict(l,mp_l);
        register_dict(r,mp_r);
    }
    ll ans = 0;
    for(auto p : mp_l) {
        auto x = p.first;
        auto cnt = p.second;
        if(mp_r.count(x)) ans += cnt*mp_r[x];
    }
    cout << ans << endl;
}

Measured memory_bytes: 27952
#include<iostream>
#include<string>

int main() {
  std::string str;
  std::cin >> str;
  int sum = 700;
  for (int i=0; i<str.size(); i++) {
    if (str.at(i) == 'o') {
      sum += 100;
    }
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

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

const int MOD = 1000000007;





int main(int argc, const char * argv[]) {
  ll H,N; cin >> H >> N;
  vector<ll> a(N+1);
  vector<ll> b(N+1);
  ll max_a=0, max_b=0;
  for(ll i=1;i<=N;i++){
    cin >> a[i] >> b[i];
    max_a = max(max_a,a[i]);
    max_b = max(max_b,b[i]);

  } 

  // cout << max_a << "  " << max_b << endl;
  ll dp[N+1][H+max_a+1];
  for(ll i=0;i<N+1;i++){
    for(ll j=0;j<H+max_a+1;j++){
      dp[i][j]= H*max_b;
      // cout << dp[i][j] << " " << endl;
    }
    // cout << endl;
  }
  for(ll i=1;i<N+1;i++){
    for(ll j=1;j<H+max_a+1;j++){
      if(j-a[i]<0) dp[i][j] = dp[i-1][j];
      else if(a[i]==j){
        dp[i][j] = min(dp[i-1][j],b[i]);
      }else{
        dp[i][j] = min(dp[i-1][j],dp[i][j-a[i]]+b[i]);
      }
    }
  }

  ll ans = H*max_b;
  for(ll i=H;i<=H+max_a;i++){
    ans = min(ans,dp[N][i]);
  }

  cout << ans << endl;


}


Measured memory_bytes: 87936
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;
 
vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//abcのbed乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 





ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];
char s[500005];
ll dp[85][5005];



int main(){	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i];		
	}
	for(i=0;i<n;i++){
		if(i%2==0){
			y[x[i]]++;
		}else{
			z[x[i]]++;
		}
	}

	for(i=0;i<100005;i++){
		if(y[i] > a){
			c = i;
			a = y[i];
		}
		if(z[i] > b){
			d = i;
			b = z[i];
		}
	}
	

	sort(y,y+200005);
	sort(z,z+200005);
	reverse(y,y+200005);
	reverse(z,z+200005);
	if(c!=d){
		p(n - y[0] - z[0]);
	}else{
		a = y[0] + z[1];
		b = y[1] + z[0];
		p(n - max(a,b));
	}
	return 0;
}

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

void QuickSort(int S[], int B, int T);

int main(){
  int n[200],nn,mn,i;
  cin >> nn;
  for(i=0;i<nn;i++){
    int h,min;
    cin >> h >> min;
    n[i] = h * 100 + min;
  }
  cin >> mn;
  for(i=nn;i<nn+mn;i++){
    int h,min;
    cin >> h >> min;
    n[i] = h * 100 + min;
  }
  QuickSort(n,0,nn+mn-1);
  for(i=0;i<nn+mn-1;i++){
    if(n[i] != n[i-1] && n[i] == n[nn+mn-1])
      cout << n[i] / 100 << ':' << (n[i] % 100) / 10 << n[i] % 10 ;
    else if(n[i] != n[i-1])
      cout << n[i] / 100 << ':' << (n[i] % 100) / 10 << n[i] % 10 << ' ';
  }
  if(n[i] != n[i-1])
    cout << n[i] / 100 << ':' <<(n[i] % 100) / 10 << n[i] % 10 << endl;
  else
    cout << endl;
  return 0;
}

void QuickSort(int S[], int B, int T)
{
	if(B>=T)
		return;
	int div = S[B];
	int i = B;
	int j = T;
	while(i<j){
		while(i<=j && S[i]<=div){
			i++;
		}
		while(i<=j && S[j]>div){
			j--;
		}
		if(i<j){
			int tmp = S[i];
			S[i] = S[j];
			S[j] = tmp;
		}
	}

	int tmp = S[B];
	S[B] = S[j];
	S[j] = tmp;
	QuickSort(S, B, j-1);
	QuickSort(S, j+1, T);
}

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

int main(void){
  int N,M;
  cin>>N>>M;
  vector<int>p(M);
  vector<string> S(M);
  for(int i=0;i<M;i++){
    cin>>p[i]>>S[i];
  }
  bool AC[100005];
  int WA[100005];
  for(int i=0;i<=N;i++){
    WA[i]=0;
    AC[i]=false;
  }
  int AC_num=0;
  int WA_num=0;
  for(int i=0;i<M;i++){
    if(AC[p[i]-1]==true) continue;
    if(S[i]=="AC"){
      AC[p[i]-1]=true;
      AC_num++;
      WA_num+=WA[p[i]-1];
    }else{
      WA[p[i]-1]++;
    }
  }
  cout<<AC_num<<" "<<WA_num<<endl;
   return 0;
}


Measured memory_bytes: 6656
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	cin >> h >> w;
	vector<vector<int> > c(10,vector<int>(10));
	rep(i,10){
		rep(j,10){
			cin >> c[i][j];
		}
	}
	int sum = 0;
	vector<int> mem(10,INF);
	rep(i,h){
		rep(j,w){
			int a;
			cin >> a;
			if(a == 1 || a == -1) continue;
			if(mem[a] != INF){
				sum += mem[a];
				continue;
			}
			vector<int> cost(10,INF);
			queue<int> que;
			que.emplace(a);
			cost[a] = 0;
			while(!que.empty()){
				int now = que.front();
				que.pop();
				rep(k,10){
					if(cost[now] + c[now][k] < cost[k]){
						cost[k] = cost[now] + c[now][k];
						que.emplace(k);
					}
				}
			}
			sum += cost[1];
			mem[a] = cost[1];
		}
	}
			
	cout << sum << '\n';

	return 0;
}


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

int main(){
    int x,num[10000],count=0;
    while(true){
        cin>>x;
        if(x==0)break;
        else num[count]=x;
        count++;
    }

    for(int i=0;i<count;i++){
        cout<<"Case "<<i+1<<": "<<num[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type StackData struct {
	data interface{}
	next *StackData
}

type Stack struct {
	sp  *StackData
	top int
}

func NewStack() *Stack {
	return &Stack{top: 0}
}

func (s *Stack) Push(data interface{}) {
	s.sp = &StackData{data: data, next: s.sp}
	s.top++
}

func (s *Stack) Pop() interface{} {
	if s.top > 0 {
		item := s.sp.data
		s.sp = s.sp.next
		s.top--
		return item
	}
	return nil
}

func (s *Stack) Peek() interface{} {
	if s.top > 0 {
		return s.sp.data
	}
	return nil
}

func (s *Stack) IsEmpty() bool {
	if s.top == 0 {
		return true
	}
	return false
}

func (s *Stack) Size() int {
	return s.top
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	var X string
	fmt.Scan(&X)

	s := NewStack()

	for _, xx := range X {
		if xx == 'S' {
			s.Push(xx)
		}

		if xx == 'T' && (s.Peek() == 'T' || s.IsEmpty()) {
			s.Push(xx)
		}

		if xx == 'T' && s.Peek() == 'S' {
			s.Pop()
		}
	}

	ans := 0
	for !s.IsEmpty() {
		s.Pop()
		ans++
	}
	fmt.Println(ans)
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<61)

#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N; cin >> N;
  vector<ll> T(N+2, 0LL), A(N+2, 0LL);

  REP(i, 1, N+1) cin >> T[i];
  REP(i, 1, N+1) cin >> A[i];

  T[0] = -1; T[N+1] = INF;
  A[0] = INF; A[N+1] = -1;
  
  vector<ll> pattern(N, 0LL);
  for(int i = 1; i <= N; i++) {
    if (T[i-1] < T[i] && A[i] > A[i+1] && T[i] == A[i]) pattern[i-1] = 1LL;
    else if (T[i-1] < T[i] && A[i] == A[i+1] && T[i] <= A[i]) pattern[i-1] = 1LL;
    else if (T[i-1] == T[i] && A[i] > A[i+1] && T[i] >= A[i]) pattern[i-1] = 1LL;
    else if (T[i-1] == T[i] && A[i] == A[i+1]) pattern[i-1] = min(T[i], A[i]);
  }

  ll ans = 1;
  rep(i, N) ans = (ans * pattern[i]) % MOD;
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 2688
sum = 0
n = int(input())
l = [list(map(int, input().split())) for i in range(3)]
 
for i in range(n-1):
  sum = sum + l[1][i]
  if l[0][i+1] - l[0][i] == 1:
    sum = sum + l[2][l[0][i]-1]
sum = sum + l[1][n-1]
print(sum)

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

int main() {
	int N;
	cin >> N;
	int Max = -1000000;
	int Min = 1000000;
	long long Sum = 0;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		Max = max(x, Max);
		Min = min(x, Min);
		Sum += x;
	}
	cout << Min << " " << Max << " " << Sum << endl;
}



Measured memory_bytes: 3108
import sys
import fractions
input = sys.stdin.readline
A, B = (int(i) for i in input().split())

gcd = fractions.gcd(A, B)
temp = gcd
count = 1
for i in range(2, int(-(-gcd**0.5//1))+1):
    if temp%i == 0:
        cnt = 0
        while temp%i ==0:
            cnt +=1
            temp //= i
        count +=1
if temp != 1:
    count +=1

print(count)


Measured memory_bytes: 65640
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>

typedef long long int ll;

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    // dp[i][offset]: use A[i:i+offset]
    vector<vector<ll>> dp(N, vector<ll>(N + 1, -1LL));
    vector<vector<ll>> costs(N, vector<ll>(N + 1, 0LL));

    // init
    for (int i = 0; i < N; i++) {
        dp[i][0] = 0LL;
        dp[i][1] = A[i];
    }
    // dp
    for (int offset = 2; offset <= N; offset++) {
        for (int i = 0; i <= (N - offset); i++) {
            // A[i:i+j] + A[i+j:i+offset]
            ll value;
            ll cost;
            for (int j = 1; j < offset; j++) {
                ll v = dp[i][j] + dp[i+j][offset-j];
                ll c = costs[i][j] + costs[i+j][offset-j] + v;
                if ((j == 1) || (cost > c)) {
                    value = v;
                    cost = c;
                }
            }
            dp[i][offset] = value;
            costs[i][offset] = cost;
        }
    }
    // cout << "dp" << endl;
    // for (int i = 0; i < N; i++) {
    //     for (int j = 0; j <= N; j++) {
    //         cout << dp[i][j] << ", ";
    //     }
    //     cout << endl;
    // }
    // cout << "costs" << endl;
    // for (int i = 0; i < N; i++) {
    //     for (int j = 0; j <= N; j++) {
    //         cout << costs[i][j] << ", ";
    //     }
    //     cout << endl;
    // }

    cout << costs[0][N] << endl;
    
    return 0;
}


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

#define M 1000000007


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

  vector<int64_t> A(N);
  for (int n = 0; n < N; n++){
    cin >> A.at(n);
  }

  int64_t a = 0;
  int64_t b;
  int64_t p;
  int64_t sum = 0;
  for (int n = 0; n < N-1; n++){
    a += A.at(n);
    b = A.at(n+1);
    p = ((a % M) * (b % M)) % M;
    sum = (sum + (p % M)) % M;
    //cout << "a:" << a << " b:" << b << " a*b:" << a*b << " part:" << p << endl;
  }

  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N=1e5+7;
vector<long> v[N];
long arr[N];
long myfun(int i)
{
	long &x=arr[i];
	if(x!=-1)
	{
		return x;
	}
		x=0;
		for(long j=0;j<v[i].size();j++)
		{
			x=max(x,1+myfun(v[i][j]));
		}
	return x;
}
int main()
{

	IOS;
	memset(arr,-1,sizeof(arr));
	long n,m;
	cin>>n>>m;
	for(long i=1;i<=m;i++)
	{
		long u,t;
		cin>>u>>t;
		v[u].push_back(t);
	}
	long ans=0;
	for(long i=1;i<=n;i++)
	{
		ans=max(ans,myfun(i));
	}
	cout<<ans<<endl;
}

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

int main() {
    int n, x, m, mn = INT_MAX;
    cin>>n>>x;
    for(int i = 0;i<n;i++){
        cin>>m;
        x-=m;
        mn = min(mn, m);
    }
    cout<<x/mn+n<<"\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String[] line = new String[3001];

		for (int i = 0; i < line.length; i++) {
			line[i] = sc.nextLine();

			if (line[i].equals("0 0")) {
				break;
			}
		}
		for (int i = 0; i < line.length; i++) {

			if (line[i].equals("0 0")) {
				break;
			}
			String[] lined = line[i].split(" ");
			int v = Integer.parseInt(lined[0]);
			int v2 = Integer.parseInt(lined[1]);
			if (v > v2) {
				System.out.println(v2 + " " + v);
			} else {
				System.out.println(v + " " + v2);
			}
		}
	}

}

Measured memory_bytes: 35128
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

vector<int> p;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n, a, b, tmp;
  cin >> n;
  cin >> a >> b;
  REP(i, n){
    cin >> tmp;
    p.push_back(tmp);
  }
  
  //sort(p.begin(), p.end());

  int ans1=0, ans2=0, ans3=0;
  REP(i, n){
    if(p[i] <= a) ans1++;
    if(p[i] > a && p[i] <= b) ans2++;
    if(p[i] > b) ans3++;
  }

  //cout << ans1 << " " << ans2 << " " << ans3;
  
  cout << min(min(ans1, ans2), ans3) << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        double[] x=new double[n];
        double[] y=new double[n];
        int i;
        for(i=0;i<n;i++)x[i]=sc.nextDouble();
        for(i=0;i<n;i++)y[i]=sc.nextDouble();
    
        System.out.println(getD(x,y,n,1));
        System.out.println(getD(x,y,n,2));
        System.out.println(getD(x,y,n,3));
        System.out.println(getCD(x,y,n));
    }
    
    static double getD(double x[],double y[],int n,int p){
        double d=0;
        for(int i=0;i<n;i++)d+=Math.pow(Math.abs(x[i]-y[i]),p);
        if(p==1)return d;
        else if(p==2)return Math.sqrt(d);
        else if(p==3)return Math.cbrt(d);
        else return -1;
    }
    static double getCD(double x[],double y[],int n){
        double max=0;
        for(int i=0;i<n;i++)if(max<Math.abs(x[i]-y[i]))max=Math.abs(x[i]-y[i]);
        return max;
    }
}



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

# define ll long long
# define mod 1000000007
# define MAX 100005
# define PI 3.141592653589793238                                                                                  //shortcut keys

# define pb push_back
# define mp make_pair
# define all(x) x.begin(),x.end()
# define fr(i,a,b) for(int i=a;i<=b;i++)

# define decimal(k) fixed<<setprecision(k)
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------
using namespace std;

int main()
{
	int x;cin>>x;
	cout<<(x^1)<<'\n';

	return 0;
}



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

int n,m,s;
int dp[50][3001];
int main(){
	while(cin >> n >> m >> s && n){
		n *= n;
		m = min(m,s);
		memset(dp,0,sizeof(dp));
		dp[0][0] = 1;
		for(int j = 1 ; j <= m ; j++){
			for(int k = s-j ; k >= 0 ; k--){
				for(int i = 1 ; i <= n ; i++){
					(dp[i][k+j] += dp[i-1][k])%=100000;
				}
			}
		}
		cout << dp[n][s] << endl;
	}
}

Measured memory_bytes: 1452
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())

    # id table
    N=0
    id=[[None]*n for _ in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            id[i][j]=N
            N+=1
    toID=lambda i,j:id[min(i,j)][max(i,j)]

    E=[[] for _ in range(N)]
    for i in range(n):
        A=list(map(lambda x:int(x)-1,input().split()))
        for j in range(n-2):
            u=toID(i,A[j])
            v=toID(i,A[j+1])
            E[u].append(v)

    # longest path problem
    dp=[-1]*N
    def dfs(v):
        if(dp[v]>=0): return dp[v]
        dp[v]=-2
        res=0
        for nv in E[v]:
            if(dp[nv]==-2):
                print(-1)
                exit()
            res=max(res,dfs(nv)+1)
        dp[v]=res
        return res

    print(max(dfs(v) for v in range(N))+1)
resolve()

Measured memory_bytes: 162304
#include<cstdio>
#include<algorithm>
inline void read(int&r)
{
	register char c;r=0;
	do c=getchar();while(c<'0'||c>'9');
	do r=r*10+c-'0',c=getchar();while(c>='0'&&c<='9');
}

int a[300000];
int main()
{
	long long ans=0;
	int n,i,j;read(n);
	for(i=0;i<n*3;i++)read(a[i]);
	std::sort(a,a+n*3);
	for(j=n*3-2,i=0;i<n;i++,j-=2)
		ans+=a[j];
	printf("%lld\n",ans);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 333333;
int n,m,ind[N],fa[N],vis[N];Vi e[N],rev[N];
int s[N],pos[N],len;
/*void dfs(int u){
	vis[u]=1;rep(i,0,SZ(e[u])-1)if(!vis[e[u][i]]){
		dfs(e[u][i]);fa[e[u][i]]=u;
	}
}*/
int main() {
	memset(vis,0,sizeof(vis));
	read(n);read(m);
	rep(t,1,n-1+m){
		int u,v;read(u);read(v);e[u].pb(v);ind[v]++;
		rev[v].pb(u);
	}
	int rt=0;rep(i,1,n)if(!ind[i])rt=i;assert(rt);
	static int sta[N];int top=0;sta[++top]=rt;
	while(top){
		int u=sta[top--];s[++len]=u;pos[u]=len;
		rep(i,0,SZ(e[u])-1){
			int v=e[u][i];ind[v]--;
			if(!ind[v])sta[++top]=v;
		}
	}
	rep(i,1,n)if(SZ(rev[i])){
		int u=0;
		rep(j,0,SZ(rev[i])-1)if(!u||pos[rev[i][j]]>pos[u])u=rev[i][j];
		fa[i]=u;
	}
	
	rep(i,1,n)printf("%d\n",fa[i]);
	return 0;
}


Measured memory_bytes: 28288
void main() {
	auto ip = readAs!(long[]), N = ip[0], M = ip[1], Q = ip[2];
	alias Pair = Tuple!(long, "a", long, "b", long, "c", long, "d");
	Pair[] pairs;
	foreach(i; 0..Q) {
		auto ip2 = readAs!(long[]), a = ip2[0], b = ip2[1], c = ip2[2], d = ip2[3];
		pairs ~= Pair(a, b, c, d);
	}

	long[][] arr2;
	long[] rec(long[] ar) {
		if(ar.length == N) return ar;
		auto k = ar.back;
		foreach(v; k..M+1) {
			auto m = rec(ar ~ v);
			if(m) arr2 ~= m;
		}
		return [];
	}
	long res;
	foreach(k; 1..M+1) rec([k]);
	debug arr2.each!writeln;
	foreach(v; arr2) {
		long tmp;
		foreach(p; pairs) {
			if(v[p.b-1] - v[p.a-1] == p.c) {
				tmp += p.d;
			}
		}
		res = max(res, tmp);
	}
	res.writeln;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;


int solve(const vector<vector<char>>& maze)
{
	int mod = 1e9 + 7;
	if(maze.empty())
		return 0;
	int R = (int)maze.size();
	int C = (int)maze[0].size();
	vector<vector<int>> dp(R, vector<int>(C, 0));
	dp[0][0] = 1;

	for(int i = 1; i < C; ++i) 
		if(maze[0][i] != '#')
			dp[0][i] += dp[0][i-1] % mod;
	for(int j = 1; j < R; ++j)
		if(maze[j][0] != '#')
			dp[j][0] += dp[j-1][0] % mod;
		
	for(int i = 1; i < R; i++) {
		for(int j = 1; j < C; j++) {
			if(maze[i][j] != '#') {
				dp[i][j] += (dp[i-1][j] % mod + dp[i][j-1] % mod);
				dp[i][j] %= mod;
			} 
		}
	}
	return dp[R-1][C-1];
}


int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<char>>maze;
	for(int i = 0; i < H; ++i) {
		vector<char> row(W);
		for(int j = 0; j < W; ++j) {
			cin >>  row[j];
		}
		maze.emplace_back(row);
	}
	int res = solve(maze);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 5248
#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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    long long N, A, B;
    while (cin >> N >> A >> B) {
        long long q = N / (A+B);
        long long r = N % (A+B);
        cout << A*q + min(r, A) << endl;
    }
}










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

using namespace std;
using ll = long long;

const int MOD = 1000000007;

int main() {
	int n;
	cin >> n;
	
	if (n < 3) {
		cout << 0 << '\n';
		return 0;
	}
	
	vector<ll> dp(n + 1, 0);
	dp[3] = 1;
	for (int i = 4; i <= n; ++i) {
		for (int j = i - 3; j >= 3; --j) dp[i] += dp[j];
		dp[i]++;
		dp[i] %= MOD;
	}
	
	cout << dp[n] << '\n';
	
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a[4];
int main(){
  for(int i = 0; 6 > i; i++){
    int tmp;cin>>tmp;tmp--;
    a[tmp]++;
  }
  vector<int> z;
  for(int i = 0; 4 > i; i++){
    z.push_back(a[i]);
  }
  sort(z.begin(),z.end());
  for(int i = 0; 4 > i; i++){
    if(i < 2){
      if(z[i] != 1){
        cout << "NO" << endl;
        return 0;
      }
    }else{
      if(z[i] != 2){
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>

int main()
{
    int n = 0;
    std::cin >> n;
    
    std::unordered_set<int> intSet;
    
    int a = 0;
    for(int index = 0; index < n; ++index)
    {
        std::cin >> a;
        if(!intSet.emplace(a).second)
        {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }
    std::cout << "YES" << std::endl;
    return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn],a[maxn],b[maxn];
int main() {
    string abc="ABC",arc="ARC",x;
    cin>>x;
    if(x==abc) cout<<arc<<endl;
    else cout<<abc<<endl;
    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

s=input()

ans1=0
for i in range(len(s)):
    if i%2:
        if s[i]!='1':
            ans1+=1
    else:
        if s[i]!='0':
            ans1+=1

ans2=0
for i in range(len(s)):
    if i%2:
        if s[i]!='0':
            ans2+=1
    else:
        if s[i]!='1':
            ans2+=1

print(min(ans1,ans2))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
int N;
ll sum;
int main() {
	cin >> N;
	for(int i = 1;i<=N;i++){
		for(int j = 1;j<=N;j++){
			for(int k = 1;k<=N;k++){
				sum+=__gcd(i, __gcd(j, k));
			}
		}
	}
	cout << sum << el;
	return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, W, dp[100001];
	fill_n(dp, 100001, -1);

	cin >> n >> W;
	vector<ll> v(n), w(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}

	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = W; j >= w[i]; j--) {
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}

	ll ans = *max_element(dp, dp + W + 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int H, W;
	cin >> H >> W;
	string maps[50];
	REP(i, H) cin >> maps[i];
	
	bool f[50][50] = {};
	REP(i, H) REP(j, W) {
		if (maps[i][j] != '#') continue;
		if (j + 1 < W && maps[i][j + 1] == '#') f[i][j] = f[i][j + 1] = true;
		if (i + 1 < H && maps[i + 1][j] == '#') f[i][j] = f[i + 1][j] = true;
	}
	
	bool ans = true;
	REP(i, H) REP(j, W) if (maps[i][j] == '#' && !f[i][j]) ans = false;
	puts(ans ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
S = str(input())

if S == "SUN":
  print("7")
elif S[2] == "N":
  print("6")
elif S[2] == "E":
  print("5")
elif S[2] == "D":
  print("4")
elif S[2] == "U":
  print("3")
elif S[2] == "I":
  print("2")
else:
  print("1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1; i<=9; i++){
        if(n%i) continue;
        int val = n/i;
        if(val%10 == val){
            cout<<"Yes\n"; return 0;
        }
    }
    cout<<"No\n"; 
}

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

int main(){
  ll N;
  cin >> N;
  ll ans=1e18;
  for(ll i=1;i*i<=N;i++){
    if(N%i!=0){
      continue;
    }
    ll j=N/i;
    ans=min(ans,i+j-2);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // int(gcd(a, b))

import functools

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

l = functools.reduce(lcm, A)

ans = sum(l // Ai for Ai in A) % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 4708
n,h=map(int,input().split())
a=[]
for i in range(n):
  b,c=map(int,input().split())
  a.append([b,0]);a.append([c,1])
a.sort(reverse=1)
i=b=0
while h>0:
  if a[i][1]==1:h-=a[i][0];b+=1
  else:b+=(h-1)//a[i][0]+1;h=0
  i+=1
print(b)

Measured memory_bytes: 30664
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long  n,a,b,c,d,e,ans=0;
    cin>>n>>a>>b>>c>>d>>e;
    long long  mn=min(a,min(b,min(c,min(d,e))));
    ans=((n+mn-1)/mn)+4;
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int A, B; cin >> A >> B;
    string S; cin >> S;

    bool ans = true;
    for (int i = 0; i < S.size(); i++) {
        if (i == A) {
            if (S[i] != '-') {
                ans = false;
            }
        } else {
            if (S[i] < '0' || '9' < S[i]) {
                ans = false;
            }
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 110;

ll n,sumd,sumh;
ll cx,cy,H;
ll x[maxn],y[maxn],h[maxn],dis[maxn];

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

int main(){
	n=read();
	for(int i=1;i<=n;i++) x[i]=read(),y[i]=read(),h[i]=read();
	
	for(ll i=0;i<=100;i++){
		for(ll j=0;j<=100;j++){
			ll th = 0,tr = 1;
			memset(dis,0,sizeof(dis));
			for(int k=1;k<=n;k++){
				dis[k] = abs(x[k] - i) + abs(y[k] - j);
				if(h[k]!=0)	th = h[k] + dis[k];
			}
			for(int k=1;k<=n;k++){
				if(h[k]!=0){
					if((h[k] + dis[k]) != th){
						tr = 0; break;
					}
				}else{
					if(dis[k] < th){
						tr = 0; break;
					}
				}
			}
			if(!tr) continue;
			else{
				printf("%lld %lld %lld\n",i,j,th);
				return 0;
			}
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 3736
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    if(N < 10) {
        cout << N << endl;
    } else if(N < 100) {
        cout << 9 << endl;
    } else if(N < 1000) {
        cout << N - 90 << endl;
    } else if(N < 10000) {
        cout << 909 << endl;
    } else if(N < 100000) {
        cout << N - 9090 << endl;
    } else {
        cout << 90909 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
import java.lang.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt(),
            k=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++)
            a[i]=sc.nextInt();
        long[] dp=new long[n];
        Arrays.fill(dp,Long.MAX_VALUE);
        dp[0]=0;
        for(int i=0;i<n;i++) {
            for(int j=1;j<=k;j++) {
                if((i+j)<n)
                    dp[i+j]=Math.min(dp[i+j],dp[i]+Math.abs(a[i]-a[i+j]));
            }
        }
        pw.print(dp[n-1]);
        pw.close();
    }
}

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

int main() {
  int r;
  cin >> r;
  const double PI=3.14159265358979323846;
  cout << fixed << setprecision(10);
  cout << 2.0 * PI * (double) r << endl;
  return 0;
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n;
    cin>>n;
    vector<int> ans;
    rep(i,0,n){
        string s1,s2;
        cin>>s1>>s2;
        int c[1001][1001];
        int s1len=s1.size(),s2len=s2.size(),ma=0;
        s1=" "+s1;s2=" "+s2;
        rep(j,0,s1len) c[j][0]=0;
        rep(j,1,s2len)c[0][j]=0;
        rep(k,1,s1len+1){
            rep(z,1,s2len+1){
                if(s1[k]==s2[z]) c[k][z]=c[k-1][z-1]+1;
                else c[k][z]=max(c[k-1][z],c[k][z-1]);
                ma=max(ma,c[k][z]);
            }
        }
        ans.push_back(ma);
    }
    for(auto i:ans)cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 7120
N = int(input())
numbers = [int(i) for i in input().split()]

def build_stairs(N, numbers):
    for i in range(1, N): # 後ろから計算する
        stair1 = numbers[-i]
        stair2 = numbers[-(i + 1)]
        diff_stair = stair1 - stair2
        if diff_stair >= 0:
            pass
        elif diff_stair <= -2:
            return False
        elif diff_stair == -1:
            numbers[-(i + 1)] -= 1
    return True

if build_stairs(N, numbers):
    print('Yes')
else :
    print('No')

Measured memory_bytes: 14396