akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)
#define sz(a) (int)a.size()

vector<int> max_dp, t;
const int INF = 2e18;

int getMax(int qs, int qe, int ss, int se, int si) {
	if(qs > se || qe < ss)
		return -INF;
	if(qs <= ss && qe >= se)
		return t[si];
	int mid = (ss + se) / 2;
	return max(getMax(qs, qe, ss, mid, 2 * si), getMax(qs, qe, mid + 1, se, 2 * si + 1));
}

void update(int i, int val, int ss, int se, int si) {
	if(i > se || i < ss)
		return;
	if(ss == se) {
		t[si] = val;
		return;
	}
	int mid = (ss + se) / 2;
	update(i, val, ss, mid, 2 * si);
	update(i, val, mid + 1, se, 2 * si + 1);
	t[si] = max(t[2 * si], t[2 * si + 1]);
}

void segTree(int ss, int se, int si) {
	if(ss == se) {
		t[si] = max_dp[ss];
		return;
	}
	int mid = (ss + se) / 2;
	segTree(ss, mid, 2 * si);
	segTree(mid + 1, se, 2 * si + 1);
	t[si] = max(t[2 * si], t[2 * si + 1]);
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	vector<int> h(n), a(n);
	for(int &x : h)
		cin >> x;
	for(int &x : a)
		cin >> x;

	vector<int> dp(n);
	max_dp.assign(n + 1, 0);
	t.assign(4 * (n + 1), 0);

	max_dp[h[0]] = a[0];
	dp[0] = a[0];

	segTree(1, n, 1);

	for(int i = 1; i < n; i++) {
		dp[i] = a[i];
		int cur = 0;
		if(h[i] > 1) {
			cur = max(cur, getMax(1, h[i] - 1, 1, n, 1));
			// for(int j = 1; j < h[i]; j++) {
			// 	dp[i] = max(dp[i], a[i] + max_dp[j]);
			// }
		}
		dp[i] += cur; 
		max_dp[h[i]] = max(max_dp[h[i]], dp[i]);
		update(h[i], max_dp[h[i]], 1, n, 1);
	}

	int ans = 0;
	for(int i = 0; i < n; i++) {
		// cout << dp[i] << ' ';
		ans = max(ans, dp[i]);
	}
	cout << ans;

	return 0;
}

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

int main(){
  long long N,K,sum,group;
cin>>N>>K;
  sum=0;
  if(K==0){
    sum=N*N;
  }
  else{
    for(int i=K+1;i<N+1;i++){
      group=(N-N%i)/i;
    sum+=(i-K)*group;
      if(N%i>=K){
        sum+=N%i-K+1;
      }
  
    }
  }

    cout<<sum<<endl;


}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

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

	int cnt = 0;
	for(int i=0; i<S.size(); i++) {
		// cout << "S.at(i)=" << S.at(i) << ", T.at(i)=" << T.at(i) << "\n";
		if(S.at(i) != T.at(i)) {
			cnt++;
		}
	}

	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 3836
import sys
input=lambda: sys.stdin.readline().rstrip()
h1,m1,h2,m2,k=map(int,input().split())
t1=h1*60+m1
t2=h2*60+m2
if t2<=t1:
  t2+=24*60
t=t2-t1
print(max(0,t-k))

Measured memory_bytes: 9180
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    if(n<1200){
        cout << "ABC";
    }
    else if(1200<=n&&n<2800){
        cout << "ARC";
    }
    else{
        cout << "AGC";
    }

    return 0;
}

Measured memory_bytes: 256
// Aizu Vol-2 0200: Traveling Alone: One-way Ticket of Youth
// 2017.8.9

#include <stdio.h>
#include <string.h>

#define INF 1000000
#define MAX 100
typedef struct { int b, c, t; } T;
T tbl[MAX + 2][MAX + 2]; int w[MAX + 2];
char visited[MAX + 2];
int total[MAX + 2];
int m;

int search(int s, int g, int f);

int main(void)
{
	int n, a, b, c, t;
	int k, p, q, r;

	while (1) {
		scanf("%d%d", &n, &m); if (n == 0) return 0;
		memset(w, 0, sizeof(w));
		for (k = 0; k < n; k++) {
			scanf("%d%d%d%d", &a, &b, &c, &t);
			tbl[a][w[a]].b = b, tbl[a][w[a]].c = c, tbl[a][w[a]++].t = t;
			tbl[b][w[b]].b = a, tbl[b][w[b]].c = c, tbl[b][w[b]++].t = t;
		}
		scanf("%d", &k);
		while (k-- > 0) {
			scanf("%d%d%d", &p, &q, &r);
			printf("%d\n", search(p, q, r));
		}
	}
	return 0;
}

