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

int main(){
    ll i,j,n;
    cin >> n;
    ll a[n+1],b[n+1];
    vector <ll> data;
    ll count = 0;
    for(i = 1; i < n+1; i++){
        cin >> a[i];
        b[i] = 0;
    }

    for(i = n; i > 0; i--){
        ll ans = 0;
        for(j = 2*i;j <= n; j = j+i){
            ans += b[j];
        }
        int hoge = (ans  + a[i] ) % 2;
        if(hoge != 0){
            count += 1;
            data.push_back(i);
            b[i] = 1;
        }
    }
    cout << data.size() << endl;
    for(i = 0; i < data.size();i++){
        cout << data[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,w;
	cin>>n>>w;
	vector<ll>wt(n+1),value(n+1);
	for(int i=1; i<=n; i++){
		cin>>wt[i]>>value[i];
	}
	vector<vector<ll> >table(n+1,vector<ll>(w+1,0));
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<=w; j++){
			if(j>=wt[i]){
				table[i][j]=max(table[i][j],value[i]+table[i-1][j-wt[i]]);
				table[i][j]=max(table[i][j],table[i-1][j]);
			}
			else
			 table[i][j]=max(table[i][j],table[i-1][j]);
		}
	}
	cout<<table[n][w];
	return 0;
	
}

Measured memory_bytes: 83084
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;
using XY = pair<int, int>;
//#include<bits/stdc++.h>

int main() {
    string s;
    cin >> s;
    bool list[3] = {0, 0, 0};
    for (auto c : s) {
        list[c - 'a'] = true;
    }
    auto yes = true;
    for (auto b : list) {
        if (!b) yes = false;
    }
    cout << (yes ? "Yes" : "No");
    
}



Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    cout<<fixed;
}

template< typename Monoid >
class SegmentTree {
public:
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

int main(){
    init();
    
    int N,Q;cin>>N>>Q;
    SegmentTree<int>sg(N,[](int a,int b){return min(a,b);},INT_MAX);

    while(Q--){
        int com,x,y;cin>>com>>x>>y;
        if(com==0)sg.update(x,y);
        else{
            cout<<sg.query(x,y+1)<<endl;
        }
    }

}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll i, j, ans, temp_ans, len1, len2;
    string t, s;
    cin >> s >> t;
    len1 = s.length();
    len2 = t.length();
    for (i = 0, ans = 0; i <= len1 - len2; i++)
    {
        temp_ans = 0;
        for (j = 0; j < len2; j++)
        {
            if (s[i + j] == t[j])
                temp_ans++;
            // cout << s[i + j] << " " << t[j] << endl;
        }
        if (temp_ans > ans)
            ans = temp_ans;
    }
    ans = len2 - ans;
    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.io.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public static int[]sizes = new int[]{60, 80, 100, 120, 140, 160};
	public static int[] weights = new int[]{2, 5, 10, 15, 20, 25};
	public static int[] fees = new int[]{600, 800, 1000, 1200, 1400, 1600};
	
	public Main() throws IOException{	
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			int size = Integer.parseInt(line);
			if(size==0) break;
			int sum = 0;
			for(int n=0; n<size; n++){
				line = in.readLine();
				String tmp[] = line.split(" ");
				int x = Integer.parseInt(tmp[0]);
				int y = Integer.parseInt(tmp[1]);
				int h = Integer.parseInt(tmp[2]);
				int w = Integer.parseInt(tmp[3]);
				int s = x + y + h;
				for(int i=0; i<6; i++){
					if(s <= sizes[i] && w <= weights[i]){
						sum += fees[i];
						break;
					}
				}
			}
			
			System.out.println(sum);
		}
	}
}

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

ll x = 1e9 + 7; 

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i%3 != 0 && i%5 != 0) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
from collections import deque

MOD = 10**9 + 7
H, W = map(int, input().split())
G = [input() for _ in range(H)]


