akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());
 
signed main()
{
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    ll MA = -1;
    rep(i,n){
        cin>>a[i];
        chmax(MA,a[i]);
    }

    ll ma = MA + 1,mi = 0; //maは右端+1, miは左端-1
    while(ma - mi > 1){
        ll mid = (ma + mi) /2;
        //midの値以下の長さにできるか
        ll ttl = 0;
        rep(i,n){
            if(a[i] > mid){
                ttl += (a[i] + mid-1)/mid - 1;//切り上げ
                //out(ttl);
            }
        }
        //cout << "ttl "<< ttl << " mid " << mid << endl;
        if(ttl <= k)ma = mid; //切れる時最小を増加
        else mi = mid; //切れない時
    }
    out(ma);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    vi v = {a,b,c};
    sort(v.begin(),v.end());
    int m = v[2];
    FOR(i,0,k){
        m *= 2;
    }
    cout << m + v[0] + v[1] << endl;
}   

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
vector<ll> v[100009];
ll vis[100009];
ll dis[100009];

ll dfs(ll node)
{
    if(vis[node])
        return dis[node];
    vis[node] = 1;

    dis[node] = 0;
    for(ll i=0;i<v[node].size();i++)
    {
        dis[node] = max(dis[node],dfs(v[node][i])+1);
    }
    return dis[node];
}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    sff(n,m);
    rep0(i,m)
    {
        sff(x,y);
        v[x].pb(y);
    }
    ll ans = 0;
    for(i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            ans = max(ans,dfs(i));
        }
    }
    pf(ans);
    return 0;
}



Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}

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

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	
	ll t,n,m,k=0,i,j;
	cin >> t;
    ll a[t+2];
    for(i=0;i<t;i++)
    {
        cin >> a[i];
    }
    sort(a,a+t, greater <ll> ());
    n=t-2;
    m=a[0];
    i=1;
    while(n>1)
    {
        m+=2*a[i];
        n-=2;
        i++;
    }
    if(n==1)
        m+=a[i];
    cout << m << "\n";
	return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

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

    ll ans = 0;
    rep(i, N - 1) {
        if (A[i] % 2 == 1 && A[i + 1] != 0) {
            A[i + 1]--;
            ans += (A[i] + 1) / 2;
        } else {
            ans += A[i] / 2;
        }
    }

    ans += A[N - 1] / 2;

    cout << ans << endl;
}

Measured memory_bytes: 640
import numpy as np

N = W = 0
g = []
MAX_V = 100100


def get_input():
    global N, W, g
    N, W = map(int, input().split())
    g = []
    for _ in range(N):
        g.append([int(x) for x in input().split()])


def dpcalc():
    global N, W, g
    # 動的計画法のテーブルを初期化
    dp = np.full((N + 1, MAX_V + 1), 10 ** 11)
    # dp = [[10 ** 11] * (MAX_V + 1) for _ in range(N + 1)]

    # テーブルをiの小さい方から順に計算してゆく
    r = 1
    for i in range(1, N + 1):
        w, v = g[i - 1]
        dp[i][:v + 1] = np.minimum(dp[i - 1][:v + 1], w)
        dp[i][v + 1:v + r] = np.minimum(dp[i - 1][1: r] + w, dp[i - 1][v + 1:v + r] )
        
        r += v
        
    for i in range(MAX_V, -1, -1):
        if dp[N][i] <= W:
            return i
    return 0


get_input()
print(dpcalc())


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

int N, K, answer = 0;
map<int, int> num_map;
vector<int> num_vector;

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

  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    num_map[num]++;
  }

  for (auto itr = num_map.begin(); itr != num_map.end(); itr++) {
    num_vector.push_back(itr->second);
  }
  sort(num_vector.begin(), num_vector.end());

  if (num_vector.size() > K)
    for (int i = 0; i < num_vector.size() - K; i++) answer += num_vector[i];

  cout << answer << endl;
}


Measured memory_bytes: 13440
#include <iostream>
#include <string>
#include <numeric>