int search(int s, int g, int f)
{
	int  i, a, b, c, next, min;

	for (i = 1; i <= m; i++) visited[i] = 0, total[i] = INF;
	total[s] = 0, next = s;
	do {
		a = next, visited[a] = 1, min = INF;
		for (i = 0; i < w[a]; i++) {
			b = tbl[a][i].b;
			if (visited[b]) continue;
			c = f ? tbl[a][i].t : tbl[a][i].c;
			if (total[a] + c < total[b]) total[b] = total[a] + c;
			if (total[b] < min) min = total[b], next = b;
		}
		for (b = 1; b <= m; b++) {
			if (!visited[b] && total[b] < min) min = total[b], next = b;
		}
	} while (min < INF);
	return total[g];
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int X;
  cin>>X;
  while(true){
    for(int i=2;i<=X/i;i++)
      if(X%i==0)goto home;
    cout<<X<<endl;
    return 0;
    home:;
    X++;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int n;
int a[21][21];
ll mem[21][1<<21 +1 ];

ll fun(int col,int mask)
{
    if(col == n)
        return 1;
        
    if(mem[col][mask] != -1)
        return mem[col][mask];
    
    ll ans=0;
    for(int i=0;i<n;i++)
        if(a[i][col] == 1 && !(mask&(1<<i)))
            ans = (ans+fun(col+1,mask|1<<i))%mod;
    return mem[col][mask] = ans;
    
}
int main() {
    cin>>n;
    
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    
    memset(mem,-1,sizeof(mem));
	cout<<fun(0,0);
	return 0;
}

Measured memory_bytes: 688512
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
char str[1110];
long long gcd(long long a,long long b){
	while(a){
		b%=a;long long c=a;a=b;b=c;
	}
	return b;
}
pair<long long,long long>solve(string a){
	if(a=="north")return make_pair(0,1);
	if(a=="west")return make_pair(90,1);
	if(a[0]=='n'){
		pair<long long,long long>ret=solve(a.substr(5));
		ret.first*=2;ret.second*=2;
		ret.first-=90;
		return ret;
	}else{
		pair<long long,long long>ret=solve(a.substr(4));
		ret.first*=2;ret.second*=2;
		ret.first+=90;
		return ret;
	}
}
long long ABS(long long a){return max(a,-a);}
int main(){
	while(1){
		scanf("%s",str);
		if(str[0]=='#')return 0;
		int at=0;
		string tmp=str;
		pair<long long,long long>t=solve(tmp);
		long long g=gcd(ABS(t.first),t.second);
		t.first/=g;t.second/=g;
		if(t.second==1)printf("%lld\n",t.first);
		else printf("%lld/%lld\n",t.first,t.second);
	}
}

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

int main(){
  int N;
  cin >> N;
  int max_count=0;
  int bangou=0;
  for(int i=0;i<N;i++){
    bool exist_odd=false;
    int count=0;
    int C=i+1;
    while(!exist_odd){
      if(C%2==1){
        exist_odd=true;
        break;
      }
      count++;
      C/=2;
    }
    if(count>=max_count){
      max_count=count;
      bangou=i+1;
    }
  }
  cout << bangou << endl;
}

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

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )
#define INF ( 1e9 )
#define MINF ( -1e9 )

int N, A, B, C;
vector<int> v;

int solv( int n, int a, int b, int c )
{
	if ( n == N )
	{
		if ( min( { a, b, c } ) > 0 )
		{
			return ( abs( A - a ) + abs( B - b ) + abs( C - c ) - 30 );
		}
		else
		{
			return ( INF );
		}
	}

	int r0 = solv( n + 1, a, b, c );
	int r1 = solv( n + 1, a + v[n], b, c ) + 10;
	int r2 = solv( n + 1, a, b + v[n], c ) + 10;
	int r3 = solv( n + 1, a, b, c + v[n] ) + 10;

	return ( min( { r0, r1, r2, r3 } ) );
}

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

	rep( i, N )
	{
		int tmp;
		cin >> tmp;
		v.eb( tmp );
	}

	cout << solv( 0, 0, 0, 0 ) << endl;

	return ( 0 );
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[4],k;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
	sort(a,a+5);
	if(a[4]-a[0]<=k){
		cout<<"Yay!"<<endl;
		return 0;
	}
	else cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 105
#define M 15
using namespace std;

int n, m = 10, c, s, mx = -2e9, a[N][M], b[N][M];
int main()
{
	int i, j, k, t;
	cin >> n;
	for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	for (i = 0; i < n; i++) for (j = 0; j <= m; j++) scanf("%d", &b[i][j]);
	for (i = 1; i < (1 << m); i++) {
		s = 0;
		for (j = 0; j < n; j++) {
			c = 0;
			for (t = i, k = m - 1; k >= 0; t /= 2, k--) c += a[j][k] & (t % 2);
			s += b[j][c];
		}
		mx = max(mx, s);
	}
    cout << mx << endl;
    return 0;
}

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

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

    rep(i, 0, N)
    {
        cin >> p.at(i);
    }

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

    ll amount = 0;
    rep(i, 0, K)
    {
        amount += p.at(i);
    }

    cout << amount << endl;

    return 0;
}


