akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int A, B, C;
vi arr;

int main() {
  io();
  
  cin >> A >> B >> C;
  arr.pb(A); arr.pb(B); arr.pb(C);
  qsortd(arr);
  int ret = arr[0] * 10 + arr[1] + arr[2];
  
  cout << ret;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
  double x,y=1.00,s,shita;
  int n,i;
  while(1){
    scanf("%d",&n);
    if(n==-1)break;
    shita=0;
    x=1.00;
    for(i=1;i<n;i++){
      s=atan2(y,x);
      shita+=s;
      x=sqrt(i+1);
    }
    printf("%.2lf\n%.2lf\n",(sqrt(n)*cos(shita)),(sqrt(n)*sin(shita)));  
  }
  return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans=0;
    ans+=min(a,k);
    k-=min(a,k);
    k-=min(b,k);
    ans-=min(k,c);
    cout << ans << endl;
}

Measured memory_bytes: 3636
a,b,c = input().split('/')
a = int(a)
b = int(b)
c = int(c)
if a > 2019:
  print('TBD')
elif a < 2019:
  print('Heisei')
else:
  if b > 4:
    print('TBD')
  else:
    print('Heisei')

Measured memory_bytes: 3060
N = int(input())
ST = []
for i in range(N):
    ST.append(input().split())
    ST[i][1] = int(ST[i][1])
X = input()

pt = 0
for i in range(N):
    if X == ST[i][0]:
        pt = i
        break

sum = 0
for i in range(pt+1,N):
    sum += ST[i][1]

print(sum)


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&a[i])
	}
	sum := sliceIntSum(a)
	res := n - sum
	if n-sum < 0 {
		res = -1
	}
	fmt.Println(res)
}

//-------------------------------------------
// util tools

// abs 絶対値を返す
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// sliceInt []intをスライスする
func sliceInt(k int) []int {
	s := make([]int, getDigit(k))
	count := 0
	for k > 0 {
		i := k % 10
		s[len(s)-1-count] = i
		count++
		k = k / 10
	}
	return s
}

// sliceIntSum []intの合計を出す
func sliceIntSum(v []int) int {
	sum := 0
	for _, x := range v {
		sum += x
	}
	return sum
}

// reverse []intを反転
func reverse(s []int) []int {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}

// getDigit intの桁数を取得
func getDigit(num int) int {
	digit := 0
	for num != 0 {
		num /= 10
		digit++
	}
	return digit
}

// getSumDigit intの各位の和を返す
func getSumDigit(num int) int {
	sum := 0
	for num != 0 {
		t := num % 10
		num /= 10
		sum += t
	}
	return sum
}

// lastPrime 素数 エラトステネスの篩
func lastPrime(max int64) int64 {
	if max <= 1 {
		return 2
	}
	primes := make([]int64, 1, max)
	primesF := make([]float64, 1, max)
	primes[0] = 2
	primesF[0] = 2.0

	count := int64(1)
	for n := int64(3); ; n += 2 {
		flag := true
		f := float64(n)
		rf := math.Sqrt(f)
		for i := 1; i < len(primes); i++ {
			if primesF[i] > rf {
				break
			} else if (n % primes[i]) == 0 {
				flag = false
				break
			}
		}
		if flag {
			count++
			if count >= max {
				return n
			}
			primes = append(primes, n)
			primesF = append(primesF, f)
		}
	}
}

// gcd 最大公約数
func gcd(p, q int64) int64 {
	for q != 0 {
		r := p % q
		p = q
		q = r
	}
	return p
}