using namespace std;

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

    int count = 0;
    for (int i = 0; i < 3; i++)
    {
        if(s[i] == t[i]){
            count++;
        }
    }

    cout << count << endl;
 
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int m = in.nextInt();
		if (m == 0) {
			System.out.println(1);

		} else {
			int[] a = new int[m];
			int[] b = new int[m];
			for (int i = 0; i < m; i++) {
				a[i] = in.nextInt();
				b[i] = in.nextInt();
			}
			int[] f = new int[n + 1];
			int[] c = new int[n + 1];
			setFrend(f, c, a, b);
			int ans = 1;
			for (int i = 1; i <= n; i++)
				if (c[i] > ans)
					ans = c[i];
			System.out.println(ans);
		}
	}

	private static void setFrend(int[] f, int[] c, int[] a, int[] b) {
		for (int i = 0; i < a.length; i++)
			setPair(f, c, a[i], b[i]);
	}

	private static void setPair(int[] f, int[] c, int a, int b) {
		int at = getTop(f, c, a);
		int bt = getTop(f, c, b);
		if (at == bt)
			return;
		c[at] += c[bt];
		c[bt] = 0;
		f[bt] = at;
	}

	private static int getTop(int[] f, int[] c, int x) {
		if (f[x] == x)
			return x;
		if (f[x] == 0) {
			c[x] = 1;
			f[x] = x;
			return x;
		}
		int t = getTop(f, c, f[x]);
		f[x] = t;
		return t;
	}
}


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

long long int binpow(long long int a, long long int b)
{
    long long int res = 1;
    while (b > 0)
    {
        if (b & 1) //If b is odd
            res = res * a;
        a = a * a;
        b >>= 1; //b=b/2;
    }
    return res;
}
int main()
{
    ll i, n, k;
    cin >> n >> k;
    ll k1 = n / k;
    ll k2 = n % k;

    ll a[k + 2];
    a[0] = k1;
    for (i = 1; i <= k2; i++)
    {
        a[i] = k1 + 1;
    }

    for (i = k2 + 1; i < k; i++)
        a[i] = k1;
    ll count = 0;
    count = binpow(k1, 3);
    if (k % 2 == 1)
    {
        cout << count;
        exit(0);
    }

    ll t = a[k / 2];
    count = count + binpow(t, 3);
    cout << count;

    return (0);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
#define ll long long int 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define f first
#define s second

const ll mod = 1000000007;
const ll N = 1e6;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k; cin >> n >> k;
	vector<int> v(n+2,false);
	vector<int> a(n+2);
	rep(i,1,n+1){
		//v[i]=false;
		cin >> a[i];
	}
	int count = 0 ;
	int i = 1;
	int c = -1;
	int offset=-1;
	while(count < n){

		if(v[i] == false){
			v[i] =true;
			i = a[i];
			count++;
		}
		else{
			c = i;
			offset = count;
			break;
		}
		if(count == k){
			cout << i;
			return 0;
		}
	}
	vector<int> cycle;
	cycle.pb(c);
	ll remain = k - offset;
	i = a[c];
	while(i != c){
		cycle.pb(i);
		i=a[i];
	}
	ll cycle_length = cycle.size();
	cout << cycle[(remain)%cycle_length];
 	return 0;
}

Measured memory_bytes: 5388
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,Q;
    string S;
    cin >> N >> Q >> S;
    int L[100010],R[100010];
    for(int i = 0;i < Q;i++) cin >> L[i] >> R[i];
    bool frags[N];
    for(int i = 0;i < N-1;i++) frags[i] = 0;
    for(int i = 0;i < N-1;i++){
      if(S[i] == 'A'){
        if(S[i+1] == 'C') frags[i] = 1;
      }
    }
    int num[N];
    num[0] = 0;
    num[1] = 0;
    for(int i = 0;i < N-1;i++){
      if(frags[i]){
        num[i+2] = num[i]+1;
      }else{
        num[i+2] = num[i+1];
      }
    }
    for(int i = 0;i < Q;i++){
      cout << num[R[i]] - num[L[i]] << endl;
    }
}

Measured memory_bytes: 2304
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var card = Console.ReadLine().Split().Select(long.Parse).Select(x => x * 2).ToArray();
            long ave = card.Sum() / 2;
            var rSum = new long[n];
            for (int i = 1; i < n; i++) rSum[i] = rSum[i - 1] + card[i - 1];
            Console.WriteLine(rSum.Select(x => Math.Abs(x - ave)).Where((x, y) => y != 0).Min());
        }
    }
}

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

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

  vector<string> name(N);
  for (int i=0; i<N; i++) cin >> name.at(i);

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

  int count=1;

  for (int i=0; i<N-1; i++) {
    if(N==1) break;
    if(name.at(i)==name.at(i+1)) continue;
    count++;
  }

  cout << count << endl;

}


