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

using namespace std;

using LL = long long;

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

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

struct query_t {
    int l, id;
};

struct fenwick_t {
    int ft[1000000];
    int query(int w) {
        int a = 0;
        for(; w; w -= (w & -w)) {
            a += ft[w];
        }
        return a;
    }
    void update(int w, int v) {
        for(; w < 1000000; w += w & (-w)) {
            ft[w] += v;
        }
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int N, Q;
    cin >> N >> Q;
    vector<int> C(N);
    vector<int> last(N + 1, -1);
    vector<int> ans(Q);
    for(int n = 0; n < N; ++n) {
        cin >> C[n];
    }
    vector<vector<query_t>> E(N);
    for(int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        -- l;
        --r;
        E[r].push_back(query_t{l, q});
    }
    fenwick_t ft;
    for(int n = 0; n < N; ++n) {
        if(last[C[n]] >= 0) {
            ft.update(last[C[n]] + 1, -1);
        }
        ft.update(n + 1, 1);
        last[C[n]] = n;
        for(auto& q : E[n]) {
            ans[q.id] = ft.query(N + 1) - ft.query(q.l);
        }
    }
    
    for(int q = 0; q < Q; ++q) {
        cout << ans[q] << "\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 33236
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(void){
  string s; cin >> s;
  ll ans = 0;
  for(int bit = 0; bit < (1 << s.size()-1);bit++){ //bit全探索。+を差し込める場所は文字列の長さ-1。
    //cout << bitset<2>(bit) << endl;
    ll sum = 0;
    for(int i = 0; i < s.size();i++){//全桁を探索
      if(bit & (1<<i)){//もしiビット目が立っていたら、足し算
        sum *= 10; //sumに入っている内容を10倍する
        sum += s[i] - '0';//今の桁の数字を足しこむ   
        ans += sum; //足す
        sum = 0; //0に初期化
      }else{
        sum *= 10; //sumに入っている内容を10倍する
        sum += s[i] - '0';//今の桁の数字を足しこむ        
      }
    }
    ans += sum;
  }
  cout << ans << endl;
}

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

using namespace std;

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> vec;
    vec.push_back(a);
    vec.push_back(b);
    vec.push_back(c);

    sort(vec.begin(), vec.end());
    
    ostringstream answer;
    for (vector<int>::iterator itr = vec.begin(); itr != vec.end(); ++itr) {
        if (answer.str() != "") {
            answer << ' ';
        }
        
        answer << *itr;
    }
    
    cout << answer.str() << endl;

    return 0;
}

Measured memory_bytes: 3156
#include <cstdio>
#include <set>
int main()
{
	// freopen("AGC029-B.in", "r", stdin);
	std::multiset<int> se;
	int n, ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		se.insert(x);
	}
	while (!se.empty())
	{
		int x = *se.rbegin(), mx = 0;
		se.erase(se.find(x));
		for (int i = 0; i < 30; i++)
		{
			if (x & (1 << i))
				mx = i;
		}
		int y = (1 << mx + 1) - x;
		if (se.find(y) != se.end())
		{
			ans++;
			se.erase(se.find(y));
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 9600
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;


int main(){
	int N;
	cin >> N;
	vector<long long> dp(200000);

	vector<long long> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h.at(i);
	}

	dp.at(0) = 0;
	dp.at(1) = abs(h.at(0) - h.at(1));
	if (N > 2) {
		for (int i = 2; i < N; i++) {
			dp.at(i) = min(dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)), dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
		}
	}
	cout << dp.at(N - 1) << endl;
}

Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    vector<ll> X(M);
    rep(i,M){
        cin >> X[i];
    }
    sort(X.begin(),X.end());
    vector<ll> dif;
    rep(i,M-1){
        dif.push_back(X[i+1]-X[i]);
    }
    sort(dif.begin(),dif.end());
    // N-1箇所の区間を通らなくて済む
    // 小さい区間をM-1-(N-1)個通る
    ll ans = 0;
    rep(i,M-N){
        ans += dif[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()
//#define max(a,b) (a>b ? a : b)
//#define min(a,b) (a<b ? a : b)
 
const int MOD = 998244353;
const int INF = 1000000002;
const double PI =4*atan(1);
const double eps = 1e-7;
const long long oo = 1e18;

int solver(const int N, const int H, vector<int> &A, vector<int> &B){
  vector<vl> dp(N+1, vl((H+1),INF));
  dp[0][0]=0;

  rep(i,N){
    rep(j,H+1){
        dp[i+1][j] = min(dp[i][j], dp[i+1][max(j-A[i],0)]+B[i]);
    } 
  }
  return dp[N][H];
}
  


int main(){
  int N, H;
  cin >> H >> N;
  vector<int> A(N), B(N);
  rep(i, N) cin >> A[i] >> B[i];
  cout << solver(N,H,A,B) << endl;

}

Measured memory_bytes: 78592
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,m;
bool check(int x, int y){
    if(x >=0 and y >=0 and x < n and y < m) return true;
    return false;
}
signed main(){
    ios_base::sync_with_stdio(false);
   // freopen("input.txt", "r", stdin);
    int a,b,c,k; cin>>a>>b>>c>>k;
    int ans;
    if(a >= k) cout<<k<<endl;
    else{
        int ans=a;
        if(k-a <= b ){
            cout<<ans<<endl;
        }
        else{
            cout<<ans - (k-(a+b))<<endl;
        }
    }
    
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

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

int main() {
  ll h, w;
  cin >> h >> w;

  vector<vector<char>> g(h, vector<char>(w));
  for (ll i = 0; i < h; ++i) {
    string s;
    cin >> s;
    for (ll j = 0; j < w; ++j) {
      g[i][j] = s[j];
    }
  }

  vector<vector<ll>> mark(h, vector<ll>(w, 1e18));

  queue<Pll> q;
  q.push(mkp(0, 0));
  mark[0][0] = g[0][0] == '#' ? 1 : 0;
  while (!q.empty()) {
    auto pos = q.front();
    q.pop();

    ll y = pos.first;
    ll x = pos.second;
    vector<ll> dy = {1, 0};
    vector<ll> dx = {0, 1};
    for (ll i = 0; i < 2; ++i) {
      ll ny = y + dy[i];
      ll nx = x + dx[i];
      if (ny >= h) continue;
      if (nx >= w) continue;
      
      ll nc = (g[y][x] == '.' && g[ny][nx] == '#') ? mark[y][x]+1 : mark[y][x];
      if (mark[ny][nx] <= nc) continue;
      mark[ny][nx] = nc;
      q.push(mkp(ny, nx));
    }
  }

  cout << mark[h-1][w-1] << endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
s = input()
dp = [0] * 13
dp[0] = 1
for c in s:
    new = [0] * 13
    if c == '?':
        for n in range(10):
            for i in range(13):
                new[(i * 10 + n) % 13] += dp[i]
    else:
        n = int(c)
        for i in range(13):
            new[(i * 10 + n) % 13] += dp[i]
    for i in range(13):
        new[i] %= 10 ** 9 + 7
    dp = new
print(dp[5])

Measured memory_bytes: 42732
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  if (N == 1) {
	  cout << "Hello World" << endl;
	} else {
	  int A, B;
	  cin >> A >> B;
	  cout << A + B << endl;
	}
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class DSnukeNumbers {
        private double eps = 1e-6;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long cur = 1;
            for (int i = 0; i < n; ++i) {
                out.println(cur);
                long next = cur + 1;
                double opt = Double.MAX_VALUE;
                String curDigs = Long.toString(next);
                for (int j = 0; j < curDigs.length(); ++j) {
                    StringBuilder tail = new StringBuilder();
                    for (int k = 0; k < j; ++k) tail.append("9");
                    String nextDigs = curDigs.substring(0, curDigs.length() - j) + tail.toString();
                    int den = 0;
                    for (int k = 0; k < nextDigs.length(); ++k) den += nextDigs.charAt(k) - '0';
                    long candidate = Long.parseLong(nextDigs);
                    if (1.0 * candidate / den + eps < opt) {
                        opt = 1.0 * candidate / den;
                        cur = candidate;
                    }
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
# 高橋君はプログラミングコンテストサイト「ButCoder」の会員です。
# ButCoder の会員には 2 つのレーティング 内部レーティング と 表示レーティング が割り当てられています。
# 表示レーティングは、その会員のコンテスト参加回数が 10 以上のときは内部レーティングに等しく、
# そうでないときは、会員のコンテスト参加回数を K として、
# 内部レーティングから 100×(10−K) を引いたものになります。
# 高橋君のコンテスト参加回数が N で表示レーティングが R であるとき、
# 高橋君の内部レーティングを求めてください。

nr = gets.chomp.split
n = nr[0].to_i
r = nr[1].to_i

if n >= 10
    puts r
else
    puts r + (100 * (10 - n))
end

Measured memory_bytes: 1788
# coding=utf-8

get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda x: [gets() for _ in xrange(x)]

n, k = gets()
A = sorted(gets())
res = 0

mod = 10**9 + 7


def inv(a):
    return pow(a, mod - 2, mod)


def power(x, y, m):
    if (y == 0):
        return 1
    p = power(x, y // 2, m) % m
    p = (p * p) % m
    if(y % 2 == 0):
        return p
    else:
        return ((x * p) % m)


def C(n, k):
    res = 1
    for i in xrange(1, k + 1):
        res *= n - i + 1
    for i in xrange(1, k + 1):
        res /= i
    return res

res = 0
combi = 1
for i in xrange(k - 1, n):
    # combi2 = C(i, k - 1)
    if i >= k:
        combi = combi * i % mod
        combi = combi * inv(i + 1 - k) % mod
    # print i, combi, combi2
    res += (A[i] - A[~i]) * combi % mod
print res % mod


Measured memory_bytes: 11356
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int k,d[100010];
deque<P>q;
signed main(){
	cin>>k;
	rep(i,k)d[i]=INF;
	d[1]=1;
	q.push_back({1,1});
	while(!q.empty()){
		P p=q.front();
		q.pop_front();
		if(d[p.se]<p.fi)continue;
		if(d[(p.se+1)%k]>p.fi+1){
			d[(p.se+1)%k]=p.fi+1;
			q.push_back({p.fi+1,(p.se+1)%k});
		}
		if(d[(p.se*10)%k]>p.fi){
			d[(p.se*10)%k]=p.fi;
			q.push_front({p.fi,(p.se*10)%k});
		}
	}
	cout<<d[0]<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N, vector<int>(N, INF));
  for (int i = 0; i < M; i++){
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    E[a][b] = c;
    E[b][a] = c;
  }
  vector<vector<int>> d = E;
  for (int i = 0; i < N; i++){
    d[i][i] = 0;
  }
  for (int k = 0; k < N; k++){
    for (int i = 0; i < N; i++){
      for (int j = 0; j < N; j++){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      if (E[i][j] != INF && d[i][j] != E[i][j]){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

bool f(string& s, string& t) {
    int len = s.size();
    for(int i=0; i<len; i++) {
        bool flag = true;
        for(int j=0; j<len; j++) {
            if(s[j]!=t[(j+i)%len]) {
                flag = false;
                break;
            }
        }
        if(flag) return true;
    }
    return false;
}

int main() {
    string s, t;
    cin >> s >> t;
    cout << (f(s, t) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
l = list(input())
if int(l[0]) + int(l[1]) + int(l[2]) + int(l[3]) == 7:
  print (l[0]+ "+" +l[1]+ "+" +l[2]+ "+" +l[3]+ "=7");exit()
elif int(l[0]) + int(l[1]) + int(l[2]) - int(l[3]) == 7:
  print (l[0]+ "+" +l[1]+ "+" +l[2]+ "-" +l[3]+ "=7");exit()
elif int(l[0]) + int(l[1]) - int(l[2]) + int(l[3]) == 7:
  print (l[0]+ "+" +l[1]+ "-" +l[2]+ "+" +l[3]+ "=7");exit()
elif int(l[0]) + int(l[1]) - int(l[2]) - int(l[3]) == 7:
  print (l[0]+ "+" +l[1]+ "-" +l[2]+ "-" +l[3]+ "=7");exit()
elif int(l[0]) - int(l[1]) + int(l[2]) + int(l[3]) == 7:
  print (l[0]+ "-" +l[1]+ "+" +l[2]+ "+" +l[3]+ "=7");exit()
elif int(l[0]) - int(l[1]) + int(l[2]) - int(l[3]) == 7:
  print (l[0]+ "-" +l[1]+ "+" +l[2]+ "-" +l[3]+ "=7");exit()
elif int(l[0]) - int(l[1]) - int(l[2]) + int(l[3]) == 7:
  print (l[0]+ "-" +l[1]+ "-" +l[2]+ "+" +l[3]+ "=7");exit()
elif int(l[0]) - int(l[1]) - int(l[2]) - int(l[3]) == 7:
  print (l[0]+ "-" +l[1]+ "-" +l[2]+ "-" +l[3]+ "=7");exit()

Measured memory_bytes: 3192
import java.util.Scanner;

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

		int result = 0;
		if(record.indexOf("R") > -1) {
			result = 1;
		}

		if(record.indexOf("RR") > -1) {
			result = 2;
		}

		if(record.indexOf("RRR") > -1) {
			result = 3;
		}

		System.out.println(result);

	}

}

Measured memory_bytes: 26956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main()
{
    int n,m,ac=0,penalty=0,p;
    string s;
    cin>>n>>m;
    map<int,bool> a;
    map<int,int> wa;
    for(int i=0;i<m;++i){
        cin>>p>>s;
        if(s=="WA"&&a[p]==0)wa[p]++;
        if(s=="AC"&&a[p]==0)a[p]=1,ac++,penalty+=wa[p];
    }
    cout<<ac<<" "<<penalty<<endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b[4];
  cin>>a;
  b[0]=a%10;
  b[3]=a/1000;
  b[2]=(a-b[3]*1000)/100;
  b[1]=(a-b[3]*1000-b[2]*100)/10;
    
  if(b[0]==b[1] && b[1]==b[2])
    cout<<"Yes"<<endl;
  else if(b[1]==b[2] && b[2]==b[3])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return(0);
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m, ans, MOD = 1e9 + 7;

int main() {
	cin >> n >> m;
	
	if(abs(n - m) > 1) { ans = 0; }
	else {
		ans = 1;
		inc1(i, n) { (ans *= i) %= MOD; }
		inc1(i, m) { (ans *= i) %= MOD; }
		if(n == m) { (ans *= 2) %= MOD; }
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

void addEdge(int from, int to, int cap){
  G[from].push_back((edge) {to, cap, static_cast<int>(G[to].size())});
  G[to].push_back((edge) {from, 0, static_cast<int>(G[from].size()) - 1});
}

int dfs(int v, int t, int f) {
  if(v == t) return f;
  used[v] = true;
  for(int i = 0; i < G[v].size(); i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0) {
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int maxFlow(int s, int t) {
  int flow = 0;
  while(true) {
    memset(used, 0, sizeof(used));
    int f = dfs(s, t, INF);
    if( f == 0 ) return flow;
    flow += f;
  }
}

int main () {
  int X, Y, E;
  cin >> X >> Y >> E;

  // s, X, Y, t
  int s = 0;
  int t = 1 + X + Y;

  rep(i,X) addEdge(s, i + 1, 1);
  rep(i,Y) addEdge(1 + X + i, t, 1);
  rep(i,E) {
    int x, y;
    cin >> x >> y;
    addEdge(x + 1, 1 + X + y, INF);
  }

  cout << maxFlow(s, t)  << endl;

  return 0;
}



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

int main(){
    int h,r;
    int ans;
    cin >> h >> r;
    if( -h > r ){
        ans = -1;
    }else if( -h == r ){
        ans = 0;
    }else{
        ans = 1;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  string S = "";
  for (int i = 0; i < H; i++) {
    string T;
    cin >> T;
    S += T;
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int U = 0;
      char s = S.at(W * i + j);
      if (s == '#') { cout << "#";}
      else {
        if (i != 0 && j != 0) {
          char a = S.at(W * (i - 1) + j - 1);
          if (a == '#') {U++;}
        }
        if (i != 0) {
          char b = S.at(W * (i - 1) + j);
          if (b == '#') {U++;}
        }
        if (i != 0 && j != W - 1) {
          char c = S.at(W * (i - 1) + j + 1);
          if (c == '#') {U++;}
        }
        if (j != 0) {
          char d = S.at(W * i + j - 1);
          if (d == '#') {U++;}
        }
        if (j != W - 1) {
          char e = S.at(W * i + j + 1);
          if (e == '#') {U++;}
        }        
        if (i != H - 1 && j != 0) {
          char f = S.at(W * (i + 1) + j - 1);
          if (f == '#') {U++;}
        }        
        if (i != H - 1) {
          char g = S.at(W * (i + 1) + j);
          if (g == '#') {U++;}
        }
        if (i != H - 1 && j != W - 1) {
          char h = S.at(W * (i + 1) + j + 1);
          if (h == '#') {U++;}
        }
        cout << U;
      }  
    }    
    cout << endl;
  }
}

Measured memory_bytes: 3600
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N], p[N];
char op[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int j = 0; j < n; ++j) {
        p[j] = 1;
        if (j > 0) {
            cin >> op[j - 1];
            p[j] = (op[j - 1] == '-'? -1: 1);
        }
        cin >> a[j];
    }
    long long sum = a[0];
    int pp = 0;
    while (pp < n - 1 && op[pp] != '-') {
        sum += a[pp + 1];
        pp++;
    }
    if (pp == n - 1) {
        cout << sum << endl;
        return 0;
    }
    long long abs_sum = a[n - 1], res = -1e18;
    sum = 0;
    for (int j = 0; j < n - 1; ++j)
        sum += a[j] * p[j];
    res = max(res, sum);
    for (int j = n - 2; j >= 0; --j) {
        if (op[j] == '-') {
            int k = j + 1;
            long long s = a[j + 1];
            while (k < n - 1 && op[k] == '+') {
                s += a[k + 1];
                k++;
            }
            res = max(res, sum + abs_sum - 2 * s);
        }
        abs_sum += a[j];
        sum -= a[j] * p[j];
    }
    cout << res << endl;
}


Measured memory_bytes: 1152
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    public void solve() {
    	int N = ni();
    	int[] H = ndi(N);
    	int[] dp = new int[N+10];
    	Arrays.fill(dp, 1000000000);
    	dp[0] = 0;
    	for (int i = 0; i < N-1; i++) {
			dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(H[i+1] - H[i]));
			if(i+2 >= N)	break;
			dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(H[i+2] - H[i]));
		}
    	out.println(dp[N-1]);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 51780
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <bitset>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<long long int,long long int> 
#define ff first
#define pb push_back
#define ss second
#define ll long long 
#define ull unsigned long long
#define vi vector<long long int>
#define vii vector<pii>
#define vvi vector <vi>
#define rep(x,a,b,c) for(int x=a;x<=b;x+=c)
#define repp(x,a,b) rep(x,a,b,1)
#define rev(x,a,b,c) for(int x=a;x>=b;x-=c)
#define revv(x,a,b) rev(x,a,b,1)
#define OO (int)2e9
#define INF (ll)1e18
 
using namespace std;

int n,list[50],a,b,k;

int main()
{
	scanf("%d",&n);
	repp(x,1,n)
	{
		list[x]=x;
	}
	scanf("%d",&k);
	repp(x,1,k)
	{
		scanf("%d,%d",&a,&b);
		swap(list[a],list[b]);
	}
	repp(x,1,n)
	{
		printf("%d\n",list[x]);
	}
	return 0;
}

Measured memory_bytes: 3180
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String str = sc.next();
      	int count = 0;
      	for(int i=0;i<str.length();i++){
        	char character = str.charAt(i);
          	if(character == '1'){
            	count++;
            }
        }
      System.out.print(count);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n,m,ans[100005],total=0;
string s;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    int i,j,c=0,maxc=0;
    cin>>n>>m>>s;
    for(i=1;i<=n;i++)
    {
        if(s[i]=='1')
        {
            c++;
            maxc=max(maxc,c);
        }
        else
        {
            c=0;
        }
    }
    if(maxc>=m)
    {
        cout<<-1;
        return 0;
    }
    i=n;
    while(i>0)
    {
        j=max(i-m,0);
        while(s[j]=='1') j++;
        ans[++total]=i-j;
        i=j;
    }
    for(i=total;i>=1;i--)
        cout<<ans[i]<<' ';
    return 0;
}


Measured memory_bytes: 1104
n=int(input())
march=['M','A','R','C','H']
s=[input() for _ in range(n)]
m=[]
a=[]
r=[]
c=[]
h=[]
for i in s:
    if i[0]=='M':
        m.append(i)
    elif i[0]=='A':
        a.append(i)
    elif i[0]=='R':
        r.append(i)
    elif i[0]=='C':
        c.append(i)
    elif i[0]=='H':
        h.append(i)
m=list(set(m))
a=list(set(a))
r=list(set(r))
c=list(set(c))
h=list(set(h))
l=[len(m),len(a),len(r),len(c),len(h)]
ans=0
rr=[]
if l.count(0)<=2:
    ll=[i for i in l if i>=1]
    ans=1
    if len(ll)==3:
        for i in ll:
            ans*=i
    elif len(ll)==4:
        for i in range(2):
            for j in range(i+1,3):
                for k in range(j+1,4):
                    rr.append(ll[i]*ll[j]*ll[k])
        ans=sum(rr)
    else:
        for i in range(3):
            for j in range(i+1,4):
                for k in range(j+1,5):
                    rr.append(ll[i]*ll[j]*ll[k])
        ans=sum(rr)
print(ans)

Measured memory_bytes: 16700
from sys import stdin


def main():
    lines = stdin.readlines()
    A = tuple(int(i) for i in lines[1].split())
    B = tuple(int(i) for i in lines[2].split())
    pre = A[0]
    ans = 0
    for a, b in zip(A[1:], B):
        tmp1 = pre if pre < b else b
        b -= tmp1
        tmp2 = a if a < b else b
        ans += tmp1 + tmp2
        pre = a - tmp2
    print(ans)
    return


main()


Measured memory_bytes: 20964
function Main(input){
    const arr = input.split(' ').map(Number);
    let K = arr[3];
    let total=0;

    if(K>=arr[0]){
        total += arr[0];
        K -= arr[0];
    } else {
        total += K;
        console.log(total);
        return;
    }
    
    if(K>=arr[1]){
        K -= arr[1];
    } else {
        console.log(total);
        return;
    }

    if(K>=arr[2]){
        total -= arr[2];
        K -= arr[2];
    } else {
        total -= K;
        console.log(total);
        return;
    }
    console.log(total);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29868
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main(int argc, char const *argv[])
{
	std::vector<int> a(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	int k;
	cin >> k;
	
	string ans = "Yay!";

	for (int i = 0; i < 4; i++){
		for (int j = i+1; j < 5; j++)
		{
			if(a[j]-a[i] > k){
				ans = ":(";
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N, T = map(int,input().split())
mincost = 100000
for i in range(N):
    ci, ti = map(int,input().split())
    if ti <= T:
            mincost = min(mincost,ci)

if mincost == 100000:
    print('TLE')
else:
    print(mincost)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
int n;
int main(void){
    int n;
    string s;cin>>n>>s;
    int dp[n+1][n+1];//sの
    rep(i,n+1){
        rep(j,n+1){
            dp[i][j]=0;
        }
    }
    rep(i,n){
        rep(j,i){
            if(i==j)continue;
            int ni=i+1,nj=j+1;
            if(s[i]==s[j]){
                dp[ni][nj]=dp[i][j]+1;
            }else{
                dp[ni][nj]=0;
            }
        }
    }
    int res=0;
    rep(i,n+1){
        rep(j,n+1){
            if(i==j)continue;
            if(i-dp[i][j]<j)continue;
            res=max(res,dp[i][j]);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 97920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, n)    for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define _in(a) \
    ll a;      \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
#define in(a, b, c, d, e) \
    _in(a);               \
    _in(b);               \
    _in(c);               \
    _in(d);               \
    _in(e)
#define in(a, b, c, d) \
    _in(a);            \
    _in(b);            \
    _in(c);            \
    _in(d)
#define in(a, b, c) \
    _in(a);         \
    _in(b);         \
    _in(c)
#define in(a, b) \
    _in(a);      \
    _in(b)
#define in(a) _in(a)
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)  (x).begin(), (x).end()    //昇順
#define rall(x) (x).rbegin(), (x).rend()  //降順
#define yes     out("Yes");
#define no      out("No");

int main() {
    in(n);
    in(x);
    in(t);
    out(((n + (x - 1)) / x) * t);
}

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

int main(){
	int N, a, b, sum = 0;
	cin >> N >> a >> b;
	for(int i = 0; i <= N; i++){
		int res = i, s = 0;
		while(res){
			s += res % 10;
			res /= 10;
		}
		
		if(s >= a && s <= b)
			sum += i;
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String S = scan.next();
		String T = scan.next();

		if(T.length() == S.length() + 1 && S.equals(T.substring(0, S.length()))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35764
#include <iostream>
#include <algorithm>

using namespace std;



int main(void) {
  int N;
  int A[100];
  int alice=0, bob=0;
  // int *B;
  cin >> N;
  // B = (int *)malloc(sizeof(int) * N);
  for(int i=0;i < N;i++) {
    cin >> A[i];
  }

  sort(A, A+N);
  reverse(A, A+N);

  for(int j=0;j < N;j += 2) {
    alice += A[j];
  }

  for(int j=1;j < N;j += 2) {
    bob += A[j];
  }

  cout << alice - bob << endl;

  return 0;
}


Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline


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

    A = []
    for i in range(len(S)-len(T)+1):
        flg = True
        for j in range(len(T)):
            if S[i+j:i+j+1] not in [T[j:j+1], '?']:
                flg = False
        
        if flg:
            K = S[:i] + T + S[i+len(T):]
            A.append(K.replace('?', 'a'))
    
    if len(A)==0 or len(S)<len(T):
        print('UNRESTORABLE')
        return
    print(min(A))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

  int sum[N+1]; //i人目までで、西を向いている人の数
  sum[0] = 0;
  for(int i=0;i<N;i++){
    if(S[i] == 'W') sum[i+1] = sum[i] + 1;
    else sum[i+1] = sum[i];
  }

  //for(int i=0;i<N;i++) cout << sum[i] << endl;

  int ans = 10000000;
  for(int i=0;i<N;i++){
    int res;
    //左側
    int left = sum[i];
    //右側
    int right = (N-1) - i - (sum[N]-sum[i+1]);

    res = left + right;
    ans = min(ans, res);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1796
import java.util.Scanner;

public class Main {

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

		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = 0;
		int count = 0;
		int yesCount = 0;

		Z = X * 2;

		if (Z != Y) {
			for (int i = 0; i < X; i++) {
				Z = Z + 2;
				if (Z == Y) {
					i = i + 1;
					count = i;
					System.out.println("Yes");
					yesCount++;
					break;
				}
			}
		} else if (X * 2 == Y) {
			System.out.println("Yes");
			yesCount++;
		}
		if (yesCount == 0) {
			System.out.println("No");
		}
		//System.out.println(X - (count) + (" ") + (count));
		sc.close();
	}
}


Measured memory_bytes: 35648
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <memory>
#include <string>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define MAX 105

struct Vtx{
    int id;
    int path;
    Vtx(){path=id=-1;}
    bool operator <(Vtx &b){
        return id<b.id;
    }
};

Vtx V[MAX];

set<int> adj[MAX];

int n,u,k,v;

void bfs(){
     queue<int> q;
     q.push(1);
     V[1].path=0;
     set<int> e;
     set<int>::iterator it;
     while(!q.empty()){
        e = adj[q.front()];
        it = e.begin();
        while(it!=e.end()){
            if(V[*it].path==-1){
                V[*it].path = V[q.front()].path+1;
                q.push(*it);
            }
            it++;
        }
        q.pop();
     }

}

void print(){
    for(int i=1;i<=n;i++){
        printf("%d %d\n",i,V[i].path);
    }
}


void solve(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&u,&k);
        V[u].id=i;
        for(int j=0;j<k;j++){
            scanf("%d",&v);
            adj[u].insert(v);
        }
    }
    bfs();
    print();
}

int main(){

   // freopen("in","r",stdin);
    solve();
    return 0;
}

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

int main(){
	int K,S;
	cin>>K>>S;
	int ans=0;
	for(int x=0;x<=K;++x){
		for(int y=0;y<=K;++y){
			int z=S-x-y;
			if((z>=0) && (z<=K)) ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

int calc(int[][] xs) {
    int n = cast(int) xs[0].length;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x = 0;
        for (int j = 0; j < n; j++) {
            if (j < i) x += xs[0][j];
            if (j == i) x += xs[0][j] + xs[1][j];
            if (j > i) x += xs[1][j];
        }
        ans = max(ans, x);
    }
    return ans;
}

void main() {
    readint;
    int[][] xs;
    xs ~= readints;
    xs ~= readints;

    int ans = calc(xs);
    writeln(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int ans = k;
    int i;
    for(i = 0;i < n-1;++i){
        ans *= k-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, q = tuple([int(i) for i in input().split(' ')])
s = input()

c = [0] * n

for i in range(1, n):
    if s[i - 1:i + 1] == 'AC':
        c[i] += c[i - 1] + 1
    else:
        c[i] += c[i - 1]

for i in range(q):
    l, r = tuple([int(i) for i in input().split(' ')])
    print(c[r - 1] - c[l - 1])


Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    string S;
    cin >> S;
    int len = S.size();
    int win = 0;
    for(int i = 0, i_len = S.size(); i < i_len; ++i) if(S[i] == 'o') ++win;
    if(15 - len >= 8 - win) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
s = input()
de = deque()
for i in s:
    if i == "0":
        de.append("0")
    elif i == "1":
        de.append("1")
    elif i == "B":
        if len(de) != 0:
            de.pop()
ans = "".join(de)
print(ans)

Measured memory_bytes: 9324
#include<iostream>
using namespace std;
#include<iomanip>
#include<cmath>

int main()
{
    int i, n;
    int x[100], y[100];
    double d1 = 0, d2 = 0, d3 = 0, d_inf = 0;

    cin >> n;
    for(i = 0; i < n; i++){ cin >> x[i]; }
    for(i = 0; i < n; i++){
        cin >> y[i];
        d1 = d1 + abs(x[i] - y[i]);
        d2 = d2 + pow(1.0 * (x[i] - y[i]), 2.0);
        d3 = d3 + pow(1.0 * abs(x[i] - y[i]), 3.0);
        if(d_inf < abs(x[i] - y[i])) d_inf = abs(x[i] - y[i]);
    }

    cout << fixed << setprecision(10) << endl;
    cout << d1 << endl << sqrt(d2) << endl;
    cout << pow(d3, 1.0 / 3) << endl << d_inf << endl;

    return 0;
}

Measured memory_bytes: 1300
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i; j < N; j++){
            ans = max(ans, abs(A[i] - A[j]));
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll n, x; cin >> n >> x;
	ll h = x; ll w = n - x; ll sum = n;
	while (h&&w) {
		ll d = w / h; ll r = w % h;
		sum += (ll)2 * d*h;
		if (r == 0)sum -= h;
		w = h; h = r;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int asize,bsize;
  asize=a.size();
  bsize=b.size();
  if(a.at(asize-1)==b.at(0)&&b.at(bsize-1)==c.at(0)){
    cout <<"YES"<<endl;
    return 0;
  }
  else cout <<"NO"<<endl;
}


Measured memory_bytes: 3612
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

main = do
  s <- B.getLine
  putStrLn $ [B.head s] ++ (show (B.length s - 2)) ++ [B.last s]

Measured memory_bytes: 380
#include<iostream>
using namespace std;
class Rectangle{
public:
  void cal(int a,int b){
    cout<<a*b<<" "<<2*a+2*b<<endl;
  }
};
int main(){
  int a,b;
  cin>>a>>b;
  Rectangle rec;
  rec.cal(a,b);
  return 0;
}

Measured memory_bytes: 1164
n, k = map(int, input().split())

if (n-1)*(n-2)//2 < k:
    print(-1)
    exit()

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

for i in range(2, n):
    for j in range(i+1, n+1):
        E.append((i, j))

m = n-1 + (n-1)*(n-2)//2 - k
print(m)
for i in range(m):
    print(*E[i])


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

using namespace std;


int main()
{
	int n; cin >> n;
	int arr[n];
	int val = 0;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
		val ^= arr[i];
	}
	for(int i = 0; i < n; i++){
		cout << (val^arr[i]) << "\n";
	}
}


Measured memory_bytes: 4404
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	ret := int64(0)
	for i := 1; i <= N; i++ {
		if i%3 != 0 && i%5 != 0 {
			ret += int64(i)
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 1752
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]){

    long long key, i, h;
	key = getKey(str);
	for(i = 0;;i++){
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h],str) == 0)return 1;
		else if(strlen(H[h]) == 0)return 0;
	}
	return 0;
}

int insert(char str[]){

    long long key, i, h;
	key = getKey(str);
	for(i = 0;;i++){
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h],str) == 0)return 1;
		else if(strlen(H[h]) == 0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
		scanf("%s %s", com, str);
	
		if ( com[0] == 'i' ){
	    	insert(str);
		} 
    	else {
	    	if (find(str)){
				printf("yes\n");
	    	} 
    		else {
				printf("no\n");
	    	}
		}
    }
    return 0;
}


Measured memory_bytes: 16052
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var s, t string
	fmt.Scan(&s, &t)

	for i:=0; i<n; i++ {
		if s[i:n] == t[0:n-i] {
			fmt.Print(n+i)
			return
		}
	}

	cn := s + t
	ans := len(cn)
	fmt.Print(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  map<int,int> mp;
  rep(i,0,N)mp[P[i]]++;
  if(mp.size()>3)flag=1;
  else if(mp.size()==3){for(auto v:mp)if(v.second!=N/3)flag=1;for(auto v:mp)sum^=v.first;if(sum)flag=1;}
  else if(mp.size()==2){if(mp[0]!=N/3||N%3!=0||mp.count(0)==0)flag=1;}
  else if(mp.size()==1)if(mp.count(0)==0)flag=1;
  if(flag)Out("No");
  else Out("Yes");
}

Measured memory_bytes: 4480