Measured memory_bytes: 2464
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
const lli pri = 29, mod = 1e9 + 1651;
lli rh[5050], a;
lli mypow(lli x, lli y)
{
	x %= mod;
	lli res = 1, tmp = x;
	while(y)
	{
		if(y % 2) res = (res * tmp) % mod;
		tmp = (tmp * tmp) % mod;
		y /= 2;
	}
	return res;
}
bool check(lli mid)
{
	lli tmp = mypow(pri, mid);
	for(int i = mid; i <= a; i++)
	{
		for(int j=a; j - i >= mid; j--)
		{
			lli t1 = rh[i - mid] * tmp % mod;
			lli t2 = rh[j - mid] * tmp % mod;
			t1 = (rh[i] - t1 + mod) % mod;
			t2 = (rh[j] - t2 + mod) % mod;
			if(t1 == t2) return true;
		}
	}
	return false;
}
int main()
{
	cin >> a;
	string str; cin >> str;
	for(int i=0; i<a; i++)
	{
		rh[i + 1] = rh[i] * pri % mod;
		rh[i + 1] = (rh[i + 1] + str[i] - 'a') % mod;
	}
	int left = 0, right = a, ans = 0;
	while(left <= right)
	{
		int mid = (left + right) >> 1;
		if(check(mid))
		{
			ans = mid;
			left = mid + 1;
		}
		else
		{
			right = mid - 1;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
	
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s,p;
    cin >> s >> p;
    s=s.append(s,0,s.size()-1);
    if (s.find(p,0)<=s.size())
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define FOR(x,n) for(int x = 0; x < n; x++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
using namespace std;
typedef long long ll;
const int MXN = 1e5 + 1;
int N;
pair<int,int> xs[MXN], ys[MXN], id[MXN];
struct Edge {
  int a, b, v;
  bool operator<(const Edge &o) const {
    return v > o.v;
  }
};

int P[MXN];
int find(int i) { return i == P[i] ? i : P[i] = find(P[i]); }
int main() {
  cin >> N;
  fore(x,0,MXN) P[x] = x;
  fore(x, 0, N) cin >> xs[x].first >> ys[x].first, xs[x].second = x, ys[x].second = x;
  sort(xs,xs+N); sort(ys,ys+N);
  fore(x,0,N) id[xs[x].second].first = x, id[ys[x].second].second = x;

  priority_queue<Edge> pq;
  fore(x,0,N-1){
    pq.push(Edge{xs[x].second, xs[x+1].second, xs[x+1].first - xs[x].first});
    pq.push(Edge{ys[x].second, ys[x+1].second, ys[x+1].first - ys[x].first});
  }

  ll ans = 0;
  while(!pq.empty()){
    Edge e = pq.top(); pq.pop();

    if(find(e.a) != find(e.b)){
      ans += e.v;
      P[find(e.a)] = find(e.b);
    }
  }

  cout << ans << "\n";
}


Measured memory_bytes: 7736
def pipe(x, funcs):
    for func in funcs:
        x = func(x)
    return x


def fmap(fn):
    return lambda x: map(fn, x)


def rot(s, w, base="A", alphabet=26):
    b = ord(base)
    return pipe(s, [
        fmap(ord),
        fmap(lambda x: x - b),
        fmap(lambda x: (x + alphabet + w) % alphabet),
        fmap(lambda x: x + b),
        fmap(chr),
        "".join,
    ])


def main():
    print(rot(input().strip(), -3))


if __name__ == "__main__":
    main()

Measured memory_bytes: 7400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        string S = Console.ReadLine();

        var sum = new int[N + 1]; //'W'の総数
        for(int i = 1; i <= N; i++)
        {
            sum[i] = sum[i - 1] + (S[i - 1] == 'W' ? 1 : 0);
        }

        int ans = int.MaxValue;
        for(int i = 1; i <= N; i++)
        {
            int tmp = sum[i - 1] + N - i - sum[N] + sum[i];
            ans = Math.Min(ans, tmp);
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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


Measured memory_bytes: 13280
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
S = input()

ans = 0
x = 0
for s in S:
    if s == "I":
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print(ans)

Measured memory_bytes: 8968
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <cstdlib>

struct point
{
    int x, y, org;
} p[100001];

int par[100001], rank[100001];

typedef std::pair<int, int> pi;
typedef std::pair<int, std::pair<int, int>> pii;
std::priority_queue<pii, std::vector<pii>, std::greater<pii>> edge;

int parent(int u)
{
    if (u == par[u])
        return u;
    else
        return par[u] = parent(par[u]);
}

void joint(int u, int v)
{
    if (rank[u] > rank[v])
    {
        par[v] = u;
        rank[u] += rank[v];
    }
    else
    {
        par[u] = v;
        rank[v] += rank[u];
    }
}

signed main()
{
    // freopen("a.inp", "r", stdin);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);

    int points, k;

    std::cin >> points;
    int x, y;
    for (int i = 0; i < points; ++i)
    {
        par[i] = i;
        p[i].org = i;
        std::cin >> p[i].x >> p[i].y;
    }
    std::sort(p, p + points, [](const point &p1, const point &p2) { return p1.x < p2.x; });
    for (int i = 0; i < points - 1; ++i)
        edge.push(pii(std::min(p[i + 1].x - p[i].x, abs(p[i + 1].y - p[i].y)), pi(p[i].org, p[i + 1].org)));
    std::sort(p, p + points, [](const point &p1, const point &p2) { return p1.y < p2.y; });
    for (int i = 0; i < points - 1; ++i)
        edge.push(pii(std::min(p[i + 1].y - p[i].y, abs(p[i + 1].x - p[i].x)), pi(p[i].org, p[i + 1].org)));
    unsigned s = 0;
    int tmp = 1;
    while (!edge.empty())
    {
        if (tmp == points)
            break;
        pii temp = edge.top();
        edge.pop();
        int cost = temp.first;
        int p_u = parent(temp.second.first);
        int p_v = parent(temp.second.second);
        if (p_u != p_v)
        {
            ++tmp;
            s += cost;
            joint(p_u, p_v);
        }
    }
    std::cout << s;
    return 0;
}

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

char T[25000][2];
char S;
int main(){
int n,m;
while(true){
cin>>n;
if(n==0){
break;
}
for(int i=0;i<n;i++){
cin>>T[i][0]>>T[i][1];
}
cin>>m;
for(int i=0;i<m;i++){
cin>>S;
for(int j=0;j<n;j++){
	if(T[j][0]==S){
	cout<<T[j][1];
	goto Exit;
	}
}
cout<<S;
Exit:;
}
cout<<endl;
}
}

Measured memory_bytes: 1152
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            Console.ReadLine();
            var map = new int[8, 8];
            for (int j = 0; j < 8; j++)
            {
                var s = Console.ReadLine().Trim();
                for (int k = 0; k < 8; k++)
                    if (s[k] == '1') map[j, k] = 1;
            }
            var y = int.Parse(Console.ReadLine().Trim());
            var x = int.Parse(Console.ReadLine().Trim());
            goDfs(map, x-1, y-1);
            display(map, i+1);
        }
    }
    public static void display (int[,] map,int c)
    {
        Console.WriteLine("Data {0}:", c);
        for (int i = 0; i < 8; i++)
            for (int j = 0; j < 8; j++)
                if (j == 7) Console.WriteLine(map[i, j]);
                else Console.Write(map[i, j]);
    }
    public static void goDfs(int[,] map, int x, int y)
    {
        map[x, y] = 0;
        for (int d = -3; d <= 3; d++)
        {
            var nx = x + d;    var ny = y + d;
            if (nx >= 0 && nx < 8 && map[nx, y] == 1) goDfs(map, nx, y);
            if (ny >= 0 && ny < 8 && map[x, ny] == 1) goDfs(map, x, ny);
        }
    }
}

Measured memory_bytes: 9108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int[] HW = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int H = HW[0];
        int W = HW[1];

        int[] hw = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int h = hw[0];
        int w = hw[1];

        Console.WriteLine((H - h) * (W - w));
    }
}

