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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

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

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

const int max_n = 100001;
vector< bool > is_prime(max_n, true);
void init()
{
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= max_n; ++i)
    {
        if (is_prime[i])
        {
            for (int j = i + i; j <= max_n; j += i) is_prime[j] = false;
        }
    }
}

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

    init();

    int sum[max_n + 1];
    sum[0] = 0;
    for (int i = 0; 2 * i + 1 <= max_n; ++i)
    {
        int num = 2 * i + 1;
        sum[num] = sum[num - 1] + (is_prime[num] && is_prime[i + 1]);
        if (num + 1 <= max_n) sum[num + 1] = sum[num];
    }

    int q;
    cin >> q;
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << "\n";
    }

    return 0;
}



Measured memory_bytes: 1024
A = list(map(int, input().split()))
ans_1 = A[0]*A[2]
ans_2 = A[0]*A[3]
ans_3 = A[1]*A[2]
ans_4 = A[1]*A[3]
answers = [ans_1,ans_2,ans_3,ans_4]
print(max(answers))

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

void s_sort(int *a,int N);

int main(){
	int N;
	int a[100];
	cin >> N;
	
	for(int i = 0;i < N;i++){
		cin >> a[i];
	}
	s_sort(a,N);
}

void s_sort(int *a,int N){
	int minj = 0;
	int t = 0;
	int count = 0;
	for(int i = 0;i < N;i++){
		minj = i;
		for(int j = i+1;j < N;j++)	{
			if(a[minj] > a[j]) minj = j;
			}
			if(i != minj){
				t = a[i];
				a[i] = a[minj];
				a[minj] = t;
				count++;
			}		
	}
	for(int k = 0;k < N;k++){
		cout << a[k];
		if(k != N-1) cout << " ";
		else{
			cout << endl;
		}
	}
	cout << count << endl;
}
		

Measured memory_bytes: 3080
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int K = s.nextInt();
        int n = 7 % K;
        for (int i = 1; i <= K + 1; i++) {
            if (n == 0) {
                System.out.println(i);
                break;
            } else if (i == K + 1) {
                System.out.println(-1);
                break;
            }
            n = 7 + (10 * n);
            n = n % K;
        }
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, K;
int main(){
    scanf("%lld%lld", &N,&K);
    printf("%lld", K%N  ? K - N : N + K);
    return 0;
}

Measured memory_bytes: 256
N,*ABC = gets.split.map &:to_i

ans = []
q = nil
readlines.map{_1.chomp}.each do |s|
    a,b,c = s=="AB" ? [0,1,2] : (s=="AC" ? [0,2,1] : [1,2,0])
    l = ABC[a]
    r = ABC[b]
    if l==0 && r==0 then
        puts "No"
        exit
    end

    if l==1 && r==1 && ABC[c]==0 then
        if q then
            ans << q[0]
            ans << q[1]
            q = nil
        else
            q = [a,b]
        end

        next
    end


    if q then
        q.delete c
        ans << q[0]
        ABC[c] -= 1
        ABC[q[0]] += 1
        q = nil
    end

    pm = ABC[a] > ABC[b] ? [b,a] : [a,b] 
    ans << pm[0]
    ABC[pm[0]] += 1
    ABC[pm[1]] -= 1
end

if q then
    ans << q[0]
end


puts "Yes"
ans.map{ "ABC"[_1]}.each{ puts _1 }

Measured memory_bytes: 32516
#include <iostream>

