akhauriyash/Code-Regression huggingface dataset:
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#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 max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll m = 1e9 + 7;
ll a[21][21];
ll dp[1<<21];
ll n;

ll go(ll mask)
{
	if((mask + 1) == (1<<n))
		return 1;
	if(mask > (1<<n))
		return 0;

	ll &ans = dp[mask];
	if(ans != -1)
		return ans;
	ans = 0;

	ll set_bit_cnt = __builtin_popcountll(mask);
	for(ll i = 0; i<n ; ++i)
	{
		if(!(mask & (1<<i)))
		{
			if(a[set_bit_cnt][i])
				ans += go(mask | (1<<i));
			ans %=m ;
		}
	}


	return ans;
}


signed main()
{

	fast;
	memset(dp , -1, sizeof dp);
////////////////////////////////////////////////////////////////////////////////////////////

	cin >> n;

	rep(i,0,n)
		rep(j,0,n)
			cin >> a[i][j];
	cout<<go(0)<<endl;



////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 16640
// AOJ 0349: Cyclic Sugoroku
// 2017.10.26 bal4u@uu
// 2017.11.14

#include <stdio.h>

int q[100002], top, end;
int a[100002], f[100002];

char buf[1100005], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, t, ans;

//	scanf("%d", &n);
	fgets(p=buf, 10, stdin), n = getint();

	fgets(p=buf, sizeof(buf), stdin);
	for (i = 0; i < n; i++) {
		t = i + getint(), p++;
		if (t >= n) t %= n;
		a[i] = t, f[t]++;
	}
	ans = 0, top = end = 0;
	for (i = 0; i < n; i++) if (!f[i]) q[end++] = i;
	while (top < end) {
		ans++;
		t = a[q[top++]];
		if (!--f[t]) q[end++] = t;
	}
	printf("%d\n", n - ans);
	return 0;
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int G[1500][1500];
int dp[1522][1500];
int main(){
	int H,W;
	cin>>H>>W;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			cin>>G[i][j];
	int max1=0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++){
			dp[i][j]=(G[i][j]+1)%2;
			max1|=dp[i][j];
		}
	for(int i=1;i<H;i++){
		for(int j=1;j<W;j++){
			if(G[i][j])	 dp[i][j]=0;
			else{
				dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
				max1=max(max1,dp[i][j]);
			}
		}
	}
	cout<<max1*max1<<endl;
}


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