Measured memory_bytes: 13268
#include<stdio.h>

int main(){
  int num;
  scanf("%d",&num);
  num=num%10;
  if(num==2||num==4||num==5||num==7||num==9){
    printf("hon\n");
  }
  else if (num==0||num==1||num==6||num==8){
    printf("pon\n");
  }
  else {
    printf("bon\n");
  }
  return 0;
}

Measured memory_bytes: 1624
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

w = sys.stdin.readline().strip().lower()

words = list()

while True:
    s = sys.stdin.readline().strip()
    if s == 'END_OF_TEXT':
        break
    words.extend(s.lower().split())

print(words.count(w))



Measured memory_bytes: 5556
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int n,m,par[55]={},ans=0,a[55]={},b[55]={},f;
int find(int x) {
  if(par[x]==x) {
    return x;
  }
  return par[x]=find(par[x]);
}
bool same(int x,int y) {
  return find(x)==find(y);
}
void unit(int x,int y) {
  x=find(x),y=find(y);
  if(x!=y) {
    par[x]=y;
  }
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
  }
  for(int i=0; i<m; i++) {
    for(int j=0; j<n; j++) {
      par[j]=j;
    }
    for(int j=0; j<m; j++) {
      if(i!=j) {
        unit(a[j],b[j]);
      }
    }
    f=0;
    for(int i=0; i<n; i++) {
      if(!same(i,i+1)) {
        f=1;
      }
    }
    if(f) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
li=[]
for i in range (0,n):
  li.append(v[i]-c[i])
t=0
len_li=len(li)
for j in range (0,len_li):
  if li[j]>=0:
    t=t+li[j]
print(t)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

from collections import defaultdict

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

def prime_factors(d,N): #素因数 1を含まないことに注意
    ret = []
    middle = int( N**(1/2))
    tmp = N
    for i in range(2, middle+1):
        if tmp%i == 0:
            c = 0
            while tmp%i == 0:
                tmp //= i
                c += 1
            if d[i] < c:
                d[i] = c
    if tmp != 1:
        if d[tmp] == 0:
            d[tmp] = 1

Q = 10**9+7
def main():
    N = int( input())
    A = list( map( int, input().split()))
    # d = defaultdict( int)
    # for a in A:
    #     prime_factors(d, a)
    s = 1
    for a in A:
        s = s*a//gcd(s,a)
    # for key, value in d.items():
    #     s *= pow( key, value)
    ans = 0
    for a in A:
        ans += s*pow(a,Q-2,Q)
    print(ans%Q)
if __name__ == '__main__':
    main()

Measured memory_bytes: 4468
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 22:01:32 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N,A,B,C = map(int,input().split())
s = []
for i in range(N):
    s.append(input())

ans = ['Yes']
No = 'No'
ab,ac,bc = 'AB', 'AC', 'BC'
a,b,c = 'A', 'B', 'C'

for i in range(N):
    if s[i] == ab:
        flg = True
        if A == 1 and B ==1:
            if i == N -1:
                flg = True
            elif s[i+1] == ac:
                flg = True
            else:
                flg = False
        elif A <= B:
            flg = True
        elif A > B:
            flg = False
        if flg:
            A += 1
            B -= 1
            ans.append(a)
        else:
            A -= 1
            B += 1
            ans.append(b)

    elif s[i] == ac:
        flg = True
        if A == 1 and C ==1:
            if i == N -1:
                flg = True
            elif s[i+1] == ab:
                flg = True
            else:
                flg = False
        elif A <= C:
            flg = True
        elif A > C:
            flg = False
        if flg:
            A += 1
            C -= 1
            ans.append(a)
        else:
            A -= 1
            C += 1
            ans.append(c)

    elif s[i] == bc:
        flg = True
        if B == 1 and C ==1:
            if i == N -1:
                flg = True
            elif s[i+1] == ab:
                flg = True
            else:
                flg = False
        elif B <= C:
            flg = True
        elif B > C:
            flg = False
        if flg:
            B += 1
            C -= 1
            ans.append(b)
        else:
            B -= 1
            C += 1
            ans.append(c)
    if A < 0 or B < 0 or C < 0:
        print(No)
        sys.exit()

for a in ans:
    print(a)




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

int main(void){
    int a[5], i, k=9, los = 0, ans = 0, po = 0, max = 0;
    scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
    for(i=0; i<5; i++){
        ans += (a[i] + 9)/10*10;
        if(a[i]%10 != 0){
            if((10 - a[i]%10) > max) max = 10 - a[i]%10;
        }
        
    }
    printf("%d", ans - max);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int n,w,g[200];
ll dp[2][201][10001],mod=1e9+7;
int main(){
	cin >> n >> w;
	rep(i,n) cin >> g[i];
	sort(g,g+n);
	dp[0][0][0]=1;
	ll ans=0;
	rep(i,n){
		rep(j,i+1) rep(k,w+1) dp[1-i%2][j][k]=0;
		rep(j,i+1){
			rep(k,w+1){
				dp[1-i%2][j][k]+=dp[i%2][j][k];
				if(k+g[i]<=w){
					if(i==j) dp[1-i%2][j+1][k+g[i]]+=dp[i%2][j][k];
					else dp[1-i%2][j][k+g[i]]+=dp[i%2][j][k];
				}
			}
		}
		rep(j,i+1) rep(k,w+1) if(dp[1-i%2][j][k]>=mod) dp[1-i%2][j][k]%=mod;
	}
	rep(k,w+1) ans+=dp[n%2][n][k];
	rep(j,n) rep(k,w+1) if(g[j]>w-k) ans+=dp[n%2][j][k];
	cout << ans%mod << endl;
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=n;
    if((b-a)%2==0) ans=min(ans,(b-a)/2);
    ans=min(ans,a+(b-a-1)/2);
    ans=min(ans,n-b+1+(n-(a+n-b+1))/2);
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		int w = scan.nextInt(); //x
		int h = scan.nextInt(); //y
		int n = scan.nextInt();

		int i = 0;
		int j = 0;

		int xko0 = 0;
		int yko0 = 0;
		int xko = w;
		int yko = h;

		List<Integer> x = new ArrayList<Integer>();
		List<Integer> y = new ArrayList<Integer>();
		List<Integer> a = new ArrayList<Integer>();

		for (i = 0; i < n; i++) {
			x.add(scan.nextInt());
			y.add(scan.nextInt());
			a.add(scan.nextInt());

		}
		/*
				System.out.println(x);
				System.out.println(y);
				System.out.println(a);
		*/
		for (j = 0; j < n; j++) {

			if (a.get(j) == 1) {

				if (xko0 <= x.get(j)) {

					xko0 = x.get(j);
				}

			} else if (a.get(j) == 2) {

				if (xko >= x.get(j)) {

					xko = x.get(j);
				}

			} else if (a.get(j) == 3) {

				if (yko0 <= y.get(j)) {

					yko0 = y.get(j);
				}

			} else if (a.get(j) == 4) {

				if (yko >= y.get(j)) {

					yko = y.get(j);
				}


			}

		}
/*
				System.out.println(xko0);
				System.out.println(xko);
				System.out.println(yko0);
				System.out.println(yko);
*/
		if (xko0 < xko && yko0 < yko) {
			System.out.println((xko - xko0) * (yko - yko0));

		} else {
			System.out.println(0);
		}

	}

}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int m = 1 << n;
    ll s[m];
    rep(i, m) {
        cin >> s[i];
        s[i] *= -1;
    }
    multiset<ll> C(s, s + m), P;
    P.emplace(*C.begin());
    C.erase(C.begin());
    rep(i, n) {
        multiset<ll> T;
        for(auto p : P){
            auto itr = C.upper_bound(p);
            if(itr == C.end()){
                cout << "No" << endl;
                return 0;
            }
            C.erase(itr);
            T.emplace(*itr);
        }
        for(auto t : T){
            P.emplace(t);
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 24100
N,A,B,K = map(int, input().split())

MOD = 998244353 # prime
MAX = 10**6

fac = [0]*MAX
finv = [0]*MAX
inv = [0]*MAX

def init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def C(n, k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    return fac[n]%MOD * (finv[k] * finv[n-k] % MOD) % MOD

res = 0
init()
for a in range(0,N+1):
    # 割り切れることを確認
    if (K - A*a)%B == 0 and (K -A*a)//B >= 0:
        b = (K -A*a)//B
        res += C(N,a)*C(N,b)
        res %= MOD
print(res)

Measured memory_bytes: 64240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll x;
    cin >> x;
    ll ans = (x/11)*2;
    x %= 11;
    if (x==0) {;}
    else if (x<=6) ans++;
    else ans += 2;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

ll mysqrt(ll x) {
	ll r = (ll) (sqrt(x) + 2);
	while (r * r > x) r--;
	return r;
}

int main() {
	int Q;
	cin >> Q;
	vector<ll> res;

	while (Q--) {
		ll a, b, c;
		cin >> a >> b;
		c = a * b - 1;
		ll s = mysqrt(c);
		ll r = s * 2;
		r -= s * (s + 1) > c;
		r -= a != b;
		res.push_back(max(r, 0LL));
	}
	for (auto& r : res) {
		cout << r << endl;
	}
}

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

int main() {
	int a,b,c;
  cin>>a>>b;
  for(int i=0;i<b;i++){
  	cin>>c;
    a=a-c;
  }
  if(a<=0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
    private static int gcd(int x, int y)
    {
        if (0 == y)
            return x;
        return gcd(y, x % y);
    }

    private static int lcm(int x, int y)
    {
        return x  / gcd(x, y) * y;
    }

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

        while (in.hasNext())
        {
            int x = in.nextInt();
            int y = in.nextInt();

            System.out.print(gcd(x, y) + " " + lcm(x, y));
            System.out.println();
        }
    }
}

Measured memory_bytes: 26144
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  char s[4];
  while (scanf(" %s", s) != EOF)
    printf("%s\n", strcmp(s, "ABC") ? "ABC" : "ARC");
  return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include <queue>
#include <functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    int n;
    cin >> n;
    vector<ll> a,b;
    REP(i,RUP(n,2)){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
        cin >> tmp;
        b.push_back(tmp);
    }
    ll ans[210000];
    
    if(n%2==0){
        REV(b);
        REP(i,n/2) ans[i] = b[i];
        REP(i,n/2) ans[i+n/2] = a[i];
    }else{
        REV(a);
        REP(i,(n+1)/2) ans[i] = a[i];
        REP(i,(n-1)/2) ans[i+(n+1)/2] = b[i];
    }

    REP(i,n) cout << ans[i] << " ";

    return 0;
}

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


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;
typedef long long lint;

lint dp[55][2];

int main() {
    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int c = 0; c < 2; c++) {
            dp[i+1][(c + A[i]) % 2] += dp[i][c];
            dp[i+1][c] += dp[i][c];
        }
    }
    cout << dp[N][P] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
};
int N,M,Q;
vector<pair<int,pair<int,int> > >E;
vector<pair<int,int> >G[4000];
int T[4000][4000];
void dfs(int u,int p,int now,int f)
{
	T[f][u]=now;
	for(pair<int,int>q:G[u])
	{
		if(q.first==p)continue;
		dfs(q.first,u,max(now,q.second),f);
	}
}
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		a--,b--;
		E.push_back(make_pair(c,make_pair(a,b)));
	}
	sort(E.begin(),E.end());
	UF uf(N);
	long sum=0;
	for(pair<int,pair<int,int> >p:E)
	{
		int u=p.second.first,v=p.second.second;
		if(uf.unite(u,v))
		{
			sum+=p.first;
			G[u].push_back(make_pair(v,p.first));
			G[v].push_back(make_pair(u,p.first));
		}
	}
	for(int i=0;i<N;i++)
	{
		dfs(i,-1,0,i);
	}
	cin>>Q;
	for(int i=0;i<Q;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		cout<<sum-T[a][b]<<endl;
	}
}