Measured memory_bytes: 3604
n=int(input())
d=[list(map(int,input().split()))for _ in range(n)]
def c(p,q,a):
  global n
  s=n
  for i in a:
    if [i[0]-p,i[1]-q]in a:s-=1
  return s
ans=50
for i in range(n):
  for j in range(n):
    p,q=d[j][0]-d[i][0],d[j][1]-d[i][1]
    if not(p==q==0):ans=min(ans,c(p,q,d))
if n==1:print(1)
else:print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
int main(){
  int i;
  long long a, b, c, d, l, ans1, ans2, ans;
  cin >> a >> b >> c >> d;
  l=lcm(c, d);
  ans1=b/c+b/d-b/l;
  ans2=(a-1)/c+(a-1)/d-(a-1)/l;
  ans=b-a+1-(ans1-ans2);
  cout <<setprecision(20) << ans;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
C=[]
S=[]
F=[]

for i in range(N-1):
    a = input().split()
    C.append(int(a[0]))
    S.append(int(a[1]))
    F.append(int(a[2]))

for i in range(N-1):
    cnt=0
    for j in range(i,N-1):
        if cnt <= S[j]:
            cnt = S[j] + C[j]
        else:
            if (cnt - S[j]) % F[j] == 0:
                cnt += C[j]
            else:
                cnt += F[j] - (cnt % F[j]) + C[j]
    print(cnt)

print(0)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,N,M,odd=0,sum=1;
  vector<int>P(0,0);
  string S,K,T;
  cin >> S;
  K=S;
  A=S.size();
  K=S[0];
  rep(i,1,A){
    T=S[i];
    rep(j,1,A-i+1){
      if(K==T)T=S.substr(i,j);
      if(K!=T){
        sum++;
        K=T;
        i=i+j-1;
        break;
    }
    }
  }
  Out(sum);
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long gcd = gcd(scanner.nextLong(), scanner.nextLong());
		scanner.close();
		int count = 1;
		int index = 0;
		while ((long) primeList.get(index) * primeList.get(index) <= gcd) {
			if (gcd % primeList.get(index) == 0) {
				count++;
				while (gcd % primeList.get(index) == 0)
					gcd /= primeList.get(index);
			}
			index++;
		}
		if (gcd > 1)
			count++;

		System.out.println(count);
	}

	static List<Integer> primeList = new ArrayList<Integer>();
	static {
		primeList.add(2);
		boolean[] sieve = new boolean[500000];
		for (int i = 1; 2 * i * (i + 1) < 500000; i++) {
			for (int j = i; 2 * i * j + i + j < 500000; j++) {
				sieve[2 * i * j + i + j] = true;
			}
		}
		for (int i = 1; i < 500000; i++) {
			if (sieve[i])
				continue;
			primeList.add(i * 2 + 1);
		}
	}

	static long gcd(long a, long b) {
		if (a % b == 0)
			return b;
		return gcd(b, a % b);
	}
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, x; std::cin >> n >> x;
  int cur = 0, ans = 1;
  rep(i, n) {
    int l; std::cin >> l;
    cur += l;
    if (cur <= x) ans++;
  }
  std::cout << ans << "\n";
}


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

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

