akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc *bufio.Scanner

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, p := nextInt(), nextInt()

	cnt0, cnt1 := 0, 0
	for i := 0; i < n; i++ {
		a := nextInt()
		switch {
		case a%2 == 0:
			cnt0++
		default:
			cnt1++
		}
	}

	bico := make([][]int, n+1)
	for i := range bico {
		bicoLine := make([]int, n+1)
		bicoLine[0] = 1
		bicoLine[i] = 1
		bico[i] = bicoLine
	}

	for i := range bico {
		for r := range bico[i] {
			if i >= 1 && r >= 1 && r < i {
				bico[i][r] = bico[i-1][r-1] + bico[i-1][r]
			}
		}
	}

	ans0 := 0
	ans1 := 0
	for j := 0; j <= cnt0; j++ {
		ans0 += bico[cnt0][j]
	}
	for k := p; k <= cnt1; k += 2 {
		ans1 += bico[cnt1][k]
	}

	fmt.Println(ans0 * ans1)
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, n) { cin >> a[i]; }

    ll ans = 0;

    repd(d, -1, 50) {

        if (d != -1 && !(k & (1LL << d)))
            continue;

        ll temp = 0;

        repd(e, 0, 50) {
            ll mask = 1LL << e;
            ll num = 0;
            rep(i, n) {
                if (a[i] & mask) {
                    num++;
                }
            }
            if (e > d) {
                if (k & mask) {
                    temp += mask * (n - num);
                } else {
                    temp += mask * num;
                }
            } else if (e == d) {
                temp += mask * num;
            } else {
                temp += mask * max(num, n - num);
            }
        }
        ans = max(ans, temp);
    }

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



Measured memory_bytes: 4376
package main

/*
#cgo CFLAGS: -Wno-unused-result
#include <stdio.h>
long long nextInt(){
	long long a;
	scanf("%lld", &a);
	return a;
}
*/
import "C"
import "fmt"


func nextInt() int{
	return int(C.nextInt())
}

func main(){
	var H, W int
	fmt.Scan(&H, &W)
	var s string
	for i := 0; i < H; i++ {
		fmt.Scan(&s)
		fmt.Println(s)
		fmt.Println(s)
	}
}

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

int main()
{
  ll K,N;cin>>K>>N;
  vector<ll> A(N);
  for (int i=0;i<N;i++)
    cin>>A[i];
  
  vector<ll> B(N);
  ll mx=0;
  for (int i=0;i<N;i++)
  {
    if (i==0) B[0]=K-A[N-1]+A[0];
    else B[i] = A[i]-A[i-1];
    
    mx = max(mx,B[i]);
    //cout<<"B["<<i<<"]="<<B[i]<<endl;
  }
  cout<<K-mx<<endl;
 
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // 内積
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // 外積
};

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

int ccw(Point a, Point b, Point c)
{
  b -= a;
  c -= a;
  if(b.det(c) > 0.0)    return  1;
  if(b.det(c) < 0.0)    return -1;
  if(b.dot(c) < 0.0)    return  2;
  if(norm(b) < norm(c)) return -2;
  return 0.0;
}

typedef vector<Point> Polygon;