int main()
{
  int r , g, b;

  std::cin >> r >> g >> b;

  int ans = g*10 + b;

  if (ans%4 == 0) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
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();
        long count = 0;
        long wcount = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'W' && i >= wcount) {
                count += i - wcount;
                wcount++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 26580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BAlgae solver = new BAlgae();
        solver.solve(1, in, out);
        out.close();
    }

    static class BAlgae {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int r = s.nextInt(), d = s.nextInt(), x = s.nextInt(), i = 10;
            while (i-- > 0) {
                w.println(x = r * x - d);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23124
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())

      
uf=UnionFind(n)
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  uf.union(a,b)
  
ans=0
for i in range(n):
  ans=max(ans,uf.size(i))
print(ans)

Measured memory_bytes: 14628
#include <iostream>

using namespace std;

const int INF = 1e9+7;
int n, m, x;
int ans = INF;
int c[15];
int a[15][15];

int main() {
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  
  for (int bit = 0; bit < (1 << n); bit++) {
    int up[15] = {};
    int c_sum = 0;
    for (int i = 0; i < n; i++) {
      if (1 & (bit >> i)) {
        c_sum += c[i];
        for (int j = 0; j < m; j++) {
          up[j] += a[i][j];
        }
      }
    }
    bool flag = true;
    for (int j = 0; j < m; j++) {
      if (up[j] < x) flag = false;
    }
    if (flag) ans = min(ans, c_sum);
  }
  
  if (ans == INF) ans = -1;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var bi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var killSum = 0L;
            for (var i = 0; i < bi.Length; i++)
            {
                var kill = Math.Min(ai[i], bi[i]);
                killSum += kill;
                bi[i] -= kill;

                kill = Math.Min(ai[i + 1], bi[i]);
                killSum += kill;
                ai[i + 1] -= kill;
            }
            Console.WriteLine(killSum);
        }
    }
}


Measured memory_bytes: 32328
(stdin => {
  // Define Function
  const smallOrLargeOrEqual = (a, b) => {
    const lessThen = (a, b) => a < b
    const greaterThen = (a, b) => a > b
    
    if (lessThen(a, b)) return 'a < b'
    if (greaterThen(a, b)) return 'a > b'

    return 'a == b'
  }
  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const [a, b] = Array.from(inputs[0].split(' '), Number)

  console.log(smallOrLargeOrEqual(a, b))
})(require('fs').readFileSync('/dev/stdin', 'utf8'))



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

