akhauriyash/Code-Regression huggingface dataset:
class BinarySearchTree:
    def __init__(self):
        self.root = None
    def insert(self, z):
        p = None
        x = self.root
        while x != None:
            p = x
            if z.key < x.key : x = x.left
            else             : x = x.right
        z.p = p
        if p == None      : self.root = z
        elif z.key < p.key: p.left  = z
        else              : p.right = z
    def get_inorder_list(self):
        def _get_inorder_list(root):
            l = root.left
            r = root.right
            if l: yield from _get_inorder_list(l)
            yield root.key
            if r: yield from _get_inorder_list(r)
        yield from _get_inorder_list(self.root)
    def get_preorder_list(self):
        def _get_preorder_list(root):
            l = root.left
            r = root.right
            yield root.key
            if l: yield from _get_preorder_list(l)
            if r: yield from _get_preorder_list(r)
        yield from _get_preorder_list(self.root)
    def find(self, k):
        x = self.root
        while x:
            if k == x.key: return True
            if k <  x.key: x = x.left
            else         : x = x.right
        return False

class Node:
    def __init__(self, k):
        self.key = k
        self.p = None
        self.left = None
        self.right = None
        

if __name__=='__main__':
    m = int(input())

    T = BinarySearchTree()
    for _ in range(m):        
        op = input().split()
        if   op[0] == 'insert': T.insert( Node(int(op[1])) )
        elif op[0] == 'find':
            print("yes" if T.find(int(op[1])) else "no")
        else:
            print("",*T.get_inorder_list())
            print("",*T.get_preorder_list())

Measured memory_bytes: 130768
#include "bits/stdc++.h"
using namespace std;
int a[100000];
int main()
{
	int n, total = 1, mod = 1000000007;
	scanf("%d", &n);
	for(int i = 0, j; i < n; ++i)
	{
		scanf("%d", &j);
		++a[j];
	}
	bool exi;
	if(n % 2)
	{
		exi = a[0] == 1;
		for(int i = 2; i < n; i += 2)
		{
			exi &= a[i] == 2;
		}
		for(int i = 0; i < n / 2; ++i)
		{
			(total *= 2) %= mod;
		}
	}
	else
	{
		exi = true;
		for(int i = 1; i < n; i += 2)
		{
			exi &= a[i] == 2;
		}
		for(int i = 0; i < n / 2; ++i)
		{
			(total *= 2 ) %= mod;
		}
	}
	printf("%d\n", exi ? total : 0);
}

Measured memory_bytes: 640
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

*******************************************************************************/

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

LL n;
vector<int> need;
deque<int> a, b;