// O(nlogn)
vector<Point> AndrewMonotoneChain(vector<Point> ps)
{
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<Point> ch(2*n);
  for(int i=0; i<n; ch[k++]=ps[i++]) // lower-hull
    while(k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for(int i=n-2, t=k+1; i>= 0; ch[k++]=ps[i--]) // upper-hull
    while(k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

int n;
double x, y;

int main()
{
  while((cin >> n) && n){
    Polygon ply;
    rep(i, n){
      scanf("%lf,%lf", &x, &y);
      ply.pb(Point(x, y));
    }
    cout << ply.size() - AndrewMonotoneChain(ply).size() << endl;
  }

  return 0;
}

Measured memory_bytes: 1296
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dp[42][1<<18][2];
int main(){
	int n;
	cin>>n;
	int x,y,z;
	cin>>x>>y>>z;
	dp[0][0][0]=1;
	int out=0,mod=1000000007;
	rep(i,n)rep(j,1<<18)rep(k,2)rep(l,10){
		if(k)(dp[i+1][j][k]+=dp[i][j][k])%=mod;
		else{
			int t=j;
			t<<=l+1;
			t|=1<<l;
			t&=(1<<18)-1;
			if(t&1<<(z-1)&&t&1<<(z+y-1)&&t&1<<(x+y+z-1))(dp[i+1][t][1]+=dp[i][j][k])%=mod;
			else (dp[i+1][t][0]+=dp[i][j][k])%=mod;
		}
	}
	rep(j,1<<18)(out+=dp[n][j][1])%=mod;
	cout<<out<<endl;
}










Measured memory_bytes: 84224
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    
    string s1,s2;
  	int cnt_s1[26] = {0},cnt_s2[26] = {0};
  
  	cin >> s1 >> s2;
  
  	rep(i,0,s1.size()){
      cnt_s1[(int)s1[i]-97]++;
    }
  
  	rep(i,0,s2.size()){
      cnt_s2[(int)s2[i]-97]++;
    }
  
  	sort(cnt_s1,cnt_s1+26);
  	sort(cnt_s2,cnt_s2+26);
  
  	rep(i,0,26){
      if(cnt_s1[i] != cnt_s2[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  
  	cout <<"Yes" << endl;
  	return 0;
  
}

Measured memory_bytes: 776
#include<stdio.h>
#include<stdlib.h>
int n;
void CountingSort(int*, int*, int);
int main(){
  int i, *A, *B, k=10000;
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  B = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++)
    scanf("%d",&A[i]);
  CountingSort(A, B, k);
  for(i=0; i<n; i++){
    printf("%d",B[i]);
    i!=n-1 ? printf(" ") : printf("\n");
  }
  free(A);
  free(B);
  return 0;
}

void CountingSort(int* A, int* B, int k){
  int i, j, C[k+1];  
  for(i=0; i<=k; i++)
    C[i] = 0;
  for(j=0; j<n; j++)
    C[A[j]]++;
  for(i=1; i<=k; i++)
    C[i]= C[i] + C[i-1];
  for(j=n-1; j>=0; j--){
    B[C[A[j]]-1] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16056
x,y,a,b=map(int,input().split())
print('R'*(a-x)+'U'*(b-y)+'L'*(a-x)+'D'*(b-y)+'D'+'R'*(a-x+1)+'U'*(b-y+1)+'L'+'U'+'L'*(a-x+1)+'D'*(b-y+1)+'R')

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


int main(){
    int H,W,h,w;
    cin >> H >> W;
    cin >> h >> w;
    cout << ((H - h) * (W - w)) << endl;
}

Measured memory_bytes: 256
(defun solver ()
  (let* ((n (read)) (ai (make-array n :fill-pointer 0))
         amax amax2 amid)
    (loop repeat n do
          (vector-push (read) ai))
    (setf amax (aref (sort ai #'>) 0)
          amax2 (/ amax 2)
          amid (aref (sort ai #'(lambda (x y)
                                  (< (abs (- x amax2)) (abs (- y amax2))))) 0))
    (format t "~a ~a~%" amax amid)))

(solver)

Measured memory_bytes: 58344
def main():
    ind = int(input())
    t = list(map(int, input().split()))
    ans = []
    for i in range(ind):
        if len(ans) + 1 == t[i]:
            ans.append(t[i])
    count = -1 if len(ans) == 0 else ind - len(ans)
    print(count)



if __name__ == '__main__':
    main()

Measured memory_bytes: 26012
#include <stdio.h>

int main(void) {
	int N;
	int sum = 0;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		int a;
		if (scanf("%d", &a) != 1) return 1;
		sum += a;
	}
	printf("%d\n", sum - N);
	return 0;
}

/*

ガーってmを増やしてけば、いつか全部a_i - 1になるでしょ。知らんけど。

*/


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

int main(){
  
  string S;
  cin >> S;
  string ans = "No";
  if (S[0] != S[1] && S[1] != S[2] && S[2] != S[0]){
    ans = "Yes";
  } 

  cout << ans << endl;

	return 0;
}


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

int main() {
    int64_t N, K, c, a = 1;
    cin >> N >> K;
    double ans = 0, b;
    
    for (int i = 0; i < N; i++) {
        c = i + 1;
        while (c < K) {
            c *= 2;
            a *= 2;
        }
      b = a;
        ans += 1 / b;
        a = 1;
    }
    cout << setprecision(15) << ans / N << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll ans;
ll pre[200005][26];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>s;
	for(int i=s.size()-1;i>=0;i--){
		int c=s[i]-'a';
		for(int j=0;j<26;j++){
			pre[i][j]=pre[i+1][j];
		}
		pre[i][c]++;
	}
	ans=s.size();ans*=(s.size()+1);ans/=2;
	ans+=1;
	for(int i=0;i<s.size();i++){
		ans-=pre[i][s[i]-'a'];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 41236
a,b,k = map(int,input().split())
ans = set()
if b-a+1 < k:
    for m in range(a,b+1):
        ans.add(m)
else:
    for i in range(a,a+k):
        ans.add(i)
    for j in range(b,b-k,-1):
        ans.add(j)

ans = list(ans)
ans.sort()
for l in range(len(ans)):
    print(ans[l])

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

int main() {

	int a, b;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) break;

		if (a < b) cout << a << " " << b << endl;
		else if (a == b) cout << a << " " << b << endl;
		else {
			swap(a, b);
			cout << a << " " << b << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int H, W;
string A[10];

void solve() {
}

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

    cin >> H >> W;
    int ans = 0;
    for (int i = 0; i < H; i++) {
        cin >> A[i];
        for (auto& c : A[i])
            if (c == '#')
                ans++;
    }
    if (ans == H + W - 1)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3616
k=[]
try:
  while True:
    k.append(list(map(int,input().split())))
except EOFError:
  pass
for a,b,c,d,e,f in k:
  if f*b-c*e==0:
    x=0
  else:
    x=(f*b-c*e)/(b*d-a*e)

  if f*a-c*d==0:
    y=0
  else:
    y=(f*a-c*d)/(a*e-b*d)
  
  print("%.3f %.3f" % (x,y))

               



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

using namespace std;

const int MAXN=2e5+6;

string ch;
int n;

int can=0;

struct side {
	int from,to,nex;
}edge[MAXN];
int head[MAXN],cntm;
void link(int from,int to) {
	edge[++cntm].from=from;
	edge[cntm].to=to;
	edge[cntm].nex=head[from];
	head[from]=cntm;
}

int N=2,root=1;

int main() {
	cin>>ch;
	n=ch.size();
	if(ch[n-1]=='1'||ch[n-2]=='0'||ch[0]=='0') {
		cout<<-1<<endl;
		return 0;
	}
	for(int i=2;i<=n/2;i++) {
		if(ch[i-1]=='0') {
			if(ch[n-i-1]=='1') {
				cout<<-1<<endl;
				return 0;
			}
			continue;
		}
		else {
			if(ch[n-i-1]=='0') {
				cout<<-1<<endl;
				return 0;
			}
			link(N,root);
			root=N;
			N++;
			while(N<=i) {
				link(root,N);
				N++;
			}
		}
	}
	if(n%2==0) {
		link(N,root);
		root=N;
		N++;
		while(N<=n) {
			link(root,N);
			N++;
		}
		for(int i=1;i<=cntm;i++) {
			cout<<edge[i].from<<" "<<edge[i].to<<endl;
		}
		return 0;
	}
	if(n%2==1) {
		link(N,root);
		root=N;
		N++;
		while(N<=n) {
			link(root,N);
			N++;
		}
		for(int i=1;i<=cntm;i++) {
			cout<<edge[i].from<<" "<<edge[i].to<<endl;
		}
		return 0;
	}
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
int main()
{
// #ifndef ONLINE_JUDGE
//    	freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
    	ll n,x=0;
    	cin>>n;
    	ll arr[n+1];
    	for(ll i=1;i<=n;i++)
    	{
    		cin>>arr[i];
    		x=x^arr[i];
    	}
    	for(ll i=1;i<=n;i++)
    		cout<<(arr[i]^x)<<" ";
    }
    return 0;
}

Measured memory_bytes: 5224
#include<iostream>
using namespace std;
int main(){
  int n,ans=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n-2;i++)
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
  cout<<ans<<endl;
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	int mcc = n/4 +1;
	int mdc = n/7 +1;
	for(int i = 0;i < mcc;i++){
		for(int j = 0;j < mdc;j++){
			if(i*4 + j*7 == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#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 h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << max(0,h2*60+m2-h1*60-m1-k) << endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N;
    cin >> N;
  
 	int h[100002];
 	int c[100002];
    for(int i = 0; i < N; i++){
      cin >> h[i];
      c[i] = 10000*i;
    }

    for(int i = 0; i < N; i++){
      int n1 = i+1;
      int n2 = i+2;
      int c1 = abs(h[n1] - h[i]) + c[i];
      int c2 = abs(h[n2] - h[i]) + c[i];
      if(c1 < c[n1]) c[n1] = c1; 
      if(c2 < c[n2]) c[n2] = c2; 
    }

    cout << c[N-1] << endl; 
}


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



public class Main {

	private static final int BIG_NUM  = 2000000000;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long sum = 0;
		int minimum = BIG_NUM,maximum = -BIG_NUM;

		try {

			int N = Integer.parseInt(br.readLine());

			String first[] = br.readLine().split("[\\s]+");
			int array[] = new int[first.length];

			for(int i = 0; i < first.length; i++){

				array[i] = Integer.parseInt(first[i]);
				minimum = Math.min(minimum, array[i]);
				maximum = Math.max(maximum, array[i]);
				sum += array[i];
			}

			System.out.printf("%d %d %d\n",minimum,maximum,sum);

		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 32044
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(){
  int n, m, i, j, k;

  while(cin >> n >> m && n != 0 || m != 0) {
    
    double gl[101][101] = {};
    double dp[101][101] = {};
    
    for(i = 0; i < n; i++) {
      for(j = 0; j < n; j++) {
	cin >> gl[i][j];
      }
    }

    for(i = 0; i < n; i++) {
      dp[0][i] = 1.0;
    }

    for(i = 1; i < m; i++) {
      for(j = 0; j < n; j++) {
	for(k = 0; k < n; k++) {
	  dp[i][j] = max(dp[i - 1][k] * gl[k][j], dp[i][j]);
	}
      }
    }

    double ans = 0.0;
    
    for(i = 0; i < n; i++) {
      ans = max(dp[m-1][i], ans);
    }
    
    printf("%.2f\n", ans);
 
  }

  return 0;

}

Measured memory_bytes: 3348
#include<stdio.h>
int main(){
int A,B;
  scanf("%d %d", &A, &B);
        if(A>=13){
          printf("%d\n", B);
        } else if(12 >= A && A >= 6){
          printf("%d\n", B /2 );
        } else
           printf("0\n");
        
        
        return 0;
        }


Measured memory_bytes: 128
fun main(args: Array<String>) {
    var (n,a,b,c,d) = readLine()!!.split(" ").map { it.toInt() }
    a-=1
    b-=1
    c-=1
    d-=1
    val s = readLine()!!
    if(s[c]=='.'&&s[d]=='.'){
        for(i in a until c-1){
            if(s[i]=='#'&&s[i+1]=='#'){
                println("No")
                return
            }
        }
        for(i in b until d-1){
            if(s[i]=='#'&&s[i+1]=='#'){
                println("No")
                return
            }
        }
        if(d<c){
            for(i in b-1 until d){
                if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
                    println("Yes")
                    return
                }
            }
            println("No")
            return
        }else{
            println("Yes")
        }
    }

}

Measured memory_bytes: 41444
func main() {
    let nxt = readLine()!.split(separator: " ").map {Int($0)!}
    let (n, x, t) = (nxt[0], nxt[1], nxt[2])
    let time = n % x == 0 ? n / x : n / x + 1
    print(t*time)
}

main()



Measured memory_bytes: 8292
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int X,A,B;

int main(int argc, char const *argv[])
{
    cin>>X>>A>>B;
    if(A-B>=0){
        cout<<"delicious"<<endl;
    }else if(B-A<=X){
        cout<<"safe"<<endl;
    }else{
        cout<<"dangerous"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n+1,0);
  for(int i=1;i<=n;i++)
    cin>>a.at(i);
  vector<int> d(n+1);
  int s=0;
  for(int i=0;i<n;i++){
    d.at(i)=abs(a.at(i+1)-a.at(i));
    s+=d.at(i);
  }
  d.at(n)=abs(a.at(n));
  s+=d.at(n);
  for(int i=1;i<=n;i++){
    if(min({a.at(i-1),a.at(i),a.at((i+1)%(n+1))})==a.at(i)||max({a.at(i-1),a.at(i),a.at((i+1)%(n+1))})==a.at(i))
      cout<<s-2*min(d.at(i-1),d.at(i))<<endl;
    else
      cout<<s<<endl;
  }
}

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

int count(long long  n){
  int tmp=0;
  while(n>0){
    tmp++;
    n/=10;
  }
  return tmp;
}

int main(){
  long long n;
  cin>>n;
  int ans=2e9,tmp;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
      long long b;
      b=n/i;
      tmp=max(count(i),count(b));
      ans=min(ans,tmp);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+9, INF = 0x3f3f3f3f;

int main( void ) {
    ios::sync_with_stdio( false );
    int q, a, b, c;
    deque< int > que;
    cin >> q;
    while( q-- ) {
        cin >> a >> b;
        if( a == 0 ) {
            cin >> c;
            b ? que.push_back( c ) : que.push_front( c );
        }
        else if( a == 1 ) cout << que[b] << '\n';
        else b ? que.pop_back() : que.pop_front();
    }

    return 0;
}



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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

ll DP[MAX];

//
int main(){
	int N,W;cin>>N>>W;
	V we(N),va(N);
	REP(i,N)cin>>we[i]>>va[i];

	fill(DP,DP+MAX,LINF);
	DP[0]=0;
	REP(i,N){
		for(int j=MAX;j>=va[i];--j){
			if(DP[j-va[i]]==LINF)continue;
			DP[j] = min(DP[j],DP[j-va[i]]+we[i]);
		}
	}

	for(int i=MAX-1;i>0;--i){
		// cout << i << " ";
		if(DP[i]<=W){
			// cout << endl;
			cout << i << endl;
			break;
		}
	}

	return 0;
}




Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<Integer> ary = new ArrayList<Integer>();
        while(true) {
            String t = br.readLine();
            if(new Integer(t) == 0)
                break;
            ary.add(new Integer(t));
        }
        for(int i=0;i < ary.size();i++) {
            System.out.println("Case " + (i+1) + ":" + " " + ary.get(i));
        }
    }
}

Measured memory_bytes: 27976
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    ll n,r;
    cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else{
        cout << r + 100*(10-n) << endl;
    }


    return 0;
}

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

ll p(ll a,ll b){
	ll sum=1,cnt=0;
	for(ll i=a;cnt<b;i--){
		sum*=i;
		cnt++;
	}
	return sum;
}

ll c(ll a,ll b){
	ll r=1;
	for(ll i=1;i<=b;i++){
		r*=i;
	}
	return a/r;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<ll,ll>mp;
	ll n,a;
	cin>>n;
	vector<ll>v(200001);
	for(ll i=0;i<n;i++){
		cin>>a;
		mp[a]++;
		v[i]=a;
	}
	ll sum=0;
	vector<ll>vv(200001);
	for(ll i=0;i<200001;i++){
		vv[v[i]]=c(p(mp[v[i]],2),2);
		if(mp[i]==0)continue;
		sum+=c(p(mp[i],2),2);
	}
	for(ll i=0;i<n;i++){
		cout<<sum-vv[v[i]]+c(p(mp[v[i]]-1,2),2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 18748
#include <bits/stdc++.h>
using namespace std;
class disjoint_set {
  public:
    vector<int> rank, p;
    disjoint_set(){};
    disjoint_set (int size) {
      rank.resize(size, 0);
      p.resize(size, 0);
      for (int i = 0; i < size; i++) {
        makeSet(i);
      }
    }
    void makeSet (int x) {
      p[x] = x;
      rank[x] = 0;
    }
    bool same (int x, int y) {
      return find_set(x) == find_set(y);
    }
    void unite (int x, int y) {
      link(find_set(x), find_set(y));
    }
    void link (int x, int y) {
      if (rank[x] > rank[y]) {
      p[y] = x;
      } else {
        p[x] = y;
        if (rank[x] == rank[y]) {
          rank[y]++;
        }
      }
    }
    int find_set (int x) {
      if (x != p[x]) {
        p[x] = find_set(p[x]);
      }
      return p[x];
    }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> x(n);
  vector<pair<int, int>> y(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    x[i] = {a, i};
    y[i] = {b, i};
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  vector<pair<int, pair<int, int>>> grh;
  for (int i = 0; i < n - 1; i++) {
    int s = x[i].second;
    int t = x[i + 1].second;
    int d = x[i + 1].first - x[i].first;
    grh.push_back({d, {s, t}});
  }
  for (int i = 0; i < n - 1; i++) {
    int s = y[i].second;
    int t = y[i + 1].second;
    int d = y[i + 1].first - y[i].first;
    grh.push_back({d, {s, t}});
  }
  sort(grh.begin(), grh.end());
  long long ans = 0;
  disjoint_set djs(n);
  for (auto e : grh) {
    int s = e.second.first;
    int t = e.second.second;
    if (!djs.same(s, t)) {
      djs.unite(s, t);
      ans += e.first;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 6516
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
graph = [[] for _ in range(n)]
colors = [-1 for _ in range(n-1)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    graph[a].append([b, i])


num_children = -1


def dfs(graph, cur, parent, num_children):
    if 0 == len(graph[cur]):
        return num_children
    num_edges = len(graph[cur])
    if not (None == parent):
        num_edges += 1
    num_children = max(num_children, num_edges)
    for child in graph[cur]:
        num_children = dfs(graph, child[0], cur, num_children)
    return num_children


def dfs_color(graph, cur, parent_edge_color, num_colors):
    color = 0
    for child in graph[cur]:
        if parent_edge_color == color:
            color += 1
        colors[child[1]] = color+1
        dfs_color(graph, child[0], color, num_colors)
        color += 1


num_children = dfs(graph, 0, None, num_children)
dfs_color(graph, 0, -1, num_children)
print(num_children)
for color in colors:
    print(color)


Measured memory_bytes: 70984
#include <stdio.h>

int main(){
  int  L=0, R=0;
  int i,j,K,mid,N1,N2,count=0;
  int num1[100000];
  int num2[50000];
  
  scanf("%d",&N1);
  for(i=0; i<N1; i++)
    scanf("%d",&num1[i]);
  
  scanf("%d",&N2);
  for(i=0; i<N2; i++)
    scanf("%d",&num2[i]);
  
  
  
  for(i=0; i<N2; i++){
    K = num2[i];
    L = 0;
    R = N1;

    while(L<R){
      
      mid = (L+R)/2;

      if(num1[mid] == K){ count++; break;}
      else if(K<num1[mid]) R=mid;
      else L = mid+1;

    }

  }


  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

// http://d.hatena.ne.jp/komiyam/20120520/1337454736

using int64 = ll;

struct EllysXors {

	int64 getXor(int64 L, int64 R) {
		int64 r = sub(R), l = sub(L-1);
		return r ^ l;
	}

	int64 sub(int64 n){
		if(n == 0){
			return 0;
		}
		if(n%4 == 0){
			return n;
		}
		if(n%4 == 1){
			return 1;
		}
		if(n%4 == 2){
			return n+1;
		}
		return 0;
	}

};

signed main() {
    int a, b;
    while (cin >> a >> b) {
        //++b;
        EllysXors solver;
        cout << solver.getXor(a, b) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, ans;
	cin >> n >> i;
	ans = n + 1 - i;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	  public static void main(String[] args) {
	        Scanner scan = new Scanner(System.in);
	        int a;
	        int b;
	        a=scan.nextInt();
	        b=scan.nextInt();
	        if(a<b){
	        	System.out.println("a < b");
	        }
	       
	        else if(a>b){
	        	System.out.println("a > b");	
	        }
	        else{
	        	System.out.println("a == b");
	        }
	    }
	}



Measured memory_bytes: 26340
n, m, k = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

accum_a, accum_b, result, max_j = [0], [0], 0, m

# A番目/B番目の本を読むのにかかる時間の累積
n.times { |i| accum_a << accum_a[i] + A[i] }
m.times { |i| accum_b << accum_b[i] + B[i] }

# n+1.times { |i|
(0..n).each { |i|
  break if accum_a[i] > k # Aが読めなくなったとき
  max_j -= 1 while accum_b[max_j] > k - accum_a[i]  # Aを読んでBが読める間
  result = [result, i + max_j].max
}

puts result


Measured memory_bytes: 45340
#include <iostream>

#define MAX 100005
#define NIL (-1)

using namespace std;

int D[MAX], n;

struct Node
{
	int parent;
	int left;
	int right;
}T[MAX];

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].parent << ", ";
	cout << "depth = " << D[u] << ", ";
	if(T[u].parent == NIL)
	{
		cout << "root, ";
	}
	else if(T[u].left == NIL)
	{
		cout << "leaf, ";
	}
	else
	{
		cout << "internal node, ";
	}
	cout << "[";
	
	for(i = 0,c = T[u].left; c != NIL; i++, c = T[c].right )
	{
		if(i)
		{
			cout << ", ";
		}
		cout << c; 
	}
	cout << "]" << endl;
}

int setdepth(int u,int p)
{
	D[u] = p;
	if(T[u].right != NIL)
	{
		setdepth(T[u].right,p);
	}
	if(T[u].left != NIL)
	{
		setdepth(T[u].left,p + 1);
	}
}

int main()
{
	int i, v, d, j, l, r, c;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		T[i].left = T[i].parent = T[i].right = NIL; 
	}
	for(i = 0; i < n; i++)
	{
		cin >> v >> d;
		for(j = 0; j < d; j++)
		{
			cin >> c;
			if(j == 0)
			{
				T[v].left = c;
			}
			else
			{
				T[l].right = c;
			}
			l = c;
			T[c].parent = v;
		}
	}
	for(i = 0; i < n; i++)
	{
		if(T[i].parent == NIL)
		{
			r = i;
		}
	}
	setdepth(r,0);
	
	for(i = 0; i < n; i++)
	{
		print(i);
	}
	
	return 0;
}


Measured memory_bytes: 7700
#include <stdio.h>

int main() {
  int a,b;
  scanf("%d", &a);
  scanf("%d", &b);
  if(a == b) {
    printf("%d\n", a*2);
  } else if(a > b) {
    printf("%d\n", a*2-1);
  } else if(b > a) {
    printf("%d\n", b*2-1);
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[60],b[60],c[60],d[60];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)  cin>>a[i]>>b[i];
    for(int i=0;i<m;i++)  cin>>c[i]>>d[i];
    for(int i=0;i<n;i++){
        int maxx=1000000000;
        int k;
        for(int j=0;j<m;j++){
            int t=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(t<maxx){
                maxx=t;
                k=j+1;
            }
        }
        cout<<k<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string S;
	cin >> S;
	ll res = 0;
	int n = S.length();
	ll a = (1 << (n - 1));
	REP(i, a) {
		ll v = 0;
		REP(j, n) {
			v *= 10;
			v += S[j] - '0';
			if (j != n - 1 && (i & (1 << j)) != 0) {
				res += v;
				v = 0;
			}
		}
		res += v;
	}
	cout << res << endl;
	return 0;
}


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

const int MAX_n = 1e5;
int n,q,b,e,cnt;
int AC[MAX_n];
string str;

int main()
{
	scanf("%d%d",&n,&q);
	cin >> str;
	
	for ( int i = 1 ; i < n ; i++ )
	{
		AC[i] = AC[i-1];
		if ( str[i-1] == 'A' && str[i] == 'C' )
			AC[i]++;
	}
		
	
	for ( int i = 0 ; i < q ; i++ )
	{
		scanf("%d%d",&b,&e);
		printf("%d\n",AC[e-1]-AC[b-1]);
	}
	return 0;
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.*;

public class Main {
    static List<Integer> [] al;
	static long [] dp;
	static long dfs(int u){
		if(dp[u]>0)return dp[u];
		long dist=1;
		for(int v : al[u]){
			  dist=Math.max(dist,1+dfs(v));
		}
		return dp[u]=dist;
	}
	public static void main( String [] args) throws IOException{
		FastScanner sc=new FastScanner();
		int n=sc.nextInt();
		int m=sc.nextInt();
		al=new ArrayList[n];
		for(int i=0;i<n;i++)al[i]=new ArrayList<>();
		dp=new long[n];
		for(int i=0;i<m;i++){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			al[u].add(v);
		}
		long max=0;
		for(int i=0;i<n;i++){
			max=Math.max(max,dfs(i));
		}
		System.out.println(max-1);
		
 
    }
    
    static final Random random = new Random();

    static void sort(final int[] a) {
        final int n = a.length;
        for (int i = 0; i < n; i++) {
            final int val = random.nextInt(n);
            final int cur = a[i];
            a[i] = a[val];
            a[val] = cur;
        }
        Arrays.sort(a);
    }

    static void sortl(final long[] a) {
        final int n = a.length;
        for (int i = 0; i < n; i++) {
            final int val = random.nextInt(n);
            final long cur = a[i];
            a[i] = a[val];
            a[val] = cur;
        }
        Arrays.sort(a);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (final IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (final IOException e) {
                e.printStackTrace();
            }
            return str;
        }

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

        int[] readArray(final int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}


Measured memory_bytes: 72168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

vector<int> g[100010];
int dp[100010];

int dfs(int u) {
	if (dp[u] != -1) return dp[u];
	// printf("u %d\n", u);
	int ans = 0;
	for (auto v : g[u]) {
		int d = dfs(v);
		ans = max(ans, d + 1);
	}
	// printf("ans %d\n", ans);
	return dp[u] = ans;
}

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> x(m), y(m); {
		rep(i, m) {
			cin >> x[i]	 >> y[i];
			x[i]--, y[i]--;
		}
		rep(i, m) g[x[i]].pb(y[i]);
	}

	rep(i, 100010) dp[i] = -1;
	rep(i, n) dfs(i);

	int ans = 0;
	rep(i, n) ans = max(ans, dp[i]);
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
ll N;
int main(){
  cin>>N;
  vector<P>A(N);
  for(ll i=0;i<N;i++){
  ll a;cin>>a;P p(a,i+1);
    A[i]=p;
  }sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  set<ll>S1;set<ll>S2;
  S1.insert(N+1);S2.insert(0);
  ll ans=0;
  for(ll i=0;i<N;i++){
  ll x=A[i].second;ll r1,r2,l1,l2;
    auto itr1=S1.upper_bound(x);
    ll a1=*itr1;r2=a1-x;
    if(a1==N+1)
      r1=0;
    else{
    auto itr2=S1.upper_bound(a1);ll a2=*itr2;
      r1=a2-a1;
    }
       auto itr3=S2.upper_bound(-x);
    ll b1=*itr3;l2=b1+x;
    if(b1==0)
      l1=0;
    else{
    auto itr4=S2.upper_bound(b1);ll b2=*itr4;
      l1=b2-b1;
    }ans+=(N-i)*(l1*r2+r1*l2);
    S1.insert(x);S2.insert(-x);
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 13972
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class L
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();

            var dp = new long[N + 1][].Select(x => x = new long[N + 1]).ToArray();
            for (var k = 0; k < N; k++)
            {
                for (var l = 0; l + k < N; l++)
                {
                    var r = l + k;
                    dp[l][r] = A[l] - dp[l + 1][r];
                    if (r > 0) dp[l][r] = Math.Max(dp[l][r], A[r] - dp[l][r - 1]);
                }
            }

            Console.WriteLine(dp[0][N - 1]);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
        }
    }
}


Measured memory_bytes: 100124
def solve(X:int) -> int:
    if(X < 100):return 0
    first = int(str(X)[-1])
    seccond = int(str(X)[-2])
    ans = 0
    if(first >= 6):
        ans += first + 200
    elif(first > 0):
        ans += first + 100
    ans += (seccond * 2) * 105
    return 1 if(ans <= X) else 0


def main():
    X = int(input())
    print(solve(X))

if __name__ == "__main__":
    main()




Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#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>
#include<complex>

using namespace std;

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

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    rep(i,n)if(a[i] == 0){
        cout << 0 << endl;
        return 0;
    }
    unsigned int ans = 1;
    rep(i,n){
        if((ans*a[i])/a[i] != ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
        if(ans > LINF){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4044
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<set>
using namespace std;
int UF[510];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
}
pair<int,pair<int,int> > edge[100000];
int ptr[1000];
int next[101000];
int zu[101000];
int zeit,dis[1000],fin[1000],low[1000],par[1000],dep[1000];
int kodat[1000],koptr[1000];
int n=700;
void dfsInfo(int u,int oy,int d){
	dis[u]=low[u]=zeit++;par[u]=oy;dep[u]=d;
	int i,v;
	for(i=ptr[u];~i;i=next[i])if((v=zu[i])!=oy){
		if(!~dis[v]){
			dfsInfo(v,u,d+1);
			low[u]=min(low[u],low[v]);
		}else{
			low[u]=min(low[u],dis[v]);
		}
	}
	fin[u]=zeit++;
}
void dfsInfos(){
	memset(dis,~0,n*4);zeit=0;
	for(int u=0;u<n;++u)if(!~dis[u])dfsInfo(u,-1,0);
	for(int u=0;u<n;++u){
		int &j=koptr[u+1]=koptr[u];
		for(int i=ptr[u];~i;i=next[i])if(u==par[zu[i]])kodat[j++]=zu[i];
	}
}
bool isBridge(int u,int v){
	if(dis[u]>dis[v])swap(u,v);
	return (u==par[v]&&dis[v]<=low[v]);
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		p--;q--;
		edge[i]=make_pair(r,make_pair(p,q));
	}
	for(int i=0;i<1000;i++)ptr[i]=-1;
	for(int i=0;i<51000;i++)next[i]=-1;
	std::sort(edge,edge+b);
	int at=0;
	int ret=0;
	int num=0;
	for(int i=0;i<a;i++)UF[i]=-1;
	while(at<b){
		int sz=0;
		int to=at;
		while(to<b&&edge[at].first==edge[to].first)to++;
	//	printf("%d %d\n",at,to);
		set<pair<int,int> >S;
		set<pair<int,int> >dame;
		map<int,int>m;
		int ind=0;
		for(int i=at;i<to;i++){
			int L=FIND(edge[i].second.first);
			int R=FIND(edge[i].second.second);
			if(L>R)swap(L,R);
			if(L==R)continue;
			if(!m.count(L))m[L]=ind++;
			if(!m.count(R))m[R]=ind++;
		}
		n=ind;
		for(int i=0;i<ind;i++)ptr[i]=-1;
		for(int i=at;i<to;i++){
			int L=FIND(edge[i].second.first);
			int R=FIND(edge[i].second.second);
			if(L>R)swap(L,R);
			if(L==R)continue;
			if(S.count(make_pair(L,R))){dame.insert(make_pair(L,R));continue;}
			S.insert(make_pair(L,R));
			zu[sz]=m[R];
			next[sz]=ptr[m[L]];
			ptr[m[L]]=sz++;
			zu[sz]=m[L];
			next[sz]=ptr[m[R]];
			ptr[m[R]]=sz++;
		}
		dfsInfos();
		//S.clear();
		for(int i=at;i<to;i++){
			int L=FIND(edge[i].second.first);
			int R=FIND(edge[i].second.second);
			if(L==R)continue;
			if(L>R)swap(L,R);
			if(!dame.count(make_pair(L,R))&&isBridge(m[L],m[R])){
				num++;ret+=edge[i].first;
			}
		}
		for(int i=at;i<to;i++)UNION(edge[i].second.first,edge[i].second.second);
		for(int i=0;i<sz;i++)next[i]=-1;
		at=to;
	}
	printf("%d %d\n",num,ret);
}

Measured memory_bytes: 5436
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A,B,K=0;cin >> A >> B;
    for(int i=A;i<=B;i++){
        if(i/10000==i%10 && i/1000%10==i%100/10){
            K++;
        }
    }
    cout << K << endl;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  string t;
  cin >> t;
  bool ok = true;
  int id = 0;
  int n = t.size();
  string las, cur;
  int len;
  int res = 0;
  while(id < n){
    cur.clear();
    while(id < n){
      cur.push_back(t[id++]);
      if(cur != las){
        res ++ ;
        break;
      }
    }
    las = cur;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 720