akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Queue;

class Main{
          public static void main(String[] args) {
                  Scanner scan = new Scanner(System.in);
                  int A = scan.nextInt();
                  int B = scan.nextInt();
                  int C = scan.nextInt();
                  boolean f = false;
                  if (A == 5 && B == 7 && C == 5) {
                          f = true;
                  }
                  if (A == 7 && B == 5 && C == 5) {
                          f = true;
                  }
                  if (A == 5 && B == 5 && C == 7) {
                          f = true;
                  }
                  if (f) {
                          System.out.println("YES");
                  }
                  else System.out.println("NO");
                  }
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    vector<int> A;
    cin >> n >> m;
    A.resize(n);
    for (int i = 0; i < n; i++)
        A[i] = m + i;
    sort(A.begin(), A.end(),
        [&](int a, int b) {
            return abs(a) < abs(b);
        });
    long long ans = 0;
    for (int i = 1; i < n; i++)
        ans += A[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n = scanner.nextInt();
		String a = scanner.next();
		String b = scanner.next();
		String c = scanner.next();
		int count = 0;

		for (int i = 0; i < n; i++) {
			if (a.charAt(i) == b.charAt(i)) {
				if (a.charAt(i) == c.charAt(i)) {

				} else {
					count++;
				}
			} else {
				if (a.charAt(i) == c.charAt(i)) {
					count++;
				} else {
					if (b.charAt(i) == c.charAt(i)) {
						count++;
					} else {
						count += 2;
					}
				}
			}
		}
		System.out.print(count);

		scanner.close();
	}

}


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

