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

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

    int ans1 = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (S[i] != '0')
            {
                ans1++;
            }
        }
        else
        {
            if (S[i] != '1')
            {
                ans1++;
            }
        }
    }

    int ans2 = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (S[i] != '1')
            {
                ans2++;
            }
        }
        else
        {
            if (S[i] != '0')
            {
                ans2++;
            }
        }
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 512
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val sa = scanner.next()
    val a = Integer.parseInt(sa)
    val b = arrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 49, 56, 63, 54, 64, 72, 81)
        if(a in b){
        println("Yes")
        }else{
            println("No")
        }
    }

Measured memory_bytes: 35960
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let mut a:Vec<u32> = vec![0; n];

    for i in 0..n {
        a[i] = read();
    }

    let mut cnt = 0;
    'count: loop {
        for i in 0..n {
            if a[i] % 2 != 0 {
                break 'count;
            } else {
                a[i] = a[i] / 2;
            }
        }
        cnt += 1;
    }

    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (50000)
//n<=50000
struct edge{
	int to;
	long long dis;
};

int n, m;
vector<edge>e[N];
long long d[N];
bool dec[N];

void init(void){
	f(i, N){
		d[i] = MOD;
		dec[i] = false;
	}
}

void dijkstra(int s){
	d[s] = 0;
	priority_queue<pair<long long, int> >pq;
	pq.push(make_pair(0, s));
	while (!pq.empty()){
		while (dec[pq.top().second]){
			pq.pop();
			if (pq.empty())return;
		}
		dec[pq.top().second] = true;
		f(i, e[pq.top().second].size()){
			if (d[e[pq.top().second][i].to] > (d[pq.top().second] + e[pq.top().second][i].dis)){
				d[e[pq.top().second][i].to] = d[pq.top().second] + e[pq.top().second][i].dis;
				pq.push(make_pair(-d[e[pq.top().second][i].to], e[pq.top().second][i].to));
			}
		}
	}
	return;
}



int main(void){
	int x, y, z;
	char a[50][51];
	int ans = 0;
	scanf("%d %d", &n, &m);
	init();
	f(i, n)scanf("%s", a[i]);
	f(i, n){
		f(j, m){
			if (a[i][j] == '.'){
				ans++;
				x = (i*m) + j;
				if (i < (n - 1)){
					if (a[i + 1][j] == '.'){
						y = ((i + 1)*m) + j;
						e[x].push_back({ y, 1 });
						e[y].push_back({ x, 1 });
					}
				}
				if (j < (m - 1)){
					if (a[i][j + 1] == '.'){
						y = (i*m) + j + 1;
						e[x].push_back({ y, 1 });
						e[y].push_back({ x, 1 });
					}
				}
			}
		}
	}
	dijkstra(0);


	if (d[((n*m) - 1)] == MOD)printf("-1\n");
	else printf("%d\n", (ans - d[((n*m) - 1)]-1));

	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

struct node
{
	int l,r;
	node(int _l=0,int _r=0):l(_l),r(_r){}
	bool operator < (const node &o)const
	{
		return r>o.r;
	}
};
priority_queue<node> Q;
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,l;
		scanf("%d%d",&x,&l);
		Q.push(node(x-l,x+l));
	}
	int now=-2e9;
	int ans=0;
	while(!Q.empty())
	{
		node T=Q.top();
		Q.pop();
		if(T.l>=now) ans++,now=T.r;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int solve(const int n) {
	set< vector<int> > s;
	vector<int> v(4);

	for (v[0] = 0; v[0] < 10; v[0]++)
		for (v[1] = 0; v[1] < 10; v[1]++)
			for (v[2] = 0; v[2] < 10; v[2]++)
				for (v[3] = 0; v[3] < 10; v[3]++) {
					int sum = 0;
					for (int i = 0; i < 4; i++) sum += v[i];
					if (sum == n) {
						s.insert(v);
						break;
					}
				}
	return s.size();
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n) {
		cout << solve(n) << endl;
	}
	return 0;
}

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

using namespace std;

int n;
int v[100005];

int C1[100005];
int C2[100005];