int main(){
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if(s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
package main
import (
  "fmt"
)
func main() {
  var n int
  fmt.Scan(&n)
  result := "No"
  for i := 0; i <= 25; i++ {
    isSolved := false
    for j := 0; j <= 14; j++ {
      sum := 4*i + 7*j
      if sum == n {
        result = "Yes"
        isSolved = true
        break
      }
    }
    if isSolved {
      break
    }
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};

function main(input) {
  const o = new I(input);

  const A = o.a();
  const B = o.a();
  const C = o.a();

  if ( A === B && B === C ) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}


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


Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long  
const long long MOD = 1000000007LL;
int main(){
    int n,m;
    cin >> n >> m;
    map<int,set<int>> bridge;
    int a[m],b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
        bridge[b[i]].insert(a[i]);
    }
    int tem = 1;
    int ans = 0;
    rep(i,n){
        if(bridge[i+1].size() != 0){
            auto itr = bridge[i+1].end();
            itr--;
            if(*itr>=tem){
                ans++;
                tem = i+1;
            }
        }
    }
    cout << ans << endl;
}

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

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> even_sm(n, 0), odd_sm(n, 0);
    
    ll sm = 0;
    rep(i, n){
        cin >> a[i];
        sm += a[i];
        if(i == 0) even_sm[i] = a[i];
        if(i > 0){
            even_sm[i] = even_sm[i-1];
            odd_sm[i] = odd_sm[i-1];

            if(i%2 == 0) even_sm[i] += a[i];
            else odd_sm[i] += a[i];
        }
    }

    vector<int> res(n);
    rep(i, n){
        if(i%2 == 0){
            ll sub = odd_sm[n-2] - odd_sm[i];
            if(i!=0) sub += even_sm[i-2];

            res[i] = sm - sub*2;
        }
        else{
            ll sub = even_sm[n-1] - even_sm[i];
            if(i!=1) sub += odd_sm[i-2];

            res[i] = sm - sub*2;
        }
    }

    rep(i, n) cout << res[i] << " ";
    cout << endl;

    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int ans = MOD;
    for (int i = 0; i <= n - k; i++)
    {
        ans = min(ans, x[i + k - 1] - x[i] + abs(x[i]));
        ans = min(ans, x[i + k - 1] - x[i] + abs(x[i + k - 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

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

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

type task struct {
	a int
	b int
}

type tasks []task

func (b tasks) Len() int           { return len(b) }
func (b tasks) Less(i, j int) bool { return b[i].b < b[j].b }
func (b tasks) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	t := make([]task, n)

	for i := range t {
		t[i].a = nextInt()
		t[i].b = nextInt()
	}
	sort.Sort(sort.Reverse(tasks(t)))

	d := t[0].b

	for i := range t {
		if d > t[i].b {
			d = t[i].b
		}
		d -= t[i].a
		debugf("i: %d, a: %d, d: %d\n", i, t[i].a, d)
		if d < 0 {
			break
		}
	}

	if d >= 0 {
		_, _ = fmt.Fprint(writer, "Yes")
	} else {
		_, _ = fmt.Fprint(writer, "No")
	}
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 8192
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var x = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			var sx = x.OrderBy(y => y).ToArray();

			long ml = sx[n / 2 - 1];
			long mr = sx[n / 2];

			var sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				if (x[i] < mr) {
					sb.AppendLine(mr.ToString());
				} else {
					sb.AppendLine(ml.ToString());
				}
			}

			Console.WriteLine(sb.ToString());
		}
	}
}

Measured memory_bytes: 49616
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
struct custom {
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=(y>>1);
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b,n,x,y,c;
    cin>>a>>b>>n;
    if(n<b)x=n;
    else
        x=b-1;
    c=a*x;
    c=c/b;
    cout<<c<<endl;
}


Measured memory_bytes: 3656
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if a[i] + a[i + 1] > x:
        ans += a[i + 1] + a[i] - x
        a[i + 1] = x - a[i]
        if a[i + 1] < 0:
            a[i + 1] = 0
print(ans)

Measured memory_bytes: 14252
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#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=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,ans;
  double a[105]={},cnt=0,x=1e9;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    cnt+=a[i];
  }
  cnt/=n;
  for(int i=0; i<n; i++) {
    if(abs(cnt-a[i])<x) {
      ans=i;
      x=abs(cnt-a[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	
using namespace std;
 
#define int long long
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)
 
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX/2;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int32_t main() {
	FAST_IO;
	
	int n;
	cin >> n;
	vi a(n);
	for (int& x: a) cin >> x;
	map<int, int> cnt;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cnt[a[i]]++;
		ans += a[i];
	}
	int q;
	cin >> q;
	while (q-->0) {
		int b, c;
		cin >> b >> c;
		cnt[c] += cnt[b];
		ans += cnt[b]*(c - b);
		cnt[b] = 0;
		cout << ans << endl;
	}
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 10056
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int n, v, A[100001] = { 0 }, B[100001] = { 0 };
	cin >> n;


	REP(i, n) {
		cin >> v;
		if (i % 2 == 0) {
			A[v]++;
		}
		else {
			B[v]++;
		}
	}

	int Af = 0, As = 0, Bf = 0, Bs = 0;
	int a, b, c, d;
	REP(i, 100001) {
		if (A[i] >= Af) {
			As = Af;
			Af = A[i];
			b = a;
			a = i;
		}
		else if (A[i] > As) {
			As = A[i];
		}
		if (B[i] >= Bf) {
			Bs = Bf;
			Bf = B[i];
			d = c;
			c = i;
		}
		else if (B[i] > Bs) {
			Bs = B[i];
		}
	}

	if (a != c) {
		cout << n - Af - Bf << endl;
	}
	else {
		cout << n - max(Af + Bs, As + Bf) << endl;
	}


	return 0;
}

Measured memory_bytes: 1024
///https://agc020.contest.atcoder.jp/tasks/agc020_c?lang=en
///http://petr-mitrichev.blogspot.com/2018/01/
#include<bits/stdc++.h>
#define i64 long long
#define inf 1000000000000000000
using namespace std;

int ara[2001];
bitset<2001*2001>bset;//[2];
int main()
{
    int n;
    scanf("%d",&n);

    int sum=0,mx=0;
    for(int i=1; i<=n; i++)
        scanf("%d",&ara[i]);


    sort(ara+1,ara+n+1);

    for(int i=1; i<=n; i++)
    {
        sum+=ara[i];
        mx=max(mx,ara[i]);
    }

    int avg=(sum+2-1)/2, last=mx*n;

    bset[0]=1;
    for(int i=1; i<=n; i++)
        bset= bset | (bset<<ara[i]);


    for(int i=avg; i<=last; i++)
    {
        if(bset[i]==1)
        {
            printf("%d\n",i);
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> v(N), P(N), Q(N);
  for (int i = 0; i < N; ++i) std::cin >> P[i];
  for (int i = 0; i < N; ++i) std::cin >> Q[i];
  for (int i = 0; i < N; ++i) v[i] = i + 1;

  int a = 0, b = 0;
  int n = 1;
  do {
    bool is_a = true, is_b = true;
    for (int i = 0; i < N; ++i) {
      if (P[i] != v[i]) is_a = false;
      if (Q[i] != v[i]) is_b = false;
    }
    if (is_a) a = n;
    if (is_b) b = n;
    ++n;
  } while(next_permutation(v.begin(), v.end()));

  std::cout << std::abs(a-b) << std::endl;
}


Measured memory_bytes: 256
#Coding:Utf-8

N=int(input())
s=[list(input()) for i in range(N)]
total=num=0
dic={}
for l in range(N):
    s[l].sort()
    if dic.get(str(s[l]))==None:
        dic[str(s[l])]=0
    else:
        dic[str(s[l])]+=1
        total+=int(dic[str(s[l])])
print(total)

Measured memory_bytes: 43244
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,i,j,a,max=0;
	scanf("%d%d",&n,&m);
	int b=n/m;
	int c=n%m;
	if(c!=0)b=b+1;
	printf("%d",b);

}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a <= b){
        cout << a << endl;
    } else {
        cout << a-1 << endl;
    }
    return 0;
}


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

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
double L[21],a[21],b[21];
int n,m;
double comp(int k) {
  vector <int> lab;
    for(int i=0;i<n;i++)
    if((k&(1<<i)) != 0) lab.push_back(i);

  double sum = 0;
  for(int i=0;i<lab.size();i++)
    for(int j=i+1;j<lab.size();j++) {
      double x = L[lab[i]] - L[lab[j]];
      double y = a[lab[i]] - a[lab[j]]; 
      double z = b[lab[i]] - b[lab[j]]; 
      double xyz = x*x + y*y + z*z;
      sum += xyz;
    }
  return sum;
}

int main() {
  cin >> n >> m;
  for(int i=0;i<n;i++) cin >> L[i] >> a[i] >> b[i];

  double ans = 0;
  for(int i=0;i<(1<<n);i++)
    if( __builtin_popcount(i) == m) ans = max(ans,comp(i));

  printf("%.15f\n",ans);

  return 0;
}

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

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

  int N;
  cin >> N;

  int ans = 0;
  for (int i = 1; i <= N; i++)
  {
    int tmp;
    cin >> tmp;
    if(i % 2 != 0 && tmp % 2 != 0) ans++;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3580
import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    List<BigInteger> A = new LinkedList<>();
    for (int i = 0; i < N; i++) A.add(BigInteger.valueOf(sc.nextInt()));
    sc.close();

    BigInteger lcm = A.stream().parallel()
      .reduce(BigInteger.ONE, (a, b) -> a.divide(a.gcd(b)).multiply(b));

    BigInteger ans = A.stream().parallel()
      .map(lcm::divide)
      .reduce(BigInteger::add)
      .get();

    BigInteger mod = BigInteger.valueOf(1000000007);
    System.out.println(ans.mod(mod));
  }
}


Measured memory_bytes: 195536
#include<bits/stdc++.h>
    #define ll long long
    #define f   first
    #define s   second
    #define pb          push_back
    #define mod         1000000007
    #define hell        998244353
    #define inf         1000000000000000000LL
    using namespace std;
    ll n,k,m,sum,q;
    ll s,l,r,x,y,h,w;
    //ll a[1005][1005];
    
    void solve()
    {   
        ll n1,n2,n3;
        cin>>n1>>n2>>n3>>k;
        ll ans=0;
        ans+=min(n1,k);
        k-=min(n1,k);
        //ans+=min(n2,k);
        k-=min(n2,k);
        ans-=min(n3,k);
        cout<<ans;
        
    }   
    int main()
    {   
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        //cout<<primes.size();
        ll t=1;
      //cin>>t;
        while(t--)
            solve();
    }


    


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=300005;

int n,a[N],pos[N];

void fff()
{
	puts("No");
	exit(0);
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]%2!=i%2) fff();
		pos[a[i]]=i;
	}
	pos[0]=pos[n+1]=-1;
	for (int i=1;i<=n;i++)
		if (pos[i-1]!=i-1&&pos[i]!=i&&pos[i+1]!=i+1) fff();
	int l=1;
	while (l<=n)
	{
		while (l<=n&&pos[l]==l) l++;
		if (l>n) break;
		int r=l;
		while (r+2<=n&&pos[r+2]!=r+2&&pos[r+1]==r+1) r+=2;
		for (int i=l;i<=r;i+=2) if (pos[i]<l||pos[i]>r) fff();
		int ls1=0,ls2=0;
		for (int i=l;i<=r;i+=2)
			if (pos[i]<i)
			{
				if (pos[i]<ls1) fff();
				ls1=pos[i];
			}
			else
			{
				if (pos[i]<ls2) fff();
				ls2=pos[i];
			}
		l=r+1;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 2560
#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 x;
    cin >> x;

    int a = x / 500;
    int b = x % 500;
    int c = b / 5;

    int ans = 1000*a + 5*c;

    cout << ans << endl;

    return 0;




}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,maxa;
int vis[100005];
void init()
{
	int sum=1;vis[1]=2;
	for(int i=2;i;i++)
	{
		if(sum+i>100000) break;
		sum+=i;vis[sum]=i+1;
		maxa=max(maxa,vis[sum]);
	}
}
vector<int> v[505];
int main()
{
	init();
	n=read();if(!vis[n]) return !puts("No");
	int m=1,now=0;
	while(now<n)
	{
		for(int i=1;i<=m;i++) v[i].push_back(i+now);
		for(int i=1;i<=m;i++) v[m+1].push_back(i+now);
		now+=m;m++;
	}
	puts("Yes");printf("%d\n",vis[n]);
	for(int i=1;i<=vis[n];i++)
	{
		printf("%d",v[i].size());
		for(int j=0;j<v[i].size();j++) printf(" %d",v[i][j]);puts("");
	}
	return 0;
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#ifdef DEBUG
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
#define DBG_cout cout
#else
#define DEBUG_PRINT(...)
#define DBG_cout
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

ll A, B, C, X, Y;

int main(){
  scanf("%lld %lld %lld %lld %lld", &A, &B, &C, &X, &Y);
  ll ans = 0;
  ll num = min(X, Y);
  ans+=min(A+B, C*2)*num;
  ll num2 = max(X, Y)-num;
  ll value = 0;
  if(num2 == X-num)value = A;
  else value = B;
  ans+=min(value*num2, C*2*num2);
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define WIDTH 12
#define HEIGHT 12

void deleteIsland( int, int );

int field[ WIDTH ][ HEIGHT ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int main( void ) {
	int x, y, island;

	do {
		for ( y = 0; y < HEIGHT; y++ ) {
			for ( x = 0; x < WIDTH; x++ )
				scanf( "%c", &field[ x ][ y ] );
			scanf( "%*c" );
		}

		island = 0;
		for ( x = 0; x < WIDTH; x++ )
			for ( y = 0; y < HEIGHT; y++ )
				if ( field[ x ][ y ] == '1' ) {
					deleteIsland( x, y );

					island++;
				}

		printf( "%d\n", island );
	} while ( scanf( "%*c" ) != EOF );

	return 0;
}

void deleteIsland( int x, int y ) {
	int i;

	field[ x ][ y ] = '0';

	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT && field[ nx ][ ny ] == '1' )
			deleteIsland( nx, ny );			
	}
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	string s[n];
	map<string, ll> mp;
	zep(i, 0, n){
		cin >> s[i];
		mp[s[i]] = 0;
	}
	
	ll mx = 0;
	zep(i, 0, n){
		mp[s[i]]++;
		mx = max(mp[s[i]], mx);
	}
	
	vector<string> ans;
	for(auto it = mp.begin(); it != mp.end(); it++){
		if((*it).second == mx){
			ans.push_back((*it).first);
		}
	}
	sort(ans.begin(), ans.end());
	zep(i, 0, ans.size()){
		print(ans[i])
	}
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  int a,b;cin>>a>>b;
  out(a*b);
}

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

using namespace std;

int main(){
  int N;
  
  cin>>N;
  
  vector<int> mochi(N);
  
  for(int i=0;i<N;i++){
    cin>>mochi.at(i);
  }
  
  sort(mochi.begin(),mochi.end());
  
  
  
  int count=1;
  
  for(int i=0;i<(N-1);i++){
    if(mochi.at(i)==mochi.at(i+1)){
    }
    else if(mochi.at(i+1)>mochi.at(i)){
      count++;
    }
  }
  
  cout<<count<<endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<cstdio>
#include<cstring>
int main()
{
  int i,k;
  char a[2][3];
  	  for(i=0;i<2;i++)
	  {
	  	  for(k=0;k<3;k++)
		  {
			cin>>a[i][k];
		  }	
	  }
	  if(a[0][0]==a[1][2]&&a[0][1]==a[1][1]&&a[0][2]==a[1][0])
	  	  cout<<"YES";
	else
		cout<<"NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  if(n % k == 0) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[105];
bool f[105];
signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i];
		f[a[i]]=true;
	}
	for(int i=0;i<=n;i++){
		if(!f[n-i]){
			cout<<n-i<<endl;
			return 0;
		}else{
			if(!f[n+i]){
				cout<<n+i<<endl;
				return 0;
			}
		}
	}
	return 0;
}


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

