akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

// Gauss-Jordanの掃き出し法
// Ref::https://kmjp.hatenablog.jp/entry/2015/04/17/0900
int gauss_jordan(vector<ll>& mat){
    int n = mat.size();
    int ret = 0;
    REP(i,n) if(mat[i]) {
        ret++;
        int x=0;
        while((1LL<<(x+1))<=mat[i]) x++;
        for(int y = i+1; y<n; y++) if(mat[y] & (1LL<<x)) mat[y] ^= mat[i];
    }
    return ret; 
}

int main(void)
{
    int N;
    cin >> N;
    vector<ll> a(N);
    ll A = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        A ^= a[i];
    }
    REP(i, N){
        pr(a[i]^A);
    }

}

Measured memory_bytes: 4648
while True:
    n = int(input())
    if n == 0:
        break
    row = n
    tab = []
    for i in range(row):
        r = list(map(int, input().split()))
        r.append(sum(r))
        tab.append(r)

    bel = []
    for i in range(row):
        tmp = 0
        for j in range(row):
            tmp += tab[j][i]
        bel.append(tmp)
    bel.append(sum(bel))
    tab.append(bel)

    for i in range(row+1):
        for j in range(row+1):
            #print("".join(map("{0:>5}".format, str(tab[i][j]))))
            print('{:>5}'.format(str(tab[i][j])), end='')
        print()

Measured memory_bytes: 7588
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class Gcd:
    def gcd(self, a, b):
        while b != 0:
            a, b = b, a % b
        return a

    def ngcd(self, A):
        res = A[0]
        for i in range(len(A)):
            if res != 1:
                res = gcd(A[i], res)
        return res

    def lcm(self, a, b):
        return a * b // gcd(a, b)

    def nlcm(self, A):
        res = A[0]
        for i in range(len(A)):
            res = lcm(res, A[i])
        return res


def resolve():
    n, x = map(int, input().split())
    X = sorted(list(map(int, input().split())))

    dist = [0] * n
    for i in range(n):
        dist[i] = abs(x - X[i])

    g = Gcd()
    res = dist[0]
    for i in range(1, len(dist)):
        res = g.gcd(res, dist[i])
    print(res)


if __name__ == '__main__':
    resolve()


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

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

    if(N >= 65 && N <= 90){
        cout << 1 << endl;
    }else if(N >= 97 && N <= 122){
        cout << 2 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = [int(_) for _ in stdin.readline().rstrip().split()]
for i in range(K+1, N+1):
	if L[i-K-1] < L[i-1]:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 31524
#include<stdio.h>
#define RANGE 101

int main(){
  int i,j,n,m,l,k;
  int a[RANGE][RANGE]={0};
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&m);
    scanf("%d",&l);
    if(l!=0){
      for(j=0;j<l;j++){
	scanf("%d",&k);
	a[m][k]=1;
      }}}
  
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",a[i][j]);
    }
    printf("%d\n",a[i][n]);
  }
  return 0;
}



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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define rREP(i, n) for(int i = n-1; i >= 0; --i)