Measured memory_bytes: 70252
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int MinimumNumIncreasingSubsequences(ll arr[], ll n) 
{ 
    multiset<ll> last;
    for (ll i = 0; i < n; i++) 
	{ 
        multiset<ll>::iterator it = last.lower_bound(arr[i]); 
        if (it == last.begin()) last.insert(arr[i]); 
  
        else { 
            it--;
            last.erase(it);
            last.insert(arr[i]);
        } 
    } 
    return last.size(); // our answer is the size of last 
}
main(){
	ll n;cin>>n;
	ll a[n+1];
	for(ll i=0; i<n; i++)	cin>>a[i];
	cout<<MinimumNumIncreasingSubsequences( a, n);
	return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N, C, K; cin >> N >> C >> K;
    vector<long long> t(N);
    for(int i = 0; i < N; i++)
        cin >> t[i];
    sort(t.begin(), t.end());
    long long T = t[0];
    long long ans = 1, cnt = 1;
    for(int i = 1; i < N; i++){
        if(t[i] > T+K || cnt == C){
            T = t[i];
            cnt = 1;
            ans++;
        }
        else cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int a = ni();
        int b = ni();
        int c = ni();
        int d = ni();

        if (a == c) {
            out.println(b);
            return;
        }

        if (b == d) {
            out.println(a);
            return;
        }

        int x = gcd(Math.abs(a - c), Math.abs(b - d));

        out.println(Math.abs(a - c) + Math.abs(b - d) - x);
    }

    int gcd(int a, int b) {
        return a == 0 ? b : gcd(b % a, a);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8276
#include <iostream>

int main()
{
  int x[5], k;
  for (int& v : x) std::cin >> v;
  std::cin >> k;
  
  for (int i = 0; i < 5; ++i)
    for (int j = i + 1; j < 5; ++j)
      if (k < x[j] - x[i]) goto fail;
  
  std::cout << "Yay!" << std::endl;
  return 0;
fail:
  std::cout << ":(" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	REP(i,n) cin >> x[i];
	
	ll ans = 0;
	for(int i=0; i<n-1; i++){
		ans += min((x[i+1]-x[i])*a, b);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UnionFind
{
private:
    vector<int> par;
    int n;

public:
    UnionFind(int size)
    {
        n = size;
        par.assign(n, -1);
    }
    int root(int node)
    {
        if (par[node] < 0)
            return node;
        return par[node] = root(par[node]);
    }
    bool unite(int a, int b)
    {
        a = root(a);
        b = root(b);
        if(a == b)
            return false;
        if(par[a] > par[b])
            swap(a, b);
        par[a] += par[b];
        par[b] = a;
        return true;
    }
    bool same(int a, int b)
    {
        return root(a) == root(b);
    }
};
int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    int x, y, z;
    for(int i = 0; i < m; i++){
        cin >> x >> y >> z;
        x--;
        y--;
        uf.unite(x, y);
    }
    set<int> s;
    for(int i = 0; i < n; i++){
        s.insert(uf.root(i));
    }
    cout << s.size() << "\n";
}

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


#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {

    ll x, t;
    cin >> x >> t;

    cout << max(x - t, 0ll) << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 100001


/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N;			// スライム個数
char S[MAX_N];	// スライムの色配列

int main () {

	int cnt = 0;
	char pre_slime = -1;

	// 個数と色の読込み
	scanf("%d", &N);
	scanf("%s", S);
	// 
	for(int i = 0; i < N; i++) {
		if(S[i] != pre_slime) {
			cnt ++;
			pre_slime = S[i];
		}
	}

	//
	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, l;
	scanf("%d %d", &n, &l);
	int i, j;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < n - 1; i++)
	{
		if (a[i] + a[i + 1] >= l)
		{
			printf("Possible\n");
			for (j = 1; j <= i; j++)
				printf("%d\n", j);
			for (j = n - 1; j > i + 1; j--)
				printf("%d\n", j);
			printf("%d\n", i + 1);
			return 0;
		}
	}
	printf("Impossible\n");
	return 0;
}

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

using namespace std;

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

	for (int i = 0; i < S.length();) {
		if (S[i] == 'L') {
			cout << "No";
			return 0;
		}
		i++;
		if (i == S.length())break;
		if (S[i] == 'R') {
			cout << "No";	
			return 0;
		}
		i++;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	ic_s;
	string ans;
	int w;
	cin >> w;
	rep(i, s.size()) {
		if (i == 0||i%w==0) {
			cout << s[i];
		}
	}
	cout << rt;

	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
struct edge {
    int to;
    int cost;
};
//vector<edge> G[100010];
V G[100010], g[100010];
int d[100010][5];
int N, M, S, T;

void solve()
{
    /*
    FOR(i, 1, N + 1)
    {
        set<int> s2, s3;
        for (int j = 0; j < (int)G[i].size(); j++) {
            int p = G[i][j];
            for (int k = 0; k < (int)G[p].size(); k++) {
                int q = G[p][k];
                
                s2.insert(q);
                for (auto l = s2.begin(); l != s2.end(); l++) {
                    int o = *l;
                    int r = G[q][o];
                    s3.insert(r);
                    cout << r << endl;
            }
             

                for (int l = 0; l < (int)G[q].size(); l++) {
                    int r = G[q][l];
                    s3.insert(r);
                    //g[i].push_back(r);
                    //cout << i << " " << r << endl;
                }
            }
        }
        for (auto j = s3.begin(); j != s3.end(); j++) {
            int r = *j;
            g[i].push_back(r);
            //cout << i << " " << r << endl;
        }
    }
    */

    for (int i = 0; i <= N; i++) {
        d[i][0] = -1;
        d[i][1] = -1;
        d[i][2] = -1;
    }
    d[S][0] = 0;
    queue<P> que;
    que.push(make_pair(S, 0));
    while (!que.empty()) {
        P p = que.front();
        int c = p.second;
        que.pop();
        for (int i = 0; i < (int)G[p.first].size(); i++) {
            int t = G[p.first][i];
            //cout << d[t] << endl;
            if (d[t][(c + 1) % 3] == -1) {
                d[t][(c + 1) % 3] = d[p.first][c] + 1;
                que.push(make_pair(t, (c + 1) % 3));
            }
        }
    }
    if (d[T][0] == -1) {
        cout << -1 << endl;
    } else {
        cout << d[T][0] / 3 << endl;
    }
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    FOR(i, 0, M)
    {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
    }
    cin >> S >> T;
    solve();
    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int N,K;
    int b[200010]= {0};
    cin >> N >> K;
    int a[200010];
    for(int i=0; i<N; i++)
        cin >> a[i];
    int cnt=0;
    for(int i=0; i<N; i++)
    {
        if(b[a[i]]==0)
            cnt++;
        b[a[i]]++;
    }
    sort(b,b+200010,cmp);
    int sum=0;
    if(cnt <= K)
        sum=0;
    else
    {
        for(int i=K; i<cnt; i++)
            sum+=b[i];
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
using namespace std;
#define int long long
#define mn 55
#define inf 777777777777777777
#define ZLA "Tak and Cards"
#define mod 1000000007

int n,A,a[mn],b[mn],kq,DP[mn][4905][mn];

int dp(int x,int y,int z)
{
	if (x==0)
	{
		if ((y==2450) && (z>0)) return 1;
		return 0;
	}
	if (DP[x][y][z]!=inf) return DP[x][y][z];
	DP[x][y][z]=dp(x-1,y,z)+dp(x-1,y+b[x],z+1);
	return DP[x][y][z];
}

void input()
{
	cin >> n >> A;
	for (int i=1;i<=n;i++)
	{
		cin >> a[i];
		b[i]=a[i]-A;
	}
}

void output()
{
	cout << dp(n,2450,0);
}

signed main()
{
//	freopen(ZLA".inp", "r", stdin);
//	freopen(ZLA".out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	input();
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=4900;j++)
		{
			for (int k=0;k<=n;k++)
			{
				DP[i][j][k]=inf;
			}
		}
	}
	output();
	return 0;
}

Measured memory_bytes: 106752
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,x,y,flag=0;
    string a,b;
    cin>>a>>b;
    x=a.size();
    y=b.size();
    if(x>y)
    {
        cout<<"GREATER"<<endl;
    }
    else if(x<y)
    {
        cout<<"LESS"<<endl;
    }
    else if(x==y)
    {
        for(i=0; i<a.size(); i++)
        {

            if(a[i]>b[i])
            {
                cout<<"GREATER"<<endl;
            flag=1;
                break;
            }
            else if(a[i]<b[i])
            {
                cout<<"LESS"<<endl;
                flag=1;
                break;
            }
            else{flag=0;}

        }
        if(flag==0)
        {
            cout<<"EQUAL"<<endl;
        }
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;

int main() {
  int N, C;
  vector<int> s(100000), t(100000), c(100000);
  vector<int> sm(200002);
//  vector<int> tt(200002);
  vector<int> differential(200002);
  vector<int> accumulation(200002);
  cin >> N >> C;
  for (int i = 0; i < N; ++i)  // Gets input.
    cin >> s[i] >> t[i] >> c[i];
  for (int i = 1; i <= C; ++i) {  // For each channel.
    fill(differential.begin(), differential.end(), 0);
    fill(accumulation.begin(), accumulation.end(), 0);
    for (int j = 0; j < N; ++j) {  // for each program.
      if (c[j] == i) {
        ++differential[s[j] * 2 - 1];
        --differential[t[j] * 2];
      }
    }
    accumulation[0] = differential[0];
    for (int j = 1; j < 200002; ++j) {
      accumulation[j] = accumulation[j - 1] + differential[j];
    }
    for (int j = 0; j < 200002; ++j) {
      if (accumulation[j] > 0) {
        ++sm[j];
      }
    }
  }
  cout << *max_element(sm.begin(), sm.end()) << endl;
}


Measured memory_bytes: 3712