akhauriyash/Code-Regression huggingface dataset:
N,ave = map(int,input().split())
card_ls = list(map(int, input().split()))
#dp[i+1][n][s] := i番目までのカード(0idx)からn枚使って合計がsとなるパターンの数
dp = [[[0]*(ave*N+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for n in range(N):
        for s in range(ave*N+1):
            # i番目を新しく使う
            if s+card_ls[i] < ave*N+1:
                dp[i+1][n+1][s+card_ls[i]] += dp[i][n][s]
            # i番目を使わない
            dp[i+1][n][s] += dp[i][n][s]

#print(dp)
ans = 0
for n in range(1,N+1):
    ans += dp[N][n][n*ave]
print(ans)

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

int main() {
	long N;
	cin >> N;
	vector<long> H(N,0);
	for(int i = 0;i<N;i++)
	{
		cin >> H.at(i);
	}
	long mx = 0,cnt = 0;
	for(int i = 1;i<N;i++)
	{
		if(H.at(i-1) < H.at(i))
		{
			mx = max(mx,cnt);
			cnt = 0;
		}
		else
		{
			cnt++;
		}
	}
	mx = max(mx,cnt);
  cout << mx << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
string S;
/*==================================================*/
/*function*/

/*==================================================*/

int main(){

    cin>>S;

    bool alp[26];

    if(S.size() < 26){
        REP(j,0,26) alp[j] = false;
        REP(j,0,S.size()){
            alp[int(S[j] - 'a')] = true;
        }
        REP(j,0,26){
            if(!alp[j]){
                cout<<S<<char('a' + j)<<endl;
                return 0;
            }
        }
    }else{
        RREP(i,0,S.size()){
            REP(j,0,26) alp[j] = false;
            REP(j,0,i){
                alp[int(S[j] - 'a')] = true;
            }

            REP(j,0,26){
                if(!alp[j] && S[i] < char('a' + j)){
                    cout<<S.substr(0,i)<<char('a' + j)<<endl;
                    return 0;
                }
            }
        }
    }

    if(S.size() == 26){
        cout<<-1<<endl;
        return 0;
    }else{
        REP(j,0,26){
            if(!alp[j]){
                cout<<S<<char('a' + j)<<endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    string a,b,c;
    char x,y,z,w;
    int d,e,f;
    cin>>a>>b>>c;
    d=a.size();
    x=a[d-1];
    y=b[0];
    e=b.size();
    z=b[e-1];
    w=c[0];

    if(x==y && z==w)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 3552
import itertools

## N
n_int = int(input())

## P
p_int_list = list(map(int, input().split()))
## 結合して1つの数値にする。
p_int = int("".join(map(str, p_int_list)))

## Q
q_int_list = list(map(int, input().split()))
## 結合して1つの数値にする。
q_int = int("".join(map(str, q_int_list)))

## 総数リスト
n_list = []
for i in range(n_int):
    n_list.append(i + 1)

p_cnt = 0
q_cnt = 0
## 順列を生成してループで列挙
for perm_arr in itertools.permutations(n_list, n_int):

    perm_int = int("".join(map(str, perm_arr)))

    ## 入力数値以下の場合は、カウント 1加算
    if perm_int <= p_int :
        p_cnt += 1

    if perm_int <= q_int :
        q_cnt += 1

    ## 全ての入力数値を超えた場合は、break
    if  perm_int > p_int \
    and perm_int > q_int :
        break

print(abs(p_cnt - q_cnt))


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

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

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

int main(void){

  int x,y;
  cin >> x >> y;
  if(x == y ) cout << "Yes" << endl;
  else if( (x==4 || x==6 || x==9|| x==11) &&
      (y==4 || y==6 || y==9|| y==11)) cout << "Yes" << endl;

  else if( (x==1 || x==3 || x==5|| x==7 || x==8|| x==10|| x==12) &&
      (y==1 || y==3 || y==5|| y==7 || y==8|| y==10 ||y==12)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string N;cin>>N;
  cout << (N[0]=='9'||N[1]=='9'? "Yes":"No")<<endl;
  return 0;
}


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

int N;
int A[3010];
long dp[2][3010][3010];


long calcdp(bool p, int i, int j){
    if (dp[p][i][j] != LONG_MAX) {
        return dp[p][i][j];
    }

    if (i == j-1) {
        if (p) {
            dp[p][i][j] = A[i];
        } else {
            dp[p][i][j] = -A[i];
        }
        return dp[p][i][j];
    } else {
        if (p) {
            dp[p][i][j] = max(calcdp(not(p), i+1, j) + A[i], calcdp(not(p), i, j-1) + A[j-1]);
        } else {
            dp[p][i][j] = min(calcdp(not(p), i+1, j) - A[i], calcdp(not(p), i, j-1) - A[j-1]);
        }
        return dp[p][i][j];
    }
}


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

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 3010; j++) {
            for (int k = 0; k < 3010; k++) {
                dp[i][j][k] = LONG_MAX;
            }
        }
    }

    cout << calcdp(true, 0, N) << endl;

    return 0;
}

Measured memory_bytes: 142080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//__uint128_t
const ll MOD = 1e9+7;


vector<ll> D(1e6+5, 1); 
vector<ll> Eratosthenes(ll N){
    vector<bool> is_prime(N+1, true);
    vector<ll> P;
    for( int i = 2; i <= N; i++ ){
        if( is_prime[i] ){
            D[i] = i;
            for( int j = 2 * i; j <= N; j += i ) {
                is_prime[j] = false;
                D[j] = i;
            }
            P.emplace_back( i );
        }
    }
    return P;
}


int main(){

    ll N; cin >> N;
    vector<ll> V(N);
    for(int i = 0; i < N; i++) cin >> V[i];
    vector<ll> P = Eratosthenes(1e6);
    map<ll, ll> M;
    for(int i = 0; i < N; i++){
        ll x = V[i];
        set<ll> ST;
        while(x != 1){
            ll p = D[x];
            ST.insert(p);
            x = x / p;
        }
        for(auto st : ST) M[st]++;
    }
    ll cnt = 0;
    for(auto m : M) cnt = max(cnt, m.second);
    if(cnt == N) cout << "not coprime" << endl;
    else if(cnt >= 2) cout << "setwise coprime" << endl;
    else cout << "pairwise coprime" << endl;

}

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

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

	int i = 0;
	bool flag = true;

	while(flag && i < s.size()){
		int j = i + 1;
		if(j % 2 == 0){
			if(s[i] == 'L' || s[i] == 'U' ||s[i] == 'D') {}
			else { flag = false;}
		}else{
			if(s[i] == 'R' || s[i] == 'U' ||s[i] == 'D'){}
			else{flag = false;}
		}
		i++;
	}

	if(flag == true) cout << "Yes" << endl;
	else cout << "No" << endl;

}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b;
  cin>>N>>a>>b;
  int c=0;
  int d=0;
  int e=0;
  for(int i=0;i<N;i++){
    int p;
    cin>>p;
    if(p<=a){
      c++;
    }
    else if(p>a&&p<=b){
      d++;
    }
    else{
      e++;
    }
  }
  cout<<min({c,d,e})<<endl;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int x,t;
	cin>>x>>t;
	cout<<max(0,x-t);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
vector<int> graph[N];
int label[N];
void dfs(int v, int c){
    label[v] = c;
    for(auto x: graph[v]){
        if(label[x] != -1)
        continue;
        else
        {
            dfs(x, c);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    int n, m, k;
    cin>>n>>m>>k;
    for(int i = 0; i < m; i++){
        int x, y;
        cin>>x>>y;
        x--; y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    memset(label, -1, sizeof(label));
    int count = 0;
    for(int i = 0; i < n; i++){
        if(label[i] != -1)  continue;
        dfs(i, count);
        count++;
    }
    vector<int> labelCount(n, 0);
    for(int i = 0; i < n; i++){
        labelCount[label[i]]++;
    }
    int ans[n];
    for (int i = 0; i < n; i++)
    {
        ans[i] = labelCount[label[i]] - graph[i].size() - 1;
    }
    for(int i = 0; i < k; i++){
        int x, y;
        cin>>x>>y;
        x--; y--;
        if(label[x] == label[y]){
            ans[x]--; ans[y]--;
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout<<ans[i]<<" ";
    }
    return 0;
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll X;
ll i, j, k;

int main(){
    scanf("%lld", &X);
    if(X>=30){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3764
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int mod=1e9+7;
const int MAXN=5005;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
struct edge{int x,y,next;}a[2*MAXN];int len,last[MAXN];
void ins(int x,int y){len++;a[len].x=x;a[len].y=y;a[len].next=last[x];last[x]=len;}
int tot[MAXN];
int pre[2*MAXN],inv[2*MAXN];
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int n,mx[MAXN];
void init(int x,int fa)
{
	tot[x]=1;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y!=fa)init(y,x),tot[x]+=tot[y],mx[x]=max(mx[x],tot[y]);
	}
	mx[x]=max(mx[x],n-tot[x]);
}
int rt,f[MAXN][MAXN],temp[MAXN];
void dp(int x,int fa)
{
	tot[x]=1;if(x==rt)f[x][1]=1;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y!=fa)
		{
			dp(y,x);
			if(x==rt)
			{
				for(int i=0;i<=tot[x];i++)for(int j=0;j<=tot[y];j++)
					ad(temp[i+j],1LL*f[x][i]*f[y][j]%mod);
				for(int i=0;i<=tot[x]+tot[y];i++)f[x][i]=temp[i],temp[i]=0;
			}
			tot[x]+=tot[y];
		}
	}
	if(fa==rt)
		for(int i=0;i<=tot[x];i++)f[x][i]=1LL*((tot[x]-i)&1?(mod-1):1)*pre[tot[x]]%mod*inv[i]%mod*pre[tot[x]]%mod*inv[i]%mod*inv[tot[x]-i]%mod;
}
int main()
{
	pre[0]=1;for(int i=1;i<2*MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[2*MAXN-1]=pow_mod(pre[2*MAXN-1],mod-2);
	for(int i=2*MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
	}
	init(1,0);
	int cnt=0;
	for(int i=1;i<=n;i++)if(2*mx[i]<=n)++cnt,rt=i;
	if(cnt==2)return pr2(1LL*pre[n/2]*pre[n/2]%mod),0;
	dp(rt,0);int ans=0;
	for(int i=0;i<=n;i++)ad(ans,1LL*f[rt][i]*pre[i]%mod);
	pr2(ans);
	return 0;
}


Measured memory_bytes: 95360
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n;
    cin >> n;
    string s;
    ll keta = 1;
    //n--;
    ll ac = 26;
    while(n>ac){
        n -= ac;
        keta++;
        ac *= 26;
    }
    n--;
    rep(i,keta){
        int a = n%26;
        s+=(char)('a'+a);
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
    // cout << n << endl;
    // cout << keta << endl;
}

Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
 
using namespace std;
 
const int maxn=500005;
typedef long long ll;
 
int read()
{
	int f=0; char c=getchar();
	while(c>'9' || c<'0') c=getchar();
	while(c<='9' && c>='0') {f=f*10+c-'0'; c=getchar();}
	return f;
}


char a,b,c;
 
int main()
{
	cin>>a>>b>>c;
	if(b=='B')
		cout<<"ARC"<<endl;
	else
		cout<<"ABC"<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    int narahatakun=0;
    for(int i=a;i<=b;i++){
        if(c%i==0)narahatakun++;
    }
    cout<<narahatakun<<endl;
}



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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

class union_find {
public:
	union_find(int n)
		: par_(n, -1)
	{}
	void init(int n) {
		par_.assign(n, -1);
	}

	int root(int x) {
		return par_[x] < 0 ? x : par_[x] = root(par_[x]);
	}

	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) {
			return false;
		}
		else {
			if (par_[x] < par_[y]) {
				par_[x] += par_[y];
				par_[y] = x;
			}
			else {
				par_[y] += par_[x];
				par_[x] = y;
			}
			return true;
		}
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	int size(int x) {
		return -par_[root(x)];
	}

private:
	std::vector<int> par_;
};

struct Kruskal {
	ll cost, from, to;
};

int main() {
	ll n, m;
	vector<ll> v;
	ll ans = 0;

	cin >> n >> m;

	union_find uf(n);

	REP(i, n) {
		ll p;
		cin >> p;
		v.push_back(p);
	}

	REP(i, m) {
		ll x, y;
		cin >> x >> y;
		uf.unite(x - 1, y - 1);
	}

	REP(i, n) {
		if (uf.same(i, v[i] - 1)) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1912
mod = 2019
l,r = [int(i) for i in input().split()]

minimum = 2018

for i in range(l,r):
    for j in range(l+1,r+1):
        if minimum == 0:
            break
        elif (i*j)%mod < minimum:
            minimum = (i*j)%mod
        else:
            pass      
    if minimum == 0:
        break
    
print(minimum)
    
    

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

struct edge {
    LL a;
    LL b;
    LL c;
};

bool fills(LL x, vector<bool> &memo, vector<edge> edges) {
    if(memo[x]) {
        return true;
    }
    memo[x] = true;
    REP(i, edges.size()) {
        if(edges[i].a == x) {
            fills(edges[i].b, memo, edges);
        }
    }
    return true;
}
bool fille(LL x, vector<bool> &memo, vector<edge> edges) {
    if(memo[x]) {
        return true;
    }
    memo[x] = true;
    REP(i, edges.size()) {
        if(edges[i].b == x) {
            fille(edges[i].a, memo, edges);
        }
    }
    return true;
}

int main() {
    LL N, M, P;
    cin >> N >> M >> P;
    vector<LL> d;
    d.resize(N + 1);
    fill(ALL(d), LINF);

    vector<edge> edges;
    edges.resize(M);
    REP(i, M) {
        LL a, b, c;
        cin >> a >> b >> c;
        edges[i] = {a, b, -c + P};
    }

    d[1] = 0;
    REP(i, N) {
        REP(j, M) {
            LL a = edges[j].a;
            LL b = edges[j].b;
            LL c = edges[j].c;

            d[b] = min<LL>(d[b], d[a] + c);
        }
    }

    vector<LL> pd;
    pd.resize(N + 1);
    REP(i, N + 1) {
        pd[i] = d[i];
    }
    REP(i, N) {
        REP(j, M) {
            LL a = edges[j].a;
            LL b = edges[j].b;
            LL c = edges[j].c;

            d[b] = min<LL>(d[b], d[a] + c);
        }
    }

    vector<bool> froms;
    froms.resize(N + 1);
    fill(ALL(froms), false);
    fills(1, froms, edges);

    vector<bool> frome;
    frome.resize(N + 1);
    fill(ALL(frome), false);
    fille(N, frome, edges);

    FOR(i, 1, N + 1) {
        if(froms[i] && frome[i] && pd[i] != d[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    LL res = max<LL>(0, -d[N]);
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 199492
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;

int main() {
  int N,d=1;
  cin>>N;
  int64_t ans;
  vector<char> S(N);
  vector<int> T(N,1);
  for(int i=0;i<N;i++) cin>>S.at(i);
  if(N>1){
  for(int i=1;i<N;i++){
    if(S.at(i-1)==S.at(i)) {
      T.at(i-1)=0;
      T.at(i)=0;
    }
  if(T.at(1)==0&&T.at(0)==0){
    ans=6;
    d=2;
  }
  else ans=3;
  }
  for(int i=d;i<N;i++){
    int a=T.at(i-1),b=T.at(i);
     if(a==0&&b==0){
       ans*=3;
       i++;
     }
    else if(a==1&&b==0){
      ans*=2;
      i++;
    }
    else if(a==0&&b==1);
    else if(a==1&&b==1) ans*=2;
    ans%=MOD;
  }
  }
  else ans=3;
  cout<<ans;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;

int b[20];
char a[100];

int main(){
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	cin >> a+1;
	if(a[1]== a[2] && a[2] == a[3]&& a[3] == a[4] || a[1] == a[2] && a[2] == a[3] || a[2] == a[3] && a[3] == a[4])
	{
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n = gets.to_i
ans = 0
prev = 0
n.times{|t|
  a = gets.to_i
  next if ans == -1

  if t == 0 && a > 0
    ans = -1
    next
  end
  
  if a == prev + 1
    ans += 1
    prev = a
    next
  end

  if a <= prev
    ans += a
    prev = a
    next
  end

  ans = -1
}
puts ans


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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

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

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	int n;
	h >> n;
	vi v(n);
	f(i, 0, n, 1)
		h >> v[i];
	int tmp = v[0];
	f(i, 0, n, 1)
		tmp = __gcd(tmp, v[i]);
	if (tmp != 1){
		g << "not coprime";
		return 0;
	}

	si s2;
	int fl2 = 0;
	f(i, 0, n, 1){
		if (s2.find(v[i]) == s2.end())
			s2.insert(v[i]);
		else if (v[i] != 1){
			fl2 = 1;
			break;
		}
	}
	if (fl2 == 1){
		g << "setwise coprime";
		return 0;
	}
	vb vis(1000001), vis2(1000001);
	f(i, 0, n, 1)
		vis2[v[i]] = true;
	lli cnt = 0;
	int mx = *max_element(all(v));
	vi temp(1000001);
	iota(all(temp), 0);
	si s;
	f(i, 2, 1000001, 1){
		if (!vis[i]){
			f(j, i, mx + 1, i){
				vis[j] = true;
				if (vis2[j]){
					if (temp[j] % i == 0){
						cnt++;
						s.insert(i);
					}
					while(temp[j] % i)
						temp[j] /= i;
				}
			}
		}
	}
/*	fit(it, s)
		cerr << *it << NL;
	cerr << NL << cnt << NL;*/
	if (s.size() == cnt)
		g << "pairwise coprime";
	else
		g << "setwise coprime";

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


Measured memory_bytes: 61804
import sys
input=sys.stdin.readline

# 約数を列挙 (ex. 6 => [1,2,3,6])
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

def main():
    N,M = map(int, input().split())
    divs = make_divisors(M)
    for d in divs:
        k = M//d
        if k >= N:
            print(d)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
/*input
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
*/
 
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.14159265
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr
  
struct node{
    ll val;
};
struct Interval {int start, end;};
bool compare(struct node n1, struct node n2) {
    return (n1.val < n2.val);
}
 
 
 ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 











int main() 
{
	ll n; cin>>n;
	ll a[100005];
	ll b[100005];
	ll c[100005];
	repA(i,1,n){cin>>a[i]>>b[i]>>c[i];}
	ll dpa[100005];
	ll dpb[100005];
	ll dpc[100005];
	dpa[1] = a[1];
	dpb[1] = b[1];
	dpc[1] = c[1];

	repA(i,2,n){
		dpa[i] = max(dpb[i-1], dpc[i-1]) + a[i];
		dpb[i] = max(dpa[i-1], dpc[i-1]) + b[i];
		dpc[i] = max(dpb[i-1], dpa[i-1]) + c[i];
	}
	cout<<max(max(dpa[n], dpb[n]), dpc[n])<<endl;
    return 0;  
}



















 

Measured memory_bytes: 8240
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
    int a[n];
    int hash[n+1];
    for(int i=0;i<=n;i++)
    {
        hash[i]=0;
    }
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        hash[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<hash[i]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  ll cnt=0;
  while(1) {
    if(a%2||b%2||c%2) break;
    ll na=b/2+c/2;
    ll nb=a/2+c/2;
    ll nc=a/2+b/2;
    a=na;
    b=nb;
    c=nc;
    cnt++;
    if(cnt>1e6) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(a: int, s: str):
    print(s if a >= 3200 else 'red')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    solve(a, s)

if __name__ == '__main__':
    main()


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

int main(){   
    int n,a=0;
    bool b=true;
    cin >> n ;
    vector<pair<int,int>> p(n);
    for(int i=0;i<n;i++){
        cin >> p.at(i).second >> p.at(i).first ;
    }
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++){
        a+=p.at(i).second;
        if(p.at(i).first<a){
            b=false;
            break;
        }
    }
    if(b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long

using namespace std;

string intToStr(int num) {
    if (num == 0) return "0";

    string ret = "";
    while (num > 0) {
	ret = (char)(num%10 + '0') + ret;
	num /= 10;
    }

    return ret;
}

signed main() {
    int n;
    cin >> n;

    string str = "";
    for (int i = 0; i < n; i++) {
	string tmp;
	cin >> tmp;
	str += tmp;
    }
    int num = 0;
    while (true) {
	if (str.find(intToStr(num)) == string::npos) {
	    cout << num << endl;
	    break;
	}
	num++;
    }

    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;

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

int main(){
    int A,B;
    cin>>A>>B;
    int ans;
    ans=max(A+A-1,B+B-1);
    ans=max(ans,A+B);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input()) 
n = [i for i in range(1, N+1)]

P = list(map(int,input().split()))
Q = list(map(int,input().split()))

P = ''.join(map(str,P))
Q = ''.join(map(str,Q))

num = 0
count = 1
A = 0
B = 0

for i in itertools.permutations(n):
  num = ''.join(map(str,i))
  if num == P:
    A = count
  if num == Q:
    B = count
  count += 1
  
print(abs(B-A))

Measured memory_bytes: 40940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, H, W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}


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

using namespace std;

int N, k, x, ans = 0;

int main() {
	cin >> N >> k;
	for (int i = 0; i < N; i++) {
		cin >> x;
		ans += min(x, k - x) * 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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


    string s;
    cin >> s;
    int K;
    cin >> K;

//    char minc = 'a';
//    rep(i, 0, s.size()) {
//        if (s[i] < minc) {
//            minc = s[i];
//        }
//    }

//    vector<string> kouho;
//
//    for (int i = 0; i < s.size(); i++) {
//        if (s[i] == minc) {
//            string tmp;
//            for (int j = i; j < s.size(); j++) {
//                tmp += s[j];
//            }
//            kouho.push_back(tmp);
//        }
//    }
//    sort(all(kouho));
//    vector<string> kouho2;


    set<string> sset;
    for (char c = 'a'; c <= 'z'; c++) {
        vector<string> kouho;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == c) {
                string tmp;
                for (int j = i; j < s.size(); j++) {
                    tmp += s[j];
                }
                kouho.push_back(tmp);
            }
        }
        sort(all(kouho));

        vector<string> mindir;
        for (int i = 0; i < kouho.size(); i++) {
            string tmp;
            for (int j = 0; j < kouho[i].size(); j++) {
                tmp += kouho[i][j];
                sset.insert(tmp);
            }
            if (sset.size() >= K) {
                for (auto e : sset) {
                    mindir.push_back(e);
                }
                sort(all(mindir));
                cout << mindir[K - 1] << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 18560
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}
    
#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}
    
#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}
    
#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}
    
fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}
    
    
#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, BTreeMap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};
    
fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! print { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! println { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    let s = readl!(String).into_bytes();
    let k = readl!(usize);
    let mut dp = vec![vec![vec![-1; k+1]; s.len()]; s.len()];
    struct Env<'a> {dp: &'a mut Vec<Vec<Vec<i32>>>, s: &'a Vec<u8>, }
    fn rec(env: &mut Env, l: isize, r: isize, k: usize) -> i32 {
        // debug!(l); debug!(r); debug!(k);
        if -1 != env.dp[l as usize][r as usize][k] {
            env.dp[l as usize][r as usize][k]
        } else if l >= r {
            if l == r {
                1
            } else {
                0
            }
        } else {
            let mut res = 0;
            res = max(rec(env, l+1, r, k), res);
            res = max(rec(env, l, r-1, k), res);
            if env.s[l as usize] == env.s[r as usize] {
                res = max(rec(env, l+1, r-1, k)+2, res);
            } else if k != 0 {
                res = max(rec(env, l+1, r-1, k-1)+2, res);
            }
            env.dp[l as usize][r as usize][k] = res;
            res
        }
    }
    println!("{}", rec(&mut Env{dp: &mut dp, s: &s}, 0, s.len() as isize - 1, k));
}

Measured memory_bytes: 121084
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/
 
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()
 
const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
 
template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}
 
int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	int n; cin >> n;
	cout << (n*(n+1)>>1);
	return 0;
}

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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

bool flag[110] = {false};

int main(){

  int n;cin >> n;
  vector<pi> ab;
  vector<pi> cd;

  rep(i,n){
    int a,b;
    cin >> a >> b;
    ab.pb(mp(a,b));
  }
  rep(i,n){
    int c,d;
    cin >> c >> d;
    cd.pb(mp(c,d));
  }

  int cnt = 0;

  sort(all(cd));

  rep(i,cd.size()){
    int maxy = -1;
    int pos = -1;
    rep(j,ab.size()){
      if(cd[i].first > ab[j].first && cd[i].second > ab[j].second){
        if(!flag[j]){
          if(maxy < ab[j].second){
            pos = j;
            maxy = ab[j].second;
          }
        }
      }
    }
    if(pos != -1){
     flag[pos] = true;
     cnt++;
    }
  }

  pr(cnt);

  return 0;

}


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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    lld A,B,C,D;
    cin >> A >> B >> C >> D;
    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            exit(0);
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
using namespace std;
const int INF = (1<<21);
int cost[100][100];
int mincost[100];
bool used[100];
int n;
int prim(){
  for(int i=0;i<n;i++){
    mincost[i]=INF;
    used[i]=false;
  }

  mincost[0]=0;
  int res=0;

  while(1){
    int v=-1;
    for(int u=0;u<n;u++){
      if(!used[u] && (v == -1 || mincost[u] < mincost[v])){
	v=u;
      }
    }

    if(v == -1) break;
    used[v]= true;
    res+=mincost[v];

    for(int u=0;u<n;u++){
      mincost[u] = min(mincost[u],cost[v][u]);
    }
  }

  return res;
}
int main(){
  while(cin>> n){
    if(n == 0){
      break;
    }
    int m;
    cin>> m;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cost[i][j]=INF;
      }
    }
    
    for(int i=0;i<m;i++){
      int a,b,c;
      scanf("%d,%d,%d",&a,&b,&c);
      cost[a][b]=cost[b][a]=c/100-1;
    }
    
    cout<< prim()<< endl;
  }
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

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

    if(x < a)
        cout << 0 << '\n';
    else
        cout << 10 << '\n';
    return 0;
}




Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
a=[0]+a
for i in range(n):a[i+1]=(a[i+1]-1+a[i])%k
d={}
c=0
for i,b in enumerate(a):
  v=d.get(b,0)
  c+=v
  d[b]=v+1
  j=i-k+1
  if j>=0:d[a[j]]=d.get(a[j],0)-1
print(c)

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

vector<bool> vis(100001,false);
vector<int> a(100001);
int n;
int ans=1e+6;

void dfs(int node,int d){
    if(node==2){
        vis[node]=true;
        ans=min(ans,d);
        return ;
    }
    if(vis[node]){
        return ;
    }
    vis[node]=true;
    dfs(a[node],d+1);
}

int main(){

    cin >> n;

    for(int i=1;i<=n;i++){
        cin >> a[i];
    }

    dfs(1,0);

    if(vis[2]){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(void)
{
    string s;
    cin >> s;

    string s_inv = s;
    string t = s.substr(0, (s.size()-1)/2);
    string t_inv = t;
    string u = s.substr((s.size()+3)/2-1);
    string u_inv = u;

    reverse(t_inv.begin(), t_inv.end());
    reverse(u_inv.begin(), u_inv.end());
    reverse(s_inv.begin(), s_inv.end());

    if(s == s_inv && t == t_inv && u == u_inv) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    string d;
    cin >> a >> b >> c;

    if(a+b+c==17){
        if(a+b==10 ||a+b==12){
            d ="YES";
        }
    }

    else{d ="NO";}

    cout << d <<endl;
}

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

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(xx) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<endl;
#define LOG2(xx,yy) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<endl;
#define LOG3(xx,yy,z) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,xx,yy,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void solve(){

	lli d,t,s;
	cin>>d>>t>>s;

	if(t*s >= d)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;



}

int main(){
	
    // cout << fixxed << setprecision(5);
    lli t=1;
    //cin>>t;
    while(t--)solve();

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  rep(i, s.length()-1) {
    if (s[i]==s[i+1]) {
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
    else if (i>=1&&s[i-1]==s[i+1]) {
      cout << i << " " << i+2 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n*2);
    REP(i,n*2){
        cin >> a[i];
    }
    SORT(a);
    int res = 0;
    REP(i,n){
        res += a[i*2];
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		String ans = "";

		if ( Math.abs(c-a) <= d ) {
			ans = "Yes";
		} else if (Math.abs(b-a) <= d && Math.abs(c-b) <= d) {
			ans = "Yes";
		} else {
			ans = "No";
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 21844