akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N;
int a[200000], b[200000];
int ans[200001];
int cnt[200001];

map<int, int> mp;

class KMP
{
public:
    string pattern;
    int plen;
    vector<int> table;
    KMP(const string s) : pattern(s), plen((int)pattern.size()), table(plen+1){
        table[0] = -1;
        int j = -1;
        for(int i = 0; i < plen; i++){
            while(j >= 0 && pattern[i] != pattern[j]) j = table[j];
            if(pattern[i+1] == pattern[++j]) table[i+1] = table[j];
            else table[i+1] = j;
        }
    }
    void search(const string& text, vector<int>& res){
        int head = 0, j = 0, tlen = (int)text.size();
        while(head + j < tlen){
            if(pattern[j] == text[head + j]){
                if(++j != plen) continue;
                res.push_back(head);
            }
            head += j - table[j], j = max(table[j], 0);
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }
    for(int i = 0; i < 30; i++){
        int m = (1<<i);
        string A, A_, B;
        for(int j = 0; j < N; j++){
            int a_ = (m&a[j]?1:0);
            int b_ = (m&b[j]?1:0);
            // cout << a_ << ' ' << b_ << endl;
            A += '0'+a_;
            A_ += '1'-a_;
            B += '0'+b_;
        }
        A += A;
        A_ += A_;
        
        vector<int> v;
        KMP kmp(B); 
        kmp.search(A, v);
        for(int j = 0; j < v.size(); j++){
            cnt[v[j]]++;
            // ans[v[j]] += m;
        }
        v.clear();
        // KMP kmp_(A_); 
        kmp.search(A_, v);
        for(int j = 0; j < v.size(); j++){
            cnt[v[j]]++;
            ans[v[j]] += m;
        }
    }
    for(int i = 0; i < N; i++){
        if(cnt[i] == 30){
            cout << i << ' ' << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 7296
using System;

public class Hello{
	public static void Main(){
	  string[] S = Console.ReadLine().Split(' ');
      int a,b,c;
      a=int.Parse(S[0]);
      b=int.Parse(S[1]);
      c=int.Parse(S[2]);
      if((a==b&&a!=c)||(b==c&&c!=a)||(c==a&&a!=b)){
        Console.WriteLine("Yes");
      }
      else Console.WriteLine("No");
	}
} 


Measured memory_bytes: 13140
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int C[] = new int[N+1];
        int A[][] = new int[N+1][M+1];
        for(int i=1; i<=N; i++) {
            C[i] = sc.nextInt();
            for(int t=1; t<=M; t++) {
                A[i][t] = sc.nextInt();
            }
        }

        int minPrice = Integer.MAX_VALUE;
        for(int p=0; p<(1 << N); p++) {
            int score[] = new int[M+1];
            int price = 0;
            for(int n=1; n<=N; n++) {
                if(!isOn(p, n-1)) continue;
                price+=C[n];
                for(int m=1; m<=M; m++) {
                    score[m] += A[n][m];
                }
            }
            // check threshold
            boolean flag = false;
            for(int m=1; m<=M; m++) {
                if(score[m]<X) {
                    flag = true;
                    break;
                }
            }
            if(flag) continue;
            if(minPrice > price) {
                minPrice = price;
            }
        }
        if(minPrice != Integer.MAX_VALUE) {
            System.out.println(minPrice);
        } else {
            System.out.println(-1);
        }
    }

    static boolean isOn(long judge, int index) {
        return ((1 << index) & judge) == (1 << index);
    }
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string n;
	cin >> n;
	int digits = n.size();
	int x = -1;
	bool y = false;
	FOR(i,0,digits){
		if(n[i] < '9'){
			if(x == -1){
				x = i;
			}else{
				y = true;
				break;
			}
		}
	}
	if(x == -1){
	}else if(x == digits-1 && digits > 1){
		n[digits-2]--;
		n[digits-1] = '9';
	}else if(y){
		n[x]--;
		FOR(i,x+1,digits){
			n[i] = '9';
		}
	}
	int ans = 0;
	FOR(i,0,digits)
		ans += n[i] - '0';
	//ANS(n);
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	int c = 0;
	for (; s;)
	{
		c += s % 10 ? 1 : 0;
		s /= 10;
	}

	cout << c << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll,ll>pll;

int main(){
	int n,k;
	cin >> n >> k;
	vector<int>v(n);
	rep(i, 0, n)cin >> v[i];

	ll ans = -inf;
	for (int l = 0; l <= k; l++) {
		for (int r = 0; r <= k; r++) {
			if (l + r > k)continue;
			vector<int>temp;
			ll sum = 0;
			if (l + r <= n) {
				rep(i, 0, l)temp.pb(v[i]);
				rep(i, 0, r)temp.pb(v[n - 1 - i]);
				sort(all(temp));
				rep(i, 0, k - l - r) {
					if(temp.size() > 0 && temp[0] < 0)temp.erase(temp.begin());
				}
			}
			else {
				temp = v;
				sort(all(temp));
				rep(i, 0, k - n) {
					if (temp.size() > 0 && temp[0] < 0)temp.erase(temp.begin());
				}
			}
			fore(x, temp)sum += x;
			ans = max(sum, ans);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

signed main() {
  vector<long long> r(87);
  r[0] = 2;
  r[1] = 1;
  for (int i = 2; i < 87; ++i) {
    r[i] = r[i - 1] + r[i - 2];
  }

  int n;
  cin >> n;
  cout << r[n] << endl;
}


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

int main(){
    int n;
    while(cin >> n, n!=0){
        vector<int> score(n, 0);
        for(int i=0; i < n; i++) cin >> score[i];
        sort(score.begin(), score.end());
        int total = 0;
        for(int i=1; i < n-1; i++) total += score[i];
        cout << total/(n-2) << endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    rep(i, 5) {
        int x;
        cin >> x;
        if (!x) cout << i + 1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    int N;
    while(cin>>N,N){
        string s;
        cin>>s;
        int cd[15] = {};
        int fi = 0;
        int now = 0;
        for(int i = 0;i < s.size();i++){
            if(s[i] == 'M')cd[now]++;
            if(s[i] == 'S')fi += cd[now]+1,cd[now] = 0;
            if(s[i] == 'L')cd[now] += fi+1,fi = 0;
            now++;
            now %= N;
        }
        sort(cd,cd+N);
        cd[N] = fi;
        cout<<cd[0];
        for(int i = 1;i <= N;i++)cout<<" "<<cd[i];
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 1228
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
    r = p = i = 1
    try:
        while True:
            x = c.get(i)
            r = r * pow(p, x, M) % M
            p = x; n -= p; i += 1
    except:
        pass
print((r, 0)[n > 1])


Measured memory_bytes: 22636
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //cout << fixed << setprecision(7);
    
    int N; cin >> N;
    ll a[100010];
    ll ans=0;
    for(int i=0; i<N; ++i){
        cin >> a[i];
        ans += a[i]-1;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
k_list = []
a_list = []
for _ in range(n):
    k, *a = map(int, input().split())
    k_list.append(k)
    a_list.append(a)
    
ans = [0]*m
for i in range(m):
    for j in range(len(k_list)):
        if i+1 in a_list[j]:
            ans[i] += 1
if max(ans) == n:
    print(ans.count(n))
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
  ll n,m;   cin >> n >> m;

 
  vector<ll>a(m);
  priority_queue<ll>b;
  ll all=0;
  for(int i=0;i<m;i++){
      cin >> a.at(i);
  }
   if(n>=m){
      cout << 0 << endl;
      return 0;
  }
  sort(a.begin(),a.end());

  for(int i=0;i<m-1;i++){
      b.push(a.at(i+1)-a.at(i));
      all+=a.at(i+1)-a.at(i);
  }
  for(int i=1;i<n;i++){
      int c;
      c=b.top();
      b.pop();
      all-=c;
  }
  cout << all << endl;
  
}

Measured memory_bytes: 2168
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    a, b, c, d = map(int, input().split())

    left = a + b
    right = c + d

    if left > right:
        print("Left")
    elif left == right:
        print("Balanced")
    else:
        print("Right")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
//#define REP(i,a,b) for(int i=a;i<=b;i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
long long MOD=1e9+7;

int main()
{	
	ios_base:: sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	int i,art[n];
	for(i=0;i<n;i++){
		cin>>art[i];
	}
	for(i=0;i<n;i++){
		if(art[i]%2==0){
			if(art[i]%3==0 || art[i]%5==0) {}
			else break;
		}
	}
	if(i==n) cout<<"APPROVED";
	else cout<<"DENIED";
}


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

int main(){
    int n, sum=0;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    rep(i, n){
        for(int j=i+1; j<n; j++){
            sum += d[i]*d[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
char ch[100010], a[100010];
int main() {
	scanf ("%s", ch + 1);
	int len = strlen (ch + 1);
	for (int i = 1; i <= len; i++)  a[i] = ch[len-i+1];
	for (int i = 1; i <= len; i++) {
		if (a[i] == 'b') a[i] = 'd';
		else if (a[i] == 'd') a[i] = 'b';
		else if (a[i] == 'p') a[i] = 'q';
		else if (a[i] == 'q') a[i] = 'p';
	}
	for (int i = 1; i <= len; i++) if (a[i] != ch[i]) {puts ("No"); return 0;}
	puts ("Yes");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b; cin >> a >> b;
  int X = 0;
  for(int i = 0; i < max(a,b); ++i){
    int x = pow(10.0, i);
    X += x;
  }
  
  cout << min(a,b)*X << endl;
}

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

int main () {
	int x; 
	cin >> x;
	long ans;
	if(x >= 500) {
		ans = (x / 500) * 1000;
		x %= 500;
		ans += (x / 5) * 5;
	}else {
		ans = (x / 5) * 5;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
n=gets.chomp.to_i
s=gets.chomp.split("").map { |e| e.to_s }

max = 0

(n-1).times do |i|
  sl = s.slice(0..i).uniq
  sr = s.slice(i+1..n-1).uniq
  leng = sl.length
  count = 0

  leng.times do |j|
    if sr.include?(sl[j])
      count += 1
    end
  end


 max = max > count ? max : count

end

puts max


Measured memory_bytes: 1788
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

D = INT()
print("Christmas ", end ="")
for _ in range(25-D):
	print("Eve ",end="")

print()

Measured memory_bytes: 5148
# B - Card Game for Two
N = int(input())
A = [int(a) for a in input().split()]

A= sorted(A,reverse=True)
Alice = 0
Bob = 0
for i in range(N):
    if i%2==0:
        Alice+=A[i]
    else:
        Bob+=A[i]
print(Alice-Bob)

Measured memory_bytes: 3060
# https://atcoder.jp/contests/abc063/tasks/abc063_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    S = list(input())
    L = set(S)
    print('yes' if len(S) == len(L) else 'no')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < n; i++)
 
int main(void){
    ll n;
    cin >> n;
 
    ll l[n];
    rep(i, n){
        cin >> l[i];
    }
 
    sort(l, l + n);
 
    ll count = 0;
    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            for(int k = n - 1; k > j; k--){
                if(l[i] + l[j] > l[k]){
                    count += k - j;
                    break;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
const int N=2e5+5;
int n,now,ans,res,a[N],b[N],v[N],f[N],g[N],vi[N],nex[N],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
vector<int>d[N];
queue<int>que;
void dfs(int x,int fa){
	if(b[x]==1)	return ;
	for(int i=head[x];i;i=nex[i])
		if(v[i]!=fa){
			dfs(v[i],x);
			if(f[v[i]]>f[x])	g[x]=f[x],f[x]=f[v[i]];
			else	if(g[x]<f[v[i]])	g[x]=f[v[i]];
		}
	if((b[x]&1)==a[x])	f[x]+=2;
	res=max(res,f[x]+g[x]);
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		d[x].push_back(y),++b[x];
		d[y].push_back(x),++b[y];
	}
	for(int i=1;i<=n;i++){
		char ch=getchar();
		while(ch!='B'&&ch!='W')	ch=getchar();
		a[i]=ch=='B';
	}
	for(int i=1;i<=n;i++)
		if(b[i]<2&&a[i])	que.push(i);
	while(!que.empty()){
		int x=que.front();
		int si=d[x].size();
		que.pop(),vi[x]=1;
		for(int i=0;i<si;i++){
			int v=d[x][i];
			if((--b[v])==1&&a[v])	que.push(v);
		}
	}
	for(int i=1;i<=n;i++)	b[i]=0;
	for(int i=1;i<=n;i++){
		if(vi[i])	continue;
		int si=d[i].size();
		for(int j=0;j<si;j++){
			int v=d[i][j];
			if(!vi[v])	addedges(i,v),++b[i];
		}
		ans+=b[i];
		if((b[i]&1)==a[i])	++ans;
	}
	for(int i=1;i<=n;i++)
		if(b[i]>1){
			dfs(i,i); break;
		}
	printf("%d\n",ans-res);
}


Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
int osikomi(int s[]){
	for(int i = 0;i<100;i++){
		if(s[i] == 0){
			s[i] = s[i+1];
			s[i+1] = 0;
		}
	}
}
int main(){
    int l, i=0;
    int s[200] = {};
    string x;

    while(cin>>x){
    	for(int i = 0;i<50;i++){
    		osikomi(s);
    	}
    //	cout<<"i"<<i<<endl;
    	if(x == "+"){
   	for(int i = 100;i>0;i--){
   		if(s[i] != 0){
   			s[i-1] += s[i];
   			s[i] = 0;
   			break;
   		}
   	}i--;
    //	cout<<"+"<<endl;
    	}
    	else if(x == "/"){
   		for(int i = 100;i>0;i--){
   			if(s[i] != 0){
   			s[i-1] /= s[i];
   			s[i] = 0;
   			break;
   			}
   		}
   		i--;
 	   	
  
    	//	cout<<"/"<<endl;
    	}
    	else if(x == "-"){

  		for(int i = 100;i>0;i--){
   		if(s[i] != 0){
   			s[i-1] -= s[i];
   			s[i] = 0;
   			break;
   		}
   	}i--;
    //		 cout<<"-"<<endl;

    	}
    	else if(x == "*"){
 		 for(int i = 100;i>0;i--){
   			if(s[i] != 0){
   				s[i-1] *= s[i];
   				s[i] = 0;
   				break;
   			}
   		}i--;
    	//	cout<<"*"<<endl;
    	}
    	else{
    		s[i] = stoi(x);
   		}
    	osikomi(s);
    	i++;
    //	for(int i = 0;i<10;i++){
   // 		cout<<s[i]<<" ";
   // 	}
   // 	cout<<endl;
    }
    cout<<s[0]<<endl;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a[n][m];
  for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin>>a[i][j];
  int b[m];
  for (int i = 0; i < m; ++i) cin>>b[i];
  for (int i = 0; i < n; ++i)
  {
    int t=0;
    for (int j = 0; j < m; ++j)
    {
      t+=a[i][j]*b[j];
    }
    cout<<t<<endl;
  }
}


Measured memory_bytes: 3124
N,A,B=map(int,input().split())
ttl,a,b=0,0,0
L=[]
for i in range(1,N+1):
  L=list(map(str,str(i)))
  for j in L:
    a=a+int(j)
  if B>=a>=A:
    ttl=ttl+i
  a=0
  L=[]
print(ttl)

Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long  i = 0; i < (long long)(n); i++)






int main() {
	int s,k;
		
	cin >> s>>k;
	
	
	

		cout << max(max(s+k,s+s-1),k+k-1)<< endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, int> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;

int main(void){
    string S;
    cin >> S;
    int N = S.size();
    
    int cntW = 0, cntB = 0;
    int firstW = -1;
    for(int i = 0; i < N; i++){
        if(S.at(i) == 'W'){
            cntW++;
            if(cntW == 1){
                firstW = i;
            }
        }else{
            cntB++;
        }
    }
    vector<int> W(cntW);
    int cnt = 0;
    int j = 0;
    for(int i = 0; i < N; i++){
        if(S.at(i) == 'B'){
            cnt++;
        }else{
            W.at(j) = cnt;
            j++;
        }
    }
    
    ll ans = 0;
    for(int i = 0; i < W.size(); i++){
        ans += W.at(i);
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll x, ans = 0;
  cin >> x;
  for (int i = 1; i <= x; ++i) {
    ans += (x / i) * (2 * i + (x / i - 1) * i) / 2;
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3568
NM=input().split()
M=int(NM[1])
a=input().split()
a_list=[]
for i in a :
  a_list.append(int(i))
a_list.sort(reverse=True)
sum1=sum(a_list)
 
flag=True
for i,youso in enumerate(a_list) :
  if(youso*4*M<sum1 and i+1<=M) :
    flag=False
    break
    
if flag==True :
  print('Yes')
else :
  print('No')

Measured memory_bytes: 38384
function main(input) {
  input=input.trim();
  const n = parseInt(input.split(" ")[0], 10);
  var arr=[];
  for(var i=0; i<=25; i++){
    for(var j=0; j<=15; j++){
      arr.push(4*i+7*j)
    }
  }
  if(arr.indexOf(n)>=0){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;
int A[100004], n;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	f(i, n) cin>>A[i];
	sort(A, A+n);
	int cnt=0;
	int prev=A[0];
	F(i, n-1){
		if (A[i]==prev) cnt++;
		prev=A[i];
	}
	cout<<n-(2*((cnt+1)/2))<<endl;
	return 0;
}


Measured memory_bytes: 640
// atcoder/code-festival-2016-qualb/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n, a, b;
  str s;
  while (cin >> n >> a >> b >> s) {
    int c = 0;
    int d = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == 'a' && c + d < a + b) {
        cout << "Yes" << endl;
        ++c;
        continue;
      }
      if (s[i] == 'b' && c + d < a + b && d < b) {
        cout << "Yes" << endl;
        ++d;
        continue;
      }
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 848
//ProblemD.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemD.cpp

/*
a[1] = a, b[1] = b, c[1] = c

a[n+1] = a[n]*a = a^n
b[n+1] = a[n]*b + b[n]*c
c[n+1] = c[n]*c = c^n

-> b[n+1] = b(a^(n-1) + b(a^(n-2))+...+b^(n-1))
          = b * (a^n - c^n)) / (a - c)
		  = b * (a^n - c^n) * k
		  ((a-c) * k = 1(mod p))

x[n+1] = a[n+1] - b[n+1]
*/

#define MOD 1000000007

static s64 getpow(s64 a, s64 x, s64 m = MOD) {
	if (x == 0) return 1;
	a = a % m; if (a < 0) a += m;

	s64 mul = a;
	s64 rst = 1;
	while (x)
	{
		if (x & 1) rst = rst * mul % m;

		x >>= 1;
		mul = mul * mul % m;
	}
	return rst;
}

#define MAXSIZE 1010

int main(int argc, char* argv[])
{
	OPENOJIO;

	int h, w;
	s64 k;
	ip >> h >> w >> k;

	s64 a, bx, cx, by, cy;
	a = bx = cx = by = cy = 0;

	static int s[MAXSIZE][MAXSIZE];
	for(int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			char tc; 
			ip >> tc;
			s[i][j] = tc == '#';
			a += s[i][j];
		}

	for (int i = 0; i < h; ++i) {
		if (s[i][0] && s[i][w - 1]) ++cx;
		for (int j = 0; j < w - 1; ++j)
		{
			if (s[i][j] && s[i][j + 1]) ++bx;
		}
	}

	for (int j = 0; j < w; ++j) {
		if (s[0][j] && s[h - 1][j]) ++cy;
		for (int i = 0; i < h - 1; ++i) {
			if (s[i][j] && s[i + 1][j]) ++by;
		}
	}

	s64 rst = 1;
	if (k <= 1) rst = 1;
	else if (cx > 0 && cy > 0) rst = 1;
	else if (cx == 0 && cy == 0) {
		rst = getpow(a, k - 1);
	}
	else {
		s64 b, c;
		if (cx > 0) { b = bx; c = cx; }
		else { b = by; c = cy; }

		s64 ak = getpow(a, k - 1);
		s64 ck = getpow(c, k - 1);

		s64 a_c = a - c;
		s64 inv = getpow(a_c, MOD - 2);
		s64 bk = (ak - ck) % MOD * b % MOD * inv % MOD;

		rst = (ak - bk) % MOD;
		if (rst < 0) rst += MOD;
	}

	cout << rst << endl;

	return 0;
}
/***************************************************************/


Measured memory_bytes: 4224
/*
author : seryu
title : ABC168A_"Therefore"
*/
#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 mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;


void solve()
{
	int n;
	cin >> n;
	n %= 10;
	if(n == 3)cout << "bon" << endl;
	else if(n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
	else cout << "hon" << endl;
	return;	
}

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    string S;
    cin >> S;
    long long sum = 0;
    
    vector<int> left(S.length() + 1, 0), right(S.length() + 1, 0);
    rep(i,S.length()) {
        left[i + 1] = S[i] == '<' ? left[i] + 1 : 0;
        right[S.length() - i - 1] = S[S.length() - i - 1] == '>' ? right[S.length() - i] + 1 : 0;
    }

    rep(i,S.length()+1) sum += max(left[i], right[i]);

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4740
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

kill = 0
rest = A[0]  
for i in range(N):
  if B[i] >= rest + A[i+1]:
    kill = kill + rest + A[i+1]
    rest = 0
  else:
    kill = kill + B[i]
    rest = rest + A[i+1] - B[i]
    if rest > A[i+1]:
      rest = A[i+1]

print(kill)

Measured memory_bytes: 19116
import java.util.*;
// import java.io.*;

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

        int num_query = sc.nextInt();

        ArrayList<Integer> front = new ArrayList<>();
        ArrayList<Integer> rear = new ArrayList<>();

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < num_query; i++) {
            int query_type = sc.nextInt();
            int d, x, p;
            switch (query_type) {
                case 0:
                    d = sc.nextInt();
                    x = sc.nextInt();
                    if (d == 0) front.add(x);
                    else rear.add(x);
                    break;
                case 1:
                    p = sc.nextInt();
                    int tmp;
                    if (p < front.size()) tmp = front.get(front.size() - 1 - p);
                    else tmp = rear.get(p - front.size());
                    sb.append(String.format("%d\n", tmp));
                    break;
                case 2:
                    d = sc.nextInt();
                    if (d == 0) {
                        if (front.isEmpty()) {
                            rear.remove(0);
                        } else {
                            front.remove(front.size() - 1);
                        }
                    } else {
                        if (rear.isEmpty()) {
                            front.remove(0);
                        } else {
                            rear.remove(rear.size() - 1);
                        }
                    }
                    break;
                default:
                    return;
            }
        }

        System.out.print(sb.toString());
        
        sc.close();
    }
}



Measured memory_bytes: 300992
n, m = gets.split().map(&:to_i)
sw = []
m.times do 
  sw << gets.split().map(&:to_i)
end

p = gets.split().map(&:to_i)
ans = 0

(0..2**n-1).each do |i|
  lightOn = []
  flag = true
  i.to_s(2).rjust(n, '0').split('').each_with_index do |bit, index|
    lightOn << index + 1 if bit == '1'
  end
  sw.each_with_index do |array, index|
    onNumbers = 0
    array[0].times do |n|
      onNumbers += 1 if lightOn.include?(array[n+1])
    end
    flag = false if onNumbers % 2 != p[index] 
  end
  ans += 1 if flag
end

puts ans

Measured memory_bytes: 1916
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

if v<=w:
  print("NO")
  exit()
  
dis = abs(a-b)
vdis = v-w
time = dis/vdis
if time <= t:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 9032
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[None]*len(h)
dp[0]=0

for i in range(1,k+1):
  if i<=n-1:
    dp[i]=abs(h[i]-h[0])

for i in range(k+1,n):
  distance=float('inf')
  for j in range(1,k+1):
    if i-j>=0:
      distance=min(distance,dp[i-j]+abs(h[i]-h[i-j]))
  dp[i]=distance
  
print(dp[-1])

Measured memory_bytes: 85676
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    int n;
    cin >> n;
    //1,2,3

    int ki = (n+1)/2;

    double res = (double)ki / (double)n;

    printf("%.8f\n",res);



    return 0;    
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	int n,i,j,a,b,c=0,t;
	vector<int> v;
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> a;
		v.push_back(a);
	}
	for(i=0;i<n;i++)
	{
		if(i==0&&v[i]==1)
		{
			for(j=1;j<n;j++)
			if(v[j]!=1)
			{t=v[i];v[i]=v[j];v[j]=t;c+=j;break;}
		}
		else if(i==n-1&&v[i]==n)
		{
			for(j=n-2;j>=0;j--)
			if(v[j]!=n)
			{t=v[i];v[i]=v[j];v[j]=t;c+=n-1-j;break;}
		}
		else if(i<n-1&&i>0)
		{
			if(i+1==v[i])
			{
				for(j=i+1;j<n;j++)
				if(v[j]!=i+1)
				{a=j;break;}
				for(j=i-1;j>=0;j--)
				if(v[j]!=i+1)
				{b=j;break;}
				if(a-i>i-b) j=b;
				else j=a;
				{t=v[i];v[i]=v[j];v[j]=t;c+=abs(j-i);}
			}
		}
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main(){
	int m,n;
	int i,j,k,l;
	int found,end;
	scanf("%d %d",&n,&m);
	
	char M[m][m];
	char N[n][n];
	
	for(i=0;i<n;i++) scanf("%s",N[i]);
	for(i=0;i<m;i++) scanf("%s",M[i]);

	end = 0;
	for(i=0;i<=n-m&&end==0;i++){
		for(j=0;j<=n-m&&end==0;j++){
			found = 1;
			for(k=0;k<m&&found==1;k++){
				for(l=0;l<m&&found==1;l++){
					//printf("%d,%d(%c),%d,%d(%c)\n",i+k,j+l,N[i+k][j+l],k,l,M[k][l]);
					if(N[i+k][j+l]!=M[k][l]) found = 0;
				}
			}
			if(found == 1){
				end = 1;
				break;	
			}
		}
	}
	
	if(found == 1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

int main() {
	ll n;
	cin >> n;
	vector<vector<pair<ll, ll>>> v;
	vector<ll> a;
	for (ll i = 0; i < n; ++i) {
		vector<pair<ll, ll>> vv;
		ll ai;
		cin >> ai;
		a.push_back(ai);
		for (ll j = 0; j < ai; ++j) {
			pair<ll, ll> p;
			cin >> p.first >> p.second;
			--p.first;
			vv.push_back(p);
		}
		v.push_back(vv);
	}
	ll ans = 0;
	for (ll bit = 0; bit < (1 << n); ++bit) {
		bool flag = true;
		ll preans = 0;
		for (ll i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				++preans;
				for (auto p : v[i]) {
					if ((1 << p.first) & bit) {
						if (p.second == 0)flag = false;
					}
					else {
						if (p.second == 1)flag = false;
					}
				}
			}
		}
		if (flag)ans = max(ans, preans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll x,y,z;
  cin >> x >> y >> z;
  cout << z << " " <<  x << " " << y << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char a[1];	
  scanf("%c", a);
  int i;
  
  char O[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

  for(i = 0; i < 52; i++){
    if(i < 26 && O[i] == a[0]){
      printf("A");
      break;
    }else if(i > 25 && O[i] == a[0]){
      printf("a");
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1588
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A,B;
	cin >> A >>B;
	if (A < 6) {
		cout << 0 << endl;
	}
	else if (6 <= A && A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << B << endl;
	}

	return 0;
}



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

using namespace std;

long long int  gcd(long long int a, long long int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {

    long long int A, B, C, D;

    std::cin >> A >> B >> C >> D;

    long long int dByDB = B / D;
    long long int dByCB = B / C;
    long long int dByDCB = B / ((D * C)/gcd(D,C));

    long long int Bpart = B - (dByDB + dByCB - dByDCB);

    long long int dByDA = (A - 1) / D;
    long long int dByCA = (A - 1) / C;
    long long int dByDCA = (A - 1) / ((D * C)/gcd(D,C));

    long long int Apart = (A - 1) - (dByDA + dByCA - dByDCA);
    
    std::cout << (Bpart - Apart) << "\n";


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M ((int)1e9+7)
vector<int> SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
	vector<int> an;  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          an.push_back(p);//cout << p << " "; 
    return an;
}
int main() {
    // your code goes here
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    int a[n],an=0;
    for(int i=0;i<n;i++)
    	{cin>>a[i];an=__gcd(an,a[i]);}
    if(an!=1)	{cout<<"not coprime";return 0;}
    bool vis[1000000];
    memset(vis,false,sizeof(vis));
    vector<int> pr=SieveOfEratosthenes(1000);
    bool pc=true;
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<pr.size();j++)
    	{
    		if(a[i]%pr[j])	continue;
    		if(vis[pr[j]])	pc=false;
    		else vis[pr[j]]=true;
    		while(a[i]%pr[j]==0)
    			a[i]/=pr[j];
    	}
    	if(a[i]!=1)	
    	{
    		if(vis[a[i]])	pc=false;
    		else vis[a[i]]=true;
    	}
    }
    if(pc)	cout<<"pairwise coprime";
    else	cout<<"setwise coprime";
    return 0;
}

Measured memory_bytes: 8488
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 16:44:19 2020

@author: shinba
"""

S = input()
T = S[::-1]

L = len(S)//2 
ans = 0

for i in range(L):
    if S[i] != T[i]:
        ans += 1

print(ans)
    


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

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

    bool first = true;
    std::string w;
    std::vector<std::string> ws;
    bool yes = true;
    char buf;
    for (int i = 0; i < n; i++) {
        std::cin >> w;
        if (not first) {
            if (w.at(0) != buf) {
                yes = false;
                break;
            }
        }
        first = false;
        buf = w.at(w.size() - 1);
        if (std::find(ws.begin(), ws.end(), w) != ws.end()) {
            yes = false;
            break;
        }
        ws.emplace_back(w);
    }
    std::cout << (yes ? "Yes" : "No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
import collections
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
Q=int(input())
B=[0]*Q;C=[0]*Q
for i in range(Q):
  B[i],C[i]=map(int,input().split())

D = collections.Counter(A)
s=sum(A)
for i in range(Q):
  s=s-B[i]*D[B[i]]
  D[C[i]]+=D[B[i]]
  s=s+C[i]*D[B[i]]
  D[B[i]]=0
  print(s)

Measured memory_bytes: 30068
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

S = S()
N = len(S)
T = S[0:(N - 1) // 2]
U = S[(N + 3) // 2 - 1:N]
if S == S[::-1] and T == T[::-1] and U == U[::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 74588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]){
    		String result = "red";
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            int a = Integer.parseInt(br.readLine());
            String s = br.readLine();
            if (a >= 3200) {
            		result = s;
            }    
        } catch (Exception e) {
            //TODO: handle exception
        }
        
        System.out.println(result);
    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  string s="No";
  if(a==b && a!=c) s="Yes";
  if(a==c && a!=b) s="Yes";
  if(c==b && a!=c) s="Yes";
  cout << s << endl;
}


Measured memory_bytes: 256
open Printf
open Scanf

let n, k = scanf "%d %d\n" (fun n k -> n, k)
let alist = Array.init n (fun _ -> scanf " %d" (fun x -> x))

let run () =
    for i = k to n - 1 do
        let x = alist.(i - k) in
        let y = alist.(i) in
        print_endline (if x < y then "Yes" else "No")
    done

let () = run ()


Measured memory_bytes: 7448
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int[] a={sc.nextInt(),sc.nextInt(),sc.nextInt()};
			if(a[0]==0&&a[1]==0&&a[2]==0){
				break;
			}
			Arrays.sort(a);
			double d=Math.hypot(a[0],a[1])/2;
			int n=sc.nextInt();
			for(int i=0;i<n;i++){
				 System.out.println(sc.nextInt()>d?"OK":"NA");
			}
		}
	}
}

Measured memory_bytes: 17216
// 582 F Next Level DSU
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second     
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define mp make_pair
#define int long long
#define double float

using namespace std;
template <typename T>
void watch(vector<T> v)
{
    for(int i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    cout<<"Look above\n";
    cout<<"\n";
}
const int INF = 1e15;
const int MAX = 2e5+3;
int MOD = 998244353;

int32_t main()
{
      int n;
      cin>>n;
      vector<int> v(n);
      for(int i=0;i<n;i++)
         cin>>v[i];
      int mx = 0;
      for(int i=0;i<n;i++)
      {
         int cnt = 0;
         while(i+1 < n && v[i] >= v[i+1])
         {
            cnt++;
            i++;
         }
         mx = max(mx, cnt);
      }
      cout<<mx;

}



Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int sum[] = new int[s.length() - 2];
        for (int i = 0; i < s.length() - 2; i++) {
            int l = Character.getNumericValue(s.charAt(i));
            int m = Character.getNumericValue(s.charAt(i + 1));
            int n = Character.getNumericValue(s.charAt(i + 2));
            sum[i] = Math.abs(l * 100 + m * 10 + n - 753);
        }
        Arrays.sort(sum);
        System.out.println(sum[0]);
    }
}

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

int main()
{
    int n; cin>>n;
    string s, t;
    cin>>s>>t;
    
    const long mod=1e9+7;
    long res=1;
    int i=0;
    while (i<n) {
        if (s[i]==t[i]) {
            if (i==0)
                res=3;
            else if (s[i-1]==t[i-1])
                res*=2;
            ++i;
        }
        else {
            if (i==0)
                res=6;
            else if (s[i-1]==t[i-1])
                res*=2;
            else
                res*=3;
            i+=2;
        }
        res%=mod;
    }
    cout<<res<<endl;
}




Measured memory_bytes: 256
main(c,t){double*p=t,v,atof();for(;t=0,~scanf("%s%c",&t,&c);c&2&&printf("%f\n",*p))v=t<48?*--p=t&1?t&2?t&4?*p/v:*p+v:*p-v:*p*v:(*++p=atof(&t));}

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

int main() {
    string s; cin >> s;
    int res = 0;
    for (int i = 0; i < s.size(); i++) {
        int counter = 0;
        for (int j = i; j < s.size(); j++) {
            if (s[j] == 'A' || s[j] == 'T' || s[j] == 'G' || s[j] == 'C') {
                counter++;
            } else break;
        }
        res = max(res, counter);
    }
    cout << res << endl;
    return 0;
}


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

struct Pair {
	int x;
	int y;
	Pair(int xx,int yy) { x=xx; y=yy; }
};

int main()
{
	int w;						// 縦線の数(1~n)
	int n;						// 横線の数
	int x,y;
	int line_now;				// あみだの現在位置
	char comma;
	vector<Pair> pairs;			// 横線の移動経路を格納する

	cin >> w >> n;
	for(int i=0;i<n;i++) {
		cin >> x >> comma >> y;
		pairs.push_back(Pair(x,y));
	}
	vector<int> goals(w);			// [i]にi+1本目のあみだの値を格納
	for(int i=0;i<w;i++) {
		line_now = (i+1);
		for(int j=0;j<n;j++) {
			if(pairs[j].x==line_now)
				line_now = pairs[j].y;
			else if(pairs[j].y == line_now)
				line_now = pairs[j].x;
		}
		goals[line_now-1] = (i+1);
	}

	for(int i=0;i<goals.size();i++)
		cout << goals[i] << endl;

	return 0;
}

Measured memory_bytes: 1200
import sys
input = sys.stdin.readline
def main():
    N, D = map(int, input().split())
    C = [list(map(int, input().split())) for i in range(N)]
    CNT = 0
    for x, y in C:
        d = x**2 + y**2
        if d <= D**2:
            CNT += 1
    print(CNT)

if __name__ == '__main__':
    main()

Measured memory_bytes: 45328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  int part_sum = 0;
  int ans = 1;
  while(part_sum + A < B){
    part_sum += A - 1;
    ans++;
  }
  if(B==1){
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256