int main(void) {

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> v[i];
	}

	for (int i = 1; i <= n; i += 2) {
		C1[v[i]]++;
	}
	for (int i = 2; i <= n; i += 2) {
		C2[v[i]]++;
	}

	int odd1=-1, num_odd1=-1, odd2=-1, num_odd2=0;

	for (int i = 1; i <= 100000; i++) {
		if (C1[i] > num_odd1) { num_odd1 = C1[i]; odd1 = i; }
	}

	C1[odd1] = 0;
	for (int i = 1; i <= 100000; i++) {
		if (C1[i] > num_odd2) { num_odd2 = C1[i]; odd2 = i; }
	}

	int even1 = -1, num_even1 = -1, even2 = -1, num_even2 = 0;

	for (int i = 1; i <= 100000; i++) {
		if (C2[i] > num_even1) { num_even1 = C2[i]; even1 = i; }
	}
	C2[even1] = 0;
	for (int i = 1; i <= 100000; i++) {
		if (C2[i] > num_even2) { num_even2 = C2[i]; even2 = i; }
	}
      
	int ans;

	if (odd1 != even1) { ans = n / 2 - num_odd1 + n / 2 - num_even1; }
	else {
		ans = min(n / 2 - num_odd1 + n / 2 - num_even2, n / 2 - num_odd2 + n / 2 - num_even1);
	}

	/*cout << "odd1= " << odd1 << "  num=" << num_odd1 << endl;
	cout << "odd2= " << odd2 << "  num=" << num_odd2 << endl;
	cout << "even1= " << even1 << "  num=" << num_even1 << endl;
	cout << "even2= " << even2 << "  num=" << num_even2 << endl;

	for (int i = 1; i <= 5; i++) {
		cout << "C2[" << i << "]= " << C2[i] << endl;
	}*/

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n,a,b,c,d[100],m=0,x;
	cin>>n>>a>>b>>c;
	int start=c/a;
	for(int i=0;i<=n-1;i++){
		cin>>d[i];
	}
	sort(d,d+n);
	for(int k=1;k<=n;k++){
		int sum=0;
		for(int i=n-1;i>=n-k;i--){
            sum=sum+d[i];
		}
		   x=(sum+c)/(a+b*k);
            m=max(m,x);
	}
	m=max(m,start);
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int X, N; cin >> X >> N;
    vector<bool> flag(121,true);

    int ans;

    for(int i=1; i<=N; i++){
        int p; cin >> p;
        flag.at(p) = false;
    }

    for(int i=X; i>=1; i--){
        if(flag.at(i) == true){
            ans = i;
            break;
        }
    }

    for(int i=X; i<=110; i++){
        if(flag.at(i) == true){
            if(abs(X-ans) > abs(X-i)){
                ans = i;
            }
        }
    }

    cout << ans << endl;

}

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

int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  pair<int, int> r[n];
  pair<int, int> b[n];
  for(int i = 0;i < n;i++)
    cin >> r[i].first >> r[i].second;
  for(int i = 0;i < n;i++)
    cin >> b[i].first >> b[i].second;
  set<pair<int, int>> avail;
  sort(b, b + n);
  sort(r, r + n);
  int cur = 0;
  int res = 0;
  for(int i = 0;i < n;i++){
    while(cur < n && r[cur].first < b[i].first){
      avail.insert({r[cur].second, r[cur].first});
      cur++;
    }
    auto it = avail.lower_bound({b[i].second, -100000});
    if(it == avail.begin())continue;
    it--;
    res++;
//    cout << it -> second << ' ' << it -> first << endl;
    avail.erase(it);

  }
  cout << res;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<n; i++)
int n,m;
vector<int> g[125252];
int dist[125252], bef[125252];
int main(){
  scanf("%d%d", &n, &m);
  REP(i,m){
    int u,v;
    scanf("%d%d", &u, &v);
    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  queue<int> Q;
  fill(dist, dist+n, 830252521);
  fill(bef, bef+n, -1);
  dist[0] = 0;
  Q.push(0);
  while(Q.size()){
    int p = Q.front(); Q.pop();
    for(int to : g[p]){
      int nd = dist[p] + 1;
      if(nd < dist[to]){
        dist[to] = nd;
        bef[to] = p;
        Q.push(to);
      }
    }
  }
  puts("Yes");
  for(int i=1; i<n; i++)printf("%d\n", bef[i]+1);
  return 0;
}

Measured memory_bytes: 11544
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=min(a,b);i>=1;i--){
		k-=(a%i==0&&b%i==0);
		if(!k){
			cout<<i<<endl;
			break;
		}
	}
	cin.get();
	cin.get();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 long double ld;
typedef pair<ll, int> ii;
const int mod = (int) 1e9 + 7;
const ll inf = 1LL << 60;
const int maxn = (int) 505;
const double eps = 1e-9;
const int base = 43;

int n, f[maxn], res, add, flag;
string a[maxn];