int main(void) {
	string str;
	cin >> str;
	if (str == "Sunny") cout << "Cloudy" << endl;
	else if (str == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 100; 
const double pi = acos(-1.0);

inline ll read()
{
    ll kk=0,f=1;
    char cc=getchar();
    while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
    while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
    return kk*f;
}


int main(void)
{
	ll x,num,ans=0;
	x=read();
//	scanf("%lf",&x);
//	ans = log(x/100)/log(1.01);
//	num = x/100;


	ll i=100;
//	printf("%lld",i);
	ll y=0;
	while(i<x)
	{
		i*=1.01;
		y++;
	}
	printf("%lld",y);
	
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int h, w;
    cin >> h >> w;
    string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    rep(i, h) rep(j, w) {
        string s;
        cin >> s;
        if (s == "snuke") {
            cout << a[j] << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, c, k) = (v[0] as usize, v[1], v[2]);
    let mut t = vec![];
    for i in 0..n {
        t.push(read::<i64>());
    }
    t.sort();
    let mut ans = 1;
    let mut current_bus_to_be_started = t[0] + k;
    let mut current_bun_number = 1;
    for i in 1..n {
        if t[i] > current_bus_to_be_started || current_bun_number == c {
            ans += 1;
            current_bun_number = 1;
            current_bus_to_be_started = t[i] + k;
        } else {
            current_bun_number += 1;
        }
    }

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
N = int(input())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
P = []
for i in range(N):
  P.append(list(map(int,input().split())))
def Base_10_to_n(X,n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n),n)+str(X%n)
  return str(X%n)
n = 2
ans = -(10**10)
for X in range(1,n**10+1):
  STR = Base_10_to_n(X,n).zfill(10)
  cur = 0
  for i in range(N):
    cnt = 0
    for j in range(10):
      if int(STR[j]) == L[i][j] == 1:
        cnt += 1
    cur += P[i][cnt]
  if ans <= cur:
    ans = cur
print(ans)

Measured memory_bytes: 52204
//my import
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7; 

//const int maxn=

vector<vector<int>>v1;

int n;

void dfs(int now,vector<int> v)
{
	if(now==n)
	{
		v1.push_back(v);
		return ;
	}
	
	v.push_back(0);
	dfs(now+1,v);
	v.pop_back();
	
	v.push_back(1);
	dfs(now+1,v);
	v.pop_back();
	
}

vector<vector<pair<int,int>>>a;
 

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	cin>>n;
	
	a.resize(n);
	
	for(int i=0,k;i<n;i++)
	{
		cin>>k;
		
		for(int j=0,x,y;j<k;j++)
		{
			cin>>x>>y;
			x--;
			
			a[i].push_back(make_pair(x,y));
		}
	}
	
	
	vector<int>v;
	v.push_back(0);
	dfs(1,v);
	v.pop_back();
	
	v.push_back(1);
	dfs(1,v);
	v.pop_back();
	
	int ans=0;
	
	for(int i=0;i<v1.size();i++)
	{
		int cnt=0;
		int flag=1;
		for(int j=0;j<v1[i].size();j++)
		{
			if(v1[i][j]==1)
			{
				cnt++;
				for(int k=0;k<a[j].size();k++)
				{
					if(v1[i][a[j][k].first]!=a[j][k].second)
					{
						flag=0;
						break;
					}
				}
			}
		}
		
		if(flag==1)
		{
			if(cnt>ans)
				ans=cnt;
		}
		
	}
	
	cout<<ans<<endl;
	
	return 0;
} 

Measured memory_bytes: 3640
#include <iostream>

int main()
{
    int N, L;
    std::cin >> N >> L;

    int m = 10000;
    int ans = N;
    for (int i = 0; i < N; i++) {
        if(abs(L + i) < m) {
            m = abs(L + i);
            ans = i;
        }
    }

    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (i == ans) continue;
        sum += (L + i);
    }

    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
double dp[301][301][301]={};int ta,tb,tc;bool bt[301][301][301]={};int n;
double rs(int a,int b,int c)
{
	if (a+b+c)
	{
		if (!bt[a][b][c])
		{
			bt[a][b][c]=1;
			if (a>0) {dp[a][b][c] += rs(a-1,b,c)*a/(a+b+c);}
			if (b>0) {dp[a][b][c] += rs(a+1,b-1,c)*b/(a+b+c);}
			if (c>0) {dp[a][b][c] += rs(a,b+1,c-1)*c/(a+b+c);}
			dp[a][b][c] += (double)n/(a+b+c);
		}
		return dp[a][b][c];
	}
	else {return 0;}
}
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		int a;cin>>a;
		if (a==1) {ta++;}
		else if (a==2) {tb++;}
		else {tc++;}
	}
	printf("%.9lf\n",rs(ta,tb,tc));
	return 0;
}