int main(){
    int n,m;
    cin >> n >> m;
    int ans = 0;
    bool flag = true;
    int p1=-1,p2=-1,p3=-1;
    if(n==1){
        for(int i=0;i<m;i++){
            int s,c; cin >> s >> c;
            if(p1==-1){
                ans += c;
                p1 = c;
            }else{
                if(c!=p1){
                    cout << -1 << endl;
                    flag = false;
                    break;
                }
            }
        }
        if(flag){
            cout << ans << endl;
        }
    }else if(n==2){
        ans = 10;
        for(int i=0;i<m;i++){
            int s,c; cin >> s >> c;
            if(s==1 && c==0){
                cout << -1 << endl;
                    flag = false;
                    break;
            }else if(p1==-1 && s==1){
                ans = ans%10;
                ans += c*10;
                p1 = c;
            }else if(s==1){
                if(c!=p1){
                    cout << -1 << endl;
                    flag = false;
                    break;
                }
            }else if(p2==-1 && s==2){
                ans += c;
                p2 = c;
            }else if(s==2){
                if(c!=p2){
                    cout << -1 << endl;
                    flag = false;
                    break;
                }
            }
        }
        if(flag){
            cout << ans << endl;
        }
    }else{
        ans = 100;
        for(int i=0;i<m;i++){
            int s,c; cin >> s >> c;
            if(s==1 && c==0){
                cout << -1 << endl;
                    flag = false;
                    break;
            }else if(p1==-1 && s==1){
                ans = ans%100;
                ans += c*100;
                p1 = c;
            }else if(s==1){
                if(c!=p1){
                    cout << -1 << endl;
                    flag = false;
                    break;
                }
            }else if(p2==-1 && s==2){
                ans += c*10;
                p2 = c;
            }else if(s==2){
                if(c!=p2){
                    cout << -1 << endl;
                    flag = false;
                    break;
                }
            }
            else if(p3==-1 && s==3){
                ans += c;
                p3 = c;
            }else if(s==3){
                if(c!=p3){
                    cout << -1 << endl;
                    flag = false;
                    break;
                }
            }
        }
        if(flag){
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        
        int[] N = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int a = N[0];
        int b = N[1];
        
        int k = b - a;
        int sum = 0;
        for(int i = 1; i <= k; i++)
        {
            sum += i;
        }
        int y = sum - b;
        Console.WriteLine(y);
    }
}

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

using namespace std;

int main() {
	double d;
	while (cin >> d) {
		if (d < 0.0) {
			break;
		} 
		if (d >= 257.0) {
			cout << "NA" << endl;
		} else {
			int a = d;
			double b = d-a;
			int counter[4] = {0};
			if (b >= 0.5) {
				b -= 0.5;
				counter[0] = 1;
			}
			if (b >= 0.25) {
				b -= 0.25;
				counter[1] = 1;
			}
			if (b >= 0.125) {
				b -= 0.125;
				counter[2] = 1;
			}
			if (b >= 0.0625) {
				b -= 0.0625;
				counter[3] = 1;
			}
			if (b > 0.0) {
				cout << "NA" << endl;
			} else {
				string zo = "01";
				string s = "";
				for (int i = 0; i < 8; i++) {
					s += zo[a%2];
					a/= 2;
				}
				string ss = "";
				for (int i = 7; i >= 0; i--) {
					ss += s[i];
				}
				string dd = "";
				for (int i = 0; i < 4; i++) {
					dd += zo[counter[i]];
				}
				cout << ss << '.' << dd << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==a[1]&&a[0]!=a[2])
    cout<<"Yes"<<endl;
    else if(a[0]==a[2]&&a[0]!=a[1])
    cout<<"Yes"<<endl;
    else if(a[2]==a[1]&&a[0]!=a[2])
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

    return 0;
}




Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <stack>
#include <set>
using namespace std;

#define N 100001

vector<int> A[N];
int NIL = -1;
int MIN = -1;

class Node {
    public:
        int color, prenum, lowest, parent;
        Node(): color(0), prenum(NIL), lowest(MIN), parent(NIL) {}
};

Node G[N];

void dfs(int root) {
    stack<int> S;
    S.push(root);
    G[root].color = 1;
    int prenum = 1;
    G[root].prenum = prenum;

    while(!S.empty()) {
        int node = S.top();
        vector<int>::iterator it = A[node].begin();
        while(it != A[node].end()) {
            if(G[*it].color == 0) {
                S.push(*it);
                G[*it].color = 1;
                G[*it].prenum = ++prenum;
                G[*it].parent = node;
                break;
            } 
            it++;
        }

        if (it == A[node].end()) {
            S.pop();
            int lowest = G[node].prenum;
            it = A[node].begin();
            for (; it != A[node].end(); it++) {
                if (G[*it].prenum > G[node].prenum) {
                    if (G[*it].lowest < lowest) {
                        lowest = G[*it].lowest;
                    }
                } else {
                    if (*it != G[node].parent) {
                        if (G[*it].prenum < lowest) {
                            lowest = G[*it].prenum;
                        }
                    }
                }
            }
            G[node].lowest = lowest;
        }
    }
}

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

    for (int i = 0; i < n; i++) {
        G[i] = Node();
    }

    int v1, v2;
    for (int i = 0; i < e; i++) {
        cin >> v1 >> v2;
        A[v1].push_back(v2);
        A[v2].push_back(v1);
    }

    dfs(0);

    set<int> ans;
    int np = 0;
    for (int i = 1; i < n; i++) {
        int parent = G[i].parent;
        if (parent == 0) {
            np++;
        } else {
            if (G[parent].prenum <= G[i].lowest) {
                ans.insert(parent);
            }
        }
    }
    if (np > 1) {
        ans.insert(0);
    }

    for (set<int>::iterator it = ans.begin(); it != ans.end(); it++) {
        cout << *it << endl;
    }

    return 0;
}



Measured memory_bytes: 7856
#include <cstdio>
#define NIL -1
typedef struct {
    int parent;
    int left;
    int right;
} Node;

Node Tree[26];

void Preorder(int index) {
    if (index != NIL) {
        printf(" %d", index);
        Preorder(Tree[index].left);
        Preorder(Tree[index].right);
    }
}

void Inorder(int index) {
    if (index != NIL) {
        Inorder(Tree[index].left);
        printf(" %d", index);
        Inorder(Tree[index].right);
    }
}

void Postorder(int index) {
    if (index != NIL) {
        Postorder(Tree[index].left);
        Postorder(Tree[index].right);
        printf(" %d", index);
    }
}


int
main () {
    int n;
    scanf("%d", &n);

    for (int i=0; i<n; i++) Tree[i].parent = NIL;
    for (int i=0; i<n; i++) {
        int id, left, right;
        scanf("%d %d %d", &id, &left, &right);
        Tree[id].left = left;
        Tree[id].right = right;
        if (left != NIL) Tree[left].parent = id;
        if (right != NIL) Tree[right].parent = id;
    }

    int root=0;
    for (int i=0; i<n; i++) if (Tree[i].parent == NIL) root = i;
    printf("Preorder\n");
    Preorder(root);
    printf("\n");
    printf("Inorder\n");
    Inorder(root);
    printf("\n");
    printf("Postorder\n");
    Postorder(root);
    printf("\n");

    return 0;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; 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()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s;
    cin >> s;
    string ans;
    rep(i, 3) {
        ans += s[i];
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3596
(let* ((w (read))
       (h (read))
       (n (read))
       (lst (loop repeat n
                  collect (list (read) (read) (read))))
       (s (* w h))
       (x 0)
       (y 0))

  (loop for i in lst
        do (cond ((= (caddr i) 1) (setq x (max (car i) x)))
                 ((= (caddr i) 2) (setq w (min (car i) w)))
                 ((= (caddr i) 3) (setq y (max (cadr i) y)))
                 ((= (caddr i) 4) (setq h (min (cadr i) h)))))

  ; (format t "x : ~A~%" x)
  ; (format t "w : ~A~%" w)
  ; (format t "y : ~A~%" y)
  ; (format t "h : ~A~%" h)

  (format t "~A~%"
          (* (max (- w x) 0) (max (- h y) 0))))


Measured memory_bytes: 16744
import numpy as np

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

dp=np.empty(N,dtype=int)
dp[0]=0
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    a=dp[i-1]+abs(H[i]-H[i-1])
    b=dp[i-2]+abs(H[i]-H[i-2])
    dp[i]=min(a,b)

print(dp[N-1])

Measured memory_bytes: 22840
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  	for(int i=0; i < N ;i++) cin >> a[i];
  
  int min = a[0], max = a[0];
  
  for(int i = 1; i < N ; i++){
    if(min > a[i]){
      min = a[i];
    }
    if(max < a[i]){
      max = a[i];
    }
  }
 
  cout << max-min << endl;
  return 0;
}

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

int main() {
	long long N, A, B, divide, ans = 0;
	cin >> N >> A >> B;
	divide = N / (A + B);
	ans += A * divide;
	long long dif = N - divide * (A + B);
	if (dif >= A) ans += A;
	else ans += dif;
	cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
if n%2==0:
    s=0
    s=2*(sum(a[0:(n//2)]))-a[0]
    print(s)
else:
    s=0
    s=2*(sum(a[0:(n//2)+1]))-a[0]-a[n//2]
    print(s)

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

int main() {
	int N, A[100002], D, ans;
	cin >> N ;
	A[0] = 0;
	D = 0; 
	for(int i=1; i<=N+1; i++){
		if(i == N+1) A[i] = 0;
		else cin >> A[i];

		D += abs(A[i]-A[i-1]);
	}
	for(int i=1; i<=N; i++){
		ans = D -abs(A[i]-A[i-1]) -abs(A[i+1]-A[i]) +abs(A[i+1]-A[i-1]) ;			
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500055;
int n,q,tot;
int a[MAXN];
int T[MAXN*100],lson[MAXN*100],rson[MAXN*100],c[MAXN*100];
int build(int l,int r) {
    int root = tot++;
    c[root] = 0;
    if(l != r) {
        int mid = (l+r)>>1;
        lson[root] = build(l,mid);
        rson[root] = build(mid+1,r);
    }
    return root;
}
int update(int root,int pos,int val) {
    int newroot = tot++, tmp = newroot;
    c[newroot] = c[root] + val;
    int l = 1, r = n;
    while(l < r) {
        int mid = (l+r)>>1;
        if(pos <= mid) {
            lson[newroot] = tot++;
            rson[newroot] = rson[root];
            newroot = lson[newroot];
            root = lson[root];
            r = mid;
        } else {
            rson[newroot] = tot++;
            lson[newroot] = lson[root];
            newroot = rson[newroot];
            root = rson[root];
            l = mid+1;
        }
        c[newroot] = c[root] + val;
    }
    return tmp;
}
int query(int root,int pos) {
    int ret = 0;
    int l = 1, r = n;
    while(pos < r) {
        int mid = (l+r)>>1;
        if(pos <= mid) {
            r = mid;
            root = lson[root];
        } else {
            ret += c[lson[root]];
            root = rson[root];
            l = mid+1;
        }
    }
    return ret + c[root];
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    scanf("%d%d",&n,&q);
    tot = 0;
    for(int i = 1; i <= n; ++i)
        scanf("%d",&a[i]);
    T[n+1] = build(1,n);
    map<int,int>mp;
    for(int i = n; i>= 1; --i) {
        if(mp.find(a[i]) == mp.end()) {
            T[i] = update(T[i+1],i,1);
        } else {
            int tmp = update(T[i+1],mp[a[i]],-1);
            T[i] = update(tmp,i,1);
        }
        mp[a[i]] = i;
    }
    int l,r;
    while(q--) {
        scanf("%d%d",&l,&r);
        printf("%d\n",query(T[l],r));
    }
    return 0;
}


Measured memory_bytes: 252996
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];

  vi inv(n, 0);
  vi less(n, 0);
  rep(i, n) {
    rep(j, n) {
      if (a[i] > a[j]) {
        less[i]++;
        if (i < j) {
          inv[i]++;
        }
      }
    }
  }

  // printV(inv);
  // printV(less);

  int ans = 0ll;
  rep(i, n) {
    (ans += ((inv[i] * k) % mod)) %= mod;
    int kC2 = (((k * ((k + (mod - 1)) % mod)) % mod) * modinv(2, mod)) % mod;
    (ans += ((less[i] * kC2) % mod)) %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

int n, k;
string s;

void read_input()
{
    cin >> k;
    cin >> s;
    n = sz(s);
}

void solve()
{
    cout << s.substr(0, min(n, k));
    if(n > k) cout << "...";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = 998244353;
const int N = (int)2e5 + 5;


void solve(){
	string s;
	cin>>s;
	string str[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI",  "SAT"};
	if(s==str[0])cout<<7;
	else if(s==str[1])cout<<6;
	else if(s==str[2])cout<<5;
	else if(s==str[3])cout<<4;
	else if(s==str[4])cout<<3;
	else if(s==str[5])cout<<2;
	else if(s==str[6])cout<<1;


} 


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#n = 0
#m = 3


n,m=map(int,input().split())

k = 2
import math
#print(math.factorial(3))

nResult = 0
if (n-k) >= 0:
    nResult = (math.factorial(n))/(2*math.factorial(n-k))
    nResult=int(nResult)
#print("N numbers comination", nResult)

mResult = 0

if (m-k) >= 0:
    mResult = (math.factorial(m))/(2*math.factorial(m-k))
    mResult=int(mResult)
#print("M numbers comination", mResult)

#print("Answer is: ", nResult+mResult)
print(nResult+mResult)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

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

  int cnt = 0;
  for(int i = 0; i < 3; i++){
    if ( s.substr(i,1) == t.substr(i,1) ){
        cnt++;
    }
  }
  cout << cnt << endl;
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

#define mod 1000000007;

main(){
  string s; cin >> s;
  vector<char> ans;
  rep(i,s.size()){
    if(s[i] == 'B' && ans.size() != 0) ans.pop_back();
    else if(s[i] != 'B') ans.push_back(s[i]);
  }
  rep(i,ans.size()) cout << ans[i];
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,r;
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{

    int a,b,c;
    std::cin >> a >> b >> c;
    for (int i = 0; i < 2; i++ ){
    if(a>b){
        std::swap(a,b);
    }
    if(b>c){
        std::swap(b,c);
    }
    if(a>c){
        std::swap(a,c);
    }
    }
    std::cout << a << " " << b << " " << c << std::endl;

    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int k;
    cin>>k;
    int ls=s.length();
    set<string>st;
    for (int i=0;i<ls;i++){
        for (int j=1;j<=k;j++){
            st.insert(s.substr(i,j));
        }
    }
    for (auto i:st){
     k--;
     if (k==0)
            cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include <stdlib.h>
int main(void){
	char s[3];
	int a=0;
	for(int i=0;i<3;i++){
	scanf("%c",&s[i]);
	if(s[i]=='1'){
	a++;
	}
	}
	printf("%d",a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    
    map<char, vector<int> > mp;
    for(int si=0; si<s.size(); si++) {
        mp[s[si]].push_back(si+1);
    }
    
    long long int ans=0;
    int cur=0;
    for(int ti=0; ti<t.size(); ti++) {
        // cout << cur << " -> ";
        if(mp[t[ti]].size()==0) {
            cout << -1 << endl;
            return 0;
        } else {
            int ind=upper_bound(mp[t[ti]].begin(), mp[t[ti]].end(), cur)-mp[t[ti]].begin();
            if(ind==mp[t[ti]].size()) {
                cur = 0;
                ans += (long long int)s.size();
                ind = upper_bound(mp[t[ti]].begin(), mp[t[ti]].end(), cur)-mp[t[ti]].begin();
                cur = mp[t[ti]][ind];
            } else {
                cur = mp[t[ti]][ind];
            }
        }
        if(ti==t.size()-1) {
            ans += (long long int)cur;
        }
        // cout << cur << endl;
        // cout << ans << endl;
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define rr return 0;
const int N = (int)(1*1e6+10);
int fen[N];
typedef long long ss;
int main()
{
    start;
    ss i,j,n,m,a,b;
    cin>>a>>b;
    n=abs(a+b);
    if(n%2==0)
    {
        cout<<n/2<<endl;
    }
    else cout<<"IMPOSSIBLE"<<endl;
    rr
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

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

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

const ll mod = 1000000007;
const int INF = 1<<29;

int main(){
  ll N, A, B; cin >> N >> A >> B;
  ll res = (N / (A + B)) * A;
  if (N % (A + B) <= A) res += N % (A + B);
  else res += N % (A + B) - (N % (A + B) - A);

  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int N=s.size();

    reverse(ALL(s));
    int i=0;
    while(i<N){
        if(s.substr(i,5)=="maerd") i+=5;
        else if(s.substr(i,7)=="remaerd") i+=7;
        else if(s.substr(i,5)=="esare") i+=5;
        else if(s.substr(i,6)=="resare") i+=6;
        else break;
    }
    cout<<(i==N? "YES":"NO")<<endl;
    
}


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

int main()
{
    char a,b,c,d;
    int x=0;
    cin>>a>>b>>c>>d;
    if(a==b&&b==c){
        x++;
    }
    if(b==c&&c==d){
        x++;
    }
    if(x>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5, INF = 1E9 + 7;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	int x;
	cin >> x;
	if (x <= 599) {
		cout << 8 << endl;
	}
	else if (x <= 799) {
		cout << 7 << endl;
	}
	else if (x <= 999) {
		cout << 6 << endl;
	}
	else if (x <= 1199) {
		cout << 5 << endl;
	}
	else if (x <= 1399) {
		cout << 4 << endl;
	}
	else if (x <= 1599) {
		cout << 3 << endl;
	}
	else if (x <= 1799) {
		cout << 2 << endl;
	}
	else if (x <= 1999) {
		cout << 1 << endl;
	}
	
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	static int[][] ban;
	static int[][] visited;
	static int[] xv= {0,1,0,-1};
	static int[] yv= {1,0,-1,0};
	static int w,h,sx,sy,gx,gy;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		while(true) {
			w=sc.nextInt();
			h=sc.nextInt();
			if(h*w==0) {
				break;
			}
			sx=sc.nextInt();
			sy=sc.nextInt();
			gx=sc.nextInt();
			gy=sc.nextInt();
			ban=new int[h+2][w+2];
			visited=new int[h+2][w+2];
			for(int i=0; i<=h+1; i++) {
				for(int j=0; j<=w+1; j++) {
					ban[i][j]=0;		//クソガバ初期化
					visited[i][j]=0;
				}
			}
			int N=sc.nextInt();
			for(int i=0; i<N; i++) {
				int color=sc.nextInt();
				int muki=sc.nextInt();//0 1
				int xx=sc.nextInt();
				int yy=sc.nextInt();
				if(muki==0) {
					ban[yy][xx]+=color;		//いもす
					ban[yy+1][xx]+=color;
					ban[yy][xx+4]-=color;
					ban[yy+1][xx+4]-=color;
				}
				else {
						ban[yy][xx]+=color;	//いもす
						ban[yy+1][xx]+=color;
						ban[yy+2][xx]+=color;
						ban[yy+3][xx]+=color;
						ban[yy][xx+2]-=color;
						ban[yy+1][xx+2]-=color;
						ban[yy+2][xx+2]-=color;
						ban[yy+3][xx+2]-=color;
				}
			}
			for(int i=0; i<=h+1; i++) {
				for(int j=0; j<w+1; j++) {
					ban[i][j+1]=ban[i][j]+ban[i][j+1];
				}
			}
			dfs(sx,sy,ban[sy][sx]);
			if(visited[gy][gx]==1) {
				pl("OK");
			}
			else {
				pl("NG");
			}
		}
	}
	public static void dfs(int x,int y,int color) {
		if(visited[y][x]==0) {
			visited[y][x]=1;
			for(int i=0; i<4; i++) {
				if(0<=x+xv[i] && x+xv[i]<=w && 0<=y+yv[i] && y+yv[i]<=h) {
					if(visited[y+yv[i]][x+xv[i]]==0 && color==ban[y+yv[i]][x+xv[i]]) {
						dfs(x+xv[i],y+yv[i],color);
					}
				}
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


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

int main() {
    ll N;
    cin >> N;
    if (N==1) {
        cout << 1 << endl;
        exit(0);
    }
    vector<ll> P(N);
    for (ll i=0; i<N; i++) {
        cin >> P[i];
    }
    ll count = 1;
    ll temp = P[0];
    for (ll i=1; i<N; i++) {
        temp = min(temp,P[i]);
        if (temp==P[i]) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
int main(){
	double a, b, h, m;
	cin >> a >> b >> h >> m; 

	double theta=pi*abs(h/6+m/360-m/30);
	cout << fixed << setprecision(20);
	cout << sqrt(a*a+b*b-2*a*b*cos(theta)) << endl;
}

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

int main(void) {
    int n, m;
    int mi = n, ma = 0;
    vector<int> ls, rs;

    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        ls.push_back(l);
        rs.push_back(r);
    }

    for (int i = 0; i < m; ++i) {
        if (ma <= ls.at(i)) {
            ma = ls.at(i);
        }
        if (mi >= rs.at(i)) {
            mi = rs.at(i);
        }
    }

    int res;
    if ((mi - ma) < 0) {
        res = 0;
    } else {
        res = (mi - ma) + 1;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>
 
int Partition(int p,int r);
 
int A[100000];
int n;
 
main(){
  int i,p;
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
  p = Partition(0,n-1);
 
  for(i=0;i<n;i++){
    if(p==i)printf("[%d]",A[i]);
    else printf("%d",A[i]);
if(i!=n-1) printf(" ");
  }
  printf("\n");
 
  return 0;
}
 
int Partition(int p, int r){
 
  int x, i,j, tmp;
 
  x = A[r];
  i = p-1;
  for(j=p; j<=r-1; j++){
 
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
 
  }
      tmp = A[i+1];
      A[i+1] = A[r];
      A[r] = tmp;
 
  return i+1;
 
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s;
	string t;
	cin>>s>>t;
	int len=s.size();
	int ans=0;
	for(int i=0;i<len;i++){
		if(s[i]!=t[i])
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3932
# coding: utf-8


def is_unique(seq):
    return len(seq) == len(set(seq))


def main():
    n = int(input())
    shiri = True

    w = []
    for i in range(n):
        w.append(input())

    for i in range(n-1):
        if w[i][-1] != w[i + 1][0]:
            shiri = False
            break

    if not is_unique(w):
        shiri = False

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


if __name__ == '__main__':
    main()


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

using namespace std;
using LLONG = long long;

int main()
{
    int N, K;
    cin >> N >> K;
    LLONG ans = K;
    for (int i = 0; i < N - 1; ++i)
    {
        ans *= (K - 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
list1=[1 for i in range(100001)]
list1[0]=0
list1[1]=0
for j in range(2,100001):
    if list1[j]==0:
        pass
    else:
        for k in range(2,100001):
            if j*k>100000:
                break
            else:
                list1[j*k]=0
#print(list1[:100])
list2=[0]
for l in range(1,100001):
    if list1[l]==0:
        list2.append(list2[l-1])
    else:
        if list1[int((l+1)/2)]==1:
            list2.append(list2[l-1]+1)
        else:
            list2.append(list2[l-1])
#print(list2[:100])
Q=int(input())
for x in range(Q):
    l,r=map(int,input().split())
    print(list2[r]-list2[l-1])

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

int bin(vector<int> &a, int target){
    int l = 0, r = sz(a)-1;

    while (r >= l){
        int m = (l+r)/2;
        if (a[m] == target) return m;
        if (a[m] > target) r = m-1;
        else l = m+1;
    }
    return -1;
}

void solve(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll t = n/(a+b);
    ll m = n % (a+b);
    ll ans = a*t;
    ans += min(m, a);
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<" "
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 200;
const int INF = 1e9;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*for(int m = 3; m <= 3; ++m) {
		vector <int> v;
		for(int i = 0; i <= m; ++i) {
			v.pb(i);
			v.pb(i);
		}
		int n = sz(v) - 1;
		do {
			int ans = -1;
			bool sorry2 = 0;
			for(int i = 0; i <= n; ++i) {
				bool sorry = 0;
				for(int j = i + 1; j <= n; ++j) {
					if(v[i] == v[j]) {
						int res = 0;
						for(int k = i; k <= j; ++k) {
							res ^= v[k];
						}
						if(ans == -1) {
							ans = res;
						}
						else if(ans != res) {
							sorry = 1;
							break;
						}
					}
				}
				if(sorry) {
					sorry2 = 1;
					break;
				}
			}
			if(!sorry2) {
				//st.insert(ans);
				cerr << "\n";
				show(ans); show(m);
				cerr << "v -> ";
				fo(i, 0, n, 1)
					cout << v[i] <<' ';
				cout << "\n";	
			}
		} while(next_permutation(all(v)));
//		show(m);
//		for(int it : st)
//			cout << it <<' ';
//		cout << '\n';
	}
	cerr << "end\n";*/
	int m, k;
	cin >> m >> k;
	if(k == 0) {
		fo(i, 0, (1 << m) - 1, 1) {
			cout << i <<' '<< i <<' ';
		}	
		return 0;
	}
	int res = 0;
	fo(i, 0, (1 << m) - 1, 1) {
		if(k == i)
			continue;
		res ^= i;
	}
	if(res != k) {
		cout << -1;
		return 0;
	}
	fo(i, 0, (1 << m) - 1, 1) {
		if(k == i)
			continue;
		cout << i <<' ';
	}
	cout << k <<' ';
	foo(i, (1 << m) - 1, 0, 1) {
		if(k == i) 
			continue;
		cout << i <<' ';	
	}
	cout << k;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#define int long long
using namespace std;
bool b[1010];
signed main() {
    int n, k; cin >> n >> k;
    //ans=(n-1)C(k-1)
    int ans = 1;n--;k--;
    for (int i = 0; i < k; i++) {
    	int p=n-i;
        for(int j=k;j>=1;j--){
        	if(!b[j]&&p%j==0){
        		b[j]=1;
        		p/=j;
        	}
        }
        ans*=p;
        ans%=1000000007;
    }
    for (int i = 1; i <= k; i++){
    	if(!b[i]){
    		while(ans%i!=0)ans+=1000000007;
    		ans/=i;
    	}
    	ans%=1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3100
#include <stdio.h>

int main(void)
{
	int N;
	int i, j;
	int count;
	int box[100];
	int tmp;
	
	while (1){
		scanf("%d", &N);
		if (N == 0){
			break;
		}
		
		count = 0;
		
		for (i = 0; i < N; i++){
			scanf("%d", &box[i]);
		}
		for (i = 0; i < N - 1; i++){
			for (j = 0; j < N - i - 1; j++){
				if (box[j] > box[j + 1]){
					tmp = box[j];
					box[j] = box[j + 1];
					box[j + 1] = tmp;
					
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,ans,k;
int32_t main(){
CODE_START;
cin>>n;
cin>>k;
ans=k;
for(ll i=0;i<n-1;i++)
    ans=ans*(k-1);
cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  bool flag=true;
  if(n%2) flag=false;
  else{
    rep(i,0,n/2){
      if(s.at(i)==s.at(n/2+i)) continue;
      else flag=false;
    }
  }


  if(flag) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
# codinf: utf-8

def check(a,b):
    if a <= 8 and b <= 8:
        return 1
    else:
        return 0


if __name__ == "__main__":
    a,b = map(int, input().split(" "))
    result = [":(","Yay!"]

    print(result[check(a,b)])

Measured memory_bytes: 2940
#include <stdio.h>
#define max 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n , m[max][max];

int prim()
{
	int u , minv;
	int d[max] , p[max] , color[max];
	
	for(int i = 0; i < n; i++)
	{
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}
	d[0] = 0;
	
	while(1)
	{
		minv = INFTY;
		int u = -1;
		for(int i = 0; i < n; i++)
		{
			if(minv > d[i] && color[i] != BLACK)
			{
				u = i;
				minv = d[i];
			}
		}
		if(u == -1){		break;}
		color[u] = BLACK;
		for(int v = 0; v < n; v++)
		{
				if(color[v] != BLACK && m[u][v] != INFTY)
				{
					if(d[v] > m[u][v])
					{
						d[v] = m[u][v];
						p[v] = u;
						color[v] = GRAY;
					}
				}
		}
	}
	int sum = 0; 
	for(int i = 0; i < n; i++)
	{
		if(p[i] != -1)
		{
			sum += m[i][p[i]];
		}
	}
	return sum;
}

int main(void)
{
	scanf("%d",&n);
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			int e;
			scanf("%d",&e);
			m[i][j] = (e == -1) ? INFTY : e;
		}
	}
	printf("%d\n",prim());
	return 0;
}


Measured memory_bytes: 2052
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int h, w, k; cin >> h >> w >> k;
	vector<string> a(h);
	rep(i, h) cin >> a[i];

	vector<vint> ans(h);
	int id = 1;
	rep(i, h){
		int count = 0;
		ans[i].resize(w);
		rep(j, w){
			if(a[i][j] == '#') count++;
			if(count >= 2){
				id++;
				count = 1;
			}
			ans[i][j] = id;
		}
		id++;
	}

	stack<int> stc1;
	rep(i, h){
		int count = 0;
		rep(j, w){
			if(a[i][j] == '#'){
				count++;
				break;
			}
		}
		if(count == 0){
			stc1.push(i);
		} else{
			while(!stc1.empty()){
				int idx = stc1.top(); stc1.pop();
				ans[idx] = ans[i];
			}
		}
	}
	stack<int> stc2;
	for(int i=h-1; i>=0; i--){
		int count = 0;
		rep(j, w){
			if(a[i][j] == '#'){
				count++;
				break;
			}
		}
		if(count == 0){
			stc2.push(i);
		} else{
			while(!stc2.empty()){
				int idx = stc2.top(); stc2.pop();
				ans[idx] = ans[i];
			}
		}
	}

	int best_id = 1;
	map <int, int> ids;
	rep(i, h){
		rep(j, w){
			if(ids.count(ans[i][j]) == 0){
				ids[ans[i][j]] = best_id;
				best_id++;
			}
			ans[i][j] = ids[ans[i][j]];
		}
	}

	rep(i, h){
		rep(j, w){
			if(j != w-1) cout << ans[i][j] << " ";
			else cout << ans[i][j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5504
#include <cmath>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
#define ll long long
#define it map<par,int>::iterator

int n;
struct par{
	int x,y;par(int xx,int yy):x(xx),y(yy){}
	bool operator <(const par &B)const{return x==B.x?y<B.y:x<B.x;}
};
map<par,int>mp;
ll ans=0;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		long double x;cin>>x;
		x*=1e9;ll y=(ll)(x+1e-2);int c=0,d=0;
		while(y%2==0)y/=2,c++;
		while(y%5==0)y/=5,d++;
		mp[par(c,d)]++;
	}
	for(it i=mp.begin();i!=mp.end();i++){
		for(it j=mp.begin();j!=mp.end();j++){
			if(i->first.x+j->first.x>=18&&i->first.y+j->first.y>=18){
				if(i==j)ans+=1ll*i->second*(i->second-1);
				else ans+=1ll*i->second*j->second;
			}
		}
	}
	cout<<ans/2ll;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<ll,ll> P;

int main(){
    int x,a; cin >> x >> a;
    if(x<a) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main(){
  int k, s;
  //0<=x,y,z<=k,x+y+z=s
  cin >> k >> s;
  int sum = 0;
  rep(i,k+1){
    rep(j,k+1){
      if(0<=s-i-j && s-i-j<=k){
        sum++;
      }
      else{
        continue;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
from scipy.misc import comb
from collections import Counter
import datetime

N = int(input())
num_list = list(map(int, input().split()))
# num_set = set(num_list)
num_dict = {}

num_counter = Counter(num_list)
  
# 全数あるときの組み合わせ
ans_dict_1 = {}
# 1個抜いたときの組み合わせ
ans_dict_2 = {}
rap_2 = datetime.datetime.now()
for k, v in num_counter.most_common():
  ans_dict_1[k] = comb(v,2,exact=True)
  ans_dict_2[k] = comb(v-1,2,exact=True)

total = sum(ans_dict_1.values())

for i in num_list:
  print(total - ans_dict_1[i] + ans_dict_2[i])

Measured memory_bytes: 56812
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

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

LL check(const vector<LL>& s, int l, int mid, int r) {
  int N = s.size() - 1;

  LL P = s[l], Q = s[mid] - s[l], R = s[r] - s[mid], S = s[N] - s[r];
  LL vmax = max({P, Q, R, S});
  LL vmin = min({P, Q, R, S});
  return vmax - vmin;
}

int main() {
  int N; cin >> N;
  vector<LL> A(N); cin >> A;
  vector<LL> S(N + 1); S[0] = 0;
  for (int i = 0; i < N; ++i) S[i + 1] = S[i] + A[i];

  int l = 1, mid = 2, r = 3;
  LL vmin = 1e18;
  for (; mid < N; ++mid) {
    LL vmin1 = abs(S[mid] - 2 * S[l]);
    while (vmin1 > abs(S[mid] - 2 * S[l + 1])) {
      ++l;
      vmin1 =  abs(S[mid] - 2 * S[l]);
    }
    LL vmin2 = abs(S[N] - 2 * S[r] + S[mid]);
    while (vmin2 > abs(S[N] - 2 * S[r + 1] + S[mid])) {
      ++r;
      vmin2 = abs(S[N] - 2 * S[r] + S[mid]);
    }

    vmin = min(vmin, check(S, l, mid, r));
  }
  cout << vmin << endl;
}


Measured memory_bytes: 6376