int main() {
    //freopen("test.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        rep(j, 0, n) if(a[i][j] == '#') flag = 1, f[j] ++;
    }
    if(!flag) return cout << "-1\n", 0;

    res = mod;
    rep(i, 0, n) {
        add -= (f[i] == n);
        int cnt = (f[i] == 0);
        rep(j, 0, n) {
            if(a[i][j] == '#') continue;
            cnt ++;
        }
        if(flag) res = min(res, cnt);
    }
    cout << res + n + add << endl;
}




Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        var N = cin.nextInt();
        var M = cin.nextInt();
        var X = cin.nextInt();
        var A = new int[M];
        for(var i = 0;i < M; i++)
        {
            A[i] = cin.nextInt();
        }

        var lcost = 0;
        for(var i = X;i >= 0; i--)
        {
            if (A.Contains(i))
            {
                lcost += 1;
            }
        }

        var rcost = 0;
        for(var i = X;i < N + 1; i++)
        {
            if (A.Contains(i))
            {
                rcost += 1;
            }
        }
        Console.WriteLine(Math.Min(lcost, rcost));
        //Console.ReadLine();


    }
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int k,x;
  cin >> k >> x;
  if(k*500>=x)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	for(int x=0;(x*4)<=n;x++){
			if((n-4*x)%7==0){
				cout<<"Yes"<<endl;
				return 0;
			}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
a = []
while b:
    m = len(b)
    ok = False
    for i in range(m)[::-1]:
        if b[i] == i+1:
            a.append(b.pop(i))
            ok = True
            break

    if not ok:
        print('-1')
        exit()

for i in range(n)[::-1]:
    print(a[i])


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

int main()
{
    int n, a[200010];
    cin >> n;

    bool f = n % 2;
    int l = 100005, r = l + 1;
    for(int i = 0; i < n; i++, f = !f){
        scanf("%d", &(f ? a[l--] : a[r++]));
    }

    for(int i = ++l; i < r; i++) printf("%d ", a[i]);
    cout << endl;

    return 0;
}


Measured memory_bytes: 2944
from bisect import bisect as bi
s = input()
t = input()
x,c,ans,num = [[] for i in range(26)],[0]*26,0,-1
for i in range(len(s)):
    x[ord(s[i])-97].append(i)
    c[ord(s[i])-97]+=1
for i in t:
    if x[ord(i)-97]:
        b = bi(x[ord(i)-97],num)
        if b==c[ord(i)-97]:
            ans+=len(s)
            num = x[ord(i)-97][0]
        else: num = x[ord(i)-97][b]
    else:
        ans,num = -1,-1
        break
print(ans+num+1)

Measured memory_bytes: 7540
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);

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

  int ans = 0;

  for (int i=0; i<n; i++) {
    ans += b[a[i]-1];
    if (i!=n-1 && a[i]+1 == a[i+1]) ans+=c[a[i]];
    // cout << ans << endl;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce


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


def iinput():
    return int(input())


def tinput():
    return input().split()


def rinput():
    return map(int, tinput())


def rlinput():
    return list(rinput())


mod = int(1e9)+7


def factors(n):
    return set(reduce(list.__add__,
                      ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))


# ----------------------------------------------------

if __name__ == "__main__":
    n, w = rinput()
    w_v = []
    for i in range(n):
        w_v.append(rlinput())
    dp = [[0 for i in range(w+1)]for j in range(n+1)]
    # print(w_v)
    for item in range(1, n+1):
        for weight in range(1, w+1):
            if weight >= w_v[item-1][0]:
                dp[item][weight] = max(dp[item-1][weight-w_v[item-1][0]]+w_v[item-1][1],dp[item-1][weight])
            else:
                dp[item][weight] =dp[item-1][weight]
    print(dp[n][w])


Measured memory_bytes: 171892
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    #
    n = int(input().strip())
    S = input().strip()
    R = []
    G = []
    B = set()
    for i in range(n):
        if S[i] == 'R':
            R.append(i)
        elif S[i] == 'G':
            G.append(i)
        elif S[i] == 'B':
            B.add(i)
    R.sort()
    G.sort()

    #
    n_all = len(R)*len(G)*len(B)
    cnt = 0
    for i in R:
        for j in G:
            high = 2*i - j
            low = 2*j - i
            if (i+j) % 2 == 0:
                mid = (i+j) // 2
            else:
                mid = -1
            cnt += (high in B) + (low in B) + (mid in B)
    eprint('n_all, cnt ',end=':\n')
    eprint(n_all, cnt)
    print(n_all - cnt)


if __name__ == '__main__':
    main()


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

#define ran 101101

int n;
vector<pair<int, int> > e[ran];
int ma;
int ans[ran];

void inc(int &x) {
	x++;
	if(x>ma) x=1;
}

void dfs(int cur, int par, int col) {
	for(int i=0;i<(int)e[cur].size();i++) {
		int nxt = e[cur][i].first, eid = e[cur][i].second;
		if(nxt==par) continue;
		
		ans[eid] = col;
		inc(col);
		dfs(nxt, cur, col);
	}
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<n;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		
		e[x].push_back(make_pair(y, i));
		e[y].push_back(make_pair(x, i));
	}
	ma = 0;
	for(int i=1;i<=n;i++)
		ma = max(ma, (int)e[i].size());
	
	dfs(1, -1, 1);
	
	printf("%d\n", ma);
	for(int i=1;i<n;i++)
		printf("%d\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 8576
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    if(b==c)cout<<1<<endl;
    else cout<<2<<endl;
  }
  else if(b==c)cout<<2<<endl;
  else if(a==c)cout<<2<<endl;
  else cout<<3<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
max_ans = sum(a)
ans = abs(a[0]-(max_ans - a[0]))
sumu = a[0]
for i in range(1,n-1):
  sumu += a[i]
  arai = max_ans - sumu
  kari = abs(sumu-arai)
  if kari < ans:
    ans = kari
print(ans)

Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
using namespace std;
int main()
{
    fIO
    int n,m;
    cin>>n>>m;
    int sum=0;
    loop(m)
    {
        int a;
        cin>>a;
        sum+=a;
    }
    if(sum>n)
    cout<<-1;
    else
    cout<<n-sum;
    return 0;
}
    

Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="abc")
    {
        cout<<"Yes";
        system("pause");
        return 0;
    }
    if(s=="acb")
    {
        cout<<"Yes";
        system("pause");
        return 0;
    }
    if(s=="bac")
    {
        cout<<"Yes";
        system("pause");
        return 0;
    }
    if(s=="bca")
    {
        cout<<"Yes";
        system("pause");
        return 0;
    }
    if(s=="cab")
    {
        cout<<"Yes";
        system("pause");
        return 0;
    }
    if(s=="cba")
    {
        cout<<"Yes";
        system("pause");
        return 0;
    }
    cout<<"No";
 system("pause");
 return 0;
}
    

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A == 1) A = 14;
	if (B == 1) B = 14;

	string ans;
	if (A > B)
		ans = "Alice";
	else if (B > A)
		ans = "Bob";
	else
		ans = "Draw";
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