long long read(){
	long long i;
	cin >> i;
	return i;
}

int main(void){
	long long size = read();
	vector<int> in(size);
	REP(i, size) {
		cin >> in[i];
	}
	vector<int>::reverse_iterator iter = in.rbegin();
	cout << *iter;
	for(++iter;  iter != in.rend(); ++iter) {
		cout << " " << *iter;
	}
	cout << endl;

	return 0;
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double EPS = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp);
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "(" << p.first << ":" << p.second << ")";
    return os;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", ";
        a = 1; os << tp;
    }
    return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll X; cin >> X;
    ll m = 100, ans = 0;
    while (m < X) {
        m = (ll)(1.01 * m);
        ++ans;
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
	//input
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >>a[i];
	//compute
	sort(a.begin(), a.end());
	int ans = 0;
	int A = 0;
	int B = 0;
	for (int i = 0; i < N; i++){
		if (i%2 == 0) {
			A += a.at(a.size()-1);
			a.pop_back();
		}
		else{
			B += a.at(a.size()-1);
			a.pop_back();
		}
	}
	ans = A - B;
	//output
	cout << ans << endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct uf {
private:
	vector<int> par, ran;
public:
	uf(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int n;
ld x[15], y[15], a[15];
ld dist[15][15];
ld high[1 << 15];

ld dp[1 << 15];

typedef pair<ld, P> speP;
void solve() {
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> y[i] >> a[i];
	}
	rep(i, n) {
		rep(j, n) {
			dist[i][j] = sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2));
		}
	}
	for (int i = 1; i < (1 << n); i++) {
		vector<int> v;
		rep(j, n) {
			if (i&(1 << j)) {
				v.push_back(j);
			}
		}
		int len = v.size();
		uf u(len);
		ld sum = 0;
		vector<speP> z;
		rep(j, len) {
			sum += a[v[j]];
			Rep(k, j + 1, len) {
				z.push_back({ dist[v[j]][v[k]],{j,k} });
			}
		}
		sort(z.begin(), z.end());
		rep(j, z.size()) {
			int l = z[j].second.first, r = z[j].second.second;
			if (u.same(l, r))continue;
			sum -= z[j].first; u.unite(l, r);
		}
		if (sum < 0)sum = 0;
		high[i] = sum / len;
	}
	//3^n
	dp[0] = INF;
	for (int i = 1; i < (1 << n); i++) {
		dp[i] = high[i];
		vector<int> v;
		rep(j, n) {
			if (i&(1 << j)) {
				v.push_back(j);
			}
		}
		int len = v.size();
		for (int j = 1; j < (1 << len) - 1;j++) {
			int s = 0;
			rep(k, len) {
				if (j&(1 << k)) {
					s += (1 << v[k]);
				}
			}
			dp[i] = max(dp[i], min(dp[s], dp[s^i]));
		}
	}
	cout << dp[(1 << n) - 1] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(){
  char s[5010],c[10],d[5][5010]={{255,0},{255,0},{255,0},{255,0},{255,0}};
  int i,j,k,m;
  scanf("%s %d",s,&m);
  for(i=0;s[i];i++){
    for(j=0;j<5;j++){
      c[j]=s[i+j];
      c[j+1]=0;
      for(k=0;k<5;k++){
	if(strcmp(d[k],c)==0)goto NEXT;
      }//printf("not\n");
      for(k=5;k&&strcmp(d[k-1],c)>0;k--)strcpy(d[k],d[k-1]);
      strcpy(d[k],c);
    NEXT:;
      //for(k=0;k<5;k++)printf("%s ",d[k]);printf("\n");
    }
  }
  printf("%s\n",d[m-1]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}

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

int main(){
  //利用変数定義
  vector<vector<int>> sheet(3, vector<int>(3,0));
  int n,x;
  bool bingo = false;
  
  //ビンゴの入力
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> sheet.at(i).at(j);
    }
  }
  
  //入力数指定
  cin >> n;
  //選択された数をチェック
  for(int a=0;a<n;a++){
    cin >> x;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(sheet.at(i).at(j)==x){
          sheet.at(i).at(j) = 0;
        }
      }
    }
  }
  
  int count = 0;
  //当たり判定(横)
  for(int i=0;i<3;i++){
    count = 0;
    for(int j=0;j<3;j++){
      if(sheet.at(i).at(j)==0){
        count++;
      }
      if(count == 3){
        bingo = true;
      }
    }
  }
  
  //当たり判定(縦)
  for(int i=0;i<3;i++){
    count = 0;
    for(int j=0;j<3;j++){
      if(sheet.at(j).at(i)==0){
        count++;
      }
      if(count == 3){
        bingo = true;
      }
    }
  }
  
  //当たり判定(ナナメ)
  if(sheet.at(0).at(0)==0 && sheet.at(1).at(1)==0 && sheet.at(2).at(2)==0){
    bingo = true;
  }else if(sheet.at(2).at(0)==0 && sheet.at(1).at(1)==0 && sheet.at(0).at(2)==0){
    bingo = true;
  }
  
  //出力判定
  if(bingo){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool used[100000] = {false};

int main(){
    int cnt = 0;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        if(!used[A])used[A] = true;
        else cnt++;
    }
    if(cnt%2 == 0) cout << N-cnt << endl;
    else cout << N-cnt-1 << endl;
}