int main() {
    string s;
    cin >> s;
    for (int i=0; i<13; i++) {
        if (i<4) {
            cout << s.at(i);
        } 
        else if (i==4) {
            cout << " ";
        }
        else {
            cout << s.at(i-1);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
  char s[8010];
  int x,y,dpx[4001][16010]={},dpy[4001][16010]={},cnt=0,d=0,n,cntx,cnty;
int main(){

  scanf("%s",s);
  scanf("%d %d",&x,&y);
  n=strlen(s);
  dpx[0][8000]=1;
  dpy[0][8000]=1;
  for(int i=0;i<n;i++){
    if(s[i]=='F')
      d++;
    if(s[i]=='T'||i==n-1){
      if(cnt==0)
        dpx[1][d+8000]=1;
      else if(cnt%2==1){
        for(int j=0;j<=16000;j++)
          if(dpy[cnt/2][j]){
            dpy[cnt/2+1][j+d]=1;
            dpy[cnt/2+1][j-d]=1;
          }
      }
      else
        for(int j=0;j<=16000;j++)
          if(dpx[cnt/2][j]){
            dpx[cnt/2+1][j+d]=1;
            dpx[cnt/2+1][j-d]=1;
          }
      d=0;
      cnt++;
    }
  }
  /*for(int i=0;i<=cnt/2+cnt%2;i++){
    printf("%d\n",i);
    for(int j=0;j<16001;j++){
      if(dpx[i][j]==1)
        printf("x %d\n",j-8000);
      if(dpy[i][j])
        printf("y %d\n",j-8000);
    }
  }*/
  if(dpx[cnt/2+cnt%2][x+8000]&&dpy[cnt/2][y+8000])
    printf("Yes\n");
  else
    printf("No\n");
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n);
    ll sum=0;
    rep(i, n){
        cin>>a[i];
        sum+=a[i];
    }
    ll sum2=0, mini=LONG_LONG_MAX;
    rep(i, n){
        ll sum3 = sum-sum2;
        mini = min(mini, abs(sum2-sum3));
        sum2+=a[i];
    }
    cout << mini << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
priority_queue<int> que;
const ll INF = 10000000000;

int main(){
    int x; cin >> x;
    for(int a=1; a<1000; ++a){
        ll a5 = 1;
        for(int i=0; i<5; ++i){a5 *= a;}
        for(int b=-1000; b<1000; ++b){
            ll b5 = 1;
            for(int i=0; i<5; ++i){b5 *= b;}
            if(a5-b5==x){
                printf("%d %d\n", a , b);
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    string S;
    cin >> S;
    int a = 0, b = 0, c = 0;
    rep(i, 0, S.size()) {
        if(S[i] == 'a') a++;
        else if(S[i] == 'b') b++;
        else c++;
    }

    if(max(a, max(b, c)) - min(a, min(b, c)) > 1) cout << "NO" << endl;
    else cout << "YES" << endl;
}


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

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> b(n-1);
  vector<int> a(n);
  for (int i = 0; i < n-1; i++) {
    cin >> b[i];
  }
  a[0] = b[0];
  a[n-1] = b[n-2];
  for (int i = 1; i < n-1; i++) {
    a[i] = min(b[i], b[i-1]);
  }

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  cout << sum << '\n';
}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size()-1; ++i) {
		if(s[i] == 'A' && s[i+1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	ios::sync_with_stdio(0);
}

Measured memory_bytes: 256
N=int(input())
st = [list(map(str,input().split())) for _ in range(N)]
X = input()
dic = dict()
res = 0
for i in range(N):
    dic[st[i][0]] = res + int(st[i][1])
    res += int(st[i][1])
print(res-dic[X])


Measured memory_bytes: 3060
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int q = sc.nextInt();
		int[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0; i < q; i++){
		    l[i] = sc.nextInt();
		    r[i] = sc.nextInt();
		}
		
		// 計算
		int[] result = new int[100001];
		Prime p = new Prime(100001);
		for(int i = 1; i < result.length; i++){
		    if(i != 2 && p.isPrime(i) && p.isPrime((i+1)/2)){
		        result[i] += result[i-1] + 1;
		    }else{
		        result[i] += result[i-1];
		    }
		}
		
		// 出力
		for(int i = 0; i < q; i++){
		    System.out.println(result[r[i]] - result[l[i]-1]);
		}
	}
}

class Prime {
    int n;
    ArrayList<Integer> primes;
    int[] seive;
    
    public Prime(int n){
        this.n = n;
        int[] seive = new int[n+1];
        Arrays.fill(seive, -1);
        ArrayList<Integer> primes = new ArrayList<Integer>();
        for(int i = 2; i <= n; i++){
            if(seive[i] != -1) continue;
            primes.add(i);
            seive[i] = i;
            for(long j = (long)i*i; j <= n; j += i){
                if(seive[(int)j] == -1) seive[(int)j] = i; 
            }
        }
        this.seive = seive;
        this.primes = primes;
    }
    
    public boolean isPrime(int x){
        return seive[x] == x;
    }
    
    public HashMap<Integer, Integer> factorization(int x){
        HashMap<Integer, Integer> factorization = new HashMap<Integer, Integer>();
        ArrayList<Integer> factorList = factorList(x);
        if(factorList.size() == 0) return factorization;
        for(Integer i : factorList){
            int cnt = factorization.getOrDefault(i, 0);
            factorization.put(i, cnt + 1);
        }
        return factorization;
    }
    
    private ArrayList<Integer> factorList(int x){
        ArrayList<Integer> factorList = new ArrayList<Integer>();
        while(x != 1){
            factorList.add(seive[x]);
            x /= seive[x];
        }
        return factorList;
    }
    
    public HashMap<Integer, Integer> lcmMap(int[] array){
        HashMap<Integer, Integer> lcmMap = new HashMap<Integer, Integer>();
		for(int i = 0; i < array.length; i++){
		    HashMap<Integer, Integer> map = factorization(array[i]);
		    for(Integer key : map.keySet()){
		        lcmMap.put(key, max(lcmMap.getOrDefault(key, 0), map.get(key)));
		    }
		}
        return lcmMap;
    }
    
}




Measured memory_bytes: 94784
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] | [_] -> exit 1
  | a :: b :: _ ->
      let v = compare a b in
      let str = if v = -1 then "a < b"
                else if v = 0 then "a == b"
                else "a > b" in
      Printf.printf "%s\n" str

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class T>
inline void out(T a) {
	cout<<a<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


string S,T;

void input() {
	cin>>S>>T;
}

void solve() {
	if(S==string(rall(T))) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int32_t main()
    {
        ll i,j,k,l,n,m,q,t,max1,min1,flag=0,flag2=0;
        cin>>n;
        for(i=sqrt(n);i>=2;i--)
        {
            if(n%i==0&&flag==0)
            {
                j=i;
                k=n/i;
                flag=1;
            }
        }
        if(flag)
        {
            cout<<j+k-2;
        }
        else
        {
            cout<<n-1;
        }
       return 0;
    }






Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

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

    void solve(Scanner sc) {
        final int INF = 1000000000;
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] costs = new int[n][n];
        for (int[] array : costs) {
            Arrays.fill(array, INF);
        }
        boolean[][] unUsedEdge = new boolean[n][n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            int c = sc.nextInt();
            costs[a][b] = costs[b][a] = c;
            unUsedEdge[a][b] = unUsedEdge[b][a] = true;
        }

        for (int i = 0; i < n; i++) {
            Node curNode = new Node(i, 0);
            ;
            int[] distances = new int[n];
            Arrays.fill(distances, INF);
            distances[curNode.id] = 0;
            PriorityQueue<Node> nodeQueue = new PriorityQueue<>();
            nodeQueue.add(curNode);

            while (!nodeQueue.isEmpty()) {
                Node node = nodeQueue.poll();
                if (distances[node.id] < node.cost) {
                    continue;
                }

                for (int j = 0; j < n; j++) {
                    if (distances[j] > node.cost + costs[node.id][j]) {
                        distances[j] = node.cost + costs[node.id][j];
                        nodeQueue.add(new Node(j, distances[j]));
                    }
                }
            }

            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    if (distances[j] == distances[k] + costs[j][k]) {
                        unUsedEdge[j][k] = unUsedEdge[k][j] = false;
                    }
                }
            }
        }

        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (unUsedEdge[i][j]) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }

    static class Node implements Comparable<Node> {
        int id;
        int cost;

        Node(int id, int cost) {
            this.id = id;
            this.cost = cost;
        }

        public int compareTo(Node o) {
            if (this.cost == o.cost) {
                return 0;
            }

            if (this.cost > o.cost) {
                return 1;
            } else {
                return -1;
            }
        }

        @Override
        public String toString() {
            return "id " + this.id + "cost " + this.cost;
        }
    }
}


Measured memory_bytes: 26460
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << max(0, min(b, d) - max(c, a)) << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

const ll mod = 1e9+7;


int main() {

    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k){
        cout<<n*x<<endl;
        return 0;
    }
    cout<<k*x + (n-k)*y<<endl;

}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	ll a;
	cin>>a;
	ll b = sqrt(a);
	for(int i=b;i > 0;i--){
		if(a%i==0) {cout<<to_string(a/i).size()<<endl;
		return 0;}
	}
}

Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]