int n, z, w, ans;
int a[2010];

int main() {
	cin >> n >> z >> w;
	for (int i = 0; i < n; i++)cin >> a[i];
	if (n == 1)ans = abs(a[0] - w);
	else ans = max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2]));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
int main() {
	int a, b;
	int r;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	while (1) {
		if (op == '?') break;
		switch (op) {
		case'+':
			r = a + b;
			break;
		case'-':
			r = a - b;
			break;
		case'*':
			r = a * b;
			break;
		case'/':
			r = a / b;
			break;
		}
		printf("%d\n",r);
		scanf("%d %c %d", &a, &op, &b);

	}
	
	return 0;
}


Measured memory_bytes: 2064
import Control.Monad
import Data.List

main = do
    [x,y,z,k] <- (map read . words) <$> getLine
    [a,b,c] <- replicateM 3 $ map read . words <$> getLine
    let d = take k $ sortBy (flip compare) ((+) <$> a <*> b)
    mapM_ print $ take k $ sortBy (flip compare) ((+) <$> d <*> c)

Measured memory_bytes: 419196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    string a, b; cin >> a >> b;
    string ab = a + b;
    double root = sqrt(stoi(ab));
    cout << (root - (int)root == 0 ? "Yes" : "No") << endl;;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(int argc, char *argv[])
{
    char str[201], tmp[201];
    int i, h, s_cnt;
 
    memset(str, '\0', sizeof(str));
     
    while (1) {
        scanf("%s", str);
 
        if (str[0] == '-') {
            break;
        }
 
        scanf("%d", &s_cnt);
        int len = strlen(str);
 
        for (i = 0; i < s_cnt; i++) {
            scanf("%d", &h);
            memset(tmp, '\0', sizeof(tmp));
            memcpy(tmp, &str[h], len - h);
            memcpy(&tmp[len - h], str, h);
            memset(str, '\0', sizeof(str));
            memcpy(str, tmp, len);
        }
 
        printf("%s\n", str);
 
    }
 
    return 0;
}

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