def main():
    dist = [[-1] * W for _ in range(H)]
    dist[0][0] = 0

    dp = [[0] * W for _ in range(H)]
    for i in range(H):
        if G[i][0] == '#':
            break
        dp[i][0] = 1
    for i in range(W):
        if G[0][i] == '#':
            break
        dp[0][i] = 1

    que = deque([(0, 0)])

    while que:
        h, w = que.popleft()
        for dh, dw in ((1, 0), (0, 1)):
            nh = h + dh
            nw = w + dw
            if nh < 0 or nw < 0 or nh >= H or nw >= W:
                continue
            if G[nh][nw] == '#':
                continue
            if dist[nh][nw] != -1:
                continue
            if nh > 0 and nw > 0:
                dp[nh][nw] = (dp[nh - 1][nw] + dp[nh][nw - 1]) % MOD
            dist[nh][nw] = dist[h][w] + 1
            que.append((nh, nw))

    print(dp[H - 1][W - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 94260
#include<stdio.h>


int main( ){

  int ia, ma, sa, ea, ib, mb, sb, eb, suma, sumb;

  scanf("%d %d %d %d\n", &ia, &ma, &sa, &ea);
  scanf("%d %d %d %d", &ib, &mb, &sb, &eb);

  suma = ia + ma + sa + ea;
  sumb = ib + mb + sb + eb;

  if(suma > sumb)
    printf("%d\n", suma);
  else
    printf("%d\n", sumb);
  


  return 0;
}

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

using namespace std;

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

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            for (int k = 1; k <= N; ++k) {
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	int n = ri();
	int k = ri();
	int res = 1;
	n -= k;
	if (n) {
		res += 1+(n-1)/(k-1);
	}
	cout << res << endl;
	
    return 0;
}


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

N = INT()
P = LIST()

cnt = 1
MIN = P[0]

for i in range(1, N):
	MIN = min(MIN, P[i])
	if P[i] == MIN:
		cnt += 1

print(cnt)

Measured memory_bytes: 27196
package main
 
import (
	"fmt"
)
 
func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	if (a-b) % 2 == 0 {
	  fmt.Printf("%d\n", (a+b)/2)
	} else {
	  fmt.Printf("IMPOSSIBLE")
	}
}


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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pb emplace_back

const int MAXN = 5009;
int dp[MAXN];
int a[MAXN];
int n, x, y;
int inf = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> y >> x;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    a[n + 1] = n + 1;
    n += 2;
    for (int i = 1; i < n; i++)
    {
        dp[i] = inf;
        int cur = 0;
        int ma = -1;
        for (int e = i - 1; e >= 0; e--)
        {
            if (a[e] < a[i] && (ma == -1 || a[e] > ma))
                dp[i] = min(dp[i], dp[e] + cur);
            if (a[e] > a[i])
                cur += y;
            else
            {
                cur += x;
                if (ma == -1)
                    ma = a[e];
                else
                    ma = max(ma, a[e]);
            }
        }
    }
    cout << dp[n - 1];
}

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

int main(){
    string S;
    int K,A,B;
    int ans ,i = 1;
    cin >> S;
    if(S[1] == 'B'){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3072
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 d = x/y;
    	int r = x%y;
    	double f = (double)x/(double)y;
    	System.out.println(d+" "+r+" "+String.format("%.5f", f));

    }
}

Measured memory_bytes: 26564
#!/usr/bin/env python3
def main():
    from bisect import bisect

    N = int(input())
    A = sorted([int(x) for x in input().split()])
    B = sorted([int(x) for x in input().split()])
    C = sorted([int(x) for x in input().split()])

    lst = [N - bisect(C, b) for b in B]
    lst = lst[::-1]
    tmp_lst = [lst[0]]
    for i in lst[1:]:
        tmp_lst.append(i + tmp_lst[-1])
    tmp_lst = tmp_lst[::-1]

    ans = 0
    for a in A:
        res = bisect(B, a)
        ans += tmp_lst[res] if res < N else 0
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n+1);
	rep(i, n){
		cin >> a[i];
	}
	rep(i, k){//100000
		vector<int> add(n+1);
		rep(j, n){//100000
//			rep(l, a[j]*2+1){//100000
//				cout << j-a[j]+l << endl;
				int st = max(j-a[j], 0);
				int en = min(j+a[j]+1, n);
				add[st]++;
				add[en]--;
//			}
		}
		int f = 0;
		int sum = 0;
		rep(j, n){
			sum += add[j];
			if(sum != n) f = 1;
			a[j] = sum;
		}
		if(f == 0) break;
	}
	rep(i, n) cout << a[i] << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 4844
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    a, b, c, d = MI()
    ans = -INF
    ans = max(ans, a*c)
    ans = max(ans, a*d)
    ans = max(ans, b*c)
    ans = max(ans, b*d)
    print(ans)


if __name__ == '__main__':
    solve()



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

using namespace std;

#define endl "\n"
typedef long long int lli;

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

lli inf = 1000000000000;
lli dp[2][1100000];
lli V[101], W[101];