Measured memory_bytes: 9520
#include <iostream>
using namespace std;
int t[31];
int main(int argc, const char * argv[])
{
    int n,m,ans=0;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int a;
            cin>>a;
            t[a]++;
        }
    }
    for(int i=1;i<=m;i++)
        if(t[i]==n) ans++;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
  int D, N;
  cin >> D >> N;
  int result = 1;
  for (int i = 0; i < D; i++) {
    result *= 100;
  }
  if (N == 100) {
    result = result * 101;
  } else {
    result *= N;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll A[100000];
ll B[100000];
ll C[100000];

int main(){
  int N, M;
  cin >> N >> M;
  rep(i, N){
    cin >> A[i];
  }
  sort(A, A + N);

  vector<pair<ll, ll>> v;
  rep(i, M){
    cin >> B[i];
    cin >> C[i];
    v.emplace_back(C[i], B[i]);
  }
  sort(v.begin(), v.end());
  int idx = 0;
  rrep(i, M){
    ll c = v[i].first;
    ll b = v[i].second;
    //printf("%lld %lld\n", c, b);
    rep(j, b){
      if(idx == N)break;
      if(A[idx] < c){
        A[idx] = c;
      }
      idx++;
    }
  }
  ll ans = 0;
  rep(i, N){
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MX 105

int pos[MX];

int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
        scanf("%d",&pos[i]);
    sort(pos,pos+n);
    printf("%d\n",pos[n-1]-pos[0]);
    return 0;
}


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

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

int main() {
  ll N,lt,la;
  cin >> N;
  cin >> lt >> la;
  for(int i=1;i<N;i++) {
    ll t,a,tmp,tmp2;
    cin >> t >> a;
    if(lt<=t&&la<=a) {
      lt=t;
      la=a;
    }else if(lt<t&&la>a) {
      tmp=la/a;
      if(la%a!=0) tmp++;
      lt=t*tmp;
      la=a*tmp;
    }else if(la<a&&lt>t) {
      tmp=lt/t;
      if(lt%t!=0) tmp++;
      lt=t*tmp;
      la=a*tmp;
    }else {
      tmp=lt/t;
      if(lt%t!=0) tmp++;
      tmp2=la/a;
      if(la%a!=0) tmp2++;
      //cout << tmp << " " << tmp2 << endl;
      if(la>a*tmp) {
        lt=t*tmp2;
        la=a*tmp2;
        continue;
      }
      if(lt>t*tmp2) {
        lt=t*tmp;
        la=a*tmp;
        continue;
      }
      if(t*tmp+a*tmp<t*tmp2+a*tmp2) {
        lt=t*tmp;
        la=a*tmp;
      }else {
        lt=t*tmp2;
        la=a*tmp2;
      }
    }
  }
  cout << lt+la << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    cin.tie(0);
    int x,y;
    cin>>x>>y;
    if(y%2!=0){
        cout<<"No";
        return 0;
    }
    else{
        if(2*x>y){
            cout<<"No";
            return 0;
        }
        else if(4*x<y){
            cout<<"No";
            return 0;
        }
        else{
            cout<<"Yes";
            return 0;
        }
    }
}

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

int main(){
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    for(auto& i : A)cin >> i;
    vector<unsigned long> r(N), l(N);
    partial_sum(A.begin(), A.end() - 1, r.begin() + 1, [](auto a, auto b){return __gcd(a, b);});
    partial_sum(A.rbegin(), A.rend() - 1, l.rbegin() + 1, [](auto a, auto b){return __gcd(a, b);});

    unsigned long ans{0};
    transform(r.begin(), r.end(), l.begin(), r.begin(), [&ans](auto a, auto b){return ans = max(ans, __gcd(a, b));});
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n,0);
    int x[20][20]={},y[20][20]={};
  for(int i=0;i<20;i++) for(int j=0;j<20;j++) x[i][j]=0,y[i][j]=0;
  for(int i=0;i<n;i++){
     cin>>a[i];
     for(int j=0;j<a[i];j++){
         cin>>x[i][j]>>y[i][j];
         x[i][j]=x[i][j]-1;
     }
  }
  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
   int flag=0;
    for(int l=0;l<n;l++){
      if(!(bit&(1<<l))) continue;
      
        for(int j=0;j<a[l];j++){
         if(y[l][j]==1&&!(bit&(1<<x[l][j]))) flag=1;
         if(y[l][j]==0&&(bit&(1<<x[l][j]))) flag=1;
      
      }
    }
    if(!flag){
      int count=0;
      for(int i=0;i<n;i++){
        if(bit&(1<<i)) ++count;
      }
      ans=max(ans,count);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;

int main() {
    //freopen("in.txt", "r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin>>n;
    int A[n+1], memo[n+1];
    memset(memo, 0, sizeof(memo));
    for (int i=1;i<=n;++i) cin>>A[i];

    for (int i=n;i>=1;i--){
        if (i>n/2){
            memo[i] = A[i];
        }
        else{
            int cnt = 0;
            int toAdd = 0;
            for (int j=n/i;j>=1;--j){
                int m = i*j; 
                if (memo[m]==1) cnt++;
                else if (m<=n/2) toAdd = m;
            }
            if ((cnt%2==0 && A[i]%2!=0) || (cnt%2!=0 && A[i]%2==0))
                memo[toAdd] = 1;
        }
    }
    int cnt = 0;
    for (int i=1;i<=n;++i) if (memo[i]==1) cnt++;
    if (cnt>0) cout<<cnt<<endl;
    bool solution = false;
    for (int i=1;i<=n;++i) 
        if (memo[i]==1){
            solution = true;
            cout<<i<<" ";
        }
    
    if (!solution) cout<<"0";
    cout<<endl;

    return 0;
}

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

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

int n;
cin >> n;
vector<int> a(n);
for(int &x : a)
	cin >> x;
sort(a.begin(), a.end());

const bool ok = a.back() < accumulate(a.begin(), a.end() - 1, 0);
cout << (ok?"Yes":"No");
	return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt(), m = sc.nextInt();
            if ((n | m) == 0)
                break;
            int[][] l = new int[5][2];
            l[0][0] = 0;
            l[0][1] = n + m;
            for (int i = 1; i < 5; i++) {
                l[i][0] = i;
                l[i][1] = sc.nextInt() + sc.nextInt();
            }
            Arrays.sort(l, new Comparator<int[]>() {
                public int compare(int[] a, int[] b) {
                    return b[1] - a[1];
                }
            });
            System.out.println((char)(l[0][0]+'A')+" "+l[0][1]);
        }
    }
}