int main()
{
    long long x;
    cin >> x;
    long long ans = x / 11 * 2, a = x % 11;
    if (1 <= a && a <= 6) {
        ans++;
    } else if (7 <= a) {
        ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int h[1500001]={},w[1500001]={},n,m,i,j,p[1500],k;
int main(){
 while(1){
   cin>>n>>m;if(n==0)break;
   for(i=0;i<n;i++){
    cin>>p[i];
    for(j=i,k=0;j>=0;j--)k+=p[j],h[k]++;
   }
   n=k;
   for(i=0;i<m;i++){
    cin>>p[i];
    for(j=i,k=0;j>=0;j--)k+=p[j],w[k]++;
   }
   if(k<n)k=n;
   n=0;
   for(i=1;i<=k;i++)n+=h[i]*w[i],h[i]=w[i]=0;
   cout<<n<<endl;
  }
 return 0;
}

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

int main(){
  int k, s; cin >> k >> s;
  
  int count = 0;
  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k; j++){
      if(s-i-j >= 0 && s-i-j <= k)count++;
    }
  }
  cout << count << endl;
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  string s; cin >> s;
  for (int i = 1; i <= s.size(); i++) {
    if ((i%2 == 0 && s[i-1] == 'R') || (i%2 != 0 && s[i-1] == 'L')) {
      cout << "No" << endl; return 0;
    }
  }
  cout << "Yes" << 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);
    String str = scanner.nextLine();
    String[] data = str.split(" ");
    int[] score = new int[2];
    score[0] = Integer.parseInt(data[0]);
    score[1] = Integer.parseInt(data[1]);
    if (score[0] > 9 || score[1] >9){
      System.out.println(-1);
    }else{
      System.out.println(score[0] * score[1]);
    }
  }
}

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


int main(){
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++) cin >> S[i];
    sort(S.begin(), S.end());
    for (int i = 0; i < N; i++) cout << S[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>

using namespace std;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int32_t K, X;
    cin >> K >> X;

    for(int i = (X - K) + 1;i < X + K;++i){
        cout << i << " ";
    }

    cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  string s; cin >> s;
  if(s == "SUN") cout << 7 << endl;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    System.out.println(ans);
  }
  
  private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  }

  /*
  private static HashMap<Integer, Long> cache = new HashMap<>();
  private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    Long cached = cache.get(v);
    if (cached != null) {
      return cached;
    }
    long value = v + sum(v-1);
    cache.put(v, value);
    return value;
  }
  */
}


Measured memory_bytes: 74780
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
vector<int> rot(vector<int> &v) {
	vector<int> ret(4);
	for (int i = 0; i < 4; i++) {
		ret[i] = v[(i + 1) % 4];
	}
	return ret;
}
vector<int> lex_min(vector<int> v) {
	vector<int> ret = v;
	for (int i = 1; i < 4; i++) {
		v = rot(v);
		ret = min(ret, v);
	}
	return ret;
}
vector<int> tile[400];
map<vector<int>, int> cnt;
map<vector<int>, int> same;
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		vector<int> v;
		for (int j = 0; j < 4; j++) {
			int C;
			cin >> C;
			v.push_back(C);
		}
		v = lex_min(v);
		tile[i] = v;
		cnt[v]++;
		same[v] = 1;
		vector<int> t = v;
		for (int j = 1; j < 4; j++) {
			t = rot(t);
			if (v == t) same[v]++;
		}
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		cnt[tile[i]]--;
		vector<int> v1 = tile[i];
		for (int j = i + 1; j < N; j++) {
			cnt[tile[j]]--;
			vector<int> v2 = tile[j];
			for (int dir = 0; dir < 4; dir++) {
				map<vector<int>, int> use;
				vector<int> v(4);
				v[0] = v1[0]; v[1] = v1[3]; v[2] = v2[2]; v[3] = v2[1];
				v = lex_min(v);
				use[v]++;
				v[0] = v1[3]; v[1] = v1[2]; v[2] = v2[3]; v[3] = v2[2];
				v = lex_min(v);
				use[v]++;
				v[0] = v1[2]; v[1] = v1[1]; v[2] = v2[0]; v[3] = v2[3];
				v = lex_min(v);
				use[v]++;
				v[0] = v1[1]; v[1] = v1[0]; v[2] = v2[1]; v[3] = v2[0];
				v = lex_min(v);
				use[v]++;
				ll t = 1;
				for (auto p : use) {
					if (cnt.find(p.first) == cnt.end() || cnt[p.first] < p.second) {
						t = 0;
						break;
					}
					for (int i = 0; i < p.second; i++) {
						t *= cnt[p.first] - i;
						t *= same[p.first];
					}
				}
				ans += t;
				v2 = rot(v2);
			}
			cnt[tile[j]]++;
		}
		cnt[tile[i]]++;
	}
	cout << ans/3 << endl;
}


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