Measured memory_bytes: 888
import re

#lower = [re.compile(r'^[a-z]+$'), 'lower']

def main():
    
    ##S
    try:
        S = input()
    except ValueError:
        print('No')
        return

    #english lower
    if(re.match('^[a-z]+$', S) is None):
        print('No')
        return
    #length
    ls = len(S)
    if(not(ls >= 1 and ls <= 10)):
        print('No')
        return

    ##T
    try:
        T = input()
    except ValueError:
        print('No')
        return

    if(re.match('^[a-z]+$', T) is None):
        print('No')
        return
    
    if (len(T) != ls + 1):
        print('No')
        return

    if(T.find(S) == 0):
        print('Yes')
        return
    else:
        print('No')
        return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9864
#include <iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b) & (b == c) & (a == c)) cout << 1 << endl;
    else if ((a != b) & (b != c) & (a != c)) cout << 3 << endl;
    else cout << 2 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vll A(N);
    REP(i, N) cin >> A[i];

    ll x = 0;
    int j = 0;
    ll ans = 0;
    REP(i, N) {
        if (i == j) {
            x ^= A[j];
            j++;
        }

        for(; j < N; ++j) {
            if ((x & A[j]) != 0) break;
            x ^= A[j];
        }
        ans += j - i;

        debug(bitset<5>(x), i, j)

        x ^= A[i];
    }

    print(ans);
}


Measured memory_bytes: 4736
#include<stdio.h>

int main()
{
    int a,b,c,x,y,bill1,bill2,bill3;

    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);

    bill1=x*a+y*b;


    if(x>y)
    {
       bill2 =2*y*c+(x-y)*a;
    }
    else
    {
       bill2 =2*x*c+(y-x)*b;
    }


    if(x>y)
    {
       bill3 =2*c*x;
    }
    else
    {
       bill3 =2*c*y;
    }

    if(bill1<=bill2&&bill1<=bill3)
        printf("%d\n",bill1);
    else if(bill2<=bill1&&bill2<=bill3)
        printf("%d\n",bill2);
    else if(bill3<=bill2&&bill3<=bill1)
        printf("%d\n",bill3);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<std::pair<lint,lint>>a(n);
    for(auto&&p:a)std::cin>>p.first>>p.second;
    ld ans=0;
    for(lint i=0;i<n;i++){
        for(lint j=i+1;j<n;j++){
            ans+=std::hypot(a.at(i).first-a.at(j).first,a.at(i).second-a.at(j).second);
        }
    }
    std::cout<<ans*2/n<<'\n';
}


Measured memory_bytes: 256
/* https://atcoder.jp/contests/abc170/tasks/abc170_d */

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert
#define mp make_pair

const int MAX = 1e5;