Measured memory_bytes: 239872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100003];
ll b[100003];
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=1;i<=n+1;i++){
		b[i]=abs(a[i]-a[i-1])+b[i-1];
	}
	ll sum=b[n+1];
	for(ll i=0;i<n;i++){
		ll now=sum+abs(a[i+2]-a[i]);
		now-=b[i+2]-b[i];
		cout <<now <<endl;
	}
	// your code goes here
	return 0;
}

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

int main(){
    int a, b, t;
    cin >> a >> b >> t;

    int all_num = 0;
    for (int i=1; i <= t; ++i){
        if (i%a==0){
            all_num+=b;
        }
    }
    cout << all_num << endl;
}

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

int main(){
    int a ,b;
    cin >> a >> b;
    int ans,rp;
    if(a>b){
        ans=b;
        rp=a;
    }else{
        ans=a;
        rp=b;
    }
    for(int i=0;i<rp;i++){
        cout << ans;
    }
}

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

using namespace std;

int main()
{
  string c;
  string d;
  cin >> c;


  int i,j;
  i = c.find('A');
  j = c.rfind('Z');
  //cout << c.substr(1, 2);
//  cout << c.substr(i, (j-i)+1);
cout << (j-i)+1;
  //  cout << "A: " << i << ", Z: " << j << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <stack>

using namespace std;

int main(){
    stack<int> S;
    int a, b, x;
    string s;
    
    while(cin >> s){
        if(s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b); 
        } else if(s[0] == '-'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(b - a);
        } else if(s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        } else{
            S.push(atoi(s.c_str()));
        }
    }
    
    cout << S.top() << endl;
    
    return 0;
}