int main(){
	int n,w; cin >> n >> w;
	for(int i=0; i<n; i++){
		cin >> W[i] >> V[i];
	}

	for(int i=1; i<1100000; i++){
		dp[0][i] = inf;
	}

	for(int i=1; i<=n; i++){
		int row=i%2;

		for(int j=0; j<1100000; j++){
			dp[row][j] = inf;
		}

		for(int j=0; j<1100000; j++){
			dp[row][j] = min(dp[row][j],dp[!row][j]);
			if(j-V[i-1] >= 0)
				dp[row][j] = min(dp[row][j], dp[!row][j-V[i-1]] + W[i-1]);
		}
	}

	int ans = 0;
	for(int i=0; i<1100000; i++){
		if(dp[n%2][i] <= w)
			ans = i;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  int ans = 0;
  ll temp = X;

  while (true) {
    if (temp <= Y) {
      ans++;
      temp *= 2;
    } else {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
static const int MAX_N = 10;
int a[MAX_N] = {0};

bool dfs(int a[],vector<int> r,vector<int> l,int i){
	if(i==MAX_N)return true;
	if(r.size()==0 || r[r.size()-1]<a[i]){
		r.push_back(a[i]);
		return dfs(a,r,l,i+1);
	}
	if(l.size()==0 || l[l.size()-1]<a[i]){
		l.push_back(a[i]);
		return dfs(a,r,l,i+1);
	}
	return false;
}


int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){//input
			cin>>a[j];
		}
		vector<int> r;
		vector<int> l;
		if(dfs(a,r,l,0)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
}

Measured memory_bytes: 2988
import re

def make_pattern():
    template = 'keyence'
    xs = []
    for i in range(len(template) + 1):
        xs.append(template[:i] + '.*' + template[i:])
    
    pat = '^(?:' + '|'.join(xs) + ')$'
    return re.compile(pat)

def main():
    s = input()
    pat = make_pattern()

    m = pat.match(s)
    if m:
        print('YES')
    else:
        print('NO')

main()


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

const int limit = 100010;
vector<int> graph[limit];
int color[limit];


bool dfs(int v,int c){
	color[v] = c;
	bool res = false;
	for(auto &v2:graph[v]){
		if(color[v2]== -1) res |= dfs(v2,c^1);
		if(color[v2]==c) return true;
	}
	return res;
}

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

	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--,b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	rep(i,n) color[i] = -1;
	bool odd = dfs(0,0);
	
	ll black = 0;	
	rep(i,n) if(color[i]==0) black++;
	ll white = n - black;

	if(odd){
		const ll all = 1LL * n * (n-1)/2LL;
		cout << all - m << endl;
	}else{
		const ll all = 1LL * black * white;
		cout << all - m << endl;
	}

	return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = Long.parseLong(sc.next());
//		String t = sc.next();
//		String buff="";
		//long b = Long.parseLong(sc.next());
		//int c = Integer.parseInt(sc.next());
		//int n = Integer.parseInt(sc.next());
		//long res=n;
		//int l = Integer.parseInt(sc.next());
		//int sum=0;
		//String s = sc.next();
		//String t = sc.next();
		//String b = sc.next();
		//int a = Integer.parseInt(sc.next());
		//String t = sc.next();

		if(a>=1200) {//a、e、i、o、u
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}
		/*for(int i=0;i<t.length();i++) {
			if(t.substring(i,i+1).equals(",")) {
				buff+=" ";
			}else {
				buff+=t.substring(i, i+1);
			}
		}*/
		//System.out.println(buff);
	}
}




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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  string S;
  cin>>S;
  rep(i,3){
    if(S[i]=='1')
      S[i]='9';
    else
      S[i]='1';

  }

  cout<<S<<endl;


  return 0;
}


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

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;
int gcd(int x,int y)
{        
    return x ? gcd(y%x,x) : y;   
}  

int main()
{
    fastio;

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

    sorted(a);

    bitset<2000*2000> bst;

    bst[0]=1;

    for(int i=0; i<n; i++)
    {
        auto x=bst<<a[i];
        bst|=x;
    }

    int st=sum/2;
    st+=sum&1;
    int ans;
    for(int i=st; i<=sum; i++)
    {
        if(bst[i])
        {
            ans=i;
            break;
        }
    }

    cout<<ans<<nl;

}

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

using namespace std;

#define ll long long 
#define mod 100000007
#define MAX 100000