int main() {
	int n;
	cin>>n;
	vi a(n);
	map<int, int> p;
	for (int i = 0;i < n;++i) {
		cin>>a[i];
		p[a[i]] += 1;
	}

	sort(all(a));
	int max_e = a.back();
	vi dp(max_e+1, true);
	for (int i = 0;i < n;++i) {
		for (int j = 2, k = a[i] * j;k <= max_e;++j, k = a[i] * j) {
			dp[k] = false;
		}
	}

	int ans = 0;
	for (int i = 0;i <= dp.size();++i) {
		if (p[i] == 1 && dp[i]) {
			ans++;
		}
	}

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


Measured memory_bytes: 54744
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
struct Writer {
    s: String,
}
#[allow(unused_imports)]
use std::fmt::Display;
#[allow(dead_code)]
impl Writer {
    #[allow(dead_code)]
    pub fn new() -> Writer {
        Writer { s: String::new() }
    }
    #[allow(dead_code)]
    pub fn flush(&mut self) {
        print!("{}", self.s);
        self.s.clear();
    }
    pub fn write<T: Display>(&mut self, x: T) {
        self.s.push_str(&format!("{}", x));
    }
    pub fn writeln<T: Display>(&mut self, x: T) {
        self.s.push_str(&format!("{}", x));
        self.s.push('\n');
    }
    #[allow(dead_code)]
    pub fn write_vec<T: Display>(&mut self, xs: &Vec<T>) {
        if xs.len() == 0 {
            self.writeln("");
            return;
        }
        self.write(&format!("{}", xs[0]));
        for i in 1..xs.len() {
            self.write(&format!(" {}", xs[i]));
        }
        self.writeln("");
    }
}
#[allow(dead_code)]
fn main() {
    input!{
        s: chars,
    }
    let mut ans = String::new();
    for ss in s {
        if ss == ',' {
            ans.push(' ');
        } else {
            ans.push(ss);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
ll dp[100100][2];
int main()
{
    string L;
    cin >> L;
    int N=L.size();
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        if(L[i]=='1'){
            dp[i+1][0]+=dp[i][0]*2;
            dp[i+1][0]%=MOD;

            dp[i+1][1]+=dp[i][0];
            dp[i+1][1]%=MOD;
        }
        else{
            dp[i+1][0]+=dp[i][0];
            dp[i+1][0]%=MOD;
        }

        dp[i+1][1]+=dp[i][1]*3;
        dp[i+1][1]%=MOD;
    }
    cout << (dp[N][0]+dp[N][1])%MOD << endl;
    return 0;
}

Measured memory_bytes: 2048
N, M = map(int, input().split())
AB = []
cons = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    cons[a - 1].append(b - 1)
    cons[b - 1].append(a - 1)
visited = [False for _ in range(N)]
visited[0] = True
Q = [0]
sirusi = [0 for _ in range(N)]
while Q:
    v = Q.pop(0)
    for i in cons[v]:
        if not visited[i]:
            visited[i] = True
            sirusi[i] = v
            Q.append(i)
print("Yes")
for i in range(1, N):
    print(sirusi[i] + 1)

Measured memory_bytes: 34512
s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll h,w;

bool in(ll y, ll x){
    return 0<=y && y<h && 0<=x && x<w;
}

int main(){
    ll n; cin >> n;
    string s;
    ll cnt[n][26] = {};
    rep(i,n){
        cin >> s;
        rep(j,s.size()){
            cnt[i][s[j]-'a']++;
        }
    }
    vl mn(26,INF);
    rep(i,26){
        rep(j,n){
            mn[i] = min(mn[i], cnt[j][i]);
        }
    }
    rep(i,26){
        rep(j,mn[i]){
            cout << (char)(i+'a');
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;
	for(int i=n-1;i>=n-k;i--){
		sum+=a[i];
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long Q, H, S, D;
    scan(Q, H, S, D);
    long N = lread();
    long A = Q * 4;
    long B = H * 2;
    long ans;
    if (min(A * 2, B * 2, S * 2, D) == D)
    {
        ans = D * (N / 2);
        ans += min(A, B, S) * (N % 2);
    }
    else
    {
        ans = min(A, B, S) * N;
    }
    writeln(ans);
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int a,b;

void solve(){
  if(a <= 8 && b <= 8){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
  return;
}
int main(){
  cin >> a >> b;
  solve();
  return 0;
}


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


#define fs first
#define sc second

using namespace std;

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


int main(){
    string s;
    ll K;
    cin >> s;
    cin >> K;

    string t = s + s + s;

    ll dp[500][2];
    for(int i = 0; i < 500; i++){
        for(int j = 0; j < 2; j++){
            dp[i][j] = 10000;
        }
    }

    dp[0][0] = 0;
    dp[0][1] = 1;
    for(int i = 1; i < t.length(); i++){
        if(t[i-1] == t[i]){
            dp[i][1] = min(dp[i][1], dp[i-1][0] + 1);
            dp[i][1] = min(dp[i][1], dp[i-1][1] + 1);
            dp[i][0] = min(dp[i][0], dp[i-1][1]);
        }
        else{
            dp[i][0] = min(dp[i][0], dp[i-1][0]);
            dp[i][0] = min(dp[i][0], dp[i-1][1]);
            dp[i][1] = min(dp[i][1], dp[i-1][0] + 1);
            dp[i][1] = min(dp[i][1], dp[i-1][1] + 1);
        }
    }

    ll res1 = min(dp[s.length()-1][0], dp[s.length()-1][1]);
    ll res2 = min(dp[s.length()*2-1][0], dp[s.length()*2-1][1]);
    ll res3 = min(dp[t.length()-1][0], dp[t.length()-1][1]);

    if(res1 * 2 == res2){
        cout << res1 * K << endl;
    }
    else if(res3 - res2 == res1){
        ll res = res2 * (K / 2);
        if(K % 2 == 1){
            res += res1;
        }
        cout << res << endl;
    }
    else{
        cout << (res2 - res1) * (K-1) + res1 << endl;
    }
//
//    if(res2 % 2 == 0){
//        cout << res2 / 2 * K << endl;
//    }
//    else{
//        if(K % 2 == 0) {
//            cout << res2 * K / 2 << endl;
//        }
//        else {
//            cout << res2 * (K - 1) / 2 + (res2 - 1) / 2 << endl;
//        }
//    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

ll n,m;
vi a[100005];
ll dp[100005];

ll go(ll node){
    if(dp[node]!=-1) return dp[node];
    ll ans=0;
    for(auto it:a[node]) ans=max(ans,go(it)+1);
    return dp[node]=ans;
}

int main()
{
    io
    ll i,j,x,y;
    memset(dp,-1,sizeof dp);
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        a[x].pb(y);
    }
    ll ans=-1e17;
    for(i=1;i<=n;i++) ans=max(ans,go(i));
    cout<<ans;

    return 0;
}

Measured memory_bytes: 8576
<?php
list($takahashi_hp, $takahashi_att, $aoki_hp, $aoki_att) = explode(' ', trim(fgets(STDIN)));

for ($i = 0; $i <= 100; $i++) {
    (int)$aoki_hp -= (int)$takahashi_att;

    if ($aoki_hp <= 0) {
        echo 'Yes';
        break;
    }

    (int)$takahashi_hp -= (int)$aoki_att;

    if ($takahashi_hp <= 0) {
        echo 'No';
        break;
    }
}

Measured memory_bytes: 16252
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#ifdef DEBUG
    #include <ctime>
#endif
using namespace std;

// template

// abbreviations
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define ii pair<int, int>
#define a first
#define b second
#define vii vector<ii>
#define mii map<ii>
#define vvi vector<vi>
#define vvl vector<vl>
#define que queue
#define pque priority_queue
#define stk stack
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define pu push
#define po pop
#define mp make_pair
#define sz(var) ((int) var.size())
#define rep(it, n) for(int it = 0; it < n; ++it)
#define dep(it, n) for(int it = n - 1; it >= 0; --it)
#define rep1(it, n) for(int it = 1; it <= n; ++it)
#define dep1(it, n) for(int it = n; it > 0; --it)
#define loop(it, from, to) for(int it = (from); it <= (to); ++it)
#define iter(it, cont) for(__typeof((cont).begin()) it = (cont).begin(); it != (cont).end(); ++it)
#define riter(it, cont) for(__typeof((cont).rbegin()) it = (cont).rbegin(); it != (cont).rend(); ++it)
#define all(cont) (cont).begin(), (cont).end()
#define rng(cont, n) cont, cont + n
#define memclr(var) memset(var, 0, sizeof(var))

typedef unsigned long long ull;
typedef long long ll;

const int INF = INT_MAX;
const int NINF = INT_MIN;
const ll INF_LL = LLONG_MAX;
const ll NINF_LL = LLONG_MIN;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;

#ifdef DEBUG
    #define debug(fmt, args...) printf("Line %d, in %s\t: " fmt, __LINE__, __FUNCTION__, ##args)
    #define rep_rt() printf("[Run time: %.3fs]\n", ((double) clock()) / CLOCKS_PER_SEC)
#else
    #define debug(...)
#endif

// end of template

int main() {
#ifdef DEBUG
    freopen("agc003_a.in", "r", stdin);
#endif
    
    string str;
    getline(cin, str);
    set<char> s;
    rep(idx, (int) str.length()) {
        s.insert(str[idx]);
    }
    if ((s.count('W') == s.count('E')) and ((s.count('N')) == (s.count('S'))))
        puts("Yes");
    else
        puts("No");

#ifdef DEBUG
    rep_rt();
#endif
    return 0;
}

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

int asc(const void* n1,const void* n2)
{
  return *(int*)n1 - *(int*)n2;
}

int main(void)
{
  int A,B,M;
  int min = 1000000;
  scanf("%d%d%d",&A,&B,&M);

  int a[A+1],b[B+1],x[M+1],y[M+1],c[M+1];

  for(int i=1; i<=A; i++){
    scanf("%d",&a[i]);
  }

  for(int i=1; i<=B; i++){
    scanf("%d",&b[i]);
  }

  for(int i=1; i<=M; i++){
    scanf("%d",&x[i]);
    scanf("%d",&y[i]);
    scanf("%d",&c[i]);
  }

  for(int i=1; i<=M; i++){
    if(min > a[x[i]]+b[y[i]]-c[i]){
      min = a[x[i]]+b[y[i]]-c[i];
    }
  }

  qsort(a+1,A,sizeof(int),asc);
  qsort(b+1,A,sizeof(int),asc);  

  if(min > a[1]+b[1]){
    min = a[1]+b[1];
  }
//  printf("%d %d",a[1],b[1]);  



  printf("%d",min);
  return 0;

}



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

int main()
{
   int l,k,a,count=0;cin>>l>>k>>a;
   for(int i=l;i<=k;i++){
       if(i%a==0){
           count++;
       }
   }
   std::cout << count << std::endl;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"

typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < n; i++)

using namespace std;

int L[2100][2100], R[2100][2100], U[2100][2100], D[2100][2100];

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	vector<string> S(H);
	rep(i, H) { cin >> S[i]; }
	
	rep(i, H) {
		int cur = 0;
		rep(j,W) {
			if (S[i][j]=='#') {	cur = 0;}
			else { 
				cur++;
				L[i][j] = cur;
			}
		}
	}
	rep(i, H) {
		int cur = 0;
		for (int j = W - 1; j >= 0; j--) {
			if (S[i][j] == '#') { cur = 0; }
			else {
				cur++;
				U[i][j] = cur;
			}
		}
	}

	rep(j, W) {
		int cur = 0;
		rep(i, H) {
			if (S[i][j] == '#') { cur = 0; }
			else {
				cur++;
				D[i][j] = cur;
			}
		}
	}
	rep(j, W) {
		int cur = 0;
		for (int i = H - 1; i >= 0; i--) {
			if (S[i][j] == '#') { cur = 0; }
			else {
				cur++;
				R[i][j] = cur;
			}
		}
	}

	int res = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') continue;
			res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
		}
	}
	cout << res << endl;

}

Measured memory_bytes: 72704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(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 print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[110];
    rep(i,0,N) cin >> A[i];
    ll cnt = 0;
    rep(i,0,N){
        ll minj = i;
        rep(j,i,N){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i != minj){
            cnt++;
            swap(A[i], A[minj]);
        }
    }
    printa(A, N);
    print(cnt);
}


Measured memory_bytes: 3176
#include<stdio.h>
double max;
int main(){
	int a;
	scanf("%d",&a);
	int x=a/3;
	for(double i=-1;i<=1;i+=0.0001){
		for(double j=-1;j<=1;j+=0.0001){
			double n=x+i;
			double m=x+j;
			double nm=a-n-m;
			if(n<0||m<0||nm<0)continue;
			if(max<n*m*nm)max=n*m*nm;
		}
	}
	printf("%lf",max);
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, A[MAXN], ind;

int main() {
    fast_io;

    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> A[i];
        if (A[i] == ind + 1) ind++;
    }
    if (ind == 0) return cout << -1 << endl, 0;
    cout << n - ind << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {
  int sum = 0;
  for ( int i = 0; i < 10; i++ ) {
	int val;
	cin >> val;
	sum += val;
  }
  cout << sum << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

char s;

int main()
{
  std::cin >> s;

  std::cout << char(s+1) << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi b(n);
  rep(i,n-1)cin >> b[i];
  ll ans = 0;

  rep(i,n-2){
    ans+=min(b[i],b[i+1]);
  }
  ans+=b[0];
  ans+=b[n-2];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3596