using namespace std;

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

    int cnt = 1e8;

    for (int i = 1; i < N; ++i){

        int A = i, B = N - i;
        int tmp = 0;

        while (A != 0) {
            tmp += A % 10;
            A /= 10;
        }

        while (B != 0) {
            tmp += B % 10;
            B /= 10;
        }

        if (cnt > tmp)
            cnt = tmp;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


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


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


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

dp = None


def main():
    S = input()

    if len(S) == len(set(S)):
        print("yes")
    else:
        print("no")


main()


Measured memory_bytes: 4720
const main = (input: string) => {
  const lines = input.split("\n")
  const C = parseInt(lines[0].split(" ")[2]);
  const N = parseInt(lines[0].split(" ")[0]);
  const B = lines[1].split(" ").map(str => parseInt(str));
  let A: number[][] = [];
  let sum = 0;
  let answer = 0;

  for (let i = 2; i <= N + 1; i++) {
    A.push(lines[i].split(" ").map(str => parseInt(str)))
  }

  A.forEach(a => {
    sum = 0;

    a.forEach((number, i) => {
      sum += number * B[i];
    })
    if(sum + C > 0) {
      answer += 1;
    }
  })

  console.log(answer)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

const int mod = 998244353;
const int N = 500005;
using LL = long long;
int n, m, factor[N], ifactor[N];
void reduce(int &x) { x += x >> 31 & mod; }
int pow(int x, int y, int ans = 1) {
	for (; y; y >>= 1, x = (LL) x * x % mod)
		if (y & 1) ans = (LL) ans * x % mod;
	return ans;
}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m; int p = std::max(n, m);
	factor[0] = 1;
	for (int i = 1; i <= p; ++i)
		factor[i] = (LL) factor[i - 1] * i % mod;
	ifactor[p] = pow(factor[p], mod - 2);
	for (int i = p; i; --i)
		ifactor[i - 1] = (LL) ifactor[i] * i % mod;
	int ans = 0;
	for (int i = 0; i <= n && i <= m; ++i) {
		int val = (LL) factor[n] * factor[m] % mod * ifactor[n - i] % mod * ifactor[m - i] % mod * ifactor[i] % mod * pow(n + 1, m - i) % mod * pow(m + 1, n - i) % mod;
		if (i & 1) reduce(ans -= val); else reduce(ans += val - mod);
	}
	std::cout << ans << '\n';
	return 0;
}


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

struct Restaurant {
  int id;
  string name;
  int score;
};

vector<int> solve() {
    int n; cin >> n;
    vector<Restaurant> book;
    string s;
    int p;
    for (int i = 1; i <=n; ++i) {
        cin >> s >> p;
        Restaurant r{i, s, p};
        book.emplace_back(r);
    }
    
    sort(book.begin(), book.end(), [](auto r1, auto r2) {
       if (r1.name == r2.name) {
           return r1.score > r2.score;
       } 
       return r1.name < r2.name;
    });
    
    vector<int> res;
    for (auto const& r : book) {
        res.emplace_back(r.id);
    }
    
    return res;
}

int main() {
    vector<int> res = solve();
    for (auto num : res) {
        cout << num << "\n";
    }
}

Measured memory_bytes: 3244
let rec take n = function
  | [] -> []
  | h :: t ->
      if n = 0
      then []
      else h :: take (n - 1) t

let rec drop n = function
  | [] -> []
  | (_ :: t) as l ->
      if n = 0
      then l
      else drop (n - 1) t

let () = Scanf.scanf "%d" @@ fun n ->
  let lv = Array.make_matrix n n 0 in
  let rec solve l vs = function
    | 0 | 1 -> ()
    | n ->
        let bs = take (n / 2) vs in
        let ws = drop (n / 2) vs in
        List.iter (fun b ->
          List.iter (fun w ->
            lv.(b).(w) <- l;
            lv.(w).(b) <- l) ws) bs;
        solve (l + 1) bs (n / 2);
        solve (l + 1) ws ((n + 1) / 2) in
  solve 1 (Array.to_list (Array.init n (( + ) 0))) n;
  for i = 0 to n - 1 do
    for j = i + 1 to n - 1 do
      Printf.printf "%d " lv.(i).(j)
    done;
    print_newline ()
  done



Measured memory_bytes: 5760
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            p=0
            for f in range(n):
                if p == 0 and s[f] == str(i):
                    p = 1
                elif p == 1 and s[f] == str(j):
                    p = 2
                elif p == 2 and s[f] == str(k):
                    ans += 1
                    break
print(ans)

Measured memory_bytes: 45532
# cf16-exhibition-final-openA - 1D Matching
def calc(x, y, total):
    MOD = 10 ** 9 + 7
    if y:
        total = (total * y) % MOD
        y -= 1
    else:
        x += 1
    return x, y, total


def main():
    # sort A, B and the lines between A, B shouldn't cross
    # cross <-> not min distance
    N, *AB = map(int, open(0))
    C = sorted([(i, 1) for i in AB[:N]] + [(i, 0) for i in AB[N:]])
    ans, a, b = 1, 0, 0
    for i, t in C:
        if t:  # laptop
            a, b, ans = calc(a, b, ans)
        else:  # power sources
            b, a, ans = calc(b, a, ans)
    print(ans)


if __name__ == "__main__":
    main()

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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
ll X;
vector<ll> A;
int main(){
  cin >> N >> X;
  A.resize(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  ll result = 0;
  for (int i = 0; i < N - 1; i++){
    ll sum = A[i] + A[i + 1];
    if (sum > X){//over
      ll rest = sum - X;
      if (rest > A[i + 1]){
	result += A[i + 1];
	rest -= A[i + 1];
	A[i + 1] = 0;
	result += rest;
      }else{
	A[i + 1] -= rest;
	result += rest;
      }
    }
  }
  cout << result << endl;  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;



int main()
{
	int N;

	cin >> N;

	map<string, int> mp;
	int mx = 0;

	for (int i = 0; i < N; ++i)
	{
		string S;
		cin >> S;

		mp[S]++;

		mx = max(mp[S], mx);
	}

	for (auto itr : mp)
	{
		if (mx == itr.second)
		{
			cout << itr.first << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 25216
import java.util.*;

class Main
{
   public static void main(String[] args)
   {
        Scanner sc = new Scanner(System.in);
	String input = sc.nextLine();
	String[] inputArray = input.split(" ");

	if(inputArray.length == 2){
		int a = Integer.parseInt(inputArray[0]);
		int b = Integer.parseInt(inputArray[1]);
		if(a < b){
			System.out.println("a < b");
		}
		else if(b < a){
			System.out.println("a > b");
		}
		else if(a == b){
			System.out.println("a == b");
		}
	}
   }
}

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

long long cnt;

void insertionSort(int A[],int n,int g){
    for(int i=g;i<n;i++){
        int v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j=j-g;
            cnt++;
        }
        A[j+g]=v;
    }
}

void shellSort(int A[],int n){
    cnt=0;
    int m=0,l=n;
    while(l>0){
        l=(l-1)/3;
        m++;
    }
    cout<<m<<endl;
    vector<int> G(m);
    G.at(0)=1;
    for(int i=1;i<m;i++){
        G.at(i)=3*G.at(i-1)+1;
    }
    reverse(G.begin(),G.end());
    for(int i=0;i<m;i++){
        insertionSort(A,n,G.at(i));
        if(i) cout<<' ';
        cout<<G.at(i);
    }
    cout<<endl; 
    cout<<cnt<<endl;
}



int main(){
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    shellSort(A,n);
    for(int i=0;i<n;i++){
        cout<<A[i]<<endl;
    }
}


Measured memory_bytes: 6988
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
    int n, m, a, b, ans = 0;
    scanf("%d%d", &n, &m);
    vector< vector<int> > e(n + 1);
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &a, &b);
        e.at(a).push_back(b);
        e.at(b).push_back(a);
    }
    queue< vector<int> > q;
    q.push({1});
    while (!q.empty()) {
        vector<int> t = q.front();
        q.pop();
        if (t.size() == n) {
            ++ans;
            continue;
        }
        for (auto i = e.at(t.back()).begin(); i != e.at(t.back()).end(); ++i) if (find(t.begin(), t.end(), *i) == t.end()) {
                vector<int> s = t;
                s.push_back(*i);
                q.push(s);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, x;
    cin >> n >> x;

    ll d = 0;
    ll ans = 1;
    rep(i, n) {
        ll L;
        cin >> L;
        d += L;
        if(d <= x) {
            ans++;
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
idx = 1


def resolve():
    def dfs(v):
        global idx
        begin[v] = idx
        idx += 1
        for u in edge[v]:
            if begin[u] != 0:
                continue
            else:
                dfs(u)
        end[v] = idx
        idx += 1

    n = int(input())
    edge = [[] for _ in range(n)]
    for _ in range(n):
        u, k, *V = map(int, input().split())
        for v in V:
            edge[u - 1].append(v - 1)

    begin = [0] * n
    end = [0] * n
    for i in range(n):
        if begin[i] == 0:
            dfs(i)
    for i in range(n):
        print(i + 1, begin[i], end[i])


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 5728
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

void solve() {
	ll a,b,c,d,e,n;
	cin >> n >> a >> b >> c >> d >> e;
	ll ret = 0;
	ret = max(ret, (n+a-1)/a + 4);
	ret = max(ret, (n+b-1)/b + 4);
	ret = max(ret, (n+c-1)/c + 4);
	ret = max(ret, (n+d-1)/d + 4);
	ret = max(ret, (n+e-1)/e + 4);
	cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vi> g(h + 2, vi(w + 2, 0));
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    char c;
    cin >> c;
    if(c == '#') g[i][j] = -1;
  }
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    if(g[i][j] == -1) continue;
    rep(k, 8) {
      int ni = i + dir[k];
      int nj = j + dir[k + 1];
      if(g[ni][nj] == -1) g[i][j]++;
    }
  }
  rep2(i, 1, h + 1) {
    rep2(j, 1, w + 1) {
      if(g[i][j] == -1)
        cout << '#';
      else
        cout << g[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
def main():
    N, K = [int(x) for x in input().split()]
    H = [int(x) for x in input().split()]
    DP = [float("inf")]*N
    DP[0] = 0
    
    for i in range(0,N):
        for k in range(1,K+1):
            if i+k < N:
                DP[i+k] = min(DP[i+k],DP[i] + abs(H[i+k]-H[i]))

    print(DP[-1])


if __name__ == "__main__":
    main()
    pass

Measured memory_bytes: 55136
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

ll F(ll n){
    ll mm=n%4;
    if(mm==0){
        return n;
    }
    else if(mm==1){
        return 1;
    }
    else if(mm==2){
        return n+1;
    }
    else{
        return 0;
    }
}
int main(){
   ll a,b,ans;
   sfl(a),sfl(b);
   ans = F(b) ^ F(a-1);
   pfl(ans);
   return 0;
}

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

int main(){
    int n; string s; cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A'){
            if(s[i+1] == 'B' && s[i+2] == 'C') ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	LL a, b, c, k;
	cin >> a >> b >> c >> k;
	if(k % 2 == 0){
		cout << a - b << endl;
	} else {
		cout << b - a << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))


def gcd(a, b):
    if a < b:
        a, b = b, a
    assert a >= b
    r = a % b
    if r == 0:
        return b
    
    else:
        return gcd(b, r)


gcd_list_l = list()
gcd_list_r = list()

for i in range(0, N):
    if i == 0:
       value = As[i]
    else:
        value = gcd(gcd_list_l[-1], As[i])
    
    gcd_list_l.append(value)

for i in range(N)[::-1]:
    if i == N - 1:
        value = As[i]
    else:
        value = gcd(gcd_list_r[-1], As[i])
    gcd_list_r.append(value)

gcd_list_r.reverse()

# print(gcd_list_l)
# print(gcd_list_r)

ans = 0
for i in range(N):
    if i == 0:
        value = gcd_list_r[i + 1]
    elif i == N - 1:
        value = gcd_list_l[i - 1]
    else:
        value = gcd(gcd_list_l[i - 1], gcd_list_r[i + 1])
    
    ans = max(value, ans)
print(ans)

Measured memory_bytes: 14076
///
// File:  1173.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 12 17:50:22 2017
//

#include <cstdint>
#include <iostream>
#include <istream>
#include <stack>

using namespace std;

int32_t main()
{
  while (true) {
    string str;
    getline(cin, str);
    if (str[0] == '.') break;

    stack<char> s;
    for (uint32_t i = 0; i < str.size(); i++) {
      if (str[i] == '(') {
        s.push('(');
      } else if (str[i] == ')') {
        if (!s.empty() && s.top() == '(') {
          s.pop();
        } else {
          s.push('*');
          break;
        }
      } else if (str[i] == '[') {
        s.push('[');
      } else if (str[i] == ']') {
        if (!s.empty() && s.top() == '[') {
          s.pop();
        } else {
          s.push('*');
          break;
        }
      }
    }

    if (s.empty()) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3004
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionA
    {
        class KS
        {
            public int K;
            public List<int> S;

            public KS(int[] ks)
            {
                K = ks[0];

                S = new List<int>();

                for(int i = 1; i <= K; i++) {
                    S.Add(ks[i] - 1);
                }
            }
        }

        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

            var n = nm[0];
            var m = nm[1];

            var ks = new KS[m];

            for(int i = 0; i < m; i++) {
                ks[i] = new KS(Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray());
            }

            var p = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            var switches = new bool[n];

            var max = 1 << n;

            var count = 0;

            for(int i = 0; i < max; i++) {
                for(int j = 0; j < n; j++) {
                    switches[j] = ((i >> j) & 1) == 1;
                }

                for(int j = 0; j < m; j++) {
                    var lightOnCount = 0;

                    for(int k = 0; k < ks[j].K; k++) {
                        if(switches[ks[j].S[k]]) {
                            lightOnCount++;
                        }
                    }

                    if(lightOnCount % 2 != p[j]) {
                        break;
                    }

                    if(j == m - 1) {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 28340
function Main (input) {
  input = input.split("\n");
  var number = input[1].split(" ");
  var k = parseInt(input[0], 10);
  var a = parseInt(number[0], 10);
  var b = parseInt(number[1], 10);
  
  if (a%k === 0 || (b-a) >= (k-a%k)) {
    console.log("OK");
  } else {
    console.log("NG");
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , ans;
string s;
char a[MAXX];

int main()
{
    _FastIO;
    for(int i = 65; i < 91; i++){
        a[i - 65] = char(i);
    }
    cin >> n;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        int k = 65 + (int(s[i] - 65) + n) % 26;
        s[i] = char(k);
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program {
  static void Main(string[] args) {
    int[] n = Console.ReadLine().Split(' ')
    .Select(i => int.Parse(i)).ToArray();
    if (Math.Abs(n[1]-n[0]) < Math.Abs(n[2]-n[0])) {
      Console.Write("A");
    } else {
      Console.Write("B");
    }
  }
}

Measured memory_bytes: 11348
#include <stdio.h>
int queue[1000];
int head=0;
int tail=0;
int n;
int adj[101][101];
int d[101];
int used[101];
void push(int x){
  queue[head]=x;
  head++;
}
int pop(){
  int x;
  x=queue[tail];
  tail++;
  return x;
}
void bfs(int x){
  int i;
  int v;
  push(x);
  used[x]=1;
  while(head!=tail){
    v=pop();
    for(i=1;i<=n;i++){
      if(adj[v][i]==1 && used[i]==0){
    push(i);
    d[i]=d[v]+1;
    used[i]=1;
      }
    }
  }
}
int main(){
  int i,j;
  int u,k,v;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
    adj[u][v]=1;
    }
  }
  
  for(i=1;i<=n;i++)d[i]=0;
  bfs(1);
  for(i=2;i<=n;i++){
    if(d[i]==0)d[i]=-1;
  }
  for(i=1;i<=n;i++)printf("%d %d\n",i,d[i]);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  int n500 = n/500;
  int r = n%500;
  int n5 = r/5;
  cout<<1000*n500+5*n5<<endl;
  return 0;
}


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

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


int main(){

  priority_queue<ll, vector<ll>, greater<ll>> q;
  ll n,m;
  cin >> n >> m;
  ll tmp;
  rep(i,n){
    cin >> tmp;
    q.push(tmp);
  }

  map<ll,ll,greater<ll>> mp;
  ll b,c;
  rep(i,m){
    cin >> b >> c;
    mp[c] += b;
  }
  // cout << mp.begin()->first << endl;

  for(auto itr : mp){
    c = itr.first;
    b = itr.second;
    if(c <= q.top()){
      break;
    }else{
      rep(j,b){
        if(c <= q.top()) break;
        q.pop();
        q.push(c);
      }
    }
  }

  ll ans = 0;
  rep(i,n){
    ans += q.top();
    // cout << q.top() << endl;
    q.pop();
  }
  cout << ans << endl;


  return 0;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B>C+D) {
    cout << "Left" << endl;
  }
  else if (A+B==C+D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

ll const MOD = 2019;

int main() {
  string s;
  cin >> s;
  ll len = s.length();
  reverse(s.begin(), s.end());
  ll ans = 0;
  ll digit = 1;
  ll sum = 0;
  vector<ll> mod_cnt(MOD);
  for (int i = 0; i < len; i++) {
    mod_cnt[sum]++;
    sum += (s[i]-'0')*digit;
    sum %= MOD;
    ans += mod_cnt[sum];
    digit = digit*10%MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll INF = 100100100100100;

ll mmin(ll a, ll b){
    if(a > b) return b;
    else return a;
}

int main(){
    ll n, m, r; cin >> n >> m >> r;
    vector<ll> data(r);
    rep(i,r){
        ll rr;
        cin >> rr;
        data[i] = rr-1;
    }
    sort(all(data));
    vector<vector<ll>> dist(n,vector<ll>(n,INF));
    rep(i,m){
        ll a, b, c; cin >> a >> b >> c;
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;
    }
    rep(i,n) dist[i][i] = 0;

    rep(k,n) rep(i,n) rep(j,n) dist[i][j] = mmin(dist[i][j], dist[i][k] + dist[k][j]);

    ll ans = INF;  
    do{
        ll count = 0;
        rep(i,r-1) count += dist[data[i]][data[i+1]];
        if(ans > count) ans = count;
    }while(next_permutation(all(data)));
  	cout << ans << endl;    
}

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

int main(){
    int a,b,c,i;
    cin >> a >> b >> c;
    if (a > b){
        i = a;
        a = b;
        b = i;
    }
    if (b > c){
        i = b;
        b = c;
        c = i;
    }
    if (a > b){
        i = a;
        a = b;
        b = i;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>

#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

ll dfs(int K, const VVI &graph, int now, int from){
	int can_use_color_num;
	if(from==-1){
		can_use_color_num = K-1;
	}else{
		can_use_color_num = K-2;
	}
	if(K<graph[now].size()){
		return 0;
	}else{
		ll case_num = 1;
		for(auto e: graph[now]){
			if(e==from)continue;

			case_num *= can_use_color_num;
			can_use_color_num--;
			case_num %= MOD;
		}
		for(auto e: graph[now]){
			if(e==from) continue;
			case_num *= dfs(K,graph,e,now);
			case_num %= MOD;
		}
		return case_num;
	}
}


int main(){
	int n, k; cin >> n >> k;
	VVI G(n);
	rep(i,n-1){
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].PB(b);
		G[b].PB(a);
	}

	ll answer = k*dfs(k,G,0,-1);
	answer %= MOD;
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 11520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n= in.nextInt();
		ArrayList<Integer>[] adj= new ArrayList[n];
		for (int i = 0; i < adj.length; i++) {
			adj[i]= new ArrayList<Integer>();
		}
		for (int i = 0; i < n-1; i++) {
			int a= in.nextInt()-1;
			int b= in.nextInt()-1;
			adj[a].add(b);
			adj[b].add(a);
		}
		int midnode= 0;
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.offer(0);
		int[] vis = new int[n];
		int [] dist= new int[n];
		Arrays.fill(vis, -1);
		vis[0] = 0;
		dist[0]=0;
		while (!q.isEmpty()) {
			int cur = q.poll();
			for (int v : adj[cur]) {
				if (vis[v] == -1) {
					vis[v] = cur;
					dist[v]= dist[cur]+1;
					q.offer(v);
				}
			}
		}
		ArrayDeque<Integer> path = new ArrayDeque<Integer>();
		int go = n-1;
		path.add(go);
		while (go != -1 && go != 0) {
			path.addFirst(vis[go]);
			go = vis[go];
		}
		int distance= dist[n-1];
		int cop= 0;
		int block= -1;
		while(cop<distance/2+1){
			block= path.poll();
			cop++;
		}
		block= path.poll();
		boolean [] numferr= new boolean[n];
		ArrayDeque<Integer> ferrad= new ArrayDeque<>();
		numferr[0]= true;
		ferrad.offer(0);
		while(!ferrad.isEmpty()){
			int cur= ferrad.poll();
			for(int nex: adj[cur]){
				if(nex==block) continue;
				if(!numferr[nex]){
					ferrad.offer(nex);
					numferr[nex]= true;
				}
			}
		}
		int res=0;
		for (int i = 0; i < numferr.length; i++) {
			if(numferr[i]){
				res++;
			}
		}

		int other= n-res;
		if(res<=other){
			System.out.println("Snuke");
		}
		else{
			System.out.println("Fennec");
		}

	}
	public static void combinations(String suffix,String prefix){
		if(prefix.length()<0)return;
		s.add(suffix);
		for(int i=0;i<prefix.length();i++)
			combinations(suffix+prefix.charAt(i),prefix.substring(i+1,prefix.length()));
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}



Measured memory_bytes: 58256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        String line;
        BigInteger n, m;
        line = br.readLine();
//        System.err.println(line);
        st = new StringTokenizer(line);
        n = new BigInteger(st.nextToken());
        m = new BigInteger(st.nextToken());
        Pair p[] = new Pair[n.intValue()];
        for (int i = 0; i < n.intValue(); i++) {
            line = br.readLine();
//            System.err.println(line);
            st = new StringTokenizer(line);
            p[i] = new Pair();
            p[i].a = new BigInteger(st.nextToken());
//            System.err.println(p[i].a);
            p[i].b = new BigInteger(st.nextToken());
//            System.err.println(p[i].b);
        }
        Arrays.sort(p, new Comparator<Pair>() {
            @Override
            public int compare(Pair o1, Pair o2) {
                return o1.a.subtract(o2.a).signum();
            }
        });
//        for (int i = 0; i < n.intValue(); i++) {
//            System.err.println(p[i].a + " " + p[i].b);
//        }
        BigInteger cur = BigInteger.ZERO, res = BigInteger.ZERO;
        int i = 0;
        while (!cur.equals(m)) {
            BigInteger mn = m.subtract(cur);
            BigInteger x = p[i].b;
            if (x.subtract(mn).signum() < 0) {
                mn = x;
            }
            cur = cur.add(mn);
            res = res.add(mn.multiply(p[i].a));
            i++;
        }
        System.out.println(res);
    }
}

class Pair {
    BigInteger a, b;


}


Measured memory_bytes: 103340
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

int getPot(int pom) {
	int wyk = 0;
			while (pom % 2 == 0) {
				pom/=2;
				++wyk;
			}
	return wyk;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	ll lcm = 1;
	int wyk = -1;
	rep(i, 0, n) {
		int a;
		cin >> a;
		a /= 2;
		int pom = a;
		if (wyk == -1) {
			wyk = getPot(pom);
		} else {
			if (getPot(pom) != wyk) {
				cout << 0 << endl;
				return 0;
			}
		}
		int g = gcd(a, lcm);
		lcm = lcm * a / g;
		if (lcm > m) {
			cout << 0 << endl;
			return 0;
		}
	}
	// cout << lcm << endl;
	m -= lcm;
	ll res = 1;
	res += (m / (2 * lcm));
	cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
      Scanner scn = new Scanner(System.in);
      int h = scn.nextInt();
      int w = scn.nextInt();
      char [][] s = new char[h][w];
      for(int i=0; i<h; i++){
        String str = scn.next();
        for(int j=0; j<w; j++){
          s[i][j] = str.charAt(j);
        }
      }
      for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
          if(s[i][j]=='.'){
            int count=0;
            for(int k=i-1; k<i+2; k++){
              for(int l=j-1; l<j+2; l++){
                if(0<=k && k<h && 0<=l && l<w){
                  if(s[k][l]=='#'){
                    count++;
                  }
                }
              }
            }
            s[i][j]=(char)(count+48);
          }
        }
      }
     for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
          System.out.print(s[i][j]);
        }
       System.out.println("");
      }
    }
}


Measured memory_bytes: 36556
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;

int main(void){
  int k,n; cin >> k >> n;
  int a[n]; rep(i,n) cin >> a[i];
  int ans = a[n-1]-a[0];
  rep(i,n-1){
    ans = min(ans, k-a[i+1]+a[i]);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1024
from sys import stdin

n,m,c = [int(x) for x in stdin.readline().rstrip().split()]
lib = list(map(int,stdin.readline().rstrip().split()))
lia = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
kosuu = 0
for i in range(n):
    point = c
    for j in range(m):
        point += lia[i][j] * lib[j]
    if point > 0:
        kosuu += 1
print(kosuu)

Measured memory_bytes: 3064
n = int(input())
s = list(str(input()))
black = 0
white = 0
count = 0
find = False

for i in reversed(range(0,n)):
    if find == True and s[i] == '#':
        black += 1
    elif s[i] == '.':
        white += 1
        find = True
    if black == white and find == True:
        count += white
        white = 0
        black = 0
        find = False
count += black
print(count)

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

int main(){
  int a,b,c,d;
  cin >>a >>b >>c >>d;
  while(true){
    c -= b;
    if(c<=0) break;
    a -= d;
    if(a<=0) break;
  }
  if(a<=0) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define usi unsigned short int
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

const int MIN = 1e3 + 2;
const int MXN = 1e6 + 3;
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 15;
const double EPS = 1e-9;

int x;                                
                                      
int main(){           
        cin >> x;
	if (x < 1200)
		cout << "ABC";
	else
		cout << "ARC";
	return 0;
}

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

map<int,vector<int>> e;
vector<int> d;

int depth_subtree(int v) {
    if (d[v] != -1) {
        return d[v];
    } else if (e[v].empty()) {
        d[v] = 0;
        return d[v];
    } else {
        int dmax=-1;
        for(auto to : e[v]) {
            int d_ = depth_subtree(to);
            if (dmax < d_) {
                dmax = d_;
            }
        }
        d[v] = dmax + 1;
        return d[v];
    }
}

int main() {
    int N,M;
    cin >> N >> M;
    d.resize(N+1,-1);
    for (int m = 0; m < M; m++) {
        int x,y;
        cin >> x >> y;
        e[x].push_back(y);
    }
    
    int dmax=-1;
    for (int v = 1; v <= N; v++) {
        int d_ = depth_subtree(v);
        if (dmax < d_) {
            dmax = d_;
        }
    }
    cout << dmax << '\n';
    return 0;
}

Measured memory_bytes: 14976
f = lambda : map(int,input().split())

n, q = f()
s = input()

ln = [0]*n
for i in range(1,n):
  ln[i] = ln[i-1] + (s[i-1:i+1]=='AC')

for _ in range(q):
  l, r = f()
  print(ln[r-1]-ln[l-1])

Measured memory_bytes: 7748
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int x = sc.nextInt();
		
		
		int[] a = new int[n];
		
		long counter =0;
		
		for(int i =0;i<n;i++) {
			a[i] = sc.nextInt();
			if(a[i]>x) {
				counter+=a[i]-x;
				a[i]=x;
			}
		}
		
		
		for(int i=0;i<n-1;i++) {
			if(a[i]+a[i+1]>x) {
				counter += a[i]+a[i+1]-x;
				a[i+1] -= a[i]+a[i+1]-x;
				
			}
		}
		
		
		System.out.println(counter);

		/*
		TreeMap<Integer,Integer> treeMap = new TreeMap<>();
		treeMap.put(b[n], n);
		*/

	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 50260
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

long long max(long long A,long long B){
    return A>B?A:B;
}

long long min(long long A,long long B){
    return A<B?A:B;
}

long long gcd(long long A,long long B){
    return B?gcd(B,A%B):A;
}

long long lcm(long long A,long long B){
    return A*B/gcd(A,B);
}

int main(void){
    long long a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    long long ans1=0;
    ans1=b/c-a/c;
    if (a%c==0){
        ans1++;
    }
    long long ans2=0;
    ans2=b/d-a/d;
    if (a%d==0){
        ans2++;
    }
    long long ans3=0,e=lcm(c,d);
    ans3=b/e-a/e;
    if (a%e==0){
        ans3++;
    }
    long long ans=ans1+ans2-ans3;
    printf("%lld\n",b-a-ans+1);
    return 0;
}

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

const int INF=1e9;

int main()
{
   int H,W; cin>>H>>W;
   vector<string> s(H);
   for(int i=0;i<H;i++) cin>>s[i];

   int ans=0;
   for(int j=0;j<W-1;j++){
      // cost[x][y]:=j列目がx個、j+1列目がy個の状態のときに操作にかかるコスト
      vector<vector<int>> cost(H+1,vector<int>(H+1));
      for(int x=0;x<=H;x++) for(int y=0;y<=H;y++){
         if(x==0 or y==0) cost[x][y]=0;
         else cost[x][y]=cost[x-1][y-1]+(s[x-1][j]==s[y-1][j+1]);
      }
      // dp[x][y]:=j列目がx個、j+1列目がy個の状態にするのにかかるコストの総和のmin
      vector<vector<int>> dp(H+1,vector<int>(H+1,INF));
      dp[H][H]=0;
      for(int x=H;x>=0;x--) for(int y=H;y>=0;y--){
         if(x+1<=H) dp[x][y]=min(dp[x][y],dp[x+1][y]+cost[x+1][y]);
         if(y+1<=H) dp[x][y]=min(dp[x][y],dp[x][y+1]+cost[x][y+1]);
      }
      ans+=dp[0][0];
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
char s[40];
int n;
map<pair<ull, ull>, int> cnt[20][20];
ull ans;
void dfs(int i, int len, ull s1, ull s2, int ty) {
    if(i == n + 1)
        ans += ty * (cnt[len][2 * n - len][make_pair(s1, s2)] += !ty);
    else
        dfs(i + 1, len + 1, s1 * 131 + s[i], s2, ty),
        dfs(i + 1, len, s1, s2 * 131 + s[i], ty);
}
int main() {
    cin >> n >> (s + 1);
    dfs(1, 0, 0, 0, 0);
    reverse(s + 1, s + 1 + 2 * n);
    dfs(1, 0, 0, 0, 1);
    cout << ans << endl;
}

Measured memory_bytes: 33024