ans = ["x"] * n

for i in range(m):
    s, c = [int(x) for x in input().split()]
    if ans[s-1] == "x":
        ans[s-1] = str(c)
    elif ans[s-1] != str(c):
        print("-1")
        exit()

if n >= 2 and ans[0] == "0":
    print("-1")
    exit()

ans = ["0" if x == "x" else x for x in ans]

if n >= 2 and ans[0] == "0":
    ans[0] = "1"

print("".join(ans))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main() {
	string S;
	cin >> S;
	while (S.size() < 15) {
		S.push_back('o');
	}
	int cnt = 0;
	for (char c : S) {
		if (c == 'o')cnt++;
	}
	if (cnt >= 8) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin>>n;
  ll ans=1e11;
  for(ll i=1;i*i<=n;i++){
    if(n%i)continue;
    ll t1=n/i,t2=i;
    ll cnt1=1,cnt2=1;
    while(t1/10)cnt1++,t1/=10;
    while(t2/10)cnt2++,t2/=10;
    ans=min(ans,max(cnt1,cnt2));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

bool CheckRotation180Match(std::string,std::string);

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

    std::string input_word_top;
    std::string input_word_bottom;

    std::cin >> input_word_top >> input_word_bottom;

    if(CheckRotation180Match(input_word_top,input_word_bottom))
        std::cout << "YES" << '\n';
    else
        std::cout << "NO" << '\n';

    return 0;
}

bool CheckRotation180Match(std::string in,std::string other)
{
    for(int index = 0 ; index < in.length() ; index++ )
    {
        if( (in[index] == other[other.length() - 1 - index]) == false )
            return false;
    }
    return true;
}


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

using namespace std;

int main () {
    string str;
    cin>>str;

    bool alp[26] = {0};
    for (int i = 0; i < str.length(); i++) {
        if (alp[str[i] - 'a'] == 0) alp[str[i] - 'a'] = true;
        else {
            cout<<"no"<<endl;
            return 0;
        }
    }
    cout<<"yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
inline void nl(){std::cout<<std::endl;}
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template<class T> inline bool UpdateMin(T& a, T b) {
    if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
    if (a < b) { a = b; return 1; } return 0;
}

//------------------------main function-------------------------------
void Main(){
    int a,b; cin >> a >> b;
    if(a < b * 2){
        cout << 0 << endl;
    }else{
        cout << a - (b *2) << endl;
    }
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define inc(i,j,l) for(int i=j;i<=l;i++)
#define dec(i,j,l) for(int i=j;i>=l;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,c=0;int k;
    cin>>n>>k;
    while(n!=0)
    {
        n=n/k;
        c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
S = input()
E = [0]*n
W = [0]*n
ans = n
for i in range(n):
  if S[i]=='E':
    E[i] = 1
  else:
    W[i] = 1

for i in range(1, n):
  W[i] += W[i-1]
  E[i] += E[i-1]

for i in range(n):
  tmp = 0
  if i:
    tmp += W[i-1]
  tmp += E[n-1] - E[i]
  ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 27128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
ll mod_pow(ll a,ll b){
	if(b==0)return 1;
	ll next=mod_pow(a,b/2);
	int num=1;
	if(b%2) num=a*(b%2)%mod;
	return num*(next*next%mod)%mod;
}
int main(){
	ll n;
	cin>>n;
	ll ans=0;
	ans=((mod_pow(10,n)-2*mod_pow(9,n)%mod)%mod+mod_pow(8,n))%mod;
	if(ans<0)ans+=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define len(a) a.length()
using namespace std;

signed main(){
    fast_io;
    ll n,ans;
    cin>>n>>ans;
    if(n>=10){
        cout<<ans;
    }
    else{
        cout<<ans+100*(10-n);
    }
}



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

int main(){
  
  int N,K;
  scanf("%d%d\n",&N,&K);
  if(N<K) return 0;
  vector<int> P(N);
  for( int i=0; i<N; i++) scanf("%d",&P[i]);
  
  int total = 0;
  sort(P.begin(), P.end());
  for( int i=0; i<K; i++) total += P[i];
  
  printf("%d\n",total);
  
  return 0;
  
}

Measured memory_bytes: 3792
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var s= Sarray()[0];
            var ai = s;
            var set = new HashSet<long>();
            set.Add(s);
            for(var i=2; ;++i)
            {
                ai = (ai % 2 == 0) ? ai / 2 : 3 * ai + 1;
                if (set.Contains( ai))
                {
                    WriteLine(i);
                    break;
                }
                set.Add(ai);
            }

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Zp {
	const int p = 998244353;
	ll r;
	void set(ll x) {
		while (x < 0) x += p;
		r = x % p;
	}

public:
	Zp(ll x) { set(x); }
	Zp() { set(0); }

	Zp operator-() const { return Zp(-r); }
	Zp &operator=(ll y) {
		set(y);
		return *this;
	}
	Zp &operator=(const Zp &y) { return *this = y.r; }

	Zp &operator+=(ll y) {
		set(r + y);
		return *this;
	}
	Zp &operator-=(ll y) { return *this += -y; }
	Zp &operator*=(ll y) {
		set(r * y);
		return *this;
	}
	Zp &operator/=(ll y) { return *this *= inv(y); }
	Zp operator+(ll y) const { return Zp(r + y); }
	Zp operator-(ll y) const { return *this + (-y); }
	Zp operator*(ll y) const { return Zp(r * y); }
	Zp operator/(ll y) const { return *this * inv(y); }

	Zp &operator+=(const Zp &y) { return *this += y.r; }
	Zp &operator-=(const Zp &y) { return *this -= y.r; }
	Zp &operator*=(const Zp &y) { return *this *= y.r; }
	Zp &operator/=(const Zp &y) { return *this /= y.r; }
	Zp operator+(const Zp &y) const { return *this + y.r; }
	Zp operator-(const Zp &y) const { return *this - y.r; }
	Zp operator*(const Zp &y) const { return *this * y.r; }
	Zp operator/(const Zp &y) const { return *this / y.r; }

	Zp pow(int n) const {
		if (n == 0) return 1;
		if (n % 2) return *this * pow(n - 1);
		Zp tmp = pow(n / 2);
		return tmp * tmp;
	}
	Zp inv(int x) const { return Zp(x).pow(p - 2); }
	Zp inv() const { return inv(r); }

	ll get() const { return r; }

	friend istream &operator>>(istream &istr, Zp &x) {
		istr >> x.r;
		x.set(x.r);
		return istr;
	}
	friend ostream &operator<<(ostream &ostr, const Zp &x) {
		ostr << x.r;
		return ostr;
	}
};
class Comb {
	vector<Zp> fact, ifact;

public:
	Comb(int N) : fact(N + 1), ifact(N + 1) {
		fact[0] = 1;
		REP(i, N)
		fact[i + 1] = fact[i] * (i + 1);
		ifact[N] = fact[N].inv();
		REPR(i, N)
		ifact[i] = ifact[i + 1] * (i + 1);
	}
	Zp operator()(int n, int k) const {
		return fact[n] * ifact[n - k] * ifact[k];
	}
	Zp f(int k) const { return fact[k]; }
	Zp invf(int k) const { return ifact[k]; }
};

Zp dp[3010][3010];

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

	int N, S;
	cin >> N >> S;
	vector<int> A(N);
	REP(i, N) { cin >> A[i]; }
	dp[0][0] = 1;
	REP(i, N) {
		REP(j, S + 1) {
			dp[i + 1][j] = dp[i][j] * 2;
		}
		REP(j, S + 1 - A[i]) {
			dp[i + 1][j + A[i]] += dp[i][j];
		}
	}
	cout << dp[N][S] << endl;

	return 0;
}


Measured memory_bytes: 145200
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

ll mod = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    int i;
    ll ans;
    if(s1[0] == s2[0]) {
        ans = 3;
        i = 1;
    }
    else {
        ans = 6;
        i = 2;
    }
    while(i < n) {
        if(s1[i] == s2[i]) {
            if(s1[i - 1] == s2[i - 1]) {
                ans = (ans * 2) % mod;
            }
            i++;
        }
        else {
            if(s1[i - 1] == s2[i - 1]) {
                ans = (ans * 2) % mod;
            }
            else {
                ans = (ans + ans  + ans) % mod;
            }
            i += 2;
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int nokori(int n){
    
}

signed main(){
    int h,w;
    cin >> h >> w;
    twovec(dp,h+1,w+1);
    dp[1][1] = 1;
    FOR(i,1,h+1){
        string s;
        cin >> s;
        REP(j,w){
            if(i == 1 && j == 0){
                continue;
            }
            if(s[j] == '.'){
                dp[i][j+1] = (dp[i][j] + dp[i-1][j+1])%max_int;
            }
            else{
                dp[i][j+1] = 0;
            }
        }
    }
    cout << dp[h][w];

    
    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
const int Log=19;
int L,m;
int p2[Log+5];
vector<int> oa,ob,ow;
void add(int u,int v,int w)
{
	oa.push_back(u);
	ob.push_back(v);
	ow.push_back(w);
	m++;
	return;
}
int main()
{
	p2[0]=1;
	for(int i=1;i<=Log;i++) p2[i]=p2[i-1]*2;
	scanf("%d",&L);
	for(int i=1;i<=18;i++)
	{
		add(i,i+1,p2[i-1]);
		add(i,i+1,0);
	}
	int bac=0;
	for(int i=Log;i>=0;i--)
	{
		if(!(p2[i]&L)) continue;
		if(i==19)
		{
			add(19,20,p2[18]);
			add(19,20,0);
		}
		else add(i+1,20,bac);
		bac|=p2[i];
	}
	printf("20 %d\n",m);
	for(int i=0;i<(int)oa.size();i++) printf("%d %d %d\n",oa[i],ob[i],ow[i]);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    string s; cin >> s;
    int n = s.length();
    ll ans = 0;
    ll cnt = 0;
    REP(i,n) {
        if(s[i]=='W') {
            ans += i-cnt;
            cnt ++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 256;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    int A[N];
    cins(A, A + N);
    int gcd1[N], gcd2[N];
    gcd1[0] = A[0];
    for(int i = 1; i < N; i++){
        gcd1[i] = gcd(gcd1[i - 1], A[i]);
    }
    gcd2[N - 1] = A[N - 1];
    for(int i = N - 2; i >= 0; i--){
        gcd2[i] = gcd(gcd2[i + 1], A[i]);
    }
    int ans = max(gcd2[1], gcd1[N - 2]);
    for(int i = 1; i < N - 1; i++){
        ans = max(ans, gcd(gcd1[i - 1], gcd2[i + 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int mod = 1000000007;


vector<vector<int>>g(200005);
vector<int>c(200005,0);
vector<int>ans(200005,-1);


void dfs(int N,int C){
  ans[N]=C;
  for (int to:g[N]){
    if (ans[to]!=-1)continue;
    int c_new=C+c[to];
  //  cout<<c_new<<'c'<<N<<'n'<<endl;
    dfs(to,c_new);
  }
}
int main()
{
  int n,q;
  cin>>n>>q;

  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  rep(i,q){
    int p,x;
    cin>>p>>x;
    p--;
    c[p]+=x;
  }
  dfs(0,c[0]);
  rep(i,n){
    if (ans[i]==-1)cout<<0<<endl;
    else cout<<ans[i]<<endl;
  }




}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll gcd(ll a,ll b){
  return b?gcd(b,a%b):a;
}

ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

ll n,m;
string s,t;

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

  cin>>n>>m;
  cin>>s>>t;

  ll L=lcm(n,m);

  ll a=(L/n);
  ll b=(L/m);

  bool ok=true;

  for(ll i=0,j=0;i<n&&j<m;i+=b,j+=a){
    if(s[i]!=t[j])ok=false;
  }
  if(!ok)cout<<-1<<endl;
  else cout<<L<<endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>


using namespace std;

int main(){

  int n;
  cin >> n;
  long long int a[n],b[n];

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

  long long int A,B;
  sort(a,a+n);
  sort(b,b+n);

  if(n%2==1){
    A=a[n/2];
    B=b[n/2];
    cout << B-A+1 << endl;
  }
  else{
    cout << b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1 << endl;
  }

}

Measured memory_bytes: 6748