Measured memory_bytes: 30436
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<EntryPoint>]
let main _ =
    let [|M;D|] = reada int

    let mutable ans = 0
    for m in 1..M do
        for d in 10..D do
            let d1,d2 = d / 10, d % 10
            if d1 * d2 = m && d1 >= 2 && d2 >= 2 then
                ans <- ans + 1

    ans |> printfn "%d"
    0 // return an integer exit code


Measured memory_bytes: 14044
package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	n := sint64()
	printf("%d\n", sol(n))
}

func sol(n int64) int64 {
	rem := n % 1000
	if rem != 0 {
		return 1000 - rem
	}
	return 0
}


Measured memory_bytes: 1840
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b = LI()
    if max(a,b) > 9:
        return -1

    return a*b


print(main())





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

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


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


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

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


bool contain(set<int> &s, int a) {
    return s.find(a) != s.end();
}

int main() {
    set<int> a = {
            1, 3, 5, 7, 8, 10, 12,
    };
    set<int> b = {4, 6, 9, 11};
    set<int> c = {2};

    int x, y;
    cin >> x >> y;

    if (
            contain(a, x) == contain(a, y)
            && contain(b, x) == contain(b, y)
            && contain(c, x) == contain(c, y)
            ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    ll a;
    map<ll, ll> iro;
    bool flag = false;
    ll cnt = 0;
    ll ziyuu = 0;
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        iro[a]++;
    }
    while (cnt < 3200)
    {
        for (int i = 0; i < 400; i++)
        {
            if (iro[cnt])
            {
                flag = true;
            }
            cnt++;
        }
        if (flag)
        {
            sum++;
        }
        flag = false;
    }
    while (cnt < 5000)
    {
        for (int i = 0; i <= 2000; i++)
        {
            ziyuu += iro[cnt];
            cnt++;
        }
    }
    if (sum == 0 && ziyuu > 0)
    {
        cout << "1" << endl;
    }
    else
    {
        cout << sum;
    }
    cout << " ";
    cout << sum + ziyuu << endl;
}


Measured memory_bytes: 512
N = int(raw_input())
A = map(int, raw_input().split())

counter = 0
for i in xrange(N):
  minj = i
  for j in xrange(i, N):
    if A[j] < A[minj]:
      minj = j
  if i != minj:
    tmp = A[i]
    A[i] = A[minj]
    A[minj] = tmp
    counter += 1
print " ".join(map(str, A))
print counter

Measured memory_bytes: 6480
n, k = map(int, input().split())
p = list(map(int, input().split()))

e = [(p[i]+1)/2 for i in range(n)]