int main()
{
	string ch;
	
	cin >> ch;
	string bh = ch;
	reverse(bh.begin(),bh.end());
	if(ch == bh)
	{
		int n = ch.size();
		n = (n-1)/2;
		string curr = "",curr2 = "";
		//cout << n-1 << endl;
		for(int i = 0;i  <= n-1; i++)
		{
			curr += ch;
		}
		curr2 = curr;
		reverse(curr2.begin(), curr2.end());
		if(curr2 == curr)
		{
			int a = ch.size();
			a = (a+3)/2;
			//cout << a-1 << " "<< ch.size()-1 << endl;
			string aga = "",aga2 = "";
			for(int i = a-1; i< ch.size(); i++)
			{
				aga += ch[i];
			}
			aga2 = aga;
			reverse(aga2.begin(),aga2.end());
			if(aga2 == aga) cout << "Yes\n";
			else cout<< "No\n";
		}
		else
		{
			cout << "No\n";
		}
	}
	else
	{
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
H1,M1,H2,M2,K = map(int,input().split())
hh1 = H1*60 + M1
hh2 = H2*60 + M2
if hh1 < hh2:
  sl = hh1 + 60*24 - hh2
else:
  sl = hh1 - hh2

time = 24*60 - sl - K
print(time)

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

using namespace std;

char s[1001];
long long n, m;
long long ans = 0;
char prv = 0;
long long lenc = 0;
long long lenf = 0;

int main() {
	scanf("%s", s + 1);
	scanf("%lld", &m);
	n = strlen(s + 1);
	if (n == 1) {
		printf("%lld\n", m >> 1);
		exit(0);
	}

	for (int i = 1; i <= n; i++) {
		if (s[i] == prv) {
			lenc++;
		} else {
			if (lenc && !lenf) {
				lenf = lenc;
			}
			ans += 1LL * m * (lenc >> 1);
			prv = s[i];
			lenc = 1;
		}
	}

	if (lenc == n) {
		ans = 1LL * m * n >> 1;
	} else {
		if (s[n] == s[1]) {
			ans -= 1LL * (lenf >> 1) * (m - 1);
			ans += 1LL * ((lenf + lenc) >> 1) * (m - 1) + (lenc >> 1);
		} else {
			ans += 1LL * (lenc >> 1) * m;
		}
	}

	printf("%lld\n", ans);

	return 0;
}


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int r;
  cin >> r;
  cout << 3*r*r << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

const a int = 97

func main(){
        var s string
        fmt.Scan(&s)
        for i := 0; i < 26; i++{
                //fmt.Println(string(i+a))
                if string(i+a) == s{
                        fmt.Println(string(i+a+1))
                        break
                }
        }
}

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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003

int main()
{
    ios;
    ll a,b,prod;
    cin>>a>>b;
    prod=a*b;
    cout<<prod;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

const int MAXN = 120000;

int n;
int m;
ll k;
int p[MAXN];
int tmp[MAXN];
int rs[MAXN];
ll x[MAXN];
ll ad[MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> x[i];
	for (int i = 0; i < n; ++i)
		p[i] = i;
	cin >> m >> k;
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		--a;
		swap(p[a], p[a - 1]);
	}
	for (int i = 0; i < n; ++i)
		tmp[p[i]] = i;
	for (int i = 0; i < n; ++i)
		p[i] = tmp[i];
	for (int i = 0; i < n; ++i)
		rs[i] = i;
	while (k) {
		while (!(k & 1)) {
			for (int i = 0; i < n; ++i)
				tmp[i] = p[p[i]];
			for (int i = 0; i < n; ++i)
				p[i] = tmp[i];
			k /= 2;
		}
		--k;
		for (int i = 0; i < n; ++i)
			tmp[i] = p[rs[i]];
		for (int i = 0; i < n; ++i)
			rs[i] = tmp[i];
	}
	for (int i = 0; i < n; ++i) {
		ad[rs[i] + 1] -= x[i];
		if (i == 0)
			ad[0] += x[i];
		else
			ad[rs[i - 1] + 1] += x[i];
	}
	ll now = 0;
	for (int i = 0; i < n; ++i) {
		now += ad[i];
		x[i] = now;
	}
	for (int i = 0; i < n; ++i) {
		cout << x[i] << "\n";
	}
	return 0;
}




Measured memory_bytes: 3968
//O(n)
#include <cstdio>
#include <iostream>
#include <string>
#include <stack>
using namespace std;
stack<char> St;
int main()
{
	string s;
	cin>>s;
	auto len=s.size(),ans=len;
	char last,now;
	//字母都在栈里面，当栈顶两个元素可以弹出时，就一直弹出 
	for(int i=0;i<len;i++)
	{
		St.push(s[i]);
		while(St.size()>=2)
		{
			char c2=St.top(); St.pop();
			char c1=St.top(); St.pop();
			if(c1=='S'&&c2=='T') continue;
			else
			{
				St.push(c1);
				St.push(c2);
				break;
			}
		}
	}
	cout<<St.size()<<endl;
	return 0;
}

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5,M=N*2;
int n,m,d[N],p[N],e[N],f[N],id[N],w[M];
inline bool cmp(int x,int y){return d[x]<d[y];}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&d[i]),p[i]=i;
	sort(p+1,p+n+1,cmp);
	for(int i=1,u,v;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		if(d[u]==d[v])
		{
			if(!f[u]&&!f[v])f[u]=1;
			if(!f[u])f[u]=-f[v];
			if(!f[v])f[v]=-f[u];
			if(f[u]==-f[v])w[i]=d[u];
		}
		else
		{
			if(d[u]<d[v])swap(u,v);
			e[u]=v;id[u]=i;
		}
	}
	for(int i=1,x;i<=n;i++)if(!f[x=p[i]])
	{
		if(!e[x]){puts("-1");return 0;}
		f[x]=f[e[x]];w[id[x]]=d[x]-d[e[x]];
	}
	for(int i=1;i<=n;i++)putchar(f[i]>0?'B':'W');
	for(int i=1;i<=m;i++)printf("\n%d",w[i]?w[i]:1000000000);
	return 0;
}