Measured memory_bytes: 3140
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	std::map<int,int> mp;
	REP(i, 1, n+1){
		int n = i;
		for(int j=2; j*j<=i; j++){
			while(n%j==0){
				mp[j]++;
				n /= j;
			}
		}
		if(n>1) mp[n]++;
	}

	ll ans = 1;
	for(P p: mp) ans = (ans * (p.se + 1)) % MOD;
	printf("%ld\n", ans);
	return 0;
}



Measured memory_bytes: 256
x , k , d= map(int, input().split())

t = abs(x)/d
t2 = abs(x)//d
if t>=k:
    print(abs(x)-k*d)
else:
    x = abs(x)-t2*d
    if (k-t2)%2==0:
        print(x)
    else:
        print(d-x)


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

int main() {
    int K, T;
    cin >> K >> T;
    int maxA = 0;
    for (int i = 0; i < T; i++) {
        int a;
        cin >> a;
        maxA = max(maxA, a);
    }

    if (K - maxA >= maxA) {
        cout << 0 << endl;
    } else {
        cout << maxA - (K - maxA) - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vb=vector<bool>;
using qi=queue<int>;
#define pb push_back

vvi adj;
vi d,indegrees;
vb vis;

void dfs(int v){
    vis[v]=1;
    for(int u:adj[v]){
        d[u]=max(d[u],d[v]+1);
        indegrees[u]--;
        if(indegrees[u]==0){
            dfs(u);
        }
    }
}

void solve(){
    int n,m,u,v;
    cin>>n>>m;
    adj=vvi(n);
    vis=vb(n,0);
    d=vi(n,0);
    indegrees=vi(n,0);
    for(int i=0;i<m;i++){
        cin>>u>>v;
        u--,v--;
        adj[u].pb(v);
        indegrees[v]++;
    }
    for(int i=0;i<n;i++){
        if(!vis[i] and indegrees[i]==0)
            dfs(i);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,d[i]);
    }
    cout<<ans<<endl;
}

int main(){
    // int t;
    // cin>>t;
    // while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).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; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));
    COMinit();

    ll ans = 0;
    rep(i, N) {
        if (N - i - 1 >= K - 1) {
            ans -= A[i] * COM(N - i - 1, K - 1);
        }
        if (i >= K - 1) {
            ans += A[i] * COM(i, K - 1);
        }
        ans %= MOD;
    }

    if (ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24448
def read_data():
    N, L = map(int, input().split())
    As = list(map(int, input().split()))
    return N, L, As

def solve(N, L, As):
    for i in range(N - 1):
        if As[i] + As[i + 1] >= L:
            return list(range(1, i + 1)) + list(range(N - 1, i, - 1))
    return []

N, L, As = read_data()
ans = solve(N, L, As)
if ans:
    print("Possible")
    for i in ans:
        print(i)
else:
    print("Impossible")


Measured memory_bytes: 14148
N,K = map(int,input().split())
arr = list(map(int,input().split()))
_max = min(N,K)
val_arr = []
for R in range(_max+1):
  max_L = _max-R
  for L in range(max_L+1):
    hand = arr[:R]
    max_D = K-R-L
    if L!=0:
      hand.extend(arr[-L:])
    hand = sorted(hand)
    
    #print(hand)
    n_num = len([h for h in hand if h < 0])
    D = min(max_D,n_num)
    value = sum(hand[D:])
    val_arr.append(value)
    
print(max(val_arr))

Measured memory_bytes: 3064
let x = require('fs').readFileSync('/dev/stdin', 'UTF-8');
let a = Number(x.split(' ')[0]);
let b = Number(x.split(' ')[1]);
let c = Number(x.split(' ')[2]);
let tmp;
if (a > b) {
  tmp = a;
  a = b;
  b = tmp;
}
if (b > c) {
  tmp = b;
  b = c;
  c = tmp;
}
if (a > b) {
    tmp = b;
    b = a;
    a = tmp
}
console.log(a + ' ' + b + ' ' + c);


Measured memory_bytes: 15128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");
		long n = Long.parseLong(list[0]);
		long m = Long.parseLong(list[1]);
		long answer = 0;

		if(n > m/2){
			answer = m/2;
		}else{
			answer = n + (m-n*2)/4;
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 21204
#[allow(dead_code)]
fn rd() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().to_owned()
}

/// 1行の文字を空白で分割してVec<T>にする。
#[allow(dead_code)]
fn rd_vec<T : std::str::FromStr>() -> Vec<T> {
    rd().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

/// 1つの要素を入力で受け取る
#[allow(dead_code)]
fn rd_one<T : std::str::FromStr>() -> T {
    rd().parse().ok().unwrap()
}

/// 複数回read_splitを行う
#[allow(dead_code)]
fn rd_vec_mul<T : std::str::FromStr>(count : i32) -> Vec<Vec<T>> {
    (0..count).map(|_| rd_vec()).collect()
}

/// Vecを1列で出力する
#[allow(dead_code)]
fn op_vec<T : std::fmt::Display>(item : Vec<T>, splitter : char) {
    let cnt = item.len();
    let mut c = 0;
    for i in item.iter() {
        c+=1;
        if cnt > c {print!("{}{}", i, splitter);} else {println!("{}", i);}
    }
}

fn main() {
    let input : Vec<i32> = rd_vec();
    let inputa : Vec<char> = rd().chars().collect();
    let mut answer = "".to_string();
    for i in 0..input[0] {
        let mut ch = inputa[i as usize];
        if i == input[1] - 1 {
            ch = ch.to_lowercase().collect::<Vec<char>>()[0];
        }
        answer.push(ch);
    }
    println!("{}", answer);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char a;
    cin>>a;
    if('a'>a) cout<<"A";
    else cout<<"a";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,ans,a[100005],prfx[100005];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll d,g;cin>>d>>g;
    ll p[d],c[d];for(ll i=0;i<d;i++)cin>>p[i]>>c[i];
    ll ans = 1e9;
    for(ll mask=0;mask<(1ll<<d);mask++){
        ll score=0,cnt=0,rest_max=-1;
        for(ll i=0;i<d;i++){
            if( (mask>>i) & 1 ){
                score+=100*(i+1)*p[i] + c[i];
                cnt+=p[i];
            }
            else rest_max=i;
        }

        if(score<g){
            ll tmp = 100*(rest_max+1);
            ll req = (g - score + tmp - 1)/tmp;
            if(req>=p[rest_max])continue;
            cnt+=req;
        }
        ans = min(ans , cnt);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repe(i,n) for (int i = 1; i <= (n); ++i)
#define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit)
using namespace std;
typedef long long ll;
typedef string str;
const ll INF = 1e18;
const int MX = 2005;
const double pi = 3.141592653589793238;

int main() {

  int N;
  cin >> N;
  int cnt_all = 0;
  repe(i,N){
    if(i%2==1){
    int cnt = 0;
    repe(j,i){
      if(i%j==0) cnt += 1;
    }
    if(cnt == 8) cnt_all+=1;
    }
  }
  cout << cnt_all << endl;

}

Measured memory_bytes: 256
from functools import lru_cache
n, k = map(int, input().split())
A = sorted(map(int, input().split()))
mod = 10 ** 9 + 7
# 階乗とその逆元の計算
factrial = [0 for _ in range(n + 1)]
factrial[0] = 1
for i in range(1, n + 1):
    factrial[i] = (factrial[i - 1] * i) % mod
inverse_factrial = list()
for f in factrial:
    inverse_factrial.append(pow(f, -1, mod))


@lru_cache(maxsize=None)
def nCr(n, r):
    return (factrial[n] * inverse_factrial[r] * inverse_factrial[n - r]) % mod


ans = 0
# 最大値の和
for i, a in enumerate(A[k - 1:], k - 1):
    ans += ((a % mod) * nCr(i, k-1)) % mod
    ans %= mod
# 最小値の和
A.reverse()
for i, a in enumerate(A[k - 1:], k - 1):
    ans -= ((a % mod) * nCr(i, k-1)) % mod
    ans %= mod
print(ans)


Measured memory_bytes: 33452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000000;
const int K = 1000000007;

int memo[100004];

int main(){
  int N, M;
  cin >> N >> M;
  int a[100000];
  a[0] = -1;
  rep(i, M){
    cin >> a[i+1];
  }
  a[M+1] = N+1;
  memo[0] = 1;
  memo[1] = 1;
  memo[2] = 2;
  for(int i = 1;i < 100000; i++){
    memo[i+2] = (memo[i] + memo[i+1])%K;
  }
  ll ans = 1;
  rep(i, M+1){
    ans = (memo[a[i+1] - a[i]-2] * ans)%K;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint A;
    cin >> A;
    string B;
    cin >> B;
    string C = "";
    REP(i, B.size()) if(B[i] != '.') C += B[i];
    int D = stoi(C);
    lint E = A*D/100;
    cout << E << endl;
}


Measured memory_bytes: 3672