int main() {
    cin >> n;
    ++n;
    while (n > 1) {
        if (n % 2 == 0) {
            n /= 2;
            need.pb(2);
        } else {
            n -= 1;
            need.pb(1);
        }
    }
    reverse(need.begin(), need.end());
    int cur = 1;
    for (int x : need) if (x == 1) {
        a.push_front(cur);
        b.push_back(cur);
        ++cur;
    } else {
        a.push_back(cur);
        b.push_back(cur);
        ++cur;
    }
    cout << int(a.size() + b.size()) << endl;
    for (int c : a) cout << c << ' ';
    for (int c : b) cout << c << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;
const int SZE = 1e6+1;

int dp[100009];
string subb[4]={"dream","dreamer","erase","eraser"};

int main(){
	string s;cin>>s;
	int n=SZ(s);
	dp[0]=1;
	REPP(i,1,n+1){
		REP(j,4){
			if(i<SZ(subb[j]))continue;
			if(!dp[i-SZ(subb[j])])continue;
			if(s.substr(i-SZ(subb[j]),SZ(subb[j]))!=subb[j])continue;
			dp[i]=1;
		}
	}
	if(dp[n])puts("YES");
	else puts("NO");
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    char c; cin >> c;
    cout << char(c + 1) << endl; 
    return 0;
}


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

using namespace std;

vector<vector<int>> g{
  {1, 3, 5, 7, 8, 10, 12},
  {4, 6, 9, 11},
  {2}
};

int find(int x)
{
  for (int i = 0; i < g.size(); i++) {
    for (int j = 0; j < g[i].size(); j++) {
      if (g[i][j] == x) return i;
    }
  }
  return -1;
}

int main()
{
  int x, y;
  cin >> x >> y;

  if (find(x) == find(y)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 384
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($A,$B) =  explode(" ",trim(fgets(STDIN)));
//$B = explode(" ",trim(fgets(STDIN)));

$v = array_count_values(str_split($S));
$t=1;
foreach($v as $vv) {
  $t*=$vv+1;
  $t = $t % 1000000007;
}
printf("%d\n",$t-1);


Measured memory_bytes: 10744
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  int d, D[10] = {};

  for (int i = 0; i < k; i++) {
    cin >> d;
    D[d] = 1;
  }

  while (1) {
    int tmp = n, judge = 1;
    while (tmp) {
      if (D[tmp % 10]) judge = 0;
      tmp /= 10;
    }
    if (judge) {
      cout << n << endl;
      break;
    }
    n++;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(long long i=(a);i<(b);++i)
#define per(i,a,b) for(long long i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  string s1 = "ABC";
  string s2 = "abc";
  ll n,k;
  cin>>n>>k;
  k--;
  string s;
  cin>>s;
  rep(i,0,s.sz){
    if(i==k){
      rep(j,0,s1.sz){
        if(s[i]==s1[j]){
          cout << s2[j];
        }
      }
    }
    else{
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0278
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = RInt();
            for (int i = 0; i < n; i++)
            {
                int[] vs = RArInt();
                int normalPrice = vs[2] * vs[0] + vs[3] * vs[1];
                if (vs[2] >= 5 && vs[3] >= 2)
                {
                    Console.WriteLine(normalPrice * 4 / 5);
                }
                else
                {
                    int bulkBuyingPrice = (Math.Max(5, vs[2]) * vs[0] + Math.Max(2, vs[3]) * vs[1]) * 4 / 5;
                    Console.WriteLine(Math.Min(normalPrice, bulkBuyingPrice));
                }
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 17904
L = int(input())

print(L.bit_length(), 2*(L.bit_length()-1) + (bin(L)[3:]).count('1'))
for i in range(L.bit_length()-1,0,-1):
    print(i,i+1,0)
    print(i,i+1,1<<(i-1))
    if (L >> i-1) & 1:
        print(i,L.bit_length(),L>>i<<i)


Measured memory_bytes: 3060
// Tazoe

#include <iostream>
using namespace std;

void conv(int n, int p)
{
	if(p==0)
		return;

	conv(n/2, p-1);

	if(p==9){
		cout << '.';
	}
	cout << n%2;
}

int main()
{
	while(true){
		double n;
		cin >> n;

		if(n<0.0)
			break;

		int n16 = (int)(n*16.0);
		if(n*16.0!=(double)n16||n16>=4096){
			cout << "NA" << '\n';
			continue;
		}

		conv(n16, 12);
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

bool ok = true;

void dfs(ll i, vector<vector<pll>>& g, vl& dist) {
  for (auto& x : g[i]) {
    ll v = x.first;
    ll d = x.second;
    if (dist[v] == INF) {
      dist[v] = dist[i] + d;
      dfs(v, g, dist);
    } else {
      if (dist[v] != dist[i] + d) {
        ok = false;
      }
    }
  }
}

int main() {
  //
  ll n, m;
  cin >> n >> m;
  vector<vector<pll>> g(n);
  vl dist(n, INF);
  rep(i, m) {
    ll l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    g[l].push_back({r, d});
    g[r].push_back({l, -d});
  }
  rep(i, n) {
    if (dist[i] == INF) {
      dist[i] = 0;
      dfs(i, g, dist);
    }
  }
  // rep(i, n) cout << dist[i] << " ";
  // cout << endl;
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 16512
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n, k; cin >> n >> k;
    int v[n]; rep(i, n) cin >> v[i];
    int ans = 0;
    rep(l, n+1)rep(r, n+1)if(l+r <= n && l+r <= k){
        int sum = 0;
        vector<int> u;
        rep(i, l) sum += v[i], u.push_back(v[i]);
        For(i, n-r, n) sum += v[i], u.push_back(v[i]);
        sort(u.begin(), u.end());
        rep(i, min((int)(u.size()), k-l-r))if(u[i] < 0) sum -= u[i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
a, b, c, d = (int(x) for x in input().split())
c_num = b//c - (a - 1)//c
d_num = b//d - (a - 1)//d

big = max(c, d)
small = min(c, d)

while big % small != 0:
    tmp = small
    small = big % small
    big = tmp

x = c * d // small

x_num = b // x - (a - 1) // x

print(int(b - a + 1 - (c_num + d_num - x_num)))

Measured memory_bytes: 3064
L,R = map(int,input().split())
amr =[]
if R-L > 2019:
  amari = sorted([i%2019 for i in range(L,L+2019)])
  if 0 in amari:
    print(0)
  else:
    for i,j in enumerate(amari):
      for k in amari[i+1::]:
        amr.append(j*k%2019)
    print(min(amr))
else:
  amari = sorted([i%2019 for i in range(L,R+1)])
  if 0 in amari:
    print(0)
  else:
    for i,j in enumerate(amari):
      for k in amari[i+1::]:
        amr.append(j*k%2019)
    print(min(amr))

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

void solve(istream& in, ostream& out)
{
    int n;
    in >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        in >> a[i];
    }
    ll even = 0, odd = 0;
    bool neg = true;
    for (int i = 0; i < n; i++)
    {
        if (a[i] > 0)
        {
            if (i % 2 == 0)
                even += a[i];
            else
                odd += a[i];
            neg = false;
        }
    }
    if (neg)
    {
        int mx = max_element(ALL(a)) - a.begin();
        vi ans;
        while (n - 1 > mx)
        {
            ans.PB(n - 1);
            n--;
        }
        for (int i = 0; i < mx; i++)
        {
            ans.PB(0);
        }
        out << a[mx] << "\n";
        out << SZ(ans) << "\n";
        for (auto x : ans)
        {
            out << x + 1 << "\n";
        }
        return;
    }
    vi ans;
    if (odd > even)
    {
        ans.PB(0);
        a.erase(a.begin());
        n--;
    }
    int pos = -1;
    for (int i = 0; i < n; i += 2)
    {
        if (a[i] > 0)
            pos = i;
    }
    while (n - 1 > pos)
    {
        ans.PB(n - 1);
        n--;
    }
    while (pos >= 2)
    {
        if (a[pos - 2] > 0)
        {
            ans.PB(pos - 1);
        }
        else
        {
            if (pos == 2)
                break;
            ans.PB(pos - 2);
        }
        pos -= 2;
    }
    for (int i = 0; i < pos; i++)
    {
        ans.PB(0);
    }
    out << max(odd, even) << "\n";
    out << SZ(ans) << "\n";
    for (auto x : ans)
    {
        out << x + 1 << "\n";
    }    
}

void check(istream& in, istream& out)
{
    int n;
    in >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        in >> a[i];
    }
    ll ans;
    out >> ans;
    int m;
    out >> m;
    for (int i = 0; i < m; i++)
    {
        int x;
        out >> x;
        x--;
        assert(0 <= x);
        assert(x < SZ(a));
        if (x == 0)
            a.erase(a.begin());
        else if (x == SZ(a) - 1)
            a.pop_back();
        else
        {
            a[x] = a[x - 1] + a[x + 1];
            a.erase(a.begin() + x + 1);
            a.erase(a.begin() + x - 1);
        }
    }
    assert(SZ(a) == 1);
    assert(ans == a[0]);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve(cin, cout);
    return 0;
}

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

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

int main(){
    string S, T;
    cin >> S >> T;
    int N = (int)S.size();
    int len = (int)T.size();

    int mn = 10000;
    for(int i = 0; i <= (N-len); i++){
        int num = 0;
        string s = S.substr(i, len);
        rep(j, len){
            if(s[j] != T[j]) num++;
        }
        mn = min(mn, num);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 3624
n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    if (n-k+1 >= i):
        print(comb(k-1, i-1) % divnum * comb(n-k+1, i) % divnum)
    else:
        print(0)


Measured memory_bytes: 341620
#include <bits/stdc++.h>
using namespace std;
#define N 10010
bitset<N>f[N];
struct node {
    int i, j;
}Q[2][N];
#define S 100000
char bf[S],*p1=bf,*p2=bf;
#define nc() (p1==p2&&(p2=(p1=bf)+fread(bf,1,S,stdin),p2==p1)?-1:*p1++)
inline int read() {
    int x = 0;
    char ch = nc();
    for (; ch < '0' || ch > '9'; ch = nc());
    for (; ch <= '9' && ch >= '0'; x = x * 10 + ch - 48, ch = nc());
    return x;
}
inline void Read(char*s) {
    char ch = nc();
    for (; ch == ' ' || ch == '\n'; ch = nc());
    for (; ch != ' ' && ch != '\n'; ch = nc())*s++ = ch;
    *s = 0;
}
char s[N/5][N];
string ans;char mn,mk;
int i,o,j,ct1,ct,k,m,n,x,y,id,K,len[N/5];
int main() {
    n = read(), K = read();
    for (i = 1; i <= n; ++i) {
        Read(s[i]);
        len[i] = strlen(s[i]);
    }
    for (f[n + 1][0] = 1, i = n; i >= 1; --i)f[i] = f[i + 1] | (f[i + 1] << len[i]);
    for (mn = 'z', i = 1; i <= n; ++i)if (f[i + 1][K - len[i]])Q[0][++ct] = (node) {i, 0}, mn = min(mn, s[i][0]);
    for (o = i = 0; i < K; ++i) {
        id = n + 1, ans += mn, mk = 'z', ct1 = 0;
        for (k = 1, j = ct; k <= j; ++k) {
            x = Q[o][k].i, y = Q[o][k].j;
            if (s[x][y] != mn)continue;
            if (y + 1 == len[x])id = min(id, x);
            else Q[o ^ 1][++ct1] = (node) {x, y + 1}, mk = min(s[x][y + 1], mk);
        }
        for (j = id + 1; j <= n; ++j)
            if (K - len[j] - i - 1 >= 0 && f[j + 1][K - len[j] - i - 1])
                Q[o ^ 1][++ct1] = (node) {j, 0}, mk = min(mk, s[j][0]);
        mn = mk, ct = ct1,o^=1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 21760
#include<iostream>
using namespace std;
int main(){
    long long int K,A,B;
    int i;
    cin >> K;
    cin >> A;
    cin >> B;
    if(A >= B -1 ) {
        cout << K+1 <<"\n";
        return 0;
    }
    long long int  Bis = 1;
    int En = 0;
    for(i = 0;i<K;i++){
        if(En >= 1 ) {
            Bis += B;
            En -= 1;
        }
        else if((Bis < A && En == 0) || (i == K-1 && En == 0)){
           Bis++;
        }
        else if(Bis >= A){
            Bis = Bis - A;
            En += 1;
        }
    }
    cout << Bis << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N = 55;
int f[N];
int getf(int x)
{
	return f[x] == x ? x : f[x] = getf(f[x]);
}
pair<int, int> e[N];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> e[i].first >> e[i].second;
	int ans = 0;
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
			f[j] = j;
		for (int j = 1; j <= m; j++)
			if (j != i)
				f[getf(e[j].first)] = getf(e[j].second);
		for (int j = 2; j <= n; j++)
			if (getf(j) != getf(1))
			{
				ans++;
				break;
			}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int[] a = new int[n];
	  int[] b = new int[n];
	  int[] c = new int[n-1];
	  for(int i=0;i<n;i++){
	  	a[i]=sc.nextInt();
	  }
	  for(int i=0;i<n;i++){
	  	b[i]=sc.nextInt();
	  }
	  for(int i=0;i<n-1;i++){
	  	c[i]=sc.nextInt();
	  }
	  
	  int sat=b[a[0]-1];
	  for(int i = 1;i<n;i++){
	  	sat+=b[a[i]-1];
	  	if(a[i-1]+1==a[i])sat+=c[a[i]-2];
	  }
	  System.out.println(sat);
    }
}

Measured memory_bytes: 22740
#include <cstdio>
int a[100010], n, i, cnt;
int main(){
	for(scanf("%d", &n); i<n; i++){
		scanf("%d", a+i);
		if(a[i]%2==1)	cnt++;
	}
	puts((cnt%2==1)?"NO":"YES");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[401200];
ll invfact[401200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


int main(){
    ll n, k;    cin >> n >> k;
    make_fact(401000);
    make_invfact(401000);

    if(n <= k){
        cout << comb(2*n-1, n) << endl;
    }
    else{
        ll res = 0;
        for(ll i = n-k; i <= n; i++){
            res = add(res, mul(comb(n, i), comb(n-1, i-1)));
        }
        cout << res << endl;
    }


    return 0;
}


Measured memory_bytes: 6656
n = int(input().rstrip())
t_list = input().rstrip().split()
t_list = [int(x) for x in t_list]
m = int(input().rstrip())

tmp_list = t_list

for i in range(m):
    line = input().rstrip().split()
    line = [int(x) for x in line]
    before = tmp_list[line[0]-1]
    val = line[1]

    tmp_list[line[0]-1] = val

    print(sum(tmp_list))

    tmp_list[line[0]-1] = before

Measured memory_bytes: 3192
def main():
    N,X,Y=map(int,input().split())

    res=[0 for i in range(N-1)]

    for i in range(1,N):
        for j in range(i+1,N+1):
            if i==j:
                continue
            if (i<=X and j>=Y):
                route=j-i-(Y-X)+1
            else:
                route=min(j-i,abs(X-i)+abs(Y-j)+1)

            res[route-1]+=1

    for r in res:
        print(r)


if __name__=="__main__":
    main()


Measured memory_bytes: 74340
#include <bits/stdc++.h>
using namespace std;
int n, i, R[200005], W[200005], ans = numeric_limits<int>::max();
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> s;
    for (i = 1; i <= n; ++i)
    {
        R[i] = R[i - 1] + (s[i - 1] == 'R' ? 1 : 0);
        W[i] = W[i - 1] + (s[i - 1] == 'W' ? 1 : 0);
    }
    for (i = n + 1; i > 0; --i)
        ans = min(ans, max(R[n] - R[i - 1], W[i - 1]));
    cout << ans;
}

Measured memory_bytes: 5328
import java.util.Scanner

fun main(args: Array<String>){
  val cin = Scanner(System.`in`)
  val a = cin.next()
  val b = cin.next()

  val m = a.length
  val n = b.length
  if (m < n){
    println("LESS")
  }
  else if (n < m){
    println("GREATER")
  }
  else {
    var f = true
    for (i in 0..m - 1){
      if (a[i] < b[i]){
        println("LESS")
        f = false
        break
      }
      else if (b[i] < a[i]){
        println("GREATER")
        f = false
        break
      }
    }
    if (f){
      println("EQUAL")
    }
  }
  cin.close()
}

Measured memory_bytes: 21552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c,d;cin>>a>>b>>c>>d;
    int flag=1;
    while(a>0&&c>0){
        if(flag){
            c-=b;
        }else a-=d;
        if(a>0&&c>0);else break;
        flag=!flag;
    }
    cout<<(flag?"Yes":"No")<<endl;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	vector<ll> vls({1, 0, -1}), qnt(3);
	ll ans = 0, k;
	for(int i = 0; i < 3; i++) cin >> qnt[i];
	cin >> k;

	//debug(vls, qnt);
	for(int i = 0; i < 3; i++) {
		auto cnd = min(qnt[i], k);
		k -= cnd;
		ans += cnd * vls[i];
	}
	cout << ans << '\n';
}



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

long N;

int main(void) {

    cin >> N;
    N %= 10;

    if ( N == 3 ) {
        cout << "bon" << endl;
    }
    else if ( N  == 0 || N == 1 || N == 6 || N == 8 ) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }


    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"


int main(){
    int n,t;
    cin >> n;
    int a[n];
    REP(i,n){
        cin >> t;
        a[i]=t-i-1;
    }
    sort(a,a+n);
    ll mid = a[n/2];
    ll ans =0;
    REP(i,n)ans+=abs(a[i]-mid);
    COUT(ans);
    return 0;
}

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

ll m,ansmax,a[200009];

int n;

bool check(int pos)
{
    int i,j;
    ll ans=0LL;
    for(i=pos,j=n*2-1;i<j;i++,j--)
    {
        if(a[i]+a[j]<m) return false;
        ans=max(ans,a[i]+a[j]-m);
    }
    for(i=0,j=pos-1;i<j;i++,j--)
        ans=max(ans,a[i]+a[j]);
    ansmax=min(ans,ansmax);
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int i,j,lo,hi,mid;
    cin >> n >> m;
    for(i=0;i<2*n;i++)
        cin >> a[i];
    sort(a,a+2*n);

    lo=0;
    hi=n;
    ansmax=inf;
    while(lo<hi)
    {
        mid=(lo+hi)/2;
        if(check(mid*2))
            hi=mid;
        else lo=mid+1;

    }
    check(lo*2);
    check(hi*2);
    cout << ansmax << endl;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    string s;
    in(s);
    if (s == "Sunny")
    {
        out("Cloudy");
    }
    if (s == "Cloudy")
        out("Rainy");
    if (s == "Rainy")
        out("Sunny");
}

Measured memory_bytes: 256
from itertools import groupby
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
d = {"r": P, "s": R, "p": S}
print(sum(sum(map(lambda p: d[p[0]]*((len(list(p[1]))+1)//2), groupby(T[k::K]))) for k in range(K)))

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

#define fir first
#define sec second
#define mp make_pair
#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

using namespace std;

inline void File() {
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
}

typedef pair<int, int> PII;

const int N = 2e3 + 10, M = 1e4 + 10, inf = 0x3f3f3f3f;
bitset<M> c[N]; PII a[2][N];
int n, k, len[N]; char s[N][M], ans[M];

int main() {
//	File();
	
	cin >> n >> k;
	For(i, 1, n) scanf("%s", s[i]), len[i] = strlen(s[i]);

	c[n + 1][0] = 1;
	Forr(i, n, 1) c[i] = c[i + 1] | (c[i + 1] << len[i]);

	int cnt = 0, tcnt = 0, t = 0;

	For(i, 1, n) if (c[i + 1][k - len[i]]) a[t][++ cnt] = mp(i, 0);

	for (int i = 0, mn; i < k; ++ i, cnt = tcnt, t ^= 1) {

		char mnc = 'z';
		For(j, 1, cnt) mnc = min(mnc, s[a[t][j].fir][a[t][j].sec]);
		ans[i] = mnc;	
				
		tcnt = 0, mn = inf;

		For(j, 1, cnt) {
			int ni = a[t][j].fir, ps = a[t][j].sec;
			if (s[ni][ps] != mnc) continue;
			if (ps == len[ni] - 1) mn = min(mn, ni);
			else a[t ^ 1][++ tcnt] = mp(ni, ps + 1);
		}

		if (mn ^ inf) For(j, mn + 1, n)
			if (k - len[j] - i - 1 >= 0 && c[j + 1][k - len[j] - i - 1]) a[t ^ 1][++ tcnt] = mp(j, 0);
	}

	For(i, 0, k - 1) putchar(ans[i]);

	return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,count=0,an1=0,an2=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		int j=i;
		while(j%2==0){
			j/=2;
			count++;
		}
		if(an1<count){an1=count;an2=i;}
		count=0;
	}
	if(n==1){cout<<"1"<<endl;return 0;}
	cout<<an2<<endl;
	return 0;
}


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

using namespace std;

int main() {
    int M, N;
    cin >> N >> M;
    vector<int> A(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    int total = 0;
    for (int i = 0; i < N; ++i) {
        total += A[i];
    }
    double threshold = 0.25 * total / M;

    sort(A.begin(), A.end(), greater<int>());
    bool ans = true;
    for (int i = 0; i < M; ++i) {
        if (A[i] < threshold) {
            ans = false;
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)
for j in range(N - 1):
    C[j], S[j], F[j] = map(int, input().split())
for i in range(N - 1):
    nowtime = [0] * N
    nowtime[i + 1] = S[i] + C[i]
    for h in range(i + 1, N-1):
        if nowtime[h] <= S[h]:
            nowtime[h + 1] = S[h] + C[h]

        else:
            if nowtime[h] % F[h] == 0:
                nowtime[h + 1] = nowtime[h] + C[h]
            else:
                nowtime[h+1] = nowtime[h]+F[h]-(nowtime[h] % F[h])+C[h]
    print(nowtime[N - 1])

print(0)


Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <assert.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N,A,B;
    cin >> N >> A >> B;

    int min_v = -1, max_v = -1;
    if (N < A + B) {
        min_v = A + B - N;
    } else {
        min_v = 0;
    }

    max_v = min(A, B);

    cout << max_v << " " << min_v << endl;

    return 0;
}


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

using namespace std;

int main (void) {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> p.at(i);
    }

    sort(p.begin(), p.end());

    int ans = 0;
    for ( int i = 0; i < K; i++ ) {
        ans += p.at(i);
    }

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


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  vi hamming(1000001,0);
  loop(i,1,1000001){
    int t=i;
    while(t%2==0)t/=2;
    while(t%3==0)t/=3;
    while(t%5==0)t/=5;
    if(t==1)hamming[i]++;
  }
  rep(i,1000000)
    hamming[i+1]+=hamming[i];
 
  while(1){
    int n,m;
    cin>>n;
    if(n==0)break;
    cin>>m;
    cout<<hamming[m]-hamming[n-1]<<endl;
  }
}

Measured memory_bytes: 6600
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	int N, M, j=1, k=1;
	cin >> N >> M;

	vector<int> s(M);
	vector<int> c(M);

	rep(i,M) cin >> s[i] >> c[i];

	if(N == 1) j=0;
	rep(i,N-1) j*=10;
	rep(i,N) k*=10;

	for(int q=j; q<k; q++){
		bool ans = true;
		string ss = to_string(q);
		for(int p=0; p<M; p++){
			if(ss[s[p] - 1]-'0' != c[p]) ans = false;
		}
		if(ans){
			cout << q << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
}

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

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

  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int a;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int s = c;
    for (int j = 0; j < m; j++) {
      cin >> a;
      s += a * b[j];
    }
    cnt += s > 0;
  }
  cout << cnt << '\n';
  return 0;
}

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

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

    string s = "ACL";
    rep(i,k) cout << s;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int n,m,x,p[30];
vector<int> g[30];
main(){
cin>>n>>m>>x;
for(int k=1;k<=n;k++){
    cin>>p[k];
    for(int i=1;i<=m;i++){
        int b;
        cin>>b;
        g[k].push_back(b);
    }
}
int N=1<<n;
int ans=INT_MAX;
for(int k=1;k<N;k++){
   bitset<14> b;
   b=k;
   int sum=0,cnt=0;
   vector<int> v(m+1,0);
   for(int i=0;i<n;i++){
    if(b[i]==1){
        for(int j=0;j<g[i+1].size();j++){
                if(v[j]<x && v[j]+g[i+1][j]>=x)
                cnt++;
            v[j]+=g[i+1][j];
        }
        sum+=p[i+1];
    }
   }
   if(cnt==m)
    ans=min(ans,sum);
}
if(ans==INT_MAX)
    cout<<-1;
else
cout<<ans;
return 0;
}


Measured memory_bytes: 3644
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

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; }

LL L, R;

int main() {
    cin >> L >> R;
    LL tmp, ans = 2019;
    for (LL i = L; i <= R; i++) {
        for (LL j = i + 1; j <= R; j++) {
            tmp = (i * j) % 2019;
            if (tmp < ans) {
                ans = tmp;
            }
            if (!ans) {
                break;
            }
        }
        if (!ans) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
考虑一个很显然的O(nlogn)的做法
首先对所有线段按照右端点排序，然后按照右端点切

由于所有线段的值域为1 - n，我们可以对所有左端点，直接记录出右端点为位置
再扫一遍即可 
*/
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 1e6 + 10;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, M;
int r[MAXN];
int main() {
	N = read(); M = read();
	for(int i = 1; i <= N; i++) r[i] = N + 1;
	for(int i = 1; i <= M; i++) {
		int x = read(), y = read();
		r[x] = min(y, r[x]);
	}
	int cur = N + 1, ans = 0;
	for(int i = 1; i <= N; i++) {
		if(r[i] != N + 1) 
			cur = min(cur, r[i]);
		if(i == cur) cur = min(N + 1, r[i]), ans++;
	}
	printf("%d", ans);
    return 0;
}
/*

*/

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
)

const Inf = 1 << 60

func main() {
	N, K := ReadInt(), ReadInt()
	P := ReadInts(N)
	C := ReadInts(N)

	for i := 0; i < N; i++ {
		P[i]--
	}

	maxScore := -Inf
	for i := 0; i < N; i++ {
		seen := make([]bool, N)
		var dfs func(v int) (int, int)
		dfs = func(v int) (int, int) {
			if seen[v] {
				return 0, 0
			}
			seen[v] = true
			size, score := dfs(P[v])
			return size + 1, C[v] + score
		}
		size, loopScore := dfs(i)

		score := 0
		rest := 0
		if loopScore > 0 {
			loop := K/size - 1
			score += loop * loopScore
			rest = K - loop*size
			if score > maxScore {
				maxScore = score
			}
		} else {
			rest = size
		}
		v := i
		for j := 0; j < rest; j++ {
			v = P[v]
			score += C[v]
			if score > maxScore {
				maxScore = score
			}
		}
	}

	fmt.Println(maxScore)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 7016
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>> e(M);
	for (int i = 0; i < M; i++)
		cin >> e[i].first >> e[i].second;

	int ans = 0;
	for (int i = 0; i < M; i++) {
		vector<vector<int>> edges(N + 1);
		vector<bool> vi(N + 1);
		for (int j = 0; j < M; j++) {
			if (j == i) continue;
			int a = e[j].first, b = e[j].second;
			edges[a].push_back(b);
			edges[b].push_back(a);
		}
		stack<int> st;
		st.push(1);
		vi[1] = true;
		int cnt = 0;
		while (!st.empty()) {
			cnt++;
			int x = st.top();
			st.pop();
			for (auto to : edges[x]) {
				if (vi[to])continue;
				vi[to] = true;
				st.push(to);
			}
		}
		if (cnt != N) ans++;
		//cout << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
package main

import(
  "bufio"
  "fmt"
  "os"
  "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main(){
  s := nextInt()
  s = s % 10
  switch s {
    case 2,4,5,7,9:
    fmt.Println("hon")
  	case 0,1,6,8:
    fmt.Println("pon")
    case 3:
    fmt.Println("bon")  
  }
  
}

Measured memory_bytes: 1756
"use strict";

const main = arg => {
  const input = arg.trim().split("\n")[0];
  let c = 0;
  for (let i = 0; i < 4; i++) {
    if (input.substring(i,  i +1 ) === "2") {
      c ++;
    }
  }
  console.log(c);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll T, ll A, vector<ll> H) {
  cout << min_element(ALL(H),
                      [&](int a, int b) {
                        return fabs(T - a * 0.006 - A) <
                               fabs(T - b * 0.006 - A);
                      }) -
              begin(H) + 1
       << endl;
}

int main() {
  ll N;
  cin >> N;
  ll T;
  cin >> T;
  ll A;
  cin >> A;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  solve(N, T, A, move(H));
  return 0;
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(0LL, min(b, d) - max(a, c)) << endl;
  return 0;
}


Measured memory_bytes: 3572
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 507;
int cnt[3][33];
int D[33][33];

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n,c; cin >> n >> c;
    FOR(i,1,c) {
        FOR(j,1,c) {
            cin >> D[i][j];
        }
    } 
    FOR(i,1,n) {
        FOR(j,1,n) {
            int color; cin >> color;
            cnt[(i+j)%3][color]++;
        }
    }
    int ans = INF;
    FOR(i,1,c) {
        FOR(j,1,c) {
            FOR(k,1,c) {
                if(i==j or j==k or k==i) continue;
                int cur = 0;
                FOR(l, 1, c) {
                    if(l==i) continue;
                    cur += D[l][i]*cnt[0][l];
                }
                FOR(l, 1, c) {
                    if(l==j) continue;
                    cur += D[l][j]*cnt[1][l];
                }
                FOR(l, 1, c) {
                    if(l==k) continue;
                    cur += D[l][k]*cnt[2][l];
                }
                chmin(ans, cur);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

char h1[10000];
char h2[10000];

int main(){
    scanf("%s",h1);
    scanf("%s",h2);
    int len1 = strlen(h1);
    int len2 = strlen(h2);
    for(int i = 0;i < len1;i++){
        printf("%c",h1[i]);
        if(i < len2){
            printf("%c",h2[i]);
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        if (N == 1)
        {
            Console.WriteLine("Hello World");
            return;
        }
        int A = intRead();
        int B = intRead();
        Console.WriteLine(A+B);
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


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

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    ll X;
    cin>>X;
    ll happiness=0;
    ll t=X/500;
    happiness+=t*1000;
    X-=500*t;
    t=X/5;
    happiness+=5*t;
    cout<<happiness<<endl;
    return 0;
}




Measured memory_bytes: 256
# 入力
S = str(input())
T = 'ATCG'

ans = 0
now = 0

for i in range(len(S)):
    isATCG = False
    for j in range(len(T)):
        if S[i] == T[j]:  # 対象の文字列がATCGのいずれかであるかどうか判定
            isATCG = True
    # 対象の文字列がATCGであればisATCGの値はTrueになっている
    if not isATCG:
        # 違う場合はnowを0にする
        now = 0
    else:
        # ATCGの場合はnowをインクリメント
        now += 1
        ans = max(now, ans)  # 最大値を更新する

print(ans)


Measured memory_bytes: 3060