Measured memory_bytes: 5120
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ai=sc.nextInt();
        int max,min;
        long sum=ai;
        max=min=ai;
        for(int i=1;i<n;i++){
            ai=sc.nextInt();
            if(max<ai){
                max=ai;
            }else if(min>ai){
                min=ai;
            }
            sum+=ai;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}


Measured memory_bytes: 42980
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<string, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}



int main()
{
	int n;
	cin >> n;
	cout << (n - 2) * 180 << endl;

}



Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;

int main(){
    double a,b,h,m;
    double h_arc, m_arc,arc,pi,unit,ans;
    cin >> a >> b >> h >> m;
    h_arc = 30.0*h + 0.5*m;
    m_arc = 6.0*m;
    arc = h_arc - m_arc;
    arc = max(arc,-1.0*arc);
    arc = min(arc,360-arc);
    pi = M_PI;
    unit = pi/180.0;
    ans = sqrt(a*a + b*b -2*a*b*cos(arc*unit));
    cout << fixed <<setprecision(15) << ans << endl;
}

Measured memory_bytes: 4136
#include<iostream>
#include<vector>

using namespace std;

int main(void)
{
  int n,x;
    cin >> n >> x;
  vector<int> l(n);
  

  for(int i = 0; i < n;i++)
  {
    cin >> l[i];
  }
  
vector<int> d(n+1);
  d[0] = 0;
  
  for(int i = 0; i < n;i++)
  {
   d[i+1] = d[i] + l[i];
  }
  
int bound_number = 0;
  for(int i = 0; i < n+1;i++)
  {
    if(d[i] <= x)
    {
      bound_number++;
    }
   
  }
  
  cout << bound_number;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
	int h,w,k,strb=1;cin>>h>>w>>k;
	vector<vector<int>>cake(h,vector<int>(w));
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			char ch; cin>>ch;
			if(ch=='.') cake[i][j]=-1;
			else cake[i][j]=strb, strb++;
	}
	for(int i=0;i<h;i++){
		int first=1, strb=-1;
		for(int j=0;j<w;j++){
			if(first && cake[i][j]!=-1){
				first=0, strb=cake[i][j];
				for(int c=0;c<j;c++) cake[i][c]=strb;
			}
			else if(cake[i][j]==-1) cake[i][j]=strb;
			else strb=cake[i][j];
		}
	}
	if(h>1){
		for(int i=0;i<h;i++){
			if(cake[i][0]==-1){
				int found=0, st_r=i, targ_r=-1, end_r=-1;
				while(st_r>=0){
					if(cake[st_r][0]!=-1){
						found=1, targ_r=st_r; break;
					}
					st_r--;
				}
				st_r=i;
				while(!found&&st_r<=h-1){
					if(cake[st_r][0]!=-1){
						found=1, targ_r=st_r; break;
					}
					st_r++;
				}
				st_r=i, end_r=targ_r;
				if(st_r>end_r) swap(st_r,end_r);
				for(int x=st_r; x<=end_r; x++)
					for(int y=0;y<w;y++)
						cake[x][y]=cake[targ_r][y];
			}
		}
	}
	for(const vector<int>& x:cake){
		for(const int& y:x){
			cout<<y<<" ";
		}	
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1152
void main() {
	readln;
	readAs!(int[]).map!(a => a-1).sum.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 380
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
    var eve = ""
    if(tmp != 25){
      for (var index = 0; index < 25 - tmp; index++) {
        eve = eve + " Eve";
      }
    }
    console.log("Christmas" + eve);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int64_t solve(string s, int k) {
    int n = s.size();
    int64_t ans = 0;
    int64_t M_sum = 0, M_count = 0, D_count = 0, D_missing = 0;
    
    int it = 0;
    
    for(int i = 0; i < n; i += 1) {
        if(s[i] == 'C') {
            while(i - it >= k) {
                if(s[it] == 'D') {
                    D_missing += 1;
                } else if(s[it] == 'M') {
                    M_sum -= D_missing;
                    M_count -= 1;
                }
                it += 1;
            }
            ans += M_sum - M_count * (D_missing);
        } else if(s[i] == 'D') {
            D_count += 1;
        } else if(s[i] == 'M') {
            M_sum += D_count;
            M_count += 1;
        }
    }

    return ans; 
}

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

    int q; cin >> q;
    for(int i = 0; i < q; i += 1) {
        int k; cin >> k;
        auto res = solve(s, k);
        cout << res << "\n";
    }   
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 4005;

int n, a[N];

int pref[N][4];

map <char, int> cost;

int main() {

	FAST;

	cin >> n;
	string s;
	cin >> s;
	s = '0' + s;
	cost['R'] = 1;
	cost['G'] = 2;
	cost['B'] = 3;
	for (int i = 1; i <= n; i ++) {
		pref[i][1] = pref[i - 1][1];
		pref[i][2] = pref[i - 1][2];
		pref[i][3] = pref[i - 1][3];
		if (s[i] == 'R') pref[i][1] ++;
		if (s[i] == 'G') pref[i][2] ++;
		if (s[i] == 'B') pref[i][3] ++;
	}
	intt ans = 0;
	for (int i = 1; i <= n - 2; i ++) {
		for (int k = i + 2; k <= n; k ++) {
			if (s[i] == s[k]) continue;
			int color = 6;
			color -= cost[s[i]];
			color -= cost[s[k]];
			int res = pref[k - 1][color] - pref[i][color];
			if ((i + k) % 2) ans += res;
			else {
				char x;
				if (color == 1) x = 'R';
				if (color == 2) x = 'G';
				if (color == 3) x = 'B';
				if (s[(i + k) / 2] == x) res --;
				ans += res;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3684
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
int N, A, B, f[100001], C[100001];
long long D, x[100001], y[100001];
typedef std::vector < std::pair < int, int > > vpii;
std::map < long long, vpii > M1, M2;
int F(int x)
{
	return f[x] == x ? x : f[x] = F(f[x]);
}
void add(int u, int v)
{
	u = F(u), v = F(v);
	f[u] = v;
}
inline int abs(int x)
{
	return x < 0 ? -x : x;
}
inline bool cmp_pair(std::pair < int, int > a, std::pair < int, int > b)
{
	return x[a.first] < x[b.first];
}
vpii::iterator lower_bound(vpii &V, long long w)
{
	auto Ol = V.begin(), Or = V.end();
	while (Ol < Or)
	{
		auto Om = Ol + (Or - Ol >> 1);
		if (x[Om -> first] >= w)
			Or = Om;
		else
			Ol = Om + 1;
	}
	return Ol;
}
vpii::iterator upper_bound(vpii &V, long long w)
{
	auto Ol = V.begin(), Or = V.end();
	while (Ol < Or)
	{
		auto Om = Ol + (Or - Ol >> 1);
		if (x[Om -> first] > w)
			Or = Om;
		else
			Ol = Om + 1;
	}
	return Ol;
}
void GetRange(int &Count, std::vector < int > &O, vpii &V, long long L, long long R)
{
	vpii::iterator first = lower_bound(V, L), second = upper_bound(V, R);
	Count += second - first;
	if (first < second)
	{
		O.push_back(first -> first);
		first -> second++;
		(second - 1) -> second--;
	}
}
int main()
{
	scanf("%d%d%d", &N, &A, &B);
	for (int i = 1; i <= N; i++)
		f[i] = i;
	for (int i = 1; i <= N; i++)
	{
		scanf("%lld%lld", x + i, y + i);
		M1[x[i] + y[i]].push_back(std::make_pair(i, 0));
		M2[x[i] - y[i]].push_back(std::make_pair(i, 0));
	}
	D = abs(x[A] - x[B]) + abs(y[A] - y[B]);
	for (auto &i : M1)
		std::sort(i.second.begin(), i.second.end(), cmp_pair);
	for (auto &i : M2)
		std::sort(i.second.begin(), i.second.end(), cmp_pair);
	for (int i = 1; i <= N; i++)
	{
		vpii &UL = M1[x[i] + y[i] - D], &UR = M2[x[i] - y[i] - D], &DL = M2[x[i] - y[i] + D], &DR = M1[x[i] + y[i] + D];
		std::vector < int > tmp;
		GetRange(C[i], tmp, UL, x[i] - D, x[i] - 1);
		GetRange(C[i], tmp, UR, x[i] - D + 1, x[i]);
		GetRange(C[i], tmp, DL, x[i], x[i] + D - 1);
		GetRange(C[i], tmp, DR, x[i] + 1, x[i] + D);
		for (int j : tmp)
			add(i, j);
	}
	for (auto &e : M1)
	{
		vpii &V = e.second;
		for (size_t i = 1; i < V.size(); i++)
			V[i].second += V[i - 1].second;
		for (size_t i = 0; i + 1 < V.size(); i++)
			if (V[i].second)
				add(V[i].first, V[i + 1].first);
	}
	for (auto &e : M2)
	{
		vpii &V = e.second;
		for (size_t i = 1; i < V.size(); i++)
			V[i].second += V[i - 1].second;
		for (size_t i = 0; i + 1 < V.size(); i++)
			if (V[i].second)
				add(V[i].first, V[i + 1].first);
	}
	long long O = 0;
	for (int i = 1; i <= N; i++)
		if (F(i) == F(A))
			O += C[i];
	printf("%lld\n", O >> 1);
	return 0;
}


Measured memory_bytes: 37632
#include <stdio.h>
#include <stdlib.h>

typedef struct{
    char suit;
    int val;
}Card;

int partition(int,Card[],int,int);
void quickSort(int,Card[],int,int);
void printArray(int,Card[]);
int checkStable(int,Card[],Card[]);

int main(int argc, char** argv) {
    int size;
    scanf("%d", &size);
    Card array[size],temp[size];
    for(int i = 0; i < size; i++)
        scanf("\n%c %d", &array[i].suit, &array[i].val);
    
    for(int i = 0; i < size; i++){
        temp[i].suit = array[i].suit;
        temp[i].val = array[i].val;
    }
    
    quickSort(size,temp,0,size-1);
    if(checkStable(size, array, temp))
        printf("Not stable\n");
    else
        printf("Stable\n");
    printArray(size,temp);
    return (EXIT_SUCCESS);
}

int partition(int size, Card array[size], int start, int end){
    Card compare = array[end];
    Card temp;
    int i = start - 1;
    for(int j = start; j < end; j++){
        if(array[j].val <= compare.val){
            i += 1;
            temp = array[i];
            array[i] = array[j];
            array[j] = temp;
        }
    }
    temp = array[i+1];
    array[i+1] = array[end];
    array[end] = temp;
    return i+1;
}

void quickSort(int size, Card array[size], int start, int end){
    if(start < end){
        int loc = partition(size,array,start,end);
        quickSort(size,array,start,loc-1);
        quickSort(size,array,loc+1,end);
    }
}

void printArray(int size, Card a[size]){
    for(int i = 0; i < size; i++){
        printf("%c %d\n", a[i].suit, a[i].val);
    }
}

int checkStable(int size, Card array[size], Card temp[size]){
    int returnVal = 0;
    int count = 0;
    int count2 = 0;
    for(int i = 0; i < size; i++){   
        for(int j = i + 1; j < size; j++)
            if(array[j].val == array[i].val)    //check how many cards have same val after the currently checking card in original array
                count++;
//            if(array[i].val == array[j].val){
//                temp1 = array[i];
//                temp2 = array[j];
//                for(int i2 = 0; i2 < size; i2++)
//                    if(temp[i2].val == temp1.val && temp[i2].suit == temp1.suit)
//                        for(int j2 = 0; j2 < size; j2++)
//                            if(temp[j2].val == temp2.val && i2 > j2)
//                                returnVal = 0;
//            }
        for(int k = 0; k < size; k++){
            if(array[i].val == temp[k].val && array[i].suit == temp[k].suit && count != 0)
                for(int j = k + 1; j < size; j++)
                    if(temp[k].val == temp[j].val)
                        count2++;               //check how many cards 
        }
        returnVal = count - count2;
        if(returnVal)
            break;
        count = 0;
        count2 = 0;
    }
    return returnVal;
}



Measured memory_bytes: 3304
local n=io.read("n")
local g={}
for i=1,n do
    g[i]={}
end
for i=1,n-1 do
    local x,y=io.read("n","n")
    g[x][y]=true
    g[y][x]=true
end

local bp,wp={},{}
local mod=1000000007
local function solve(cur,frm)
    bp[cur]=1
    wp[cur]=1
    for nxt in pairs(g[cur]) do
        if nxt~=frm then
            solve(nxt,cur)
            wp[cur]=wp[cur]*(wp[nxt]+bp[nxt])%mod
            bp[cur]=bp[cur]*wp[nxt]%mod
        end
    end
    return (bp[cur]+wp[cur])%mod
end
print(solve(1,0))

Measured memory_bytes: 45832
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int x,ans;
 	cin >> x;
 	if(x==111){
 		cout << 3 << endl;
 	}
 	if(x==110||x==101||x==11){
 		cout << 2 << endl;
 	}
 	if(x==1||x==10||x==100){
 		cout << 1 << endl;
 	}
 	if(x==0){
 		cout << 0 << endl;
 	}
 	
 }

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}
typedef pair<int,int> P;

struct BIT {
  int n;
  vector<ll> tree;
  BIT(int n):n(n),tree(n+1) {} 
  void fill(ll val) {
    REP(i, n+1) tree[i] = (i&-i) * val;
  }
  void add(int idx, ll val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  ll range(int idx) {
    ll sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
  ll range(int a, int b) {
    return range(b) - range(a - 1);
  }
};


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int M = nextInt();

  int all = 0;
  vector<P> ps;

  int maxL = -1, minR = M+2;
  REP(i, N) {
    int L = nextInt();
    int R = nextInt();
    ps.push_back(P(L, R));
    chmax(maxL, L);
    chmin(minR, R);
  }
  sort(ALL(ps), [](const P& a, const P& b) -> bool {
    if (a.first != b.first) return a.first < b.first;
    return a.second > b.second;
  });

  BIT bit(200000 + 10);

  int ans = max(0, N - min(M, maxL + (M+1)-minR));
  for (P p : ps) {
    bit.add((M+1) - p.second, 1);
    int man = bit.range((M+1) - p.second);
    int chair = (p.first) + ((M+1) - p.second);
    int need = man - chair;
    ans = max(ans, need);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}


Measured memory_bytes: 3440
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
a = na()

for i in range(k,n):
    print('Yes' if a[i] > a[i-k] else 'No')

Measured memory_bytes: 31456
#include <iostream>
#include <vector>
#include <math.h>
#include <map>
using namespace std;

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

    int find=0;
    for(int i=0; i<3; i++) {
        if(N[i]=='7') find=1;
    }
    if(find) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

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

int main(void) {

  char s[100001];
  scanf("%s", s);
  long k;
  scanf("%ld", &k);
  long length = strlen(s);
  for (long i = 0; i < length-1; i++) {
    if (k == 0) {
      break;
    }
    if (s[i] != 'a' && 'z'+1-s[i] <= k) {
      k -= 'z'+1-s[i];
      s[i] = 'a';
    }
  }
  k %= 26;
  int to_a = 'z'-s[length-1]+1;
  if (to_a <= k) {
    k -= to_a;
    s[length-1] = 'a';
  }
  s[length-1] += k;
  printf("%s\n", s);

  return 0;
}

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

int main() {
  double a,b,x,ans;
  cin >> a >> b >> x;
  
  
  if(x>=a*a*b/2) ans = atan(2*(a*a*b-x)/(a*a*a));
  else ans = atan((a*b*b)/(2*x));
  ans = ans * 180 / 3.1415926535;
  printf("%5.7f",ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	string s;
	int ans=0;
	
	cin>>s;
	s[5]=' ';
	s[13]=' ';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  int N,Z,W;cin >> N >> Z >> W;
  vector<int>a(N);
  rep(i,N)cin >> a[i];
  if(N==1){
     cout << abs(a[0]-W) << endl;
     return 0;
  }
  cout << max(abs(a[N-1]-W),abs(a[N-2]-a[N-1])) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
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 Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main(){
	string s, t;
	cin >> s >> t;
	int i;
	V where(26, -1);
	set<char> se;
	set<char> te;
	int n = s.size();
	for (i = 0; i < n; i++) {
		int al = t[i] - 'a';
		if (where[al] == -1) {
			se.insert(s[i]);
			te.insert(t[i]);
			if (se.size() != te.size()) {
				cout << "No";
				return 0;
			}
			where[al] = i;
		}
		else {
			if (s[where[al]] != s[i]) {
				cout << "No" << endl;
				return 0;
			}
			where[al] = i;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776