int main(){
  int n,m,taro[100],hana[100],i,j,sum,exsum,s,num;
  int min,T,H,f=0;
  while(1){
    sum=0;
    exsum=0;
    min=200;
    T=0;
    
    cin>>n>>m;
    if(n==0 && m==0)break;
    for(i=0;i<n;i++){
      cin>>taro[i];
      sum+=taro[i];
      exsum+=taro[i];
    }
    for(i=0;i<m;i++){
      cin>>hana[i];
      sum+=hana[i];
    }
    if(sum%2!=0){
      cout<<"-1"<<endl;
      continue;
    }
    
    sum/=2;
    
    for(i=0;i<n;i++){
      s=exsum-taro[i];
      num=sum-s;
      if(num<0)continue;
      for(j=0;j<m;j++){
	if(hana[j]==num){
	  if((hana[j]+taro[i])<min){
	    min=(taro[i]+hana[j]);
	    T=taro[i];
	    H=hana[j];
	  }
	}
      }
    }
    if(T==0)cout<<"-1"<<endl;
    else cout<<T<<' '<<H<<endl;
  }
  return 0;
}


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

int main(){
  string s,t;
  cin>>s;
  cin>>t;
  
  int64_t N=s.size();
  
  map<char,vector<int>> m;
  for(int i=0;i<N;++i){
    m[s[i]].push_back(i);
  }

  bool flag=true;
  for(int i=0;i<t.size();++i){
    if(m[t[i]].size()==0){
      flag=false;
      break;
    }
  }
  

  for(auto p:m){
    sort(p.second.begin(),p.second.end());
  }

  int64_t ans=-1;
  if(flag){
    ans=0;
    int i=m[t[0]][0];
    int cnt=1;
    while(cnt<t.size()){
      if(m[t[cnt]].end()-upper_bound(m[t[cnt]].begin(),m[t[cnt]].end(),i)==0){
        ans += N;
        i=m[t[cnt]][0];
        ++cnt;
      }
      else{
        i=*upper_bound(m[t[cnt]].begin(),m[t[cnt]].end(),i);
        ++cnt;
      }
    }
    ans += i+1;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 1468
// Make a Sequence
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1249 

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int N, M, P;

const int NONE = 0;
const int BLACK = 1;
const int WHITE = 2;
const int MAX = 10;

int field[MAX][MAX][MAX];
int height[MAX][MAX];

vector<int> dx;
vector<int> dy;
vector<int> dz;

inline bool is_out_of_range(int x, int y, int z) {
    return (x < 0 || x >= N || y < 0 || y >= N || z < 0 || z >= N);
}

void init() {
    fill_n((int *)field, sizeof(field) / sizeof(int), NONE); 
    fill_n((int *)height, sizeof(height) / sizeof(int), 0); 
}

void put_ball(int x, int y, int player) {
    field[x][y][height[x][y]] = player;
    height[x][y]++;
}

bool judge(int x, int y, int z, int player) {
    for (int d = 0; d < 26; ++d) {
        int nx = x, ny = y, nz = z, cnt = 0; 
        while (!is_out_of_range(nx, ny, nz)) {
            if (field[nx][ny][nz] != player) break;
            cnt++;
            if (cnt == M) return true;
            nx += dx[d];
            ny += dy[d];
            nz += dz[d];
        }
    }
    return false;
}

int main() {

    int d[3] = {0, 1, -1};
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (d[i] == 0 && d[j] == 0 && d[k] == 0) continue;
                dx.push_back(d[i]);
                dy.push_back(d[j]);
                dz.push_back(d[k]);
            }
        }
    }

    while (cin >> N >> M >> P) {
        if (N == 0) break;
        init();
        string winner = "";
        int win_turn = 0;
        for (int turn = 1; turn <= P; ++turn) {
            int player = (turn % 2 != 0) ? BLACK : WHITE;
            int x, y;
            cin >> x >> y;
            x--; y--;
            if (winner != "") continue;
            put_ball(x, y, player);

            for (int x = 0; x < N; ++x) {
                for (int y = 0; y < N; ++y) {
                    for (int z = 0; z < N; ++z) {
                        if (!judge(x, y, z, player)) continue;
                        winner = (player == BLACK) ? "Black" : "White";
                        win_turn = turn;
                    }
                }
            }
        }

        if (winner == "") {
            cout << "Draw" << endl;
        } else {
            cout << winner << " " << win_turn << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2976
//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux

require('fs').readFileSync(config.stdin, 'ascii')
	.trim()
	.split(config.newline)
	.forEach(function (line) {
		var ary = line.split(' ').map(Number);
		var a = ary[0], b = ary[1], c = ary[2],
			d = ary[3], e = ary[4], f = ary[5];
		var det = a * e - b * d;
		var Ainv_c = (e * c - b * f) / det;
		var Ainv_f = (-d * c + a * f) / det;
		console.log('%s %s', format(Ainv_c), format(Ainv_f));
	});

function format(num) {
	var s = num.toFixed(4);
	var point = s.indexOf('.');
	if (point === -1) return s + '.000';
	return (s + '000').slice(0, point + 4);
}

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

using namespace std;

int main() {
    int k;
    cin >> k;
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << v[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
// *3 or /2

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int a, b;

int main() {
    cin >> a >> b;
    cout << ((b - a) * (b - a + 1) / 2) - b << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    d = list(map(int, input().split()))

    comb = list(itertools.combinations(range(N), 2))
    ans = 0
    for c in comb:
        i1, i2 = c
        ans += d[i1] * d[i2]

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  long long a , v , b , w , t;
  scanf("%lld %lld %lld %lld %lld",&a , &v , &b , &w , &t);

  long long sa;
  if(a > b){
    sa = a - b;
  }
  else{
    sa = b - a;
  }

  long long sa2;
  if(v > w){
    sa2 = v - w;
  }
  else{
    sa2 = 0;
  }

  if(sa > sa2 * t){
    printf("NO\n");
  }
  else{
    printf("YES\n");
  }

  return 0;

}

Measured memory_bytes: 1664
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*   
*   文件名称：A.cpp
*   创 建 者：YaliKiWi
*   创建日期：2019年08月04日
*   描    述：
*
================================================================*/


#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>a>>b>>c;
	cout<<max(0,b+c-a);
	return 0;
}

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

using namespace std;

int main(){
    int a ,b;
    int ans;

    cin >> a >> b;
    int temp = a;
    ans = 0;
    if(b == 1){
        cout << ans << endl;
        return 0;
    }else{
        for(int i = 1; i < 50; i++){
            if(temp >= b){
                ans = i;
                break;
            }else{
                temp += a - 1;
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int h,w; cin >> h >> w;
    char tmp;
    for (int j=0;j<w+2;j++) cout << '#';
    cout << endl;
    for (int i=0;i<h;i++) {
        cout << '#';
        for (int j=0; j<w;j++){
            cin >> tmp;
            cout << tmp;
        }
        cout << '#' << endl;
    }
    for (int j=0;j<w+2;j++) cout << '#';
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<ios>
using namespace std;
int sum,cnt,a,b,c;
main()
{
    while(~scanf("%d,%d",&a,&b))
    {
        c++;
        cnt+=b;
        sum+=a*b;
    }
    cout<<sum<<endl;
    if(cnt*10/c%10>=5)cout<<cnt/c+1<<endl;
    else cout<<cnt/c<<endl;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
#define br "\n"
#define MAX  1000001
#define ff first
#define ss second

ll mod = 1e9 + 7;

void solve(){
  ll n;
  cin >> n;
  vll v(n);
  rep(i,0,n) cin >> v[i];
  ll ans = 0;
  rep(i,0,n){
    rep(j,i + 1,n){
      rep(k,j + 1,n){
        if(v[i] + v[j] > v[k] && v[k] + v[j] > v[i] && v[i] + v[k] > v[j] && v[i] != v[j] && v[k] != v[j] && v[i] != v[k]){ 
          ans++;
        }
      }
    }
  }
  cout << ans << br;

}
	

int main(){
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif  
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}

Measured memory_bytes: 3648
/*  -*- coding: utf-8 -*-
 *
 * c.cc: E: Meaningful Mean
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;
typedef map<ll,int> mli;

template <typename T, const int MAX_N>
struct BIT {
  int n;
  T bits[MAX_N + 1];
  BIT() {}

  void init(int _n) {
    n = _n;
    memset(bits, 0, sizeof(bits));
  }

  T sum(int x) {
    T s = 0;
    while (x > 0) {
      s += bits[x];
      x -= (x & -x);
    }
    return s;
  }

  void add(int x, T v) {
    while (x <= n) {
      bits[x] += v;
      x += (x & -x);
    }
  }
};

/* global variables */

ll asums[MAX_N + 1], bs[MAX_N + 1], xs[MAX_N + 1];
mli xmap;

BIT<int, MAX_N + 1> bit;

/* subroutines */

/* main */

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

  asums[0] = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    asums[i + 1] = asums[i] + ai;
  }

  for (int i = 0; i <= n; i++) bs[i] = asums[i] - k * i, xs[i] = bs[i];
  //for (int i = 0; i <= n; i++) printf("%lld ", bs[i]); putchar('\n');

  sort(xs, xs + n + 1);
  int xn = unique(xs, xs + n + 1) - xs;
  for (int i = 0; i < xn; i++) xmap[xs[i]] = i;
  //printf("xn=%d\n", xn);

  bit.init(xn + 1);

  ll cnt = 0;
  for (int i = 0; i <= n; i++) {
    int xi = xmap[bs[i]] + 1;
    cnt += bit.sum(xi);
    bit.add(xi, 1);
  }

  printf("%lld\n", cnt);
  return 0;
}


Measured memory_bytes: 18176
r,c = map(int,input().split())
data = []
for i in range(r):
    data.append(list(map(int,input().split())))
data.append([0] * c)

for i in range(r+1):
    data[i].append(0)
    for j in range(c):
        data[i][c] += data[i][j]

for i in range(c+1):
    for j in range(r):
        data[r][i] += data[j][i]

for i in range(r+1):
    print(" ".join(map(str,data[i])))
    
    


Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b && b==c){
        cout << 1 << endl;
    }else if(a!=b && b!=c && c!=a){
        cout << 3 << endl;
    }else{
        cout << 2 << endl;
    }
    return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

ll calc(ll n) {
    ll ans = LLONG_MAX;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) { ans = min(ans, i + (n / i) - 2); }
    }
    return ans;
}

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

    ll n;
    cin >> n;
    cout << calc(n) << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
i = s.index("i")
s, t = "." + s[:i][::-1], "." + s[i + 3:]
s = s.translate(str.maketrans("(){}[]", ")(}{]["))
l = [[0 for _ in range(len(s))] for _ in range(len(t))]
for i in range(1, len(t)):
    for j in range(1, len(s)):
        if t[i] == s[j]:l[i][j] = l[i - 1][j - 1] + 1
        else:l[i][j] = max(l[i -1][j], l[i][j - 1])
print(3 + 2 * l[-1][-1])


Measured memory_bytes: 5576
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<string> vs;
int n;
void dfs(string s,int cnt,char c){
  if(cnt==n){
    vs.push_back(s);
    return;
  }
  for(int i=0;i<c-'a'+2;i++){
    char x=i+'a';
    dfs(s+x,cnt+1,max(c,x));
  }
}
int main(){
  cin >> n;
  string s="a";
  dfs(s,1,'a');
  sort(vs.begin(),vs.end());
  for(auto& x:vs)cout << x << endl;
}

Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
using namespace std;

int main( ) {
    ll N,K;
    ll count=0;
    cin>>N>>K;
    if(K%2==0) {
        ll a=K/2;
        if(N%K>=a)
        count+=pow(N/K,3)+pow(N/K+1,3);
        else count+=2*pow(N/K,3);

    }
    else count+=pow(N/K,3);
    cout<<count<<endl;
    }

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		
		if(k > a) {
			b = b - (k - a);
			a = 0;
			if(b < 0) b = 0;
		}
		else {
			a -= k;
		}
		System.out.println(a+" "+b);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define __count __builtin_popcount
#define __countll __builtin_popcountll
#define X first
#define Y second
#define mst(x) memset(x,0,sizeof(x))
#define mst1(x) memset(x,-1,sizeof(x))
#define ALL(c) (c).begin(),(c).end()
#define FOR(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORit(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it)
#define pb push_back
#define RI(x) scanf("%d",&x)
#define RID(x) int x;RI(x)
using namespace std;
typedef long long LL;
const int N = 2e5+7;
int a[N];

int main(){
  RID(n);
  LL sum = 0;
  FOR(i,n){
    RI(a[i]);
    sum += a[i];
  }
  LL l = 0, res = 1LL<<62;
  FOR(i, n-1){
    l += a[i];
    LL now = l - (sum-l);
    if(now<0)now = -now;
    res = min(res, now);
  }
  cout << res << endl;
}


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


void solve(long long N, std::vector<std::string> S){
    set<string> se;
    for(int i = 0;i < N;i++){
        se.insert(S[i]);
    }
    cout<<se.size()<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

int main() {
  string s, ans;
  cin >> s;
  for (char c : s) {
    if (c == 'B') {
      if (ans.empty()) continue;
      ans.pop_back();
    } else {
      ans += c;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
dict = {}
for i in range(1, N+1):
    S, P_str = tuple(input().split())
    P = int(P_str)
    try:
        dict[S].append((P, i))
    except:
        dict[S] = [(P, i)]

items = sorted(dict.items())
for city, info in items:
    for p, n in sorted(info, reverse=True):
        print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
// " ", ' '
// std::string str;
// str = std::to_string(int i);
// bitset<3> s(N);

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string S, ans; cin >> S;

	if(S == "Sunny") ans = "Cloudy";
	else if(S == "Cloudy") ans = "Rainy";
	else ans = "Sunny";

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


Measured memory_bytes: 256