tmp = sum(e[:k])
ans = tmp
for i in range(n-k):
    tmp += (e[i+k]-e[i])
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 32180
#include <stdio.h>
int main(){
	int i;
	int min;
	int K=0;
	int U=0;
	int P=0;
	int C=0;
	char a[1000];
	for(i=0;i<1000;i++)
	{
		a[i]=0;
	}
	scanf("%s", a);
	for(i=0;i<1000;i++)
	{
		if(a[i]==75)
		{
			K++;
		}
		else if(a[i]==85)
		{
			U++;
		}
		else if(a[i]==80)
		{
			P++;
		}
		else if(a[i]==67)
		{
			C++;
		}
	}
	min=K;
	if(min>U)
	{
		min=U;
	}
	if(min>P)
	{
		min=P;
	}
	if(min>C)
	{
		min=C;
	}
	printf("%d\n", min);
	return 0;
}

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

int main(){
    string str1,str2;
    cin>>str1>>str2;

    int dp[str1.length()+1][str2.length()+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=str1.length();i++){
        for(int j=1;j<=str2.length();j++){
            if(str1[i-1]==str2[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
string str;
    int j=str2.length();
    int i=str1.length();

    while(i>0 && j>0){
        if(str1[i-1]==str2[j-1]){
            str.push_back(str1[i-1]);
            i--;
            j--;
        }
        else if(dp[i][j-1]>dp[i-1][j]){
            j--;
        }
        else{
            i--;
        }
    }
    reverse(str.begin(),str.end());
    cout<<str<<endl;
    
    

}

Measured memory_bytes: 35456
n,c = gets.chomp.split(" ").map(&:to_i)
x = n.times.map{gets.chomp.split(" ").map(&:to_i)}.sort_by{|i,j|i}
y = Marshal.load(Marshal.dump(x))
rx,ry = 2.times.map{Array.new(n+1,0)}
ans = 0
temp = 0
y.reverse!
for i in 0..n-1
  y[i][0] = c-y[i][0]
end
x.unshift([0,0])
y.unshift([0,0])
for i in 1..n
  x[i][1] += x[i-1][1]
  y[i][1] += y[i-1][1]
  rx[i] = [x[i][1]-2*x[i][0],rx[i-1]].max
  ry[i] = [y[i][1]-2*y[i][0],ry[i-1]].max
end
for i in 0..n
  temp = y[i][1]-y[i][0]+rx[n-i]
  ans = [temp,ans].max
  temp = x[i][1]-x[i][0]+ry[n-i]
  ans = [temp,ans].max
end
puts ans

Measured memory_bytes: 31580
#include <iostream>
#include <cassert>

template<int Modulus>
struct modint {
	using value_type = int;
	static constexpr int mod = Modulus;
	static_assert(mod > 1, "Modulus must be greater than 1");

private :
	value_type x;

	template<class T>
	constexpr value_type normalize (T value) noexcept {
		if (value < 0) {
			value = (-value) % mod;
			return (value ? value : mod - value);
		}
		return (value % mod);
	}

public :
	constexpr modint () noexcept : x(0) { }

	template<class T>
	constexpr modint (T value) noexcept : x(normalize(value)) { }

	constexpr modint &operator+= (const modint &p) noexcept {
		if ((x += p.x) >= mod) x -= mod;
		return (*this);
	}

	constexpr modint &operator-= (const modint &p) noexcept {
		if ((x += mod - p.x) >= mod) x -= mod;
		return (*this);
	}

	constexpr modint &operator*= (const modint &p) noexcept {
		x = (int)(1LL * x * p.x % mod);
		return (*this);
	}

	constexpr modint &operator/= (const modint &p) noexcept {
		return ((*this) *= p.inverse());
	}

	constexpr modint operator+ (const modint &p) const noexcept {
		return (modint(*this) += p);
	}

	constexpr modint operator- (const modint &p) const noexcept {
		return (modint(*this) -= p);
	}

	constexpr modint operator* (const modint &p) const noexcept {
		return (modint(*this) *= p);
	}

	constexpr modint operator/ (const modint &p) const noexcept {
		return (modint(*this) /= p);
	}

	constexpr modint pow (long long exp) const noexcept {
		modint value(1), buff(x);
		while (exp) {
			if (exp & 1) value *= buff;
			buff *= buff;
			exp >>= 1;
		}
		return value;
	}

	constexpr modint inverse () const noexcept {
		return pow(Modulus - 2);
	}

	friend std::ostream &operator<< (std::ostream &os, const modint &p) {
		return (os << p.x);
	}

	friend std::istream &operator>> (std::istream &is, modint &p) {
		long long v;
		is >> v;
		p = modint(v);
		return (is);
	}

};


#include <iostream>
constexpr int MOD = 1'000'000'007;

modint<MOD> binom (int n, int r) {
	if (n < r or n < 0 or r < 0) return modint<MOD>(0);
	r = std::min(r, n - r);
	modint<MOD> ans = 1;
	for (int i = n; i > n - r; i--) ans *= i;
	for (int i = 2; i <= r; i++) ans /= i;
	return ans;
}

int main() {
	int n, a, b;
	std::cin >> n >> a >> b;
	
	modint<MOD> ans = modint<MOD>(2).pow(n) - 1;
	ans -= (binom(n, a) + binom(n, b));
	
	std::cout << ans << '\n';
	
	return 0;
	
}

Measured memory_bytes: 3608
#include<stdio.h>

typedef struct que{
  char name[100];
  int time;
}S;

int head, tail;
S Q[100000];

void initialize(){
  head = 0;
  tail = 0;
}

void enqueue(S x){
  Q[tail] = x;

  tail = (tail+1)%100000;
}

S dequeue(){
  S x;

  x = Q[head];

  head = (head+1)%100000;

  return x;
}

int main(){
  int n,q,t=0,i;
  S Q2;

  initialize();

  scanf("%d%d", &n, &q);


  tail = n;

  for(i = 0; i < n; i++)
    scanf("%s%d", Q[i].name, &Q[i].time);

  while(tail != head){
    Q2 = dequeue();

    if(Q2.time-q <= 0){     
      t += Q2.time;
      printf("%s %d\n", Q2.name, t);
    }

    else{
      Q2.time = Q2.time - q;
      enqueue(Q2);
      t += q;
    }
  }

  return 0;
}

Measured memory_bytes: 10756
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rec(n,i) for(int i=0;i<n;i++)
using namespace std;
int main() {
	int p, q, r;
	cin >> p >> q >> r;
	int ans=(p+q+r)-max(p, max(q, r));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
alist=[0]*(m+1)
for i in range(n):
  blist=list(map(int, input().split()))
  for j in range(blist[0]):
    alist[blist[j+1]]+=1
cnt=0
for i in range(m+1):
  if alist[i]==n:
    cnt+=1
print(cnt)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


// O( 26 * n )
string lcs( const string& s, const string& t )
{
	// dp[i][j] : sのi番目とtのj番目までの最長共通部分文字列
	vector< vector<ll> > dp( s.length()+1, vector<ll>( t.length()+1, 0 ) );
	REP( i, s.length() ) REP( j, t.length() )
	{
		dp[i+1][j+1] = max( dp[i][j+1], dp[i+1][j] );
		if( s[i] == t[j] )
			dp[i+1][j+1] = max( dp[i+1][j+1], dp[i][j] + 1 );
	}
	// Reconstruct
	string ret = "";
	ll i = s.length(); ll j = t.length();
	while( ret.length() < dp[s.length()][t.length()] )
	{
		if( dp[i][j] == dp[i-1][j] ) --i;
		else if( dp[i][j] == dp[i][j-1] ) --j;
		else --i, --j, ret += s[i];		
	}
	reverse( ALL( ret ) );
	return ret;
}

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

	cout << lcs(s,t) << endl;
	
	return 0;
}

Measured memory_bytes: 70784
function main()
	lines=readlines()
	N=parse(Int,shift!(lines))
	G=[Array{Pair{Int,Int}}(0) for _=1:N]
	for s=lines
		u,v,w=map(x->parse(Int,x),split(s))
		push!(G[u],v=>w)
		push!(G[v],u=>w)
	end
	d=zeros(Int,N)
	used=[false for _=1:N]
	function dfs(u,di)
		d[u]=di%2
		used[u]=true
		for (v,x)=G[u]
			if !used[v]
				dfs(v,di+x)
			end
		end
	end
	dfs(1,0)
	for d=d
		println(d)
	end
end
main()


Measured memory_bytes: 186676
from functools import cmp_to_key
def cmp(a, b):
    w1, s1, v1 = a
    w2, s2, v2 = b
    if min(s1, s2-w1)>min(s2, s1-w2):
        return 1
    else:
        return -1
N = int(input())
dp = [[0]*10001 for _ in range(N)]
wsv = []
for _ in range(N):
    w, s, v = map(int, input().split())
    wsv.append((w, s, v))
wsv.sort(key = lambda x:-(x[0]+x[1]))
w, s, v = wsv[0]
dp[0][s] = v
for i in range(N-1):
    w, s, v = wsv[i+1]
    for j in range(10001):
        if j>=w:
            dp[i+1][min(s, j-w)] = max(dp[i][j]+v, dp[i+1][min(s, j-w)])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
    dp[i+1][s] = max(dp[i+1][s], v)
print(max(dp[-1]))




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

void fail(){
	cout<<"Impossible"<<endl;
	exit(0);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	multiset<int> m;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		m.insert(x);
	}
	int x=*prev(m.end());
	for(int i=0;i<=x;i++){
		auto it=m.find(x-i/2);
		if(it==m.end())
			fail();
		m.erase(it);
	}
	if(m.size()==0||(*m.begin()>=1+(x+1)/2))
		cout<<"Possible"<<endl;
	else
		fail();
}




Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.algorithm, std.array, std.range;

void main() {
  int t = readln.chomp.to!(int);
  long ans = long.min;
  long[][] arr;
  long[][] dp = new long[][](t, t);
  for(long i = 0; i < t; i++)
    arr ~= (readln.chomp.split(" ").map!(to!(long)).array);
  for(int i = 0; i < t; i++) {
    for(int j = 0; j < t; j++) {
      int sum = 0;
      for(int k = j; k < t; k++) {
        sum += arr[i][k];
        dp[j][k] = max(dp[j][k], 0) + sum;
        if (ans < dp[j][k]) ans = dp[j][k];
      }
    }
  }
  writeln(ans);
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int dp[200001];

int main() {
    string s;
    cin >> s;
    reverse(all(s));
    Int x = 1;
    for (Int i = 0; i < (Int)s.size(); i++) {
        dp[i] = (s[i] - '0') * x % 2019;
        x = x * 10 % 2019;
    }
    for (Int i = 0; i < (Int)s.size() - 1; i++) {        
        dp[i + 1] += dp[i];
        dp[i + 1] %= 2019;
    }
    map<Int, Int> mp;
    mp[0]++;
    for (Int i = 0; i < (Int)s.size(); i++) {
        mp[dp[i]]++;
    }
    Int res = 0;
    for (auto i : mp) {
        res += i.second * (i.second - 1) / 2;
    }
    print(res);
    return 0;
}

Measured memory_bytes: 5288
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

template<typename V, typename W>
struct bellman_ford_result {
	bool has_negative_loop; // 減少閉路があるかどうか
	std::vector<W> distance; // 距離
	std::vector<V> prev; // 「前」の頂点
};

/**
 * ベルマンフォード法により最短経路を求める
 *
 * @param edges 辺集合表現による辺の集合
 * @param start 始点
 * @param num 頂点の数
 * @param goal ある終点への経路だけが求まればいい場合はその終点を指定する。
 *             指定した場合、その終点に到達できない頂点への経路に減少閉路があっても has_negative_loop は true にならない。
 *             指定を省略した場合、全ての頂点への最短経路を求め、どこかに減少閉路があると中断される。
 *             なお、指定した場合の方が計算に時間がかかる。
 */
template<typename V, typename W>
bellman_ford_result<V, W> bellman_ford(const std::vector<std::tuple<V, V, W>>& edges, V start, V num, V goal = -1)
{
	std::vector<W> distance(num);
	std::vector<V> prev(num);
	std::fill(distance.begin(), distance.end(), std::numeric_limits<W>::max());
	distance[start] = 0;
	prev[start] = start;

	for (int i = 0; i < (goal == -1 ? num : num * 2); ++i) {
		for (const auto& edge : edges) {
			auto& u = std::get<0>(edge);
			auto& v = std::get<1>(edge);
			auto& w = std::get<2>(edge);
			if (distance[u] != std::numeric_limits<W>::max() && distance[v] > distance[u] + w) {
				distance[v] = distance[u] + w;
				prev[v] = u;
				if (goal == -1) {
					if (i == num - 1) {
						return { true, distance, prev };
					}
				} else {
					if (i >= num - 1 && v == goal) {
						return { true, distance, prev };
					}
				}
			}
		}
	}

	return { false, distance, prev };
}

int main()
{
	// ABC137E

	long N, M, P;
	std::vector<std::tuple<long, long, long>> edges;

	std::cin >> N >> M >> P;
	edges.resize(N);
	for (int i = 0; i < M; ++i) {
		long a, b, c;
		std::cin >> a >> b >> c;
		edges.emplace_back(a-1, b-1, c);
	}

	auto bf_edges = edges;
	for (auto& e : bf_edges) {
		std::get<2>(e) = P-std::get<2>(e);
	}

	auto result = bellman_ford(bf_edges, (long)0, N, N-1);
	if (result.has_negative_loop) {
		std::cout << "-1\n";
	} else {
		std::cout << std::max(0L, -result.distance[N-1]) << "\n";
	}
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int ans = m;
	for (int i = 0; i <= n - m; i++) {
		int x = 0;
		for (int j = 0; j < m; j++) {
			if (t[j] != s[i + j])
				x++;
		}
		ans = min(x, ans);
	}
	cout << ans ;
}


Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    int mini = 1e9;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        mini = min(mini, p);
        ans += p <= mini;
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a_list=list(map(int,input().split()))
D={}
for i in a_list:
    if i in D:
        D[i]+=1
    else:
        D[i]=1
ans=0
for i in D:
    if D[i]>=i:
        ans+=D[i]-i
    else:
        ans+=D[i]
print(ans)


Measured memory_bytes: 67112
#include <stdio.h>
int main() {
	long long a, b, x,f=0;
	scanf("%lld%lld%lld", &a, &b, &x);
	if (a % x == 0) f++;
	printf("%lld\n", b/x-a/x+f); //aがxで割れたら＋１
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int main() {
  ll N, M; cin >> N >> M;
  ll b[100001];
  for (ll i = 0; i < 100001; i++) {
    b[i] = 1;
  }
  for (ll i = 0; i < M; i++) {
    ll x; cin >> x; b[x] = 0;
  }
  ll res[100001]; res[0] = 1; res[1] = b[1];
  for (ll i = 2; i <= N; i++) {
    res[i] = (res[i-1]*b[i-1]+res[i-2]*b[i-2])%mod * b[i];
  }
  cout << res[N] << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  int n;
  cin >> n;

  if(n==1){
	cout << "Hello World\n";
  }
  else{
	int a,b;
	cin >> a >> b;
	cout << (a+b) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>) {
	val abc = readLine()!!.split(" ").map{ it.toInt() }
	val k = readLine()!!.toInt()
	val m=abc.max()!!
	val ans = abc.sum()-m + m*Math.pow(2.toDouble(),k.toDouble()).toLong()
	println(ans)
}

Measured memory_bytes: 36232
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	int N, K;
	std::cin >> N >> K;
	std::vector<double> vec(N);
	double min = 0, max = 0;
	for (auto& v : vec)
	{
		std::cin >> v;
		max = std::max(max, v);
	}
	for (auto _ : boost::irange(200))
	{
		auto mid = (max + min) / 2;
		int sum = 0;
		for (auto&& v : vec)
		{
			int a = v / mid;
			if (mid * a == v)
			{
				--a;
			}
			sum += a;
		}
		if (sum <= K)
		{
			max = mid;
		}
		else
		{
			min = mid;
		}
	}
	std::cout << int(std::ceil(max)) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 4780
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		try{
			Scanner sc = new Scanner(System.in);
			int n=sc.nextInt();
			double a[] = new double[n];
			int b[] = new int[7];
			Arrays.fill(b, 0);

			for(int i=0; i<n; i++)
				a[i]=sc.nextDouble();
			for(int i=0; i<n; i++)
			{
				if(a[i]<165.0)
					b[1]++;
				if(165.0<=a[i]&& a[i]<170.0)
					b[2]++;
				if(170.0<=a[i]&&a[i]<175.0)
					b[3]++;
				if(175.0<=a[i]&&a[i]<180.0)
					b[4]++;
				if(180.0<=a[i]&&a[i]<185.0)
					b[5]++;
				if(a[i]>=185.0)
					b[6]++;
			}
			for(int i=1; i<=6; i++)
			{
				System.out.print(i+":");
				for(int j=0; j<b[i]; j++)
					System.out.print("*");
				System.out.println();
			}
		}catch(Exception e){}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  ll N;
  string S;
  cin >> N >> S;
  vector<ll> W(N),E(N);
  W[0]=0;
  for(int i=0;i<N-1;i++) {
    int west=0;
    if(S[i]=='W') west++;
    W[i+1] = W[i] + west;
  }

  E[N-1]=0;
  for(int i=N-1;i>0;i--) {
    int east=0;
    if(S[i]=='E') east++;
    E[i-1] = E[i] + east;
  }
  vector<ll> ANS(N);
  for(int i=0;i<N;i++) {
    ANS[i]= (E[i]+W[i]);
  }
  sort(ANS.begin(),ANS.end());
  cout << ANS[0] << endl;
}

Measured memory_bytes: 7684
#include<stdio.h>
int main()
{
	int n,a[21],b[21],c[21],i,x,y;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(i=1;i<=n-1;i++){
		scanf("%d",&c[i]);
	}
	x=0;
	for(i=1;i<=n;i++){
		x+=b[a[i]];
		if(a[i]+1==a[i+1]){
			x+=c[a[i]];
		}
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char c = sc.next().charAt(0);
		char a = '0';
		switch (c) {
			case 'A':
			a = 'T';
			break;
			case 'T':
			a = 'A';
			break;
			case 'G':
			a = 'C';
			break;
			case 'C':
			a = 'G';
			break;
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

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


Measured